Revision 75bf3149 test/py/ganeti.backend_unittest.py

b/test/py/ganeti.backend_unittest.py
77 77

  
78 78

  
79 79
class TestNodeVerify(testutils.GanetiTestCase):
80

  
81
  def setUp(self):
82
    testutils.GanetiTestCase.setUp(self)
83
    self._mock_hv = None
84

  
85
  def _GetHypervisor(self, hv_name):
86
    self._mock_hv = hypervisor.GetHypervisor(hv_name)
87
    self._mock_hv.ValidateParameters = mock.Mock()
88
    self._mock_hv.Verify = mock.Mock()
89
    return self._mock_hv
90

  
80 91
  def testMasterIPLocalhost(self):
81 92
    # this a real functional test, but requires localhost to be reachable
82 93
    local_data = (netutils.Hostname.GetSysName(),
83 94
                  constants.IP4_ADDRESS_LOCALHOST)
84
    result = backend.VerifyNode({constants.NV_MASTERIP: local_data}, None)
95
    result = backend.VerifyNode({constants.NV_MASTERIP: local_data}, None, {})
85 96
    self.failUnless(constants.NV_MASTERIP in result,
86 97
                    "Master IP data not returned")
87 98
    self.failUnless(result[constants.NV_MASTERIP], "Cannot reach localhost")
......
92 103
    bad_data =  ("master.example.com", "192.0.2.1")
93 104
    # we just test that whatever TcpPing returns, VerifyNode returns too
94 105
    netutils.TcpPing = lambda a, b, source=None: False
95
    result = backend.VerifyNode({constants.NV_MASTERIP: bad_data}, None)
106
    result = backend.VerifyNode({constants.NV_MASTERIP: bad_data}, None, {})
96 107
    self.failUnless(constants.NV_MASTERIP in result,
97 108
                    "Master IP data not returned")
98 109
    self.failIf(result[constants.NV_MASTERIP],
99 110
                "Result from netutils.TcpPing corrupted")
100 111

  
112
  def testVerifyHvparams(self):
113
    test_hvparams = {constants.HV_XEN_CMD: constants.XEN_CMD_XL}
114
    test_what = {constants.NV_HVPARAMS: \
115
        [("mynode", constants.HT_XEN_PVM, test_hvparams)]}
116
    result = {}
117
    backend._VerifyHvparams(test_what, True, result,
118
                            get_hv_fn=self._GetHypervisor)
119
    self._mock_hv.ValidateParameters.assert_called_with(test_hvparams)
120

  
121
  def testVerifyHypervisors(self):
122
    hvname = constants.HT_XEN_PVM
123
    hvparams = {constants.HV_XEN_CMD: constants.XEN_CMD_XL}
124
    all_hvparams = {hvname: hvparams}
125
    test_what = {constants.NV_HYPERVISOR: [hvname]}
126
    result = {}
127
    backend._VerifyHypervisors(
128
        test_what, True, result, all_hvparams=all_hvparams,
129
        get_hv_fn=self._GetHypervisor)
130
    self._mock_hv.Verify.assert_called_with(hvparams=hvparams)
131

  
101 132

  
102 133
def _DefRestrictedCmdOwner():
103 134
  return (os.getuid(), os.getgid())

Also available in: Unified diff