-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.
-
- """
- def __init__(self, context):
- """Initialized the RPC runner.
-
- @type context: C{masterd.GanetiContext}
- @param context: Ganeti context
-
- """
- _generated_rpc.RpcClientDefault.__init__(self)
-
- self._cfg = context.cfg
- self._proc = _RpcProcessor(compat.partial(_NodeConfigResolver,
- self._cfg.GetNodeInfo,
- self._cfg.GetAllNodesInfo),
- netutils.GetDaemonPort(constants.NODED),
- lock_monitor_cb=context.glm.AddToLockMonitor)
-
- def _InstDict(self, instance, hvp=None, bep=None, osp=None):
- """Convert the given instance to a dict.
-
- This is done via the instance's ToDict() method and additionally
- we fill the hvparams with the cluster defaults.
-
- @type instance: L{objects.Instance}
- @param instance: an Instance object
- @type hvp: dict or None
- @param hvp: a dictionary with overridden hypervisor parameters
- @type bep: dict or None
- @param bep: a dictionary with overridden backend parameters
- @type osp: dict or None
- @param osp: a dictionary with overridden os parameters
- @rtype: dict
- @return: the instance dict, with the hvparams filled with the
- cluster defaults