- When line wrapping is needed, move spaces to the next line.
- Remove embedded line breaks from error messages.
Reviewed-by: schreiberal
except Exception, msg:
# Ignore errors while loading the file and treat it as empty
self.data = {}
- sys.stderr.write("Empty or invalid state file. "
- "Using defaults. Error message: %s\n" % msg)
+ sys.stderr.write("Empty or invalid state file."
+ " Using defaults. Error message: %s\n" % msg)
if "instance" not in self.data:
self.data["instance"] = {}
# secondary node.
for instance in GetInstanceList(with_secondaries=check_nodes):
try:
- self.messages.append(Message(NOTICE,
- "Activating disks for %s." %
- instance.name))
+ self.messages.append(Message(NOTICE, ("Activating disks for %s." %
+ instance.name)))
instance.ActivateDisks()
except Error, x:
self.messages.append(Message(ERROR, str(x)))
(instance.name, MAXTRIES)))
continue
try:
- self.messages.append(Message(NOTICE,
- "Restarting %s%s." %
- (instance.name, last)))
+ self.messages.append(Message(NOTICE, ("Restarting %s%s." %
+ (instance.name, last))))
instance.Restart()
except Error, x:
self.messages.append(Message(ERROR, str(x)))
else:
if notepad.NumberOfRestartAttempts(instance):
notepad.RemoveInstance(instance)
- msg = Message(NOTICE,
- "Restart of %s succeeded." % instance.name)
+ msg = Message(NOTICE, "Restart of %s succeeded." % instance.name)
self.messages.append(msg)
def WriteReport(self, logfile):
return None
else:
raise errors.ProgrammerError("Cannot snapshot non-lvm block device"
- "'%s' of type '%s'" %
+ " '%s' of type '%s'" %
(disk.unique_id, disk.dev_type))
secondary_ip != hostname.ip and
(not utils.TcpPing(constants.LOCALHOST_IP_ADDRESS, secondary_ip,
constants.DEFAULT_NODED_PORT))):
- raise errors.OpPrereqError("You gave %s as secondary IP,\n"
- "but it does not belong to this host." %
+ raise errors.OpPrereqError("You gave %s as secondary IP,"
+ " but it does not belong to this host." %
secondary_ip)
self.secondary_ip = secondary_ip
if not (os.path.isfile(constants.NODE_INITD_SCRIPT) and
os.access(constants.NODE_INITD_SCRIPT, os.X_OK)):
- raise errors.OpPrereqError("Init.d script '%s' missing or not "
- "executable." % constants.NODE_INITD_SCRIPT)
+ raise errors.OpPrereqError("Init.d script '%s' missing or not"
+ " executable." % constants.NODE_INITD_SCRIPT)
def Exec(self, feedback_fn):
"""Initialize the cluster.
(fname, to_node))
finally:
if not rpc.call_node_start_master(master):
- logger.Error("Could not re-enable the master role on the master,\n"
- "please restart manually.")
+ logger.Error("Could not re-enable the master role on the master,"
+ " please restart manually.")
def _WaitForSync(cfgw, instance, proc, oneshot=False, unlock=False):
if not utils.TcpPing(myself.secondary_ip,
secondary_ip,
constants.DEFAULT_NODED_PORT):
- raise errors.OpPrereqError(
- "Node secondary ip not reachable by TCP based ping to noded port")
+ raise errors.OpPrereqError("Node secondary ip not reachable by TCP"
+ " based ping to noded port")
self.new_node = objects.Node(name=node,
primary_ip=primary_ip,
new_node.secondary_ip,
constants.DEFAULT_NODED_PORT,
10, False):
- raise errors.OpExecError("Node claims it doesn't have the"
- " secondary ip you gave (%s).\n"
- "Please fix and re-run this command." %
- new_node.secondary_ip)
+ raise errors.OpExecError("Node claims it doesn't have the secondary ip"
+ " you gave (%s). Please fix and re-run this"
+ " command." % new_node.secondary_ip)
success, msg = ssh.VerifyNodeHostname(node)
if not success:
raise errors.OpExecError("Node '%s' claims it has a different hostname"
- " than the one the resolver gives: %s.\n"
- "Please fix and re-run this command." %
+ " than the one the resolver gives: %s."
+ " Please fix and re-run this command." %
(node, msg))
# Distribute updated /etc/hosts and known_hosts to all nodes,
if self.old_master == self.new_master:
raise errors.OpPrereqError("This commands must be run on the node"
- " where you want the new master to be.\n"
- "%s is already the master" %
+ " where you want the new master to be."
+ " %s is already the master" %
self.old_master)
def Exec(self, feedback_fn):
if not rpc.call_node_start_master(self.new_master):
logger.Error("could not start the master role on the new master"
" %s, please check" % self.new_master)
- feedback_fn("Error in activating the master IP on the new master,\n"
- "please fix manually.")
+ feedback_fn("Error in activating the master IP on the new master,"
+ " please fix manually.")
result = rpc.call_blockdev_assemble(node, node_disk,
instance.name, is_primary)
if not result:
- logger.Error("could not prepare block device %s on node %s (is_pri"
- "mary=%s)" % (inst_disk.iv_name, node, is_primary))
+ logger.Error("could not prepare block device %s on node %s"
+ " (is_primary=%s)" %
+ (inst_disk.iv_name, node, is_primary))
if is_primary or not ignore_secondaries:
disks_ok = False
if is_primary:
try:
feedback_fn("Running the instance OS create scripts...")
if not rpc.call_instance_os_add(inst.primary_node, inst, "sda", "sdb"):
- raise errors.OpExecError("Could not install OS for instance %s "
- "on node %s" %
+ raise errors.OpExecError("Could not install OS for instance %s"
+ " on node %s" %
(inst.name, inst.primary_node))
finally:
_ShutdownInstanceDisks(inst, self.cfg)
try:
if not rpc.call_instance_run_rename(inst.primary_node, inst, old_name,
"sda", "sdb"):
- msg = ("Could run OS rename script for instance %s\n"
- "on node %s\n"
- "(but the instance has been renamed in Ganeti)" %
+ msg = ("Could run OS rename script for instance %s on node %s (but the"
+ " instance has been renamed in Ganeti)" %
(inst.name, inst.primary_node))
logger.Error(msg)
finally:
raise errors.OpPrereqError("Can't find this device ('%s') in the"
" instance." % self.op.disk_name)
if len(disk.children) > 1:
- raise errors.OpPrereqError("The device already has two slave"
- " devices.\n"
- "This would create a 3-disk raid1"
- " which we don't allow.")
+ raise errors.OpPrereqError("The device already has two slave devices."
+ " This would create a 3-disk raid1 which we"
+ " don't allow.")
self.disk = disk
def Exec(self, feedback_fn):
if not _CreateBlockDevOnSecondary(cfg, remote_node, instance,
new_drbd, False,
_GetInstanceInfoText(instance)):
- raise errors.OpExecError("Failed to create new component on"
- " secondary node %s\n"
- "Full abort, cleanup manually!" %
+ raise errors.OpExecError("Failed to create new component on secondary"
+ " node %s. Full abort, cleanup manually!" %
remote_node)
logger.Info("adding new mirror component on primary")
# remove secondary dev
cfg.SetDiskID(new_drbd, remote_node)
rpc.call_blockdev_remove(remote_node, new_drbd)
- raise errors.OpExecError("Failed to create volume on primary!\n"
- "Full abort, cleanup manually!!")
+ raise errors.OpExecError("Failed to create volume on primary!"
+ " Full abort, cleanup manually!!")
# the device exists now
# call the primary node to add the mirror to md
"""Main program.
"""
- parser = OptionParser(usage="%prog [options] <config-file> "
- "<known-hosts-file>")
+ parser = OptionParser(usage="%prog [options] <config-file>"
+ " <known-hosts-file>")
parser.add_option('--dry-run', dest='dry_run',
action="store_true",
help="Show what would be done")
"""Shows a warning about the cron job.
"""
- msg = ("For the following tests it's recommended to turn off the "
- "ganeti-watcher cronjob.")
+ msg = ("For the following tests it's recommended to turn off the"
+ " ganeti-watcher cronjob.")
print
print qa_utils.FormatWarning(msg)
node2disk[node_name].append(name)
if [node2_full, node_full][int(onmaster)] not in node2disk:
- raise qa_error.Error("Couldn't find physical disks used on "
- "%s node" % ["secondary", "master"][int(onmaster)])
+ raise qa_error.Error("Couldn't find physical disks used on"
+ " %s node" % ["secondary", "master"][int(onmaster)])
# Check whether nodes have ability to stop disks
for node_name, disks in node2disk.iteritems():
def TestInstanceMasterDiskFailure(instance, node, node2):
"""Testing disk failure on master node."""
- print qa_utils.FormatError("Disk failure on primary node cannot be "
- "tested due to potential crashes.")
+ print qa_utils.FormatError("Disk failure on primary node cannot be"
+ " tested due to potential crashes.")
# The following can cause crashes, thus it's disabled until fixed
#return _TestInstanceDiskFailure(instance, node, node2, True)
master = qa_config.GetMasterNode()
if qa_utils.GetNodeInstances(node2, secondaries=False):
- raise qa_error.UnusableNodeError("Secondary node has at least one "
- "primary instance. This test requires "
- "it to have no primary instances.")
+ raise qa_error.UnusableNodeError("Secondary node has at least one"
+ " primary instance. This test requires"
+ " it to have no primary instances.")
# Fail over to secondary node
cmd = ['gnt-node', 'failover', '-f', node['primary']]
node3 = qa_config.AcquireNode(exclude=[node, node2])
try:
if qa_utils.GetNodeInstances(node3, secondaries=True):
- raise qa_error.UnusableNodeError("Evacuation node has at least one "
- "secondary instance. This test requires "
- "it to have no secondary instances.")
+ raise qa_error.UnusableNodeError("Evacuation node has at least one"
+ " secondary instance. This test requires"
+ " it to have no secondary instances.")
# Evacuate all secondary instances
cmd = ['gnt-node', 'evacuate', '-f', node2['primary'], node3['primary']]
# this is an option common to more than one command, so we declare
# it here and reuse it
node_option = make_option("-n", "--node", action="append", dest="nodes",
- help="Node to copy to (if not given, all nodes)"
- ", can be given multiple times", metavar="<node>",
- default=[])
+ help="Node to copy to (if not given, all nodes),"
+ " can be given multiple times",
+ metavar="<node>", default=[])
commands = {
'init': (InitCluster, ARGS_ONE,
instance_name = args[0]
if not opts.force:
- usertext = ("This will reinstall the instance %s and remove "
- "all data. Continue?") % instance_name
+ usertext = ("This will reinstall the instance %s and remove"
+ " all data. Continue?") % instance_name
if not AskUser(usertext):
return 1
parser = optparse.OptionParser()
parser.add_option('--dry-run', dest='dry_run',
action="store_true",
- help="Try to do the conversion, but don't write "
- "output file")
+ help="Try to do the conversion, but don't write"
+ " output file")
parser.add_option(FORCE_OPT)
parser.add_option('--verbose', dest='verbose',
action="store_true",
raise Error("Configuration file not specified")
if not options.force:
- usertext = ("%s MUST run on the master node. Is this the master "
- "node?" % program)
+ usertext = ("%s MUST run on the master node. Is this the master"
+ " node?" % program)
if not AskUser(usertext):
sys.exit(1)
osname, nodename, release, version, arch = os.uname()
if osname != 'Linux':
- raise PrereqError("This tool only runs on Linux "
- "(detected OS: %s)." % osname)
+ raise PrereqError("This tool only runs on Linux"
+ " (detected OS: %s)." % osname)
if not release.startswith("2.6."):
- raise PrereqError("Wrong major kernel version (detected %s, needs "
- "2.6.*)" % release)
+ raise PrereqError("Wrong major kernel version (detected %s, needs"
+ " 2.6.*)" % release)
if not os.path.ismount("/sys"):
- raise PrereqError("Can't find a filesystem mounted at /sys. "
- "Please mount /sys.")
+ raise PrereqError("Can't find a filesystem mounted at /sys."
+ " Please mount /sys.")
if not os.path.isdir("/sys/block"):
- raise SysconfigError("Can't find /sys/block directory. Has the "
- "layout of /sys changed?")
+ raise SysconfigError("Can't find /sys/block directory. Has the"
+ " layout of /sys changed?")
if not os.path.ismount("/proc"):
- raise PrereqError("Can't find a filesystem mounted at /proc. "
- "Please mount /proc.")
+ raise PrereqError("Can't find a filesystem mounted at /proc."
+ " Please mount /proc.")
if not os.path.exists("/proc/mounts"):
raise SysconfigError("Can't find /proc/mounts")
vg_free: The available space in the volume group
"""
- result = ExecCommand("vgs --nohead -o lv_count,vg_size,"
- "vg_free --nosuffix --units g "
- "--ignorelockingfailure %s" % vgname)
+ result = ExecCommand("vgs --nohead -o lv_count,vg_size,vg_free"
+ " --nosuffix --units g"
+ " --ignorelockingfailure %s" % vgname)
if not result.failed:
try:
lv_count, vg_size, vg_free = result.stdout.strip().split()
break
time.sleep(0.250)
else:
- raise SysconfigError("the device file %s does not exist, but the block "
- "device exists in the /sys/block tree" % path)
+ raise SysconfigError("the device file %s does not exist, but the block"
+ " device exists in the /sys/block tree" % path)
rdev = os.stat(path).st_rdev
if devnum != rdev:
- raise SysconfigError("For device %s, the major:minor in /dev is %04x "
- "while the major:minor in sysfs is %s" %
+ raise SysconfigError("For device %s, the major:minor in /dev is %04x"
+ " while the major:minor in sysfs is %s" %
(path, rdev, devnum))
"""
if not CheckReread(name):
- raise OperationalError("CRITICAL: disk %s you selected seems to be in "
- "use. ABORTING!" % name)
+ raise OperationalError("CRITICAL: disk %s you selected seems to be in"
+ " use. ABORTING!" % name)
fd = os.open("/dev/%s" % name, os.O_RDWR | os.O_SYNC)
olddata = os.read(fd, 512)
if len(olddata) != 512:
- raise OperationalError("CRITICAL: Can't read partition table information "
- "from /dev/%s (needed 512 bytes, got %d" %
+ raise OperationalError("CRITICAL: Can't read partition table information"
+ " from /dev/%s (needed 512 bytes, got %d" %
(name, len(olddata)))
newdata = "\0" * 512
os.lseek(fd, 0, 0)
os.close(fd)
if bytes_written != 512:
raise OperationalError("CRITICAL: Can't write partition table information"
- " to /dev/%s (tried to write 512 bytes, written "
- "%d. I don't know how to cleanup. Sorry." %
+ " to /dev/%s (tried to write 512 bytes, written"
+ " %d. I don't know how to cleanup. Sorry." %
(name, bytes_written))
if not CheckReread(name):
fd = os.open("/dev/%s" % name, os.O_RDWR | os.O_SYNC)
os.write(fd, olddata)
os.close(fd)
- raise OperationalError("CRITICAL: disk %s which I have just wiped cannot "
- "reread partition table. Most likely, it is "
- "in use. You have to clean after this yourself. "
- "I tried to restore the old partition table, "
- "but I cannot guarantee nothing has broken." %
+ raise OperationalError("CRITICAL: disk %s which I have just wiped cannot"
+ " reread partition table. Most likely, it is"
+ " in use. You have to clean after this yourself."
+ " I tried to restore the old partition table,"
+ " but I cannot guarantee nothing has broken." %
name)
result = ExecCommand(
'echo ,,8e, | sfdisk /dev/%s' % name)
if result.failed:
- raise OperationalError("CRITICAL: disk %s which I have just partitioned "
- "cannot reread its partition table, or there "
- "is some other sfdisk error. Likely, it is in "
- "use. You have to clean this yourself. Error "
- "message from sfdisk: %s" %
+ raise OperationalError("CRITICAL: disk %s which I have just partitioned"
+ " cannot reread its partition table, or there"
+ " is some other sfdisk error. Likely, it is in"
+ " use. You have to clean this yourself. Error"
+ " message from sfdisk: %s" %
(name, result.output))
"""
result = ExecCommand("pvcreate -yff /dev/%s1 " % name)
if result.failed:
- raise OperationalError("I cannot create a physical volume on "
- "partition /dev/%s1. Error message: %s. "
- "Please clean up yourself." %
+ raise OperationalError("I cannot create a physical volume on"
+ " partition /dev/%s1. Error message: %s."
+ " Please clean up yourself." %
(name, result.output))
pnames = ["'/dev/%s1'" % disk for disk in disks]
result = ExecCommand("vgcreate -s 64MB '%s' %s" % (vgname, " ".join(pnames)))
if result.failed:
- raise OperationalError("I cannot create the volume group %s from "
- "disks %s. Error message: %s. Please clean up "
- "yourself." %
+ raise OperationalError("I cannot create the volume group %s from"
+ " disks %s. Error message: %s. Please clean up"
+ " yourself." %
(vgname, " ".join(disks), result.output))
sysdisks = GetDiskList()
if not sysdisks:
- raise PrereqError("no disks found (I looked for "
- "non-removable block devices).")
+ raise PrereqError("no disks found (I looked for"
+ " non-removable block devices).")
sysd_free = []
sysd_used = []
for name, size, dev, part, used in sysdisks:
return disklist
+
def BootStrap():
"""Actual main routine."""
status, lv_count, size, free = CheckVGExists(vgname)
if status:
print "Done! %s: size %s GiB, disks: %s" % (vgname, size,
- ",".join(disklist))
+ ",".join(disklist))
else:
- raise OperationalError("Although everything seemed ok, the volume "
- "group did not get created.")
+ raise OperationalError("Although everything seemed ok, the volume"
+ " group did not get created.")
def main():
BootStrap()
except PrereqError, err:
print >> sys.stderr, "The prerequisites for running this tool are not met."
- print >> sys.stderr, ("Please make sure you followed all the steps in "
- "the build document.")
+ print >> sys.stderr, ("Please make sure you followed all the steps in"
+ " the build document.")
print >> sys.stderr, "Description: %s" % str(err)
sys.exit(1)
except SysconfigError, err:
- print >> sys.stderr, ("This system's configuration seems wrong, at "
- "least is not what I expect.")
- print >> sys.stderr, ("Please check that the installation didn't fail "
- "at some step.")
+ print >> sys.stderr, ("This system's configuration seems wrong, at"
+ " least is not what I expect.")
+ print >> sys.stderr, ("Please check that the installation didn't fail"
+ " at some step.")
print >> sys.stderr, "Description: %s" % str(err)
sys.exit(1)
except ParameterError, err:
- print >> sys.stderr, ("Some parameters you gave to the program or the "
- "invocation is wrong. ")
+ print >> sys.stderr, ("Some parameters you gave to the program or the"
+ " invocation is wrong. ")
print >> sys.stderr, "Description: %s" % str(err)
Usage()
except OperationalError, err:
- print >> sys.stderr, ("A serious error has happened while modifying "
- "the system's configuration.")
- print >> sys.stderr, ("Please review the error message below and make "
- "sure you clean up yourself.")
- print >> sys.stderr, ("It is most likely that the system configuration "
- "has been partially altered.")
+ print >> sys.stderr, ("A serious error has happened while modifying"
+ " the system's configuration.")
+ print >> sys.stderr, ("Please review the error message below and make"
+ " sure you clean up yourself.")
+ print >> sys.stderr, ("It is most likely that the system configuration"
+ " has been partially altered.")
print >> sys.stderr, str(err)
sys.exit(1)
except ProgrammingError, err:
- print >> sys.stderr, ("Internal application error. Please signal this "
- "to xencluster-team.")
+ print >> sys.stderr, ("Internal application error. Please signal this"
+ " to xencluster-team.")
print >> sys.stderr, "Error description: %s" % str(err)
sys.exit(1)
except Error, err: