Revision b3989551 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
1763 | 1763 |
return result |
1764 | 1764 |
|
1765 | 1765 |
|
1766 |
class LUClusterCopyFile(NoHooksLU): |
|
1767 |
"""Copy file to cluster. |
|
1768 |
|
|
1769 |
""" |
|
1770 |
_OP_REQP = ["nodes", "filename"] |
|
1771 |
|
|
1772 |
def CheckPrereq(self): |
|
1773 |
"""Check prerequisites. |
|
1774 |
|
|
1775 |
It should check that the named file exists and that the given list |
|
1776 |
of nodes is valid. |
|
1777 |
|
|
1778 |
""" |
|
1779 |
if not os.path.exists(self.op.filename): |
|
1780 |
raise errors.OpPrereqError("No such filename '%s'" % self.op.filename) |
|
1781 |
|
|
1782 |
self.nodes = _GetWantedNodes(self, self.op.nodes) |
|
1783 |
|
|
1784 |
def Exec(self, feedback_fn): |
|
1785 |
"""Copy a file from master to some nodes. |
|
1786 |
|
|
1787 |
Args: |
|
1788 |
opts - class with options as members |
|
1789 |
args - list containing a single element, the file name |
|
1790 |
Opts used: |
|
1791 |
nodes - list containing the name of target nodes; if empty, all nodes |
|
1792 |
|
|
1793 |
""" |
|
1794 |
filename = self.op.filename |
|
1795 |
|
|
1796 |
myname = utils.HostInfo().name |
|
1797 |
|
|
1798 |
for node in self.nodes: |
|
1799 |
if node == myname: |
|
1800 |
continue |
|
1801 |
if not self.ssh.CopyFileToNode(node, filename): |
|
1802 |
logger.Error("Copy of file %s to node %s failed" % (filename, node)) |
|
1803 |
|
|
1804 |
|
|
1805 | 1766 |
class LUDumpClusterConfig(NoHooksLU): |
1806 | 1767 |
"""Return a text-representation of the cluster-config. |
1807 | 1768 |
|
... | ... | |
1821 | 1782 |
return self.cfg.DumpConfig() |
1822 | 1783 |
|
1823 | 1784 |
|
1824 |
class LURunClusterCommand(NoHooksLU): |
|
1825 |
"""Run a command on some nodes. |
|
1826 |
|
|
1827 |
""" |
|
1828 |
_OP_REQP = ["command", "nodes"] |
|
1829 |
|
|
1830 |
def CheckPrereq(self): |
|
1831 |
"""Check prerequisites. |
|
1832 |
|
|
1833 |
It checks that the given list of nodes is valid. |
|
1834 |
|
|
1835 |
""" |
|
1836 |
self.nodes = _GetWantedNodes(self, self.op.nodes) |
|
1837 |
|
|
1838 |
def Exec(self, feedback_fn): |
|
1839 |
"""Run a command on some nodes. |
|
1840 |
|
|
1841 |
""" |
|
1842 |
# put the master at the end of the nodes list |
|
1843 |
master_node = self.sstore.GetMasterNode() |
|
1844 |
if master_node in self.nodes: |
|
1845 |
self.nodes.remove(master_node) |
|
1846 |
self.nodes.append(master_node) |
|
1847 |
|
|
1848 |
data = [] |
|
1849 |
for node in self.nodes: |
|
1850 |
result = self.ssh.Run(node, "root", self.op.command) |
|
1851 |
data.append((node, result.output, result.exit_code)) |
|
1852 |
|
|
1853 |
return data |
|
1854 |
|
|
1855 |
|
|
1856 | 1785 |
class LUActivateInstanceDisks(NoHooksLU): |
1857 | 1786 |
"""Bring up an instance's disks. |
1858 | 1787 |
|
Also available in: Unified diff