- """
- params = [self._InstDict(inst), osdev, swapdev,
- src_node, src_image, cluster_name]
- c = Client("instance_os_import", params)
- self._ConnectNode(c, node)
- c.Run()
- return c.GetResults().get(node, False)
+ encoders = _ENCODERS.copy()
+
+ encoders.update({
+ # Encoders requiring configuration object
+ rpc_defs.ED_INST_DICT: self._InstDict,
+ rpc_defs.ED_INST_DICT_HVP_BEP_DP: self._InstDictHvpBepDp,
+ rpc_defs.ED_INST_DICT_OSP_DP: self._InstDictOspDp,
+
+ # Encoders annotating disk parameters
+ rpc_defs.ED_DISKS_DICT_DP: self._DisksDictDP,
+ rpc_defs.ED_SINGLE_DISK_DICT_DP: self._SingleDiskDictDP,
+
+ # Encoders with special requirements
+ rpc_defs.ED_FILE_DETAILS: compat.partial(_PrepareFileUpload, _getents),
+ })
+
+ # Resolver using configuration
+ resolver = compat.partial(_NodeConfigResolver, cfg.GetNodeInfo,
+ cfg.GetAllNodesInfo)
+
+ # Pylint doesn't recognize multiple inheritance properly, see
+ # <http://www.logilab.org/ticket/36586> and
+ # <http://www.logilab.org/ticket/35642>
+ # pylint: disable=W0233
+ _RpcClientBase.__init__(self, resolver, encoders.get,
+ lock_monitor_cb=lock_monitor_cb,
+ _req_process_fn=_req_process_fn)
+ _generated_rpc.RpcClientConfig.__init__(self)
+ _generated_rpc.RpcClientBootstrap.__init__(self)
+ _generated_rpc.RpcClientDnsOnly.__init__(self)
+ _generated_rpc.RpcClientDefault.__init__(self)
+
+ def _InstDict(self, instance, hvp=None, bep=None, osp=None):
+ """Convert the given instance to a dict.