"""Create a block device.
"""
- bdev_s, size, on_primary, info = params
+ bdev_s, size, owner, on_primary, info = params
bdev = objects.Disk.FromDict(bdev_s)
if bdev is None:
raise ValueError("can't unserialize data!")
- return backend.CreateBlockDevice(bdev, size, on_primary, info)
+ return backend.CreateBlockDevice(bdev, size, owner, on_primary, info)
@staticmethod
def perspective_blockdev_remove(params):
return backend.RemoveBlockDevice(bdev)
@staticmethod
+ def perspective_blockdev_rename(params):
+ """Remove a block device.
+
+ """
+ devlist = [(objects.Disk.FromDict(ds), uid) for ds, uid in params]
+ return backend.RenameBlockDevices(devlist)
+
+ @staticmethod
def perspective_blockdev_assemble(params):
"""Assemble a block device.
"""
- bdev_s, on_primary = params
+ bdev_s, owner, on_primary = params
bdev = objects.Disk.FromDict(bdev_s)
if bdev is None:
raise ValueError("can't unserialize data!")
- return backend.AssembleBlockDevice(bdev, on_primary)
+ return backend.AssembleBlockDevice(bdev, owner, on_primary)
@staticmethod
def perspective_blockdev_shutdown(params):
return backend.ShutdownBlockDevice(bdev)
@staticmethod
- def perspective_blockdev_addchild(params):
+ def perspective_blockdev_addchildren(params):
"""Add a child to a mirror device.
Note: this is only valid for mirror devices. It's the caller's duty
"""
bdev_s, ndev_s = params
bdev = objects.Disk.FromDict(bdev_s)
- ndev = objects.Disk.FromDict(ndev_s)
- if bdev is None or ndev is None:
+ ndevs = [objects.Disk.FromDict(disk_s) for disk_s in ndev_s]
+ if bdev is None or ndevs.count(None) > 0:
raise ValueError("can't unserialize data!")
- return backend.MirrorAddChild(bdev, ndev)
+ return backend.MirrorAddChildren(bdev, ndevs)
@staticmethod
- def perspective_blockdev_removechild(params):
+ def perspective_blockdev_removechildren(params):
"""Remove a child from a mirror device.
This is only valid for mirror devices, of course. It's the callers
"""
bdev_s, ndev_s = params
bdev = objects.Disk.FromDict(bdev_s)
- ndev = objects.Disk.FromDict(ndev_s)
- if bdev is None or ndev is None:
+ ndevs = [objects.Disk.FromDict(disk_s) for disk_s in ndev_s]
+ if bdev is None or ndevs.count(None) > 0:
raise ValueError("can't unserialize data!")
- return backend.MirrorRemoveChild(bdev, ndev)
+ return backend.MirrorRemoveChildren(bdev, ndevs)
@staticmethod
def perspective_blockdev_getmirrorstatus(params):
return backend.StartInstance(instance, extra_args)
@staticmethod
+ def perspective_instance_reboot(params):
+ """Reboot an instance.
+
+ """
+ instance = objects.Instance.FromDict(params[0])
+ reboot_type = params[1]
+ extra_args = params[2]
+ return backend.RebootInstance(instance, reboot_type, extra_args)
+
+ @staticmethod
def perspective_instance_info(params):
"""Query instance information.
"""Query detailed information about existing OSes.
"""
- os_list = backend.DiagnoseOS()
- if not os_list:
- # this catches also return values of 'False',
- # for which we can't iterate over
- return os_list
- result = []
- for data in os_list:
- if isinstance(data, objects.OS):
- result.append(data.ToDict())
- elif isinstance(data, errors.InvalidOS):
- result.append(data.args)
- else:
- raise errors.ProgrammerError("Invalid result from backend.DiagnoseOS"
- " (class %s, %s)" %
- (str(data.__class__), data))
-
- return result
+ return [os.ToDict() for os in backend.DiagnoseOS()]
@staticmethod
def perspective_os_get(params):
"""
name = params[0]
try:
- os_obj = backend.OSFromDisk(name).ToDict()
+ os_obj = backend.OSFromDisk(name)
except errors.InvalidOS, err:
- os_obj = err.args
- return os_obj
+ os_obj = objects.OS.FromInvalidOS(err)
+ return os_obj.ToDict()
# hooks -----------------------
hr = backend.HooksRunner()
return hr.RunHooks(hpath, phase, env)
+ # test -----------------------
+
+ @staticmethod
+ def perspective_test_delay(params):
+ """Run test delay.
+
+ """
+ duration = params[0]
+ return utils.TestDelay(duration)
+
class MyRealm:
"""Simple realm that forwards all requests to a ServerObject.
"""
options, args = ParseOptions()
+ utils.debug = options.debug
for fname in (constants.SSL_CERT_FILE,):
if not os.path.isfile(fname):
print "config %s not there, will not run." % fname
os.close(fd)
except OSError: # ERROR, fd wasn't open to begin with (ignored)
pass
- os.open(REDIRECT_TO, os.O_RDWR|os.O_CREAT|os.O_APPEND) # standard input (0)
+ os.open(REDIRECT_TO, os.O_RDWR|os.O_CREAT|os.O_APPEND, 0600)
# Duplicate standard input to standard output and standard error.
os.dup2(0, 1) # standard output (1)
os.dup2(0, 2) # standard error (2)