+ def __init__(self, _cfgdir=None, _run_cmd_fn=None, _cmd=None):
+ hv_base.BaseHypervisor.__init__(self)
+
+ if _cfgdir is None:
+ self._cfgdir = pathutils.XEN_CONFIG_DIR
+ else:
+ self._cfgdir = _cfgdir
+
+ if _run_cmd_fn is None:
+ self._run_cmd_fn = utils.RunCmd
+ else:
+ self._run_cmd_fn = _run_cmd_fn
+
+ self._cmd = _cmd
+
+ def _GetCommand(self, hvparams=None):
+ """Returns Xen command to use.
+
+ @type hvparams: dict of strings
+ @param hvparams: hypervisor parameters
+
+ """
+ if self._cmd is None:
+ if hvparams is not None:
+ cmd = hvparams[constants.HV_XEN_CMD]
+ else:
+ # TODO: Remove autoconf option once retrieving the command from
+ # the hvparams is fully implemented.
+ cmd = constants.XEN_CMD
+ else:
+ cmd = self._cmd
+
+ if cmd not in constants.KNOWN_XEN_COMMANDS:
+ raise errors.ProgrammerError("Unknown Xen command '%s'" % cmd)
+
+ return cmd
+
+ def _RunXen(self, args, hvparams=None):
+ """Wrapper around L{utils.process.RunCmd} to run Xen command.
+
+ @type hvparams: dict of strings
+ @param hvparams: dictionary of hypervisor params
+ @see: L{utils.process.RunCmd}
+
+ """
+ cmd = [self._GetCommand(hvparams=hvparams)]
+ cmd.extend(args)
+
+ return self._run_cmd_fn(cmd)
+
+ def _ConfigFileName(self, instance_name):