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.
reactor.stop()
def cb_call(self, obj):
- """Callback for successfull connect.
+ """Callback for successful connect.
If the connect and login sequence succeeded, we proceed with
making the actual call.
finally:
fd.close()
except EnvironmentError, err:
- raise errors.ConfigurationError, ("missing SSL certificate: %s" %
- str(err))
+ raise errors.ConfigurationError("missing SSL certificate: %s" %
+ str(err))
self.mycert = crypto.load_certificate(crypto.FILETYPE_PEM, data)
self.mypem = crypto.dump_certificate(crypto.FILETYPE_PEM, self.mycert)
self.mydigest = self.mycert.digest('SHA')
This is a single-node call.
"""
- c = Client("instance_start", [instance.Dumps(), extra_args])
+ c = Client("instance_start", [instance.ToDict(), extra_args])
c.connect(node)
c.run()
return c.getresult().get(node, False)
This is a single-node call.
"""
- c = Client("instance_shutdown", [instance.Dumps()])
+ c = Client("instance_shutdown", [instance.ToDict()])
c.connect(node)
c.run()
return c.getresult().get(node, False)
This is a single-node call.
"""
- params = [inst.Dumps(), osdev, swapdev]
+ params = [inst.ToDict(), osdev, swapdev]
c = Client("instance_os_add", params)
c.connect(node)
c.run()
return c.getresult().get(node, False)
+def call_instance_run_rename(node, inst, old_name, osdev, swapdev):
+ """Run the OS rename script for an instance.
+
+ This is a single-node call.
+
+ """
+ params = [inst.ToDict(), old_name, osdev, swapdev]
+ c = Client("instance_run_rename", params)
+ c.connect(node)
+ c.run()
+ return c.getresult().get(node, False)
+
+
def call_instance_info(node, instance):
"""Returns information about a single instance.
return c.getresult()
-def call_blockdev_create(node, bdev, size, on_primary):
+def call_blockdev_create(node, bdev, size, on_primary, info):
"""Request creation of a given block device.
This is a single-node call.
"""
- params = [bdev.Dumps(), size, on_primary]
+ params = [bdev.ToDict(), size, on_primary, info]
c = Client("blockdev_create", params)
c.connect(node)
c.run()
This is a single-node call.
"""
- c = Client("blockdev_remove", [bdev.Dumps()])
+ c = Client("blockdev_remove", [bdev.ToDict()])
c.connect(node)
c.run()
return c.getresult().get(node, False)
This is a single-node call.
"""
- params = [disk.Dumps(), on_primary]
+ params = [disk.ToDict(), on_primary]
c = Client("blockdev_assemble", params)
c.connect(node)
c.run()
This is a single-node call.
"""
- c = Client("blockdev_shutdown", [disk.Dumps()])
+ c = Client("blockdev_shutdown", [disk.ToDict()])
c.connect(node)
c.run()
return c.getresult().get(node, False)
This is a single-node call.
"""
- params = [bdev.Dumps(), ndev.Dumps()]
+ params = [bdev.ToDict(), ndev.ToDict()]
c = Client("blockdev_addchild", params)
c.connect(node)
c.run()
This is a single-node call.
"""
- params = [bdev.Dumps(), ndev.Dumps()]
+ params = [bdev.ToDict(), ndev.ToDict()]
c = Client("blockdev_removechild", params)
c.connect(node)
c.run()
This is a single-node call.
"""
- params = [dsk.Dumps() for dsk in disks]
+ params = [dsk.ToDict() for dsk in disks]
c = Client("blockdev_getmirrorstatus", params)
c.connect(node)
c.run()
This is a single-node call.
"""
- c = Client("blockdev_find", [disk.Dumps()])
+ c = Client("blockdev_find", [disk.ToDict()])
c.connect(node)
c.run()
return c.getresult().get(node, False)
if result[node_name]:
for data in result[node_name]:
if data:
- if isinstance(data, basestring):
- nr.append(objects.ConfigObject.Loads(data))
- elif isinstance(data, tuple) and len(data) == 2:
- nr.append(errors.InvalidOS(data[0], data[1]))
+ if isinstance(data, dict):
+ nr.append(objects.OS.FromDict(data))
+ elif isinstance(data, tuple) and len(data) == 3:
+ nr.append(errors.InvalidOS(data[0], data[1], data[2]))
else:
- raise errors.ProgrammerError, ("Invalid data from"
- " xcserver.os_diagnose")
+ raise errors.ProgrammerError("Invalid data from"
+ " xcserver.os_diagnose")
new_result[node_name] = nr
return new_result
new_result = {}
for node_name in result:
data = result[node_name]
- if isinstance(data, basestring):
- new_result[node_name] = objects.ConfigObject.Loads(data)
- elif isinstance(data, tuple) and len(data) == 2:
- new_result[node_name] = errors.InvalidOS(data[0], data[1])
+ if isinstance(data, dict):
+ new_result[node_name] = objects.OS.FromDict(data)
+ elif isinstance(data, tuple) and len(data) == 3:
+ new_result[node_name] = errors.InvalidOS(data[0], data[1], data[2])
else:
new_result[node_name] = data
return new_result
This is a single-node call.
"""
- c = Client("blockdev_snapshot", [cf_bdev.Dumps()])
+ c = Client("blockdev_snapshot", [cf_bdev.ToDict()])
c.connect(node)
c.run()
return c.getresult().get(node, False)
This is a single-node call.
"""
- params = [snap_bdev.Dumps(), dest_node, instance.Dumps()]
+ params = [snap_bdev.ToDict(), dest_node, instance.ToDict()]
c = Client("snapshot_export", params)
c.connect(node)
c.run()
"""
flat_disks = []
for disk in snap_disks:
- flat_disks.append(disk.Dumps())
- params = [instance.Dumps(), flat_disks]
+ flat_disks.append(disk.ToDict())
+ params = [instance.ToDict(), flat_disks]
c = Client("finalize_export", params)
c.connect(node)
c.run()
This is a single-node call.
"""
- params = [inst.Dumps(), osdev, swapdev, src_node, src_image]
+ params = [inst.ToDict(), osdev, swapdev, src_node, src_image]
c = Client("instance_os_import", params)
c.connect(node)
c.run()