Revision 2176724e qa/qa_config.py
b/qa/qa_config.py | ||
---|---|---|
44 | 44 |
__slots__ = [ |
45 | 45 |
"name", |
46 | 46 |
"nicmac", |
47 |
"used", |
|
47 |
"_used",
|
|
48 | 48 |
"_disk_template", |
49 | 49 |
] |
50 | 50 |
|
... | ... | |
54 | 54 |
""" |
55 | 55 |
self.name = name |
56 | 56 |
self.nicmac = nicmac |
57 |
self.used = None |
|
57 |
self._used = None
|
|
58 | 58 |
self._disk_template = None |
59 | 59 |
|
60 | 60 |
@classmethod |
... | ... | |
70 | 70 |
|
71 | 71 |
return cls(name=data["name"], nicmac=nicmac) |
72 | 72 |
|
73 |
def Use(self): |
|
74 |
"""Marks instance as being in use. |
|
75 |
|
|
76 |
""" |
|
77 |
assert not self._used |
|
78 |
assert self._disk_template is None |
|
79 |
|
|
80 |
self._used = True |
|
81 |
|
|
73 | 82 |
def Release(self): |
74 | 83 |
"""Releases instance and makes it available again. |
75 | 84 |
|
76 | 85 |
""" |
77 |
assert self.used, \ |
|
86 |
assert self._used, \
|
|
78 | 87 |
("Instance '%s' was never acquired or released more than once" % |
79 | 88 |
self.name) |
80 | 89 |
|
81 |
self.used = False |
|
90 |
self._used = False
|
|
82 | 91 |
self._disk_template = None |
83 | 92 |
|
84 | 93 |
def GetNicMacAddr(self, idx, default): |
... | ... | |
103 | 112 |
self._disk_template = template |
104 | 113 |
|
105 | 114 |
@property |
115 |
def used(self): |
|
116 |
"""Returns boolean denoting whether instance is in use. |
|
117 |
|
|
118 |
""" |
|
119 |
return self._used |
|
120 |
|
|
121 |
@property |
|
106 | 122 |
def disk_template(self): |
107 | 123 |
"""Returns the current disk template. |
108 | 124 |
|
... | ... | |
485 | 501 |
if not instances: |
486 | 502 |
raise qa_error.OutOfInstancesError("No instances left") |
487 | 503 |
|
488 |
inst = instances[0] |
|
489 |
|
|
490 |
assert not inst.used |
|
491 |
assert inst.disk_template is None |
|
492 |
|
|
493 |
inst.used = True |
|
504 |
instance = instances[0] |
|
505 |
instance.Use() |
|
494 | 506 |
|
495 |
return inst |
|
507 |
return instance
|
|
496 | 508 |
|
497 | 509 |
|
498 | 510 |
def SetExclusiveStorage(value): |
Also available in: Unified diff