Revision 5ae7cd11
b/lib/storage.py | ||
---|---|---|
332 | 332 |
yield fields |
333 | 333 |
|
334 | 334 |
|
335 |
def _LvmPvGetAllocatable(attr): |
|
336 |
"""Determines whether LVM PV is allocatable. |
|
337 |
|
|
338 |
@rtype: bool |
|
339 |
|
|
340 |
""" |
|
341 |
if attr: |
|
342 |
return (attr[0] == "a") |
|
343 |
else: |
|
344 |
logging.warning("Invalid PV attribute: %r", attr) |
|
345 |
return False |
|
346 |
|
|
347 |
|
|
335 | 348 |
class LvmPvStorage(_LvmBase): # pylint: disable-msg=W0223 |
336 | 349 |
"""LVM Physical Volume storage unit. |
337 | 350 |
|
338 | 351 |
""" |
339 |
@staticmethod |
|
340 |
def _GetAllocatable(attr): |
|
341 |
if attr: |
|
342 |
return (attr[0] == "a") |
|
343 |
else: |
|
344 |
logging.warning("Invalid PV attribute: %r", attr) |
|
345 |
return False |
|
346 |
|
|
347 | 352 |
LIST_COMMAND = "pvs" |
348 | 353 |
|
349 | 354 |
# Make sure to update constants.VALID_STORAGE_FIELDS when changing field |
... | ... | |
353 | 358 |
(constants.SF_SIZE, ["pv_size"], _ParseSize), |
354 | 359 |
(constants.SF_USED, ["pv_used"], _ParseSize), |
355 | 360 |
(constants.SF_FREE, ["pv_free"], _ParseSize), |
356 |
(constants.SF_ALLOCATABLE, ["pv_attr"], _GetAllocatable), |
|
361 |
(constants.SF_ALLOCATABLE, ["pv_attr"], _LvmPvGetAllocatable),
|
|
357 | 362 |
] |
358 | 363 |
|
359 | 364 |
def _SetAllocatable(self, name, allocatable): |
b/qa/qa_node.py | ||
---|---|---|
150 | 150 |
else: |
151 | 151 |
test_allocatable = ["yes", "no"] |
152 | 152 |
|
153 |
if (constants.SF_ALLOCATABLE in
|
|
154 |
constants.MODIFIABLE_STORAGE_FIELDS.get(storage_type, [])):
|
|
155 |
assert_fn = AssertEqual |
|
156 |
else:
|
|
153 |
fail = (constants.SF_ALLOCATABLE not in
|
|
154 |
constants.MODIFIABLE_STORAGE_FIELDS.get(storage_type, []))
|
|
155 |
|
|
156 |
if fail:
|
|
157 | 157 |
assert_fn = AssertNotEqual |
158 |
else: |
|
159 |
assert_fn = AssertEqual |
|
158 | 160 |
|
159 | 161 |
for i in test_allocatable: |
160 | 162 |
cmd = ["gnt-node", "modify-storage", "--allocatable", i, |
... | ... | |
162 | 164 |
assert_fn(StartSSH(master["primary"], |
163 | 165 |
utils.ShellQuoteArgs(cmd)).wait(), 0) |
164 | 166 |
|
167 |
# Verify list output |
|
168 |
cmd = ["gnt-node", "list-storage", "--storage-type", storage_type, |
|
169 |
"--output=name,allocatable", "--separator=|", |
|
170 |
"--no-headers", node_name] |
|
171 |
listout = qa_utils.GetCommandOutput(master["primary"], |
|
172 |
utils.ShellQuoteArgs(cmd)) |
|
173 |
for line in listout.splitlines(): |
|
174 |
(vfy_name, vfy_allocatable) = line.split("|") |
|
175 |
if vfy_name == st_name and not fail: |
|
176 |
AssertEqual(vfy_allocatable, i[0].upper()) |
|
177 |
else: |
|
178 |
AssertEqual(vfy_allocatable, st_allocatable) |
|
179 |
|
|
165 | 180 |
# Test repair functionality |
166 | 181 |
cmd = ["gnt-node", "repair-storage", node_name, storage_type, st_name] |
167 | 182 |
|
Also available in: Unified diff