Commit 46c293f0 authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

rpc: Convert wrappers for starting import/export daemons


Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent f69b367e
......@@ -145,6 +145,22 @@ _INSTANCE_CALLS = [
]
_IMPEXP_CALLS = [
("import_start", SINGLE, TMO_NORMAL, [
("opts", OBJECT_TO_DICT, None),
("instance", INST_TO_DICT, None),
("component", None, None),
("dest", None, None),
("dest_args", "self._EncodeImportExportIO(dest, %s)", None),
], None, "Starts an import daemon"),
("export_start", SINGLE, TMO_NORMAL, [
("opts", OBJECT_TO_DICT, None),
("host", None, None),
("port", None, None),
("instance", INST_TO_DICT, None),
("component", None, None),
("source", None, None),
("source_args", "self._EncodeImportExportIO(source, %s)", None),
], None, "Starts an export daemon"),
("impexp_status", SINGLE, TMO_FAST, [
("names", None, "Import/export names"),
], "self._ImpExpStatusPostProc", "Gets the status of an import or export"),
......
......@@ -437,21 +437,6 @@ class _RpcProcessor:
return self._CombineResults(results, requests, procedure)
def _EncodeImportExportIO(ieio, ieioargs):
"""Encodes import/export I/O information.
"""
if ieio == constants.IEIO_RAW_DISK:
assert len(ieioargs) == 1
return (ieioargs[0].ToDict(), )
if ieio == constants.IEIO_SCRIPT:
assert len(ieioargs) == 2
return (ieioargs[0].ToDict(), ieioargs[1])
return ieioargs
class RpcRunner(_generated_rpc.RpcClientDefault):
"""RPC runner class.
......@@ -621,6 +606,21 @@ class RpcRunner(_generated_rpc.RpcClientDefault):
return result
@staticmethod
def _EncodeImportExportIO(ieio, ieioargs):
"""Encodes import/export I/O information.
"""
if ieio == constants.IEIO_RAW_DISK:
assert len(ieioargs) == 1
return (ieioargs[0].ToDict(), )
if ieio == constants.IEIO_SCRIPT:
assert len(ieioargs) == 2
return (ieioargs[0].ToDict(), ieioargs[1])
return ieioargs
#
# Begin RPC calls
#
......@@ -832,44 +832,3 @@ class RpcRunner(_generated_rpc.RpcClientDefault):
hv_full = objects.FillDict(cluster.hvparams.get(hvname, {}), hvparams)
return self._MultiNodeCall(node_list, "hypervisor_validate_params",
[hvname, hv_full])
@_RpcTimeout(_TMO_NORMAL)
def call_import_start(self, node, opts, instance, component,
dest, dest_args):
"""Starts a listener for an import.
This is a single-node call.
@type node: string
@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), component, dest,
_EncodeImportExportIO(dest, dest_args)])
@_RpcTimeout(_TMO_NORMAL)
def call_export_start(self, node, opts, host, port,
instance, component, source, source_args):
"""Starts an export daemon.
This is a single-node call.
@type node: string
@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),
component, source,
_EncodeImportExportIO(source, source_args)])
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