Commit f4bc1f2c authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Various code style fixes for strings.

- When line wrapping is needed, move spaces to the next line.
- Remove embedded line breaks from error messages.

Reviewed-by: schreiberal
parent abe3db55
...@@ -122,8 +122,8 @@ class WatcherState(object): ...@@ -122,8 +122,8 @@ class WatcherState(object):
except Exception, msg: except Exception, msg:
# Ignore errors while loading the file and treat it as empty # Ignore errors while loading the file and treat it as empty
self.data = {} self.data = {}
sys.stderr.write("Empty or invalid state file. " sys.stderr.write("Empty or invalid state file."
"Using defaults. Error message: %s\n" % msg) " Using defaults. Error message: %s\n" % msg)
if "instance" not in self.data: if "instance" not in self.data:
self.data["instance"] = {} self.data["instance"] = {}
...@@ -367,9 +367,8 @@ class Watcher(object): ...@@ -367,9 +367,8 @@ class Watcher(object):
# secondary node. # secondary node.
for instance in GetInstanceList(with_secondaries=check_nodes): for instance in GetInstanceList(with_secondaries=check_nodes):
try: try:
self.messages.append(Message(NOTICE, self.messages.append(Message(NOTICE, ("Activating disks for %s." %
"Activating disks for %s." % instance.name)))
instance.name))
instance.ActivateDisks() instance.ActivateDisks()
except Error, x: except Error, x:
self.messages.append(Message(ERROR, str(x))) self.messages.append(Message(ERROR, str(x)))
...@@ -402,9 +401,8 @@ class Watcher(object): ...@@ -402,9 +401,8 @@ class Watcher(object):
(instance.name, MAXTRIES))) (instance.name, MAXTRIES)))
continue continue
try: try:
self.messages.append(Message(NOTICE, self.messages.append(Message(NOTICE, ("Restarting %s%s." %
"Restarting %s%s." % (instance.name, last))))
(instance.name, last)))
instance.Restart() instance.Restart()
except Error, x: except Error, x:
self.messages.append(Message(ERROR, str(x))) self.messages.append(Message(ERROR, str(x)))
...@@ -416,8 +414,7 @@ class Watcher(object): ...@@ -416,8 +414,7 @@ class Watcher(object):
else: else:
if notepad.NumberOfRestartAttempts(instance): if notepad.NumberOfRestartAttempts(instance):
notepad.RemoveInstance(instance) notepad.RemoveInstance(instance)
msg = Message(NOTICE, msg = Message(NOTICE, "Restart of %s succeeded." % instance.name)
"Restart of %s succeeded." % instance.name)
self.messages.append(msg) self.messages.append(msg)
def WriteReport(self, logfile): def WriteReport(self, logfile):
......
...@@ -1135,7 +1135,7 @@ def SnapshotBlockDevice(disk): ...@@ -1135,7 +1135,7 @@ def SnapshotBlockDevice(disk):
return None return None
else: else:
raise errors.ProgrammerError("Cannot snapshot non-lvm block device" raise errors.ProgrammerError("Cannot snapshot non-lvm block device"
"'%s' of type '%s'" % " '%s' of type '%s'" %
(disk.unique_id, disk.dev_type)) (disk.unique_id, disk.dev_type))
......
...@@ -522,8 +522,8 @@ class LUInitCluster(LogicalUnit): ...@@ -522,8 +522,8 @@ class LUInitCluster(LogicalUnit):
secondary_ip != hostname.ip and secondary_ip != hostname.ip and
(not utils.TcpPing(constants.LOCALHOST_IP_ADDRESS, secondary_ip, (not utils.TcpPing(constants.LOCALHOST_IP_ADDRESS, secondary_ip,
constants.DEFAULT_NODED_PORT))): constants.DEFAULT_NODED_PORT))):
raise errors.OpPrereqError("You gave %s as secondary IP,\n" raise errors.OpPrereqError("You gave %s as secondary IP,"
"but it does not belong to this host." % " but it does not belong to this host." %
secondary_ip) secondary_ip)
self.secondary_ip = secondary_ip self.secondary_ip = secondary_ip
...@@ -550,8 +550,8 @@ class LUInitCluster(LogicalUnit): ...@@ -550,8 +550,8 @@ class LUInitCluster(LogicalUnit):
if not (os.path.isfile(constants.NODE_INITD_SCRIPT) and if not (os.path.isfile(constants.NODE_INITD_SCRIPT) and
os.access(constants.NODE_INITD_SCRIPT, os.X_OK)): os.access(constants.NODE_INITD_SCRIPT, os.X_OK)):
raise errors.OpPrereqError("Init.d script '%s' missing or not " raise errors.OpPrereqError("Init.d script '%s' missing or not"
"executable." % constants.NODE_INITD_SCRIPT) " executable." % constants.NODE_INITD_SCRIPT)
def Exec(self, feedback_fn): def Exec(self, feedback_fn):
"""Initialize the cluster. """Initialize the cluster.
...@@ -950,8 +950,8 @@ class LURenameCluster(LogicalUnit): ...@@ -950,8 +950,8 @@ class LURenameCluster(LogicalUnit):
(fname, to_node)) (fname, to_node))
finally: finally:
if not rpc.call_node_start_master(master): if not rpc.call_node_start_master(master):
logger.Error("Could not re-enable the master role on the master,\n" logger.Error("Could not re-enable the master role on the master,"
"please restart manually.") " please restart manually.")
def _WaitForSync(cfgw, instance, proc, oneshot=False, unlock=False): def _WaitForSync(cfgw, instance, proc, oneshot=False, unlock=False):
...@@ -1401,8 +1401,8 @@ class LUAddNode(LogicalUnit): ...@@ -1401,8 +1401,8 @@ class LUAddNode(LogicalUnit):
if not utils.TcpPing(myself.secondary_ip, if not utils.TcpPing(myself.secondary_ip,
secondary_ip, secondary_ip,
constants.DEFAULT_NODED_PORT): constants.DEFAULT_NODED_PORT):
raise errors.OpPrereqError( raise errors.OpPrereqError("Node secondary ip not reachable by TCP"
"Node secondary ip not reachable by TCP based ping to noded port") " based ping to noded port")
self.new_node = objects.Node(name=node, self.new_node = objects.Node(name=node,
primary_ip=primary_ip, primary_ip=primary_ip,
...@@ -1500,16 +1500,15 @@ class LUAddNode(LogicalUnit): ...@@ -1500,16 +1500,15 @@ class LUAddNode(LogicalUnit):
new_node.secondary_ip, new_node.secondary_ip,
constants.DEFAULT_NODED_PORT, constants.DEFAULT_NODED_PORT,
10, False): 10, False):
raise errors.OpExecError("Node claims it doesn't have the" raise errors.OpExecError("Node claims it doesn't have the secondary ip"
" secondary ip you gave (%s).\n" " you gave (%s). Please fix and re-run this"
"Please fix and re-run this command." % " command." % new_node.secondary_ip)
new_node.secondary_ip)
success, msg = ssh.VerifyNodeHostname(node) success, msg = ssh.VerifyNodeHostname(node)
if not success: if not success:
raise errors.OpExecError("Node '%s' claims it has a different hostname" raise errors.OpExecError("Node '%s' claims it has a different hostname"
" than the one the resolver gives: %s.\n" " than the one the resolver gives: %s."
"Please fix and re-run this command." % " Please fix and re-run this command." %
(node, msg)) (node, msg))
# Distribute updated /etc/hosts and known_hosts to all nodes, # Distribute updated /etc/hosts and known_hosts to all nodes,
...@@ -1572,8 +1571,8 @@ class LUMasterFailover(LogicalUnit): ...@@ -1572,8 +1571,8 @@ class LUMasterFailover(LogicalUnit):
if self.old_master == self.new_master: if self.old_master == self.new_master:
raise errors.OpPrereqError("This commands must be run on the node" raise errors.OpPrereqError("This commands must be run on the node"
" where you want the new master to be.\n" " where you want the new master to be."
"%s is already the master" % " %s is already the master" %
self.old_master) self.old_master)
def Exec(self, feedback_fn): def Exec(self, feedback_fn):
...@@ -1602,8 +1601,8 @@ class LUMasterFailover(LogicalUnit): ...@@ -1602,8 +1601,8 @@ class LUMasterFailover(LogicalUnit):
if not rpc.call_node_start_master(self.new_master): if not rpc.call_node_start_master(self.new_master):
logger.Error("could not start the master role on the new master" logger.Error("could not start the master role on the new master"
" %s, please check" % self.new_master) " %s, please check" % self.new_master)
feedback_fn("Error in activating the master IP on the new master,\n" feedback_fn("Error in activating the master IP on the new master,"
"please fix manually.") " please fix manually.")
...@@ -1778,8 +1777,9 @@ def _AssembleInstanceDisks(instance, cfg, ignore_secondaries=False): ...@@ -1778,8 +1777,9 @@ def _AssembleInstanceDisks(instance, cfg, ignore_secondaries=False):
result = rpc.call_blockdev_assemble(node, node_disk, result = rpc.call_blockdev_assemble(node, node_disk,
instance.name, is_primary) instance.name, is_primary)
if not result: if not result:
logger.Error("could not prepare block device %s on node %s (is_pri" logger.Error("could not prepare block device %s on node %s"
"mary=%s)" % (inst_disk.iv_name, node, is_primary)) " (is_primary=%s)" %
(inst_disk.iv_name, node, is_primary))
if is_primary or not ignore_secondaries: if is_primary or not ignore_secondaries:
disks_ok = False disks_ok = False
if is_primary: if is_primary:
...@@ -2134,8 +2134,8 @@ class LUReinstallInstance(LogicalUnit): ...@@ -2134,8 +2134,8 @@ class LUReinstallInstance(LogicalUnit):
try: try:
feedback_fn("Running the instance OS create scripts...") feedback_fn("Running the instance OS create scripts...")
if not rpc.call_instance_os_add(inst.primary_node, inst, "sda", "sdb"): if not rpc.call_instance_os_add(inst.primary_node, inst, "sda", "sdb"):
raise errors.OpExecError("Could not install OS for instance %s " raise errors.OpExecError("Could not install OS for instance %s"
"on node %s" % " on node %s" %
(inst.name, inst.primary_node)) (inst.name, inst.primary_node))
finally: finally:
_ShutdownInstanceDisks(inst, self.cfg) _ShutdownInstanceDisks(inst, self.cfg)
...@@ -2210,9 +2210,8 @@ class LURenameInstance(LogicalUnit): ...@@ -2210,9 +2210,8 @@ class LURenameInstance(LogicalUnit):
try: try:
if not rpc.call_instance_run_rename(inst.primary_node, inst, old_name, if not rpc.call_instance_run_rename(inst.primary_node, inst, old_name,
"sda", "sdb"): "sda", "sdb"):
msg = ("Could run OS rename script for instance %s\n" msg = ("Could run OS rename script for instance %s on node %s (but the"
"on node %s\n" " instance has been renamed in Ganeti)" %
"(but the instance has been renamed in Ganeti)" %
(inst.name, inst.primary_node)) (inst.name, inst.primary_node))
logger.Error(msg) logger.Error(msg)
finally: finally:
...@@ -3144,10 +3143,9 @@ class LUAddMDDRBDComponent(LogicalUnit): ...@@ -3144,10 +3143,9 @@ class LUAddMDDRBDComponent(LogicalUnit):
raise errors.OpPrereqError("Can't find this device ('%s') in the" raise errors.OpPrereqError("Can't find this device ('%s') in the"
" instance." % self.op.disk_name) " instance." % self.op.disk_name)
if len(disk.children) > 1: if len(disk.children) > 1:
raise errors.OpPrereqError("The device already has two slave" raise errors.OpPrereqError("The device already has two slave devices."
" devices.\n" " This would create a 3-disk raid1 which we"
"This would create a 3-disk raid1" " don't allow.")
" which we don't allow.")
self.disk = disk self.disk = disk
def Exec(self, feedback_fn): def Exec(self, feedback_fn):
...@@ -3425,9 +3423,8 @@ class LUReplaceDisks(LogicalUnit): ...@@ -3425,9 +3423,8 @@ class LUReplaceDisks(LogicalUnit):
if not _CreateBlockDevOnSecondary(cfg, remote_node, instance, if not _CreateBlockDevOnSecondary(cfg, remote_node, instance,
new_drbd, False, new_drbd, False,
_GetInstanceInfoText(instance)): _GetInstanceInfoText(instance)):
raise errors.OpExecError("Failed to create new component on" raise errors.OpExecError("Failed to create new component on secondary"
" secondary node %s\n" " node %s. Full abort, cleanup manually!" %
"Full abort, cleanup manually!" %
remote_node) remote_node)
logger.Info("adding new mirror component on primary") logger.Info("adding new mirror component on primary")
...@@ -3438,8 +3435,8 @@ class LUReplaceDisks(LogicalUnit): ...@@ -3438,8 +3435,8 @@ class LUReplaceDisks(LogicalUnit):
# remove secondary dev # remove secondary dev
cfg.SetDiskID(new_drbd, remote_node) cfg.SetDiskID(new_drbd, remote_node)
rpc.call_blockdev_remove(remote_node, new_drbd) rpc.call_blockdev_remove(remote_node, new_drbd)
raise errors.OpExecError("Failed to create volume on primary!\n" raise errors.OpExecError("Failed to create volume on primary!"
"Full abort, cleanup manually!!") " Full abort, cleanup manually!!")
# the device exists now # the device exists now
# call the primary node to add the mirror to md # call the primary node to add the mirror to md
......
...@@ -215,8 +215,8 @@ def main(): ...@@ -215,8 +215,8 @@ def main():
"""Main program. """Main program.
""" """
parser = OptionParser(usage="%prog [options] <config-file> " parser = OptionParser(usage="%prog [options] <config-file>"
"<known-hosts-file>") " <known-hosts-file>")
parser.add_option('--dry-run', dest='dry_run', parser.add_option('--dry-run', dest='dry_run',
action="store_true", action="store_true",
help="Show what would be done") help="Show what would be done")
......
...@@ -95,8 +95,8 @@ def PrintCronWarning(): ...@@ -95,8 +95,8 @@ def PrintCronWarning():
"""Shows a warning about the cron job. """Shows a warning about the cron job.
""" """
msg = ("For the following tests it's recommended to turn off the " msg = ("For the following tests it's recommended to turn off the"
"ganeti-watcher cronjob.") " ganeti-watcher cronjob.")
print print
print qa_utils.FormatWarning(msg) print qa_utils.FormatWarning(msg)
......
...@@ -232,8 +232,8 @@ def _TestInstanceDiskFailure(instance, node, node2, onmaster): ...@@ -232,8 +232,8 @@ def _TestInstanceDiskFailure(instance, node, node2, onmaster):
node2disk[node_name].append(name) node2disk[node_name].append(name)
if [node2_full, node_full][int(onmaster)] not in node2disk: if [node2_full, node_full][int(onmaster)] not in node2disk:
raise qa_error.Error("Couldn't find physical disks used on " raise qa_error.Error("Couldn't find physical disks used on"
"%s node" % ["secondary", "master"][int(onmaster)]) " %s node" % ["secondary", "master"][int(onmaster)])
# Check whether nodes have ability to stop disks # Check whether nodes have ability to stop disks
for node_name, disks in node2disk.iteritems(): for node_name, disks in node2disk.iteritems():
...@@ -319,8 +319,8 @@ def _TestInstanceDiskFailure(instance, node, node2, onmaster): ...@@ -319,8 +319,8 @@ def _TestInstanceDiskFailure(instance, node, node2, onmaster):
def TestInstanceMasterDiskFailure(instance, node, node2): def TestInstanceMasterDiskFailure(instance, node, node2):
"""Testing disk failure on master node.""" """Testing disk failure on master node."""
print qa_utils.FormatError("Disk failure on primary node cannot be " print qa_utils.FormatError("Disk failure on primary node cannot be"
"tested due to potential crashes.") " tested due to potential crashes.")
# The following can cause crashes, thus it's disabled until fixed # The following can cause crashes, thus it's disabled until fixed
#return _TestInstanceDiskFailure(instance, node, node2, True) #return _TestInstanceDiskFailure(instance, node, node2, True)
......
...@@ -94,9 +94,9 @@ def TestNodeFailover(node, node2): ...@@ -94,9 +94,9 @@ def TestNodeFailover(node, node2):
master = qa_config.GetMasterNode() master = qa_config.GetMasterNode()
if qa_utils.GetNodeInstances(node2, secondaries=False): if qa_utils.GetNodeInstances(node2, secondaries=False):
raise qa_error.UnusableNodeError("Secondary node has at least one " raise qa_error.UnusableNodeError("Secondary node has at least one"
"primary instance. This test requires " " primary instance. This test requires"
"it to have no primary instances.") " it to have no primary instances.")
# Fail over to secondary node # Fail over to secondary node
cmd = ['gnt-node', 'failover', '-f', node['primary']] cmd = ['gnt-node', 'failover', '-f', node['primary']]
...@@ -117,9 +117,9 @@ def TestNodeEvacuate(node, node2): ...@@ -117,9 +117,9 @@ def TestNodeEvacuate(node, node2):
node3 = qa_config.AcquireNode(exclude=[node, node2]) node3 = qa_config.AcquireNode(exclude=[node, node2])
try: try:
if qa_utils.GetNodeInstances(node3, secondaries=True): if qa_utils.GetNodeInstances(node3, secondaries=True):
raise qa_error.UnusableNodeError("Evacuation node has at least one " raise qa_error.UnusableNodeError("Evacuation node has at least one"
"secondary instance. This test requires " " secondary instance. This test requires"
"it to have no secondary instances.") " it to have no secondary instances.")
# Evacuate all secondary instances # Evacuate all secondary instances
cmd = ['gnt-node', 'evacuate', '-f', node2['primary'], node3['primary']] cmd = ['gnt-node', 'evacuate', '-f', node2['primary'], node3['primary']]
......
...@@ -210,9 +210,9 @@ def SearchTags(opts, args): ...@@ -210,9 +210,9 @@ def SearchTags(opts, args):
# this is an option common to more than one command, so we declare # this is an option common to more than one command, so we declare
# it here and reuse it # it here and reuse it
node_option = make_option("-n", "--node", action="append", dest="nodes", node_option = make_option("-n", "--node", action="append", dest="nodes",
help="Node to copy to (if not given, all nodes)" help="Node to copy to (if not given, all nodes),"
", can be given multiple times", metavar="<node>", " can be given multiple times",
default=[]) metavar="<node>", default=[])
commands = { commands = {
'init': (InitCluster, ARGS_ONE, 'init': (InitCluster, ARGS_ONE,
......
...@@ -242,8 +242,8 @@ def ReinstallInstance(opts, args): ...@@ -242,8 +242,8 @@ def ReinstallInstance(opts, args):
instance_name = args[0] instance_name = args[0]
if not opts.force: if not opts.force:
usertext = ("This will reinstall the instance %s and remove " usertext = ("This will reinstall the instance %s and remove"
"all data. Continue?") % instance_name " all data. Continue?") % instance_name
if not AskUser(usertext): if not AskUser(usertext):
return 1 return 1
......
...@@ -173,8 +173,8 @@ if __name__ == "__main__": ...@@ -173,8 +173,8 @@ if __name__ == "__main__":
parser = optparse.OptionParser() parser = optparse.OptionParser()
parser.add_option('--dry-run', dest='dry_run', parser.add_option('--dry-run', dest='dry_run',
action="store_true", action="store_true",
help="Try to do the conversion, but don't write " help="Try to do the conversion, but don't write"
"output file") " output file")
parser.add_option(FORCE_OPT) parser.add_option(FORCE_OPT)
parser.add_option('--verbose', dest='verbose', parser.add_option('--verbose', dest='verbose',
action="store_true", action="store_true",
...@@ -188,8 +188,8 @@ if __name__ == "__main__": ...@@ -188,8 +188,8 @@ if __name__ == "__main__":
raise Error("Configuration file not specified") raise Error("Configuration file not specified")
if not options.force: if not options.force:
usertext = ("%s MUST run on the master node. Is this the master " usertext = ("%s MUST run on the master node. Is this the master"
"node?" % program) " node?" % program)
if not AskUser(usertext): if not AskUser(usertext):
sys.exit(1) sys.exit(1)
......
...@@ -190,24 +190,24 @@ def CheckPrereq(): ...@@ -190,24 +190,24 @@ def CheckPrereq():
osname, nodename, release, version, arch = os.uname() osname, nodename, release, version, arch = os.uname()
if osname != 'Linux': if osname != 'Linux':
raise PrereqError("This tool only runs on Linux " raise PrereqError("This tool only runs on Linux"
"(detected OS: %s)." % osname) " (detected OS: %s)." % osname)
if not release.startswith("2.6."): if not release.startswith("2.6."):
raise PrereqError("Wrong major kernel version (detected %s, needs " raise PrereqError("Wrong major kernel version (detected %s, needs"
"2.6.*)" % release) " 2.6.*)" % release)
if not os.path.ismount("/sys"): if not os.path.ismount("/sys"):
raise PrereqError("Can't find a filesystem mounted at /sys. " raise PrereqError("Can't find a filesystem mounted at /sys."
"Please mount /sys.") " Please mount /sys.")
if not os.path.isdir("/sys/block"): if not os.path.isdir("/sys/block"):
raise SysconfigError("Can't find /sys/block directory. Has the " raise SysconfigError("Can't find /sys/block directory. Has the"
"layout of /sys changed?") " layout of /sys changed?")
if not os.path.ismount("/proc"): if not os.path.ismount("/proc"):
raise PrereqError("Can't find a filesystem mounted at /proc. " raise PrereqError("Can't find a filesystem mounted at /proc."
"Please mount /proc.") " Please mount /proc.")
if not os.path.exists("/proc/mounts"): if not os.path.exists("/proc/mounts"):
raise SysconfigError("Can't find /proc/mounts") raise SysconfigError("Can't find /proc/mounts")
...@@ -228,9 +228,9 @@ def CheckVGExists(vgname): ...@@ -228,9 +228,9 @@ def CheckVGExists(vgname):
vg_free: The available space in the volume group vg_free: The available space in the volume group
""" """
result = ExecCommand("vgs --nohead -o lv_count,vg_size," result = ExecCommand("vgs --nohead -o lv_count,vg_size,vg_free"
"vg_free --nosuffix --units g " " --nosuffix --units g"
"--ignorelockingfailure %s" % vgname) " --ignorelockingfailure %s" % vgname)
if not result.failed: if not result.failed:
try: try:
lv_count, vg_size, vg_free = result.stdout.strip().split() lv_count, vg_size, vg_free = result.stdout.strip().split()
...@@ -272,12 +272,12 @@ def CheckSysDev(name, devnum): ...@@ -272,12 +272,12 @@ def CheckSysDev(name, devnum):
break break
time.sleep(0.250) time.sleep(0.250)
else: else:
raise SysconfigError("the device file %s does not exist, but the block " raise SysconfigError("the device file %s does not exist, but the block"
"device exists in the /sys/block tree" % path) " device exists in the /sys/block tree" % path)
rdev = os.stat(path).st_rdev rdev = os.stat(path).st_rdev
if devnum != rdev: if devnum != rdev:
raise SysconfigError("For device %s, the major:minor in /dev is %04x " raise SysconfigError("For device %s, the major:minor in /dev is %04x"
"while the major:minor in sysfs is %s" % " while the major:minor in sysfs is %s" %
(path, rdev, devnum)) (path, rdev, devnum))
...@@ -546,14 +546,14 @@ def WipeDisk(name): ...@@ -546,14 +546,14 @@ def WipeDisk(name):
""" """
if not CheckReread(name): if not CheckReread(name):
raise OperationalError("CRITICAL: disk %s you selected seems to be in " raise OperationalError("CRITICAL: disk %s you selected seems to be in"
"use. ABORTING!" % name) " use. ABORTING!" % name)
fd = os.open("/dev/%s" % name, os.O_RDWR | os.O_SYNC) fd = os.open("/dev/%s" % name, os.O_RDWR | os.O_SYNC)
olddata = os.read(fd, 512) olddata = os.read(fd, 512)
if len(olddata) != 512: if len(olddata) != 512:
raise OperationalError("CRITICAL: Can't read partition table information " raise OperationalError("CRITICAL: Can't read partition table information"
"from /dev/%s (needed 512 bytes, got %d" % " from /dev/%s (needed 512 bytes, got %d" %
(name, len(olddata))) (name, len(olddata)))
newdata = "\0" * 512 newdata = "\0" * 512
os.lseek(fd, 0, 0) os.lseek(fd, 0, 0)
...@@ -561,19 +561,19 @@ def WipeDisk(name): ...@@ -561,19 +561,19 @@ def WipeDisk(name):
os.close(fd) os.close(fd)
if bytes_written != 512: if bytes_written != 512:
raise OperationalError("CRITICAL: Can't write partition table information" raise OperationalError("CRITICAL: Can't write partition table information"
" to /dev/%s (tried to write 512 bytes, written " " to /dev/%s (tried to write 512 bytes, written"
"%d. I don't know how to cleanup. Sorry." % " %d. I don't know how to cleanup. Sorry." %
(name, bytes_written)) (name, bytes_written))
if not CheckReread(name): if not CheckReread(name):
fd = os.open("/dev/%s" % name, os.O_RDWR | os.O_SYNC) fd = os.open("/dev/%s" % name, os.O_RDWR | os.O_SYNC)
os.write(fd, olddata) os.write(fd, olddata)
os.close(fd) os.close(fd)
raise OperationalError("CRITICAL: disk %s which I have just wiped cannot " raise OperationalError("CRITICAL: disk %s which I have just wiped cannot"
"reread partition table. Most likely, it is " " reread partition table. Most likely, it is"
"in use. You have to clean after this yourself. " " in use. You have to clean after this yourself."
"I tried to restore the old partition table, " " I tried to restore the old partition table,"
"but I cannot guarantee nothing has broken." % " but I cannot guarantee nothing has broken." %
name) name)
...@@ -589,11 +589,11 @@ def PartitionDisk(name): ...@@ -589,11 +589,11 @@ def PartitionDisk(name):
result = ExecCommand( result = ExecCommand(
'echo ,,8e, | sfdisk /dev/%s' % name) 'echo ,,8e, | sfdisk /dev/%s' % name)
if result.failed: if result.failed:
raise OperationalError("CRITICAL: disk %s which I have just partitioned " raise OperationalError("CRITICAL: disk %s which I have just partitioned"
"cannot reread its partition table, or there " " cannot reread its partition table, or there"
"is some other sfdisk error. Likely, it is in " " is some other sfdisk error. Likely, it is in"