Revision efb8da02 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
735 | 735 |
return instances |
736 | 736 |
|
737 | 737 |
|
738 |
def _GetStorageTypeArgs(cfg, storage_type): |
|
739 |
"""Returns the arguments for a storage type. |
|
740 |
|
|
741 |
""" |
|
742 |
# Special case for file storage |
|
743 |
if storage_type == constants.ST_FILE: |
|
744 |
return [cfg.GetFileStorageDir()] |
|
745 |
|
|
746 |
return [] |
|
747 |
|
|
748 |
|
|
738 | 749 |
class LUDestroyCluster(NoHooksLU): |
739 | 750 |
"""Logical unit for destroying the cluster. |
740 | 751 |
|
... | ... | |
2349 | 2360 |
"""Computes the list of nodes and their attributes. |
2350 | 2361 |
|
2351 | 2362 |
""" |
2352 |
# Special case for file storage |
|
2353 |
if self.op.storage_type == constants.ST_FILE: |
|
2354 |
st_args = [self.cfg.GetFileStorageDir()] |
|
2355 |
else: |
|
2356 |
st_args = [] |
|
2357 |
|
|
2358 | 2363 |
# Always get name to sort by |
2359 | 2364 |
if constants.SF_NAME in self.op.output_fields: |
2360 | 2365 |
fields = self.op.output_fields[:] |
... | ... | |
2368 | 2373 |
field_idx = dict([(name, idx) for (idx, name) in enumerate(fields)]) |
2369 | 2374 |
name_idx = field_idx[constants.SF_NAME] |
2370 | 2375 |
|
2376 |
st_args = _GetStorageTypeArgs(self.cfg, self.op.storage_type) |
|
2371 | 2377 |
data = self.rpc.call_storage_list(self.nodes, |
2372 | 2378 |
self.op.storage_type, st_args, |
2373 | 2379 |
self.op.name, fields) |
... | ... | |
2406 | 2412 |
return result |
2407 | 2413 |
|
2408 | 2414 |
|
2415 |
class LUModifyNodeStorage(NoHooksLU): |
|
2416 |
"""Logical unit for modifying a storage volume on a node. |
|
2417 |
|
|
2418 |
""" |
|
2419 |
_OP_REQP = ["node_name", "storage_type", "name", "changes"] |
|
2420 |
REQ_BGL = False |
|
2421 |
|
|
2422 |
def CheckArguments(self): |
|
2423 |
node_name = self.cfg.ExpandNodeName(self.op.node_name) |
|
2424 |
if node_name is None: |
|
2425 |
raise errors.OpPrereqError("Invalid node name '%s'" % self.op.node_name) |
|
2426 |
|
|
2427 |
self.op.node_name = node_name |
|
2428 |
|
|
2429 |
storage_type = self.op.storage_type |
|
2430 |
if storage_type not in constants.VALID_STORAGE_FIELDS: |
|
2431 |
raise errors.OpPrereqError("Unknown storage type: %s" % storage_type) |
|
2432 |
|
|
2433 |
def ExpandNames(self): |
|
2434 |
self.needed_locks = { |
|
2435 |
locking.LEVEL_NODE: self.op.node_name, |
|
2436 |
} |
|
2437 |
|
|
2438 |
def CheckPrereq(self): |
|
2439 |
"""Check prerequisites. |
|
2440 |
|
|
2441 |
""" |
|
2442 |
storage_type = self.op.storage_type |
|
2443 |
|
|
2444 |
try: |
|
2445 |
modifiable = constants.MODIFIABLE_STORAGE_FIELDS[storage_type] |
|
2446 |
except KeyError: |
|
2447 |
raise errors.OpPrereqError("Storage units of type '%s' can not be" |
|
2448 |
" modified" % storage_type) |
|
2449 |
|
|
2450 |
diff = set(self.op.changes.keys()) - modifiable |
|
2451 |
if diff: |
|
2452 |
raise errors.OpPrereqError("The following fields can not be modified for" |
|
2453 |
" storage units of type '%s': %r" % |
|
2454 |
(storage_type, list(diff))) |
|
2455 |
|
|
2456 |
def Exec(self, feedback_fn): |
|
2457 |
"""Computes the list of nodes and their attributes. |
|
2458 |
|
|
2459 |
""" |
|
2460 |
st_args = _GetStorageTypeArgs(self.cfg, self.op.storage_type) |
|
2461 |
result = self.rpc.call_storage_modify(self.op.node_name, |
|
2462 |
self.op.storage_type, st_args, |
|
2463 |
self.op.name, self.op.changes) |
|
2464 |
result.Raise("Failed to modify storage unit '%s' on %s" % |
|
2465 |
(self.op.name, self.op.node_name)) |
|
2466 |
|
|
2467 |
|
|
2409 | 2468 |
class LUAddNode(LogicalUnit): |
2410 | 2469 |
"""Logical unit for adding node to the cluster. |
2411 | 2470 |
|
... | ... | |
2773 | 2832 |
def ExpandNames(self): |
2774 | 2833 |
"""Locking for PowercycleNode. |
2775 | 2834 |
|
2776 |
This is a last-resource option and shouldn't block on other
|
|
2835 |
This is a last-resort option and shouldn't block on other
|
|
2777 | 2836 |
jobs. Therefore, we grab no locks. |
2778 | 2837 |
|
2779 | 2838 |
""" |
Also available in: Unified diff