#
#
-# Copyright (C) 2006, 2007, 2008, 2009, 2010 Google Inc.
+# Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Google Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
from ganeti import errors
from ganeti import netutils
from ganeti import ssconf
+from ganeti import runtime
# pylint has a bug here, doesn't see this import
import ganeti.http.client # pylint: disable-msg=W0611
self.fail_msg = None
self.payload = data[1]
- assert hasattr(self, "call")
- assert hasattr(self, "data")
- assert hasattr(self, "fail_msg")
- assert hasattr(self, "node")
- assert hasattr(self, "offline")
- assert hasattr(self, "payload")
+ for attr_name in ["call", "data", "fail_msg",
+ "node", "offline", "payload"]:
+ assert hasattr(self, attr_name), "Missing attribute %s" % attr_name
@staticmethod
def _EnsureErr(val):
#
@_RpcTimeout(_TMO_URGENT)
+ def call_bdev_sizes(self, node_list, devices):
+ """Gets the sizes of requested block devices present on a node
+
+ This is a multi-node call.
+
+ """
+ return self._MultiNodeCall(node_list, "bdev_sizes", [devices])
+
+ @_RpcTimeout(_TMO_URGENT)
def call_lv_list(self, node_list, vg_name):
"""Gets the logical volumes present in a given volume group.
return self._SingleNodeCall(node, "bridges_exist", [bridges_list])
@_RpcTimeout(_TMO_NORMAL)
- def call_instance_start(self, node, instance, hvp, bep):
+ def call_instance_start(self, node, instance, hvp, bep, startup_paused):
"""Starts an instance.
This is a single-node call.
"""
idict = self._InstDict(instance, hvp=hvp, bep=bep)
- return self._SingleNodeCall(node, "instance_start", [idict])
+ return self._SingleNodeCall(node, "instance_start", [idict, startup_paused])
@_RpcTimeout(_TMO_NORMAL)
def call_instance_shutdown(self, node, instance, timeout):
[(d.ToDict(), uid) for d, uid in devlist])
@_RpcTimeout(_TMO_NORMAL)
- def call_blockdev_assemble(self, node, disk, owner, on_primary):
+ def call_blockdev_pause_resume_sync(self, node, disks, pause):
+ """Request a pause/resume of given block device.
+
+ This is a single-node call.
+
+ """
+ return self._SingleNodeCall(node, "blockdev_pause_resume_sync",
+ [[bdev.ToDict() for bdev in disks], pause])
+
+ @_RpcTimeout(_TMO_NORMAL)
+ def call_blockdev_assemble(self, node, disk, owner, on_primary, idx):
"""Request assembling of a given block device.
This is a single-node call.
"""
return self._SingleNodeCall(node, "blockdev_assemble",
- [disk.ToDict(), owner, on_primary])
+ [disk.ToDict(), owner, on_primary, idx])
@_RpcTimeout(_TMO_NORMAL)
def call_blockdev_shutdown(self, node, disk):
return result
@_RpcTimeout(_TMO_NORMAL)
+ def call_blockdev_getmirrorstatus_multi(self, node_list, node_disks):
+ """Request status of (mirroring) devices from multiple nodes.
+
+ This is a multi-node call.
+
+ """
+ result = self._MultiNodeCall(node_list, "blockdev_getmirrorstatus_multi",
+ [dict((name, [dsk.ToDict() for dsk in disks])
+ for name, disks in node_disks.items())])
+ for nres in result.values():
+ if nres.fail_msg:
+ continue
+
+ for idx, (success, status) in enumerate(nres.payload):
+ if success:
+ nres.payload[idx] = (success, objects.BlockDevStatus.FromDict(status))
+
+ return result
+
+ @_RpcTimeout(_TMO_NORMAL)
def call_blockdev_find(self, node, disk):
"""Request identification of a given block device.
return self._SingleNodeCall(node, "blockdev_close", params)
@_RpcTimeout(_TMO_NORMAL)
- def call_blockdev_getsizes(self, node, disks):
+ def call_blockdev_getsize(self, node, disks):
"""Returns the size of the given disks.
This is a single-node call.
file_contents = utils.ReadFile(file_name)
data = cls._Compress(file_contents)
st = os.stat(file_name)
- params = [file_name, data, st.st_mode, st.st_uid, st.st_gid,
- st.st_atime, st.st_mtime]
+ getents = runtime.GetEnts()
+ params = [file_name, data, st.st_mode, getents.LookupUid(st.st_uid),
+ getents.LookupGid(st.st_gid), st.st_atime, st.st_mtime]
return cls._StaticMultiNodeCall(node_list, "upload_file", params,
address_list=address_list)
"""
return cls._StaticMultiNodeCall(node_list, "write_ssconf_files", [values])
+ @_RpcTimeout(_TMO_NORMAL)
+ def call_run_oob(self, node, oob_program, command, remote_node, timeout):
+ """Runs OOB.
+
+ This is a single-node call.
+
+ """
+ return self._SingleNodeCall(node, "run_oob", [oob_program, command,
+ remote_node, timeout])
+
@_RpcTimeout(_TMO_FAST)
def call_os_diagnose(self, node_list):
"""Request a diagnose of OS definitions.
return self._SingleNodeCall(node, "iallocator_runner", [name, idata])
@_RpcTimeout(_TMO_NORMAL)
- def call_blockdev_grow(self, node, cf_bdev, amount):
+ def call_blockdev_grow(self, node, cf_bdev, amount, dryrun):
"""Request a snapshot of the given block device.
This is a single-node call.
"""
return self._SingleNodeCall(node, "blockdev_grow",
- [cf_bdev.ToDict(), amount])
+ [cf_bdev.ToDict(), amount, dryrun])
@_RpcTimeout(_TMO_1DAY)
def call_blockdev_export(self, node, cf_bdev,
[old_file_storage_dir, new_file_storage_dir])
@classmethod
- @_RpcTimeout(_TMO_FAST)
+ @_RpcTimeout(_TMO_URGENT)
def call_jobqueue_update(cls, node_list, address_list, file_name, content):
"""Update job queue.
return cls._StaticSingleNodeCall(node, "jobqueue_purge", [])
@classmethod
- @_RpcTimeout(_TMO_FAST)
+ @_RpcTimeout(_TMO_URGENT)
def call_jobqueue_rename(cls, node_list, address_list, rename):
"""Rename a job queue file.
return self._SingleNodeCall(node, "x509_cert_remove", [name])
@_RpcTimeout(_TMO_NORMAL)
- def call_import_start(self, node, opts, instance, dest, dest_args):
+ def call_import_start(self, node, opts, instance, component,
+ dest, dest_args):
"""Starts a listener for an import.
This is a single-node call.
@param node: Node name
@type instance: C{objects.Instance}
@param instance: Instance object
+ @type component: string
+ @param component: which part of the instance is being imported
"""
return self._SingleNodeCall(node, "import_start",
[opts.ToDict(),
- self._InstDict(instance), dest,
+ self._InstDict(instance), component, dest,
_EncodeImportExportIO(dest, dest_args)])
@_RpcTimeout(_TMO_NORMAL)
def call_export_start(self, node, opts, host, port,
- instance, source, source_args):
+ instance, component, source, source_args):
"""Starts an export daemon.
This is a single-node call.
@param node: Node name
@type instance: C{objects.Instance}
@param instance: Instance object
+ @type component: string
+ @param component: which part of the instance is being imported
"""
return self._SingleNodeCall(node, "export_start",
[opts.ToDict(), host, port,
- self._InstDict(instance), source,
+ self._InstDict(instance),
+ component, source,
_EncodeImportExportIO(source, source_args)])
@_RpcTimeout(_TMO_FAST)