Revision 1ca7b773 lib/client/gnt_cluster.py
b/lib/client/gnt_cluster.py | ||
---|---|---|
1397 | 1397 |
return constants.EXIT_FAILURE |
1398 | 1398 |
|
1399 | 1399 |
|
1400 |
def Epo(opts, args): |
|
1400 |
def Epo(opts, args, cl=None, _on_fn=_EpoOn, _off_fn=_EpoOff, |
|
1401 |
_confirm_fn=ConfirmOperation, |
|
1402 |
_stdout_fn=ToStdout, _stderr_fn=ToStderr): |
|
1401 | 1403 |
"""EPO operations. |
1402 | 1404 |
|
1403 | 1405 |
@param opts: the command line options selected by the user |
... | ... | |
1408 | 1410 |
|
1409 | 1411 |
""" |
1410 | 1412 |
if opts.groups and opts.show_all: |
1411 |
ToStderr("Only one of --groups or --all are allowed")
|
|
1413 |
_stderr_fn("Only one of --groups or --all are allowed")
|
|
1412 | 1414 |
return constants.EXIT_FAILURE |
1413 | 1415 |
elif args and opts.show_all: |
1414 |
ToStderr("Arguments in combination with --all are not allowed")
|
|
1416 |
_stderr_fn("Arguments in combination with --all are not allowed")
|
|
1415 | 1417 |
return constants.EXIT_FAILURE |
1416 | 1418 |
|
1417 |
client = GetClient() |
|
1419 |
if cl is None: |
|
1420 |
cl = GetClient() |
|
1418 | 1421 |
|
1419 | 1422 |
if opts.groups: |
1420 |
node_query_list = itertools.chain(*client.QueryGroups(names=args, |
|
1421 |
fields=["node_list"], |
|
1422 |
use_locking=False)) |
|
1423 |
node_query_list = \ |
|
1424 |
itertools.chain(*cl.QueryGroups(args, ["node_list"], False)) |
|
1423 | 1425 |
else: |
1424 | 1426 |
node_query_list = args |
1425 | 1427 |
|
1426 |
result = client.QueryNodes(names=node_query_list, |
|
1427 |
fields=["name", "master", "pinst_list", |
|
1428 |
"sinst_list", "powered", "offline"], |
|
1429 |
use_locking=False) |
|
1428 |
result = cl.QueryNodes(node_query_list, ["name", "master", "pinst_list", |
|
1429 |
"sinst_list", "powered", "offline"], |
|
1430 |
False) |
|
1430 | 1431 |
|
1431 | 1432 |
all_nodes = map(compat.fst, result) |
1432 | 1433 |
node_list = [] |
... | ... | |
1447 | 1448 |
# already operating on the master at this point :) |
1448 | 1449 |
continue |
1449 | 1450 |
elif master and not opts.show_all: |
1450 |
ToStderr("%s is the master node, please do a master-failover to another"
|
|
1451 |
" node not affected by the EPO or use --all if you intend to" |
|
1452 |
" shutdown the whole cluster", node) |
|
1451 |
_stderr_fn("%s is the master node, please do a master-failover to another"
|
|
1452 |
" node not affected by the EPO or use --all if you intend to"
|
|
1453 |
" shutdown the whole cluster", node)
|
|
1453 | 1454 |
return constants.EXIT_FAILURE |
1454 | 1455 |
elif powered is None: |
1455 |
ToStdout("Node %s does not support out-of-band handling, it can not be"
|
|
1456 |
" handled in a fully automated manner", node) |
|
1456 |
_stdout_fn("Node %s does not support out-of-band handling, it can not be"
|
|
1457 |
" handled in a fully automated manner", node)
|
|
1457 | 1458 |
elif powered == opts.on: |
1458 |
ToStdout("Node %s is already in desired power state, skipping", node)
|
|
1459 |
_stdout_fn("Node %s is already in desired power state, skipping", node)
|
|
1459 | 1460 |
elif not offline or (offline and powered): |
1460 | 1461 |
node_list.append(node) |
1461 | 1462 |
|
1462 |
if not opts.force and not ConfirmOperation(all_nodes, "nodes", "epo"):
|
|
1463 |
if not (opts.force or _confirm_fn(all_nodes, "nodes", "epo")):
|
|
1463 | 1464 |
return constants.EXIT_FAILURE |
1464 | 1465 |
|
1465 | 1466 |
if opts.on: |
1466 |
return _EpoOn(opts, all_nodes, node_list, inst_map)
|
|
1467 |
return _on_fn(opts, all_nodes, node_list, inst_map)
|
|
1467 | 1468 |
else: |
1468 |
return _EpoOff(opts, node_list, inst_map) |
|
1469 |
return _off_fn(opts, node_list, inst_map) |
|
1470 |
|
|
1469 | 1471 |
|
1470 | 1472 |
commands = { |
1471 | 1473 |
"init": ( |
Also available in: Unified diff