Revision bd39b6bb test/py/cmdlib/testsupport/config_mock.py

b/test/py/cmdlib/testsupport/config_mock.py
18 18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 19
# 02110-1301, USA.
20 20

  
21
import uuid
21

  
22
"""Support for mocking the cluster configuration"""
23

  
24

  
25
import uuid as uuid_module
22 26

  
23 27
from ganeti import config
24 28
from ganeti import constants
......
31 35
  return mocks.FakeGetentResolver()
32 36

  
33 37

  
38
# pylint: disable=R0904
34 39
class ConfigMock(config.ConfigWriter):
35 40
  """A mocked cluster configuration with added methods for easy customization.
36 41

  
......
45 50
                                     _getents=_StubGetEntResolver())
46 51

  
47 52
  def _GetUuid(self):
48
    return str(uuid.uuid4())
53
    return str(uuid_module.uuid4())
49 54

  
50 55
  def AddNewNodeGroup(self,
51 56
                      uuid=None,
......
56 61
                      hv_state_static=None,
57 62
                      disk_state_static=None,
58 63
                      alloc_policy=None,
59
                      networks=[]):
64
                      networks=None):
60 65
    """Add a new L{objects.NodeGroup} to the cluster configuration
61 66

  
62 67
    See L{objects.NodeGroup} for parameter documentation.
......
72 77
      uuid = self._GetUuid()
73 78
    if name is None:
74 79
      name = "mock_group_%d" % group_id
80
    if networks is None:
81
      networks = []
75 82

  
76 83
    group = objects.NodeGroup(uuid=uuid,
77 84
                              name=name,
......
87 94
    self.AddNodeGroup(group, None)
88 95
    return group
89 96

  
97
  # pylint: disable=R0913
90 98
  def AddNewNode(self,
91 99
                 uuid=None,
92 100
                 name=None,
......
154 162
                     primary_node=None,
155 163
                     os="mocked_os",
156 164
                     hypervisor=constants.HT_FAKE,
157
                     hvparams={},
158
                     beparams={},
159
                     osparams={},
165
                     hvparams=None,
166
                     beparams=None,
167
                     osparams=None,
160 168
                     admin_state=constants.ADMINST_DOWN,
161
                     nics=[],
162
                     disks=[],
169
                     nics=None,
170
                     disks=None,
163 171
                     disk_template=constants.DT_DISKLESS,
164 172
                     disks_active=False,
165 173
                     network_port=None):
......
182 190
      primary_node = self._master_node.uuid
183 191
    if isinstance(primary_node, objects.Node):
184 192
      primary_node = self._master_node.uuid
193
    if hvparams is None:
194
      hvparams = {}
195
    if beparams is None:
196
      beparams = {}
197
    if osparams is None:
198
      osparams = {}
199
    if nics is None:
200
      nics = []
201
    if disks is None:
202
      disks = []
185 203

  
186 204
    inst = objects.Instance(uuid=uuid,
187 205
                            name=name,
......
241 259
    pass
242 260

  
243 261
  def _GetRpc(self, address_list):
244
    raise NotImplementedError
262
    raise AssertionError("This should not be used during tests!")

Also available in: Unified diff