self._cmd = _cmd
- def _GetCommand(self):
+ def _GetCommand(self, hvparams=None):
"""Returns Xen command to use.
+ @type hvparams: dict of strings
+ @param hvparams: hypervisor parameters
+
"""
if self._cmd is None:
- # TODO: Make command a hypervisor parameter
- cmd = constants.XEN_CMD
+ 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
hv = hv_xen.XenHypervisor(_cmd="invalidcommand")
self.assertRaises(errors.ProgrammerError, hv._GetCommand, None)
+ def testCommandHvparams(self):
+ expected_cmd = "xl"
+ test_hvparams = {constants.HV_XEN_CMD: constants.XEN_CMD_XL}
+ hv = hv_xen.XenHypervisor()
+ self.assertEqual(hv._GetCommand(hvparams=test_hvparams), expected_cmd)
+
+ def testCommandHvparamsInvalid(self):
+ test_hvparams = {}
+ hv = hv_xen.XenHypervisor()
+ self.assertRaises(KeyError, hv._GetCommand, test_hvparams)
+
+ def testCommandHvparamsCmdInvalid(self):
+ test_hvparams = {constants.HV_XEN_CMD: "invalidcommand"}
+ hv = hv_xen.XenHypervisor()
+ self.assertRaises(errors.ProgrammerError, hv._GetCommand, test_hvparams)
+
class TestParseXmList(testutils.GanetiTestCase):
def test(self):