Revision 51a95d00

b/lib/hypervisor/hv_xen.py
335 335

  
336 336
    self._cmd = _cmd
337 337

  
338
  def _GetCommand(self):
338
  def _GetCommand(self, hvparams=None):
339 339
    """Returns Xen command to use.
340 340

  
341
    @type hvparams: dict of strings
342
    @param hvparams: hypervisor parameters
343

  
341 344
    """
342 345
    if self._cmd is None:
343
      # TODO: Make command a hypervisor parameter
344
      cmd = constants.XEN_CMD
346
      if hvparams is not None:
347
        cmd = hvparams[constants.HV_XEN_CMD]
348
      else:
349
        # TODO: Remove autoconf option once retrieving the command from
350
        # the hvparams is fully implemented.
351
        cmd = constants.XEN_CMD
345 352
    else:
346 353
      cmd = self._cmd
347 354

  
b/test/py/ganeti.hypervisor.hv_xen_unittest.py
97 97
    hv = hv_xen.XenHypervisor(_cmd="invalidcommand")
98 98
    self.assertRaises(errors.ProgrammerError, hv._GetCommand, None)
99 99

  
100
  def testCommandHvparams(self):
101
    expected_cmd = "xl"
102
    test_hvparams = {constants.HV_XEN_CMD: constants.XEN_CMD_XL}
103
    hv = hv_xen.XenHypervisor()
104
    self.assertEqual(hv._GetCommand(hvparams=test_hvparams), expected_cmd)
105

  
106
  def testCommandHvparamsInvalid(self):
107
    test_hvparams = {}
108
    hv = hv_xen.XenHypervisor()
109
    self.assertRaises(KeyError, hv._GetCommand, test_hvparams)
110

  
111
  def testCommandHvparamsCmdInvalid(self):
112
    test_hvparams = {constants.HV_XEN_CMD: "invalidcommand"}
113
    hv = hv_xen.XenHypervisor()
114
    self.assertRaises(errors.ProgrammerError, hv._GetCommand, test_hvparams)
115

  
100 116

  
101 117
class TestParseXmList(testutils.GanetiTestCase):
102 118
  def test(self):

Also available in: Unified diff