Revision a08e181f

b/Makefile.am
1035 1035
	test/data/proc_drbd83_sync.txt \
1036 1036
	test/data/proc_drbd83_sync_want.txt \
1037 1037
	test/data/proc_drbd83_sync_krnl2.6.39.txt \
1038
	test/data/qa-minimal-nodes-instances-only.json \
1038 1039
	test/data/sys_drbd_usermode_helper.txt \
1039 1040
	test/data/vgreduce-removemissing-2.02.02.txt \
1040 1041
	test/data/vgreduce-removemissing-2.02.66-fail.txt \
b/qa/qa_config.py
36 36
_INSTANCE_CHECK_KEY = "instance-check"
37 37
_ENABLED_HV_KEY = "enabled-hypervisors"
38 38

  
39
#: Cluster-wide run-time value of the exclusive storage flag
40
_exclusive_storage = None
41

  
42

  
43 39
#: QA configuration (L{_QaConfig})
44 40
_config = None
45 41

  
......
51 47
    """
52 48
    self._data = data
53 49

  
50
    #: Cluster-wide run-time value of the exclusive storage flag
51
    self._exclusive_storage = None
52

  
54 53
  @classmethod
55 54
  def Load(cls, filename):
56 55
    """Loads a configuration file and produces a configuration object.
......
159 158
    """
160 159
    return self.GetEnabledHypervisors()[0]
161 160

  
161
  def SetExclusiveStorage(self, value):
162
    """Set the expected value of the C{exclusive_storage} flag for the cluster.
163

  
164
    """
165
    self._exclusive_storage = bool(value)
166

  
167
  def GetExclusiveStorage(self):
168
    """Get the expected value of the C{exclusive_storage} flag for the cluster.
169

  
170
    """
171
    value = self._exclusive_storage
172
    assert value is not None
173
    return value
174

  
175
  def IsTemplateSupported(self, templ):
176
    """Is the given disk template supported by the current configuration?
177

  
178
    """
179
    if self.GetExclusiveStorage():
180
      return templ in constants.DTS_EXCL_STORAGE
181
    else:
182
      return True
183

  
162 184

  
163 185
def Load(path):
164 186
  """Loads the passed configuration file.
......
337 359

  
338 360

  
339 361
def SetExclusiveStorage(value):
340
  """Set the expected value of the exclusive_storage flag for the cluster.
362
  """Wrapper for L{_QaConfig.SetExclusiveStorage}.
341 363

  
342 364
  """
343
  global _exclusive_storage # pylint: disable=W0603
344

  
345
  _exclusive_storage = bool(value)
365
  return GetConfig().SetExclusiveStorage(value)
346 366

  
347 367

  
348 368
def GetExclusiveStorage():
349
  """Get the expected value of the exclusive_storage flag for the cluster.
369
  """Wrapper for L{_QaConfig.GetExclusiveStorage}.
350 370

  
351 371
  """
352
  val = _exclusive_storage
353
  assert val is not None
354
  return val
372
  return GetConfig().GetExclusiveStorage()
355 373

  
356 374

  
357 375
def IsTemplateSupported(templ):
358
  """Is the given disk template supported by the current configuration?
376
  """Wrapper for L{_QaConfig.GetExclusiveStorage}.
359 377

  
360 378
  """
361
  if GetExclusiveStorage():
362
    return templ in constants.DTS_EXCL_STORAGE
363
  else:
364
    return True
379
  return GetConfig().IsTemplateSupported(templ)
365 380

  
366 381

  
367 382
def AcquireNode(exclude=None):
b/test/data/qa-minimal-nodes-instances-only.json
1
{
2
  "name": "xen-test-qa-minimal-nodes-instances-only",
3

  
4
  "disk": ["1G", "512M"],
5
  "disk-growth": ["2G", "768M"],
6

  
7
  "nodes": [
8
    {
9
      "# Master node": null,
10
      "primary": "xen-test-0",
11
      "secondary": "192.0.2.1"
12
    },
13

  
14
    {
15
      "primary": "xen-test-1",
16
      "secondary": "192.0.2.2"
17
    },
18

  
19
    {
20
      "primary": "xen-test-2",
21
      "secondary": "192.0.2.3"
22
    },
23

  
24
    {
25
      "primary": "xen-test-3",
26
      "secondary": "192.0.2.4"
27
    }
28
  ],
29

  
30
  "instances": [
31
    {
32
      "name": "xen-test-inst1",
33
      "nic.mac/0": "AA:00:00:11:11:11"
34
    },
35
    {
36
      "name": "xen-test-inst2",
37
      "nic.mac/0": "AA:00:00:22:22:22"
38
    }
39
  ],
40

  
41
  "tests": {
42
    "default": false
43
  },
44

  
45
  "# vim: set syntax=javascript :": null
46
}
b/test/py/qa.qa_config_unittest.py
252 252
    self.assertEqual(self.config.GetMasterNode(), self.config["nodes"][0])
253 253

  
254 254

  
255
class TestQaConfig(unittest.TestCase):
256
  def setUp(self):
257
    filename = \
258
      testutils.TestDataFilename("qa-minimal-nodes-instances-only.json")
259

  
260
    self.config = qa_config._QaConfig.Load(filename)
261

  
262
  def testExclusiveStorage(self):
263
    self.assertRaises(AssertionError, self.config.GetExclusiveStorage)
264

  
265
    for value in [False, True, 0, 1, 30804, ""]:
266
      self.config.SetExclusiveStorage(value)
267
      self.assertEqual(self.config.GetExclusiveStorage(), bool(value))
268

  
269
      for template in constants.DISK_TEMPLATES:
270
        if value and template not in constants.DTS_EXCL_STORAGE:
271
          self.assertFalse(self.config.IsTemplateSupported(template))
272
        else:
273
          self.assertTrue(self.config.IsTemplateSupported(template))
274

  
275

  
255 276
if __name__ == "__main__":
256 277
  testutils.GanetiTestProgram()

Also available in: Unified diff