Commit 098c0958 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Comment formatting updates.

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