- def _MultiNodeCall(self, node_list, procedure, args, read_timeout=None):
- """Helper for making a multi-node call
-
- """
- body = serializer.DumpJson(args, indent=False)
- return self._proc(node_list, procedure, body, read_timeout=read_timeout)
-
- def _Call(self, node_list, procedure, timeout, args):
- """Entry point for automatically generated RPC wrappers.
-
- """
- return self._MultiNodeCall(node_list, procedure, args, read_timeout=timeout)
-
- @staticmethod
- def _StaticMultiNodeCall(node_list, procedure, args,
- address_list=None, read_timeout=None):
- """Helper for making a multi-node static call
-
- """
- body = serializer.DumpJson(args, indent=False)
-
- if address_list is None:
- resolver = _SsconfResolver
- else:
- # Caller provided an address list
- resolver = _StaticResolver(address_list)
-
- proc = _RpcProcessor(resolver,
- netutils.GetDaemonPort(constants.NODED))
- return proc(node_list, procedure, body, read_timeout=read_timeout)
-
- def _SingleNodeCall(self, node, procedure, args, read_timeout=None):
- """Helper for making a single-node call
-
- """
- body = serializer.DumpJson(args, indent=False)
- return self._proc([node], procedure, body, read_timeout=read_timeout)[node]
-
- @classmethod
- def _StaticSingleNodeCall(cls, node, procedure, args, read_timeout=None):
- """Helper for making a single-node static call
-
- """
- body = serializer.DumpJson(args, indent=False)
- proc = _RpcProcessor(_SsconfResolver,
- netutils.GetDaemonPort(constants.NODED))
- return proc([node], procedure, body, read_timeout=read_timeout)[node]
-
- @staticmethod
- def _BlockdevFindPostProc(result):
- if not result.fail_msg and result.payload is not None:
- result.payload = objects.BlockDevStatus.FromDict(result.payload)
- return result
-
- @staticmethod
- def _BlockdevGetMirrorStatusPostProc(result):
- if not result.fail_msg:
- result.payload = [objects.BlockDevStatus.FromDict(i)
- for i in result.payload]
- return result
-
- @staticmethod
- def _BlockdevGetMirrorStatusMultiPostProc(result):
- 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
-
- @staticmethod
- def _OsGetPostProc(result):
- if not result.fail_msg and isinstance(result.payload, dict):
- result.payload = objects.OS.FromDict(result.payload)
- return result
-
- @staticmethod
- def _PrepareFinalizeExportDisks(snap_disks):
- flat_disks = []
-
- for disk in snap_disks:
- if isinstance(disk, bool):
- flat_disks.append(disk)
- else:
- flat_disks.append(disk.ToDict())
-
- return flat_disks
-
- @staticmethod
- def _ImpExpStatusPostProc(result):
- """Post-processor for import/export status.
-
- @rtype: Payload containing list of L{objects.ImportExportStatus} instances
- @return: Returns a list of the state of each named import/export or None if
- a status couldn't be retrieved
-
- """
- if not result.fail_msg:
- decoded = []
-
- for i in result.payload:
- if i is None:
- decoded.append(None)
- continue
- decoded.append(objects.ImportExportStatus.FromDict(i))
-
- result.payload = decoded
-
- 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