From 098c0958281c48228fe57eb7832153dafefbd07c Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Thu, 26 Jul 2007 11:40:37 +0000
Subject: [PATCH] Comment formatting updates.

Reviewed-by: iustinp
---
 daemons/ganeti-noded   |  3 ++-
 daemons/ganeti-watcher |  1 +
 lib/backend.py         | 26 ++++++++++++--------------
 lib/bdev.py            |  3 +--
 lib/cli.py             |  1 +
 lib/cmdlib.py          |  9 +--------
 lib/config.py          |  4 ++--
 lib/errors.py          |  5 +++++
 lib/hypervisor.py      |  2 --
 lib/objects.py         |  1 -
 lib/rpc.py             |  3 ++-
 lib/ssh.py             |  1 -
 lib/utils.py           |  9 +++++----
 scripts/gnt-backup     |  8 +++-----
 scripts/gnt-cluster    |  1 +
 scripts/gnt-instance   |  3 ---
 16 files changed, 36 insertions(+), 44 deletions(-)

diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded
index f9016e35f..f63000553 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 7525f7b30..586199180 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 46b104786..6bc2bc117 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 7409493f9..480c5ba3a 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 45644db80..cfb8c3876 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 8fca355ff..c202a3529 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 75770d892..225cc160a 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 7bcd56441..0971907a5 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 39a628ba9..366a8ab3e 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 63ca437fd..d34f9c2f1 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 e632e49d5..061eead4d 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 4a1f3a2d8..26b61d2af 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 0df99a69e..a8137ccfe 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 aba46a4bc..e185473d4 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 f8a6086b6..3fd271cef 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 5ef396617..27c44ac05 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>",
-- 
GitLab