diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded index f9016e35f862351220b59396044b6b0d0276c9e4..f6300055308e5500c7945ca960d508600edeee4a 100755 --- a/daemons/ganeti-noded +++ b/daemons/ganeti-noded @@ -63,8 +63,8 @@ class ServerObject(pb.Avatar): to handle the method; subclasses of Avatar are expected to implement methods of this naming convention. - """ + """ args = broker.unserialize(args, self) kw = broker.unserialize(kw, self) method = getattr(self, "perspective_%s" % message) @@ -346,6 +346,7 @@ def main(): def createDaemon(): """Detach a process from the controlling terminal and run it in the background as a daemon. + """ UMASK = 077 WORKDIR = "/" diff --git a/daemons/ganeti-watcher b/daemons/ganeti-watcher index 7525f7b30d8d7b66e11a3c086b97d1abf377acb2..5861991804ea1ab7c83f281f73d235291352ad20 100755 --- a/daemons/ganeti-watcher +++ b/daemons/ganeti-watcher @@ -195,6 +195,7 @@ class Instance(object): Methods: Restart(): issue a command to restart the represented machine. + """ def __init__(self, name, state): self.name = name diff --git a/lib/backend.py b/lib/backend.py index 46b104786ef257ae840e180c4a90fbd69b6ddc8b..6bc2bc117871ee898d6cc2d907b2182c2e36abfc 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -85,8 +85,8 @@ def AddNode(dsa, dsapub, rsa, rsapub, ssh, sshpub): - adds the ssh-key - sets the node id - sets the node status to installed - """ + """ f = open("/etc/ssh/ssh_host_rsa_key", 'w') f.write(rsa) f.close() @@ -159,8 +159,8 @@ def GetNodeInfo(vgname): memory_dom0 is the memory allocated for domain0 in MiB memory_free is the currently available (free) ram in MiB memory_total is the total number of ram in MiB - """ + """ outputarray = {} vginfo = _GetVGInfo(vgname) outputarray['vg_size'] = vginfo['vg_size'] @@ -192,7 +192,6 @@ def VerifyNode(what): by ssh-execution of 'hostname', result compared against name in list. """ - result = {} if 'hypervisor' in what: @@ -289,8 +288,8 @@ def GetInstanceList(): A list of all running instances on the current node - instance1.example.com - instance2.example.com - """ + """ try: names = hypervisor.GetHypervisor().ListInstances() except errors.HypervisorError, err: @@ -313,8 +312,8 @@ def GetInstanceInfo(instance): memory: memory size of instance (int) state: xen state of instance (string) time: cpu time of instance (float) - """ + """ output = {} iinfo = hypervisor.GetHypervisor().GetInstanceInfo(instance) @@ -341,8 +340,8 @@ def GetAllInstancesInfo(): state: xen state of instance (string) time: cpu time of instance (float) vcpus: the number of cpus - """ + """ output = {} iinfo = hypervisor.GetHypervisor().GetAllInstancesInfo() @@ -471,8 +470,8 @@ def StartInstance(instance, extra_args): Args: instance - name of instance to start. - """ + """ running_instances = GetInstanceList() if instance.name in running_instances: @@ -495,8 +494,8 @@ def ShutdownInstance(instance): Args: instance - name of instance to shutdown. - """ + """ running_instances = GetInstanceList() if instance.name not in running_instances: @@ -958,8 +957,8 @@ def SnapshotBlockDevice(disk): Returns: a config entry for the actual lvm device snapshotted. - """ + """ if disk.children: if len(disk.children) == 1: # only one child, let's recurse on it @@ -993,8 +992,8 @@ def ExportSnapshot(disk, dest_node, instance): Returns: True if successful, False otherwise. - """ + """ inst_os = OSFromDisk(instance.os) export_script = inst_os.export_script @@ -1050,8 +1049,8 @@ def FinalizeExport(instance, snap_disks): Returns: False in case of error, True otherwise. - """ + """ destdir = os.path.join(constants.EXPORT_DIR, instance.name + ".new") finaldestdir = os.path.join(constants.EXPORT_DIR, instance.name) @@ -1108,7 +1107,6 @@ def ExportInfo(dest): A serializable config file containing the export info. """ - cff = os.path.join(dest, constants.EXPORT_CONF_FILE) config = objects.SerializableConfigParser() @@ -1135,7 +1133,6 @@ def ImportOSIntoInstance(instance, os_disk, swap_disk, src_node, src_image): False in case of error, True otherwise. """ - inst_os = OSFromDisk(instance.os) import_script = inst_os.import_script @@ -1195,6 +1192,7 @@ def ImportOSIntoInstance(instance, os_disk, swap_disk, src_node, src_image): def ListExports(): """Return a list of exports currently available on this machine. + """ if os.path.isdir(constants.EXPORT_DIR): return os.listdir(constants.EXPORT_DIR) @@ -1210,8 +1208,8 @@ def RemoveExport(export): Returns: False in case of error, True otherwise. - """ + """ target = os.path.join(constants.EXPORT_DIR, export) shutil.rmtree(target) diff --git a/lib/bdev.py b/lib/bdev.py index 7409493f9016ba0f5d4484528009427551f5d91d..480c5ba3a0bef069b8943a0c77a8d96e8167eb8f 100644 --- a/lib/bdev.py +++ b/lib/bdev.py @@ -80,7 +80,6 @@ class BlockDev(object): after assembly we'll have our correct major/minor. """ - STATUS_UNKNOWN = 0 STATUS_EXISTING = 1 STATUS_STANDBY = 2 @@ -321,6 +320,7 @@ class LogicalVolume(BlockDev): Returns: list of (free_space, name) with free_space in mebibytes + """ command = ["pvs", "--noheadings", "--nosuffix", "--units=m", "-opv_name,vg_name,pv_free,pv_attr", "--unbuffered", @@ -451,7 +451,6 @@ class LogicalVolume(BlockDev): """Create a snapshot copy of an lvm block device. """ - snap_name = self._lv_name + ".snap" # remove existing snapshot if found diff --git a/lib/cli.py b/lib/cli.py index 45644db803d007990d41e0b246295d1ebd38aad0..cfb8c387654f0701d1aa58bb8dab70c703036d3c 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -107,6 +107,7 @@ def _ParseArgs(argv, commands): commands: dictionary with special contents, see the design doc for cmdline handling + """ if len(argv) == 0: binary = "<command>" diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 8fca355ff1c52cafe7bfe0a97f54d84d288b38be..c202a3529c684d153cfe6cabbccf4f0712118dcc 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -466,7 +466,6 @@ class LUInitCluster(LogicalUnit): ourselves in the post-run node list. """ - env = {"CLUSTER": self.op.cluster_name, "MASTER": self.hostname['hostname_full']} return env, [], [self.hostname['hostname_full']] @@ -623,6 +622,7 @@ class LUVerifyCluster(NoHooksLU): node: name of the node to check file_list: required list of files local_cksum: dictionary of local files and their checksums + """ # compares ganeti version local_version = constants.PROTOCOL_VERSION @@ -913,7 +913,6 @@ def _CheckDiskConsistency(cfgw, dev, node, on_primary): """Check that mirrors are not degraded. """ - cfgw.SetDiskID(dev, node) result = True @@ -986,7 +985,6 @@ class LURemoveNode(LogicalUnit): Any errors are signalled by raising errors.OpPrereqError. """ - node = self.cfg.GetNodeInfo(self.cfg.ExpandNodeName(self.op.node_name)) if node is None: logger.Error("Error: Node '%s' is unknown." % self.op.node_name) @@ -1441,7 +1439,6 @@ class LUMasterFailover(LogicalUnit): master. """ - #TODO: do not rely on gethostname returning the FQDN logger.Info("setting master to %s, old master: %s" % (self.new_master, self.old_master)) @@ -1924,7 +1921,6 @@ class LUQueryInstances(NoHooksLU): """Computes the list of nodes and their attributes. """ - instance_names = utils.NiceSort(self.cfg.GetInstanceList()) instance_list = [self.cfg.GetInstanceInfo(iname) for iname in instance_names] @@ -2132,7 +2128,6 @@ def _CreateBlockDevOnPrimary(cfg, node, device): This always creates all devices. """ - if device.children: for child in device.children: if not _CreateBlockDevOnPrimary(cfg, node, child): @@ -3044,7 +3039,6 @@ class LUQueryInstanceData(NoHooksLU): def Exec(self, feedback_fn): """Gather and return data""" - result = {} for instance in self.wanted_instances: remote_info = rpc.call_instance_info(instance.primary_node, @@ -3096,7 +3090,6 @@ class LUQueryNodeData(NoHooksLU): """Compute and return the list of nodes. """ - ilist = [self.cfg.GetInstanceInfo(iname) for iname in self.cfg.GetInstanceList()] result = [] diff --git a/lib/config.py b/lib/config.py index 75770d89212e3232dedc745b73eeedb16c9b78ba..225cc160a6a89509a6289eb71a17639b450bed79 100644 --- a/lib/config.py +++ b/lib/config.py @@ -48,8 +48,9 @@ from ganeti import objects class ConfigWriter: - """The interface to the cluster configuration""" + """The interface to the cluster configuration. + """ def __init__(self, cfg_file=None, offline=False): self._config_data = None self._config_time = None @@ -267,7 +268,6 @@ class ConfigWriter: """Mark the status of an instance to down in the configuration. """ - self._OpenConfig() if instance_name not in self._config_data.instances: diff --git a/lib/errors.py b/lib/errors.py index 7bcd564415c04625ac7ae5523bb59f876c2b3c41..0971907a53b0d23e6a676313aac6fb44208afd31 100644 --- a/lib/errors.py +++ b/lib/errors.py @@ -129,11 +129,13 @@ class OpPrereqError(GenericError): """ + class OpExecError(GenericError): """Error during OpCode execution. """ + class OpCodeUnknown(GenericError): """Unknown opcode submitted. @@ -142,6 +144,7 @@ class OpCodeUnknown(GenericError): """ + class HooksFailure(GenericError): """A generic hook failure. @@ -149,6 +152,7 @@ class HooksFailure(GenericError): """ + class HooksAbort(HooksFailure): """A required hook has failed. @@ -159,6 +163,7 @@ class HooksAbort(HooksFailure): """ + class UnitParseError(GenericError): """Unable to parse size unit. diff --git a/lib/hypervisor.py b/lib/hypervisor.py index 39a628ba96caa06daa4b5e4473003342e57dbc61..366a8ab3e5ac28cd2510c355b90ee99d3d039846 100644 --- a/lib/hypervisor.py +++ b/lib/hypervisor.py @@ -130,7 +130,6 @@ class XenHypervisor(BaseHypervisor): """Create a Xen 3.0 config file. """ - config = StringIO() config.write("# this is autogenerated by Ganeti, please do not edit\n#\n") config.write("kernel = '/boot/vmlinuz-2.6-xenU'\n") @@ -334,7 +333,6 @@ class FakeHypervisor(BaseHypervisor): a real virtualisation software installed. """ - _ROOT_DIR = "/var/run/ganeti-fake-hypervisor" def __init__(self): diff --git a/lib/objects.py b/lib/objects.py index 63ca437fdbd58eff00d06946ddb9165fb5d77732..d34f9c2f17465eccbf3fc966552b82ad954671a1 100644 --- a/lib/objects.py +++ b/lib/objects.py @@ -285,7 +285,6 @@ class Instance(ConfigObject): Otherwise, { 'nodename' : ['volume1', 'volume2', ...], ... } """ - if node == None: node = self.primary_node diff --git a/lib/rpc.py b/lib/rpc.py index e632e49d563744918acb55ce0b81dcec488ade8f..061eead4d5a14ea2633d96566e57ca21c4bd0421 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -30,8 +30,9 @@ import os from twisted.internet.pollreactor import PollReactor class ReReactor(PollReactor): - """A re-startable Reactor implementation""" + """A re-startable Reactor implementation. + """ def run(self, installSignalHandlers=1): """Custom run method. diff --git a/lib/ssh.py b/lib/ssh.py index 4a1f3a2d8431839ffa9ca26404888bf2d490e42b..26b61d2af7d4404759cca6524c7d013b8627e841 100644 --- a/lib/ssh.py +++ b/lib/ssh.py @@ -45,7 +45,6 @@ def SSHCall(hostname, user, command, batch=True, ask_key=False): `utils.RunResult` as for `utils.RunCmd()` """ - argv = ["ssh", "-q", "-oEscapeChar=none"] if batch: argv.append("-oBatchMode=yes") diff --git a/lib/utils.py b/lib/utils.py index 0df99a69e545ee6515de52857071a73656317d49..a8137ccfe3a8859861f6806f7e1352046e89e4d4 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -156,8 +156,9 @@ def Lock(name, max_retries=None, debug=False): def Unlock(name): - """Unlock a given subsystem.""" + """Unlock a given subsystem. + """ lockfile = _GetLockFile(name) try: @@ -182,8 +183,9 @@ def Unlock(name): def LockCleanup(): - """Remove all locks.""" + """Remove all locks. + """ for lock in _locksheld: Unlock(lock) @@ -401,8 +403,8 @@ def LookupHostname(hostname): - ip: IP addr - hostname_full: hostname fully qualified - hostname: hostname fully qualified (historic artifact) - """ + """ try: (fqdn, dummy, ipaddrs) = socket.gethostbyname_ex(hostname) ipaddr = ipaddrs[0] @@ -452,7 +454,6 @@ def BridgeExists(bridge): True if it does, false otherwise. """ - return os.path.isdir("/sys/class/net/%s/bridge" % bridge) diff --git a/scripts/gnt-backup b/scripts/gnt-backup index aba46a4bc6818bb12cddf9604ea4e5a95a9ea4cb..e185473d439cc02ab2a58eb69667cf6a9b651c5f 100755 --- a/scripts/gnt-backup +++ b/scripts/gnt-backup @@ -38,7 +38,6 @@ def PrintExportList(opts, args): nothing """ - op = opcodes.OpQueryExports(nodes=opts.nodes) exports = SubmitOpCode(op) for node in exports: @@ -83,14 +82,14 @@ def ImportInstance(opts, args): 1 in case of error, 0 otherwise """ - instance = args[0] op = opcodes.OpCreateInstance(instance_name=instance, mem_size=opts.mem, disk_size=opts.size, swap_size=opts.swap, disk_template=opts.disk_template, - mode=constants.INSTANCE_IMPORT, pnode=opts.node, - snode=opts.snode, vcpus=opts.vcpus, + mode=constants.INSTANCE_IMPORT, + pnode=opts.node, snode=opts.snode, + vcpus=opts.vcpus, ip=opts.ip, bridge=opts.bridge, start=False, src_node=opts.src_node, src_path=opts.src_dir, wait_for_sync=opts.wait_for_sync) @@ -136,7 +135,6 @@ import_opts = [ metavar="<dir>"), ] - commands = { 'list': (PrintExportList, ARGS_NONE, [DEBUG_OPT, diff --git a/scripts/gnt-cluster b/scripts/gnt-cluster index f8a6086b61fab096d1b4fcf4fcf33e43ad454307..3fd271cef0b1c12363bb132b283297b8076953ff 100755 --- a/scripts/gnt-cluster +++ b/scripts/gnt-cluster @@ -51,6 +51,7 @@ def DestroyCluster(opts, args): Args: opts - class with options as members + """ if not opts.yes_do_it: print ("Destroying a cluster is irreversibly. If you really want destroy" diff --git a/scripts/gnt-instance b/scripts/gnt-instance index 5ef3966178135ec6cf3f034be509252808c6ad0a..27c44ac059148a6a56cdd6bec2ac1b25b3e9eff4 100755 --- a/scripts/gnt-instance +++ b/scripts/gnt-instance @@ -82,7 +82,6 @@ def AddInstance(opts, args): node - node to run new instance on """ - instance = args[0] op = opcodes.OpCreateInstance(instance_name=instance, mem_size=opts.mem, @@ -333,7 +332,6 @@ def ShowInstanceConfig(opts, args): """Compute instance run-time status. """ - retcode = 0 op = opcodes.OpQueryInstanceData(instances=args) result = SubmitOpCode(op) @@ -435,7 +433,6 @@ add_opts = [ default=None, metavar="<bridge>") ] - commands = { 'add': (AddInstance, ARGS_ONE, add_opts, "[opts...] <name>",