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

rpc: Convert blockdev-related calls


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 2effde8d
......@@ -343,5 +343,5 @@ _MISC_CALLS = [
CALLS = {
"RpcClientDefault": (_IMPEXP_CALLS + _X509_CALLS + _OS_CALLS + _NODE_CALLS +
_FILE_STORAGE_CALLS + _MISC_CALLS + _INSTANCE_CALLS),
_FILE_STORAGE_CALLS + _MISC_CALLS + _INSTANCE_CALLS + _BLOCKDEV_CALLS),
}
......@@ -625,15 +625,6 @@ class RpcRunner(_generated_rpc.RpcClientDefault):
# Begin RPC calls
#
@_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_NORMAL)
def call_storage_list(self, node_list, su_name, su_args, name, fields):
"""Get list of storage units.
......@@ -758,203 +749,6 @@ class RpcRunner(_generated_rpc.RpcClientDefault):
"""
return cls._StaticMultiNodeCall(node_list, "version", [])
@_RpcTimeout(_TMO_NORMAL)
def call_blockdev_create(self, node, bdev, size, owner, on_primary, info):
"""Request creation of a given block device.
This is a single-node call.
"""
return self._SingleNodeCall(node, "blockdev_create",
[bdev.ToDict(), size, owner, on_primary, info])
@_RpcTimeout(_TMO_SLOW)
def call_blockdev_wipe(self, node, bdev, offset, size):
"""Request wipe at given offset with given size of a block device.
This is a single-node call.
"""
return self._SingleNodeCall(node, "blockdev_wipe",
[bdev.ToDict(), offset, size])
@_RpcTimeout(_TMO_NORMAL)
def call_blockdev_remove(self, node, bdev):
"""Request removal of a given block device.
This is a single-node call.
"""
return self._SingleNodeCall(node, "blockdev_remove", [bdev.ToDict()])
@_RpcTimeout(_TMO_NORMAL)
def call_blockdev_rename(self, node, devlist):
"""Request rename of the given block devices.
This is a single-node call.
"""
return self._SingleNodeCall(node, "blockdev_rename",
[[(d.ToDict(), uid) for d, uid in devlist]])
@_RpcTimeout(_TMO_NORMAL)
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, idx])
@_RpcTimeout(_TMO_NORMAL)
def call_blockdev_shutdown(self, node, disk):
"""Request shutdown of a given block device.
This is a single-node call.
"""
return self._SingleNodeCall(node, "blockdev_shutdown", [disk.ToDict()])
@_RpcTimeout(_TMO_NORMAL)
def call_blockdev_addchildren(self, node, bdev, ndevs):
"""Request adding a list of children to a (mirroring) device.
This is a single-node call.
"""
return self._SingleNodeCall(node, "blockdev_addchildren",
[bdev.ToDict(),
[disk.ToDict() for disk in ndevs]])
@_RpcTimeout(_TMO_NORMAL)
def call_blockdev_removechildren(self, node, bdev, ndevs):
"""Request removing a list of children from a (mirroring) device.
This is a single-node call.
"""
return self._SingleNodeCall(node, "blockdev_removechildren",
[bdev.ToDict(),
[disk.ToDict() for disk in ndevs]])
@_RpcTimeout(_TMO_NORMAL)
def call_blockdev_getmirrorstatus(self, node, disks):
"""Request status of a (mirroring) device.
This is a single-node call.
"""
result = self._SingleNodeCall(node, "blockdev_getmirrorstatus",
[dsk.ToDict() for dsk in disks])
if not result.fail_msg:
result.payload = [objects.BlockDevStatus.FromDict(i)
for i in result.payload]
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.
This is a single-node call.
"""
result = self._SingleNodeCall(node, "blockdev_find", [disk.ToDict()])
if not result.fail_msg and result.payload is not None:
result.payload = objects.BlockDevStatus.FromDict(result.payload)
return result
@_RpcTimeout(_TMO_NORMAL)
def call_blockdev_close(self, node, instance_name, disks):
"""Closes the given block devices.
This is a single-node call.
"""
params = [instance_name, [cf.ToDict() for cf in disks]]
return self._SingleNodeCall(node, "blockdev_close", params)
@_RpcTimeout(_TMO_NORMAL)
def call_blockdev_getsize(self, node, disks):
"""Returns the size of the given disks.
This is a single-node call.
"""
params = [[cf.ToDict() for cf in disks]]
return self._SingleNodeCall(node, "blockdev_getsize", params)
@_RpcTimeout(_TMO_NORMAL)
def call_drbd_disconnect_net(self, node_list, nodes_ip, disks):
"""Disconnects the network of the given drbd devices.
This is a multi-node call.
"""
return self._MultiNodeCall(node_list, "drbd_disconnect_net",
[nodes_ip, [cf.ToDict() for cf in disks]])
@_RpcTimeout(_TMO_NORMAL)
def call_drbd_attach_net(self, node_list, nodes_ip,
disks, instance_name, multimaster):
"""Disconnects the given drbd devices.
This is a multi-node call.
"""
return self._MultiNodeCall(node_list, "drbd_attach_net",
[nodes_ip, [cf.ToDict() for cf in disks],
instance_name, multimaster])
@_RpcTimeout(_TMO_SLOW)
def call_drbd_wait_sync(self, node_list, nodes_ip, disks):
"""Waits for the synchronization of drbd devices is complete.
This is a multi-node call.
"""
return self._MultiNodeCall(node_list, "drbd_wait_sync",
[nodes_ip, [cf.ToDict() for cf in disks]])
@_RpcTimeout(_TMO_URGENT)
def call_drbd_helper(self, node_list):
"""Gets drbd helper.
This is a multi-node call.
"""
return self._MultiNodeCall(node_list, "drbd_helper", [])
@classmethod
@_RpcTimeout(_TMO_NORMAL)
def call_upload_file(cls, node_list, file_name, address_list=None):
......@@ -993,37 +787,6 @@ class RpcRunner(_generated_rpc.RpcClientDefault):
"""
return cls._StaticMultiNodeCall(node_list, "write_ssconf_files", [values])
@_RpcTimeout(_TMO_NORMAL)
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, dryrun])
@_RpcTimeout(_TMO_1DAY)
def call_blockdev_export(self, node, cf_bdev,
dest_node, dest_path, cluster_name):
"""Export a given disk to another node.
This is a single-node call.
"""
return self._SingleNodeCall(node, "blockdev_export",
[cf_bdev.ToDict(), dest_node, dest_path,
cluster_name])
@_RpcTimeout(_TMO_NORMAL)
def call_blockdev_snapshot(self, node, cf_bdev):
"""Request a snapshot of the given block device.
This is a single-node call.
"""
return self._SingleNodeCall(node, "blockdev_snapshot", [cf_bdev.ToDict()])
@classmethod
@_RpcTimeout(_TMO_NORMAL)
def call_node_leave_cluster(cls, node, modify_ssh_setup):
......
......@@ -277,7 +277,7 @@ class NodeHttpServer(http.server.HttpServer):
"""
disks = [objects.Disk.FromDict(dsk_s)
for dsk_s in params]
for dsk_s in params[0]]
return [status.ToDict()
for status in backend.BlockdevGetmirrorstatus(disks)]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment