Revision 87747cda lib/watcher/__init__.py
b/lib/watcher/__init__.py | ||
---|---|---|
511 | 511 |
_WriteInstanceStatus(filename, inststatus) |
512 | 512 |
|
513 | 513 |
|
514 |
def GetLuxiClient(try_restart): |
|
514 |
def GetLuxiClient(try_restart, query=False):
|
|
515 | 515 |
"""Tries to connect to the master daemon. |
516 | 516 |
|
517 | 517 |
@type try_restart: bool |
... | ... | |
519 | 519 |
|
520 | 520 |
""" |
521 | 521 |
try: |
522 |
return cli.GetClient() |
|
522 |
return cli.GetClient(query=query)
|
|
523 | 523 |
except errors.OpPrereqError, err: |
524 | 524 |
# this is, from cli.GetClient, a not-master case |
525 | 525 |
raise NotMasterError("Not on master node (%s)" % err) |
... | ... | |
535 | 535 |
raise errors.GenericError("Can't start the master daemon") |
536 | 536 |
|
537 | 537 |
# Retry the connection |
538 |
return cli.GetClient() |
|
538 |
return cli.GetClient(query=query)
|
|
539 | 539 |
|
540 | 540 |
|
541 | 541 |
def _StartGroupChildren(cl, wait): |
... | ... | |
642 | 642 |
return constants.EXIT_SUCCESS |
643 | 643 |
|
644 | 644 |
|
645 |
def _GetGroupData(cl, uuid): |
|
645 |
def _GetAllNodesInGroup(qcl, uuid): |
|
646 |
"""Get all nodes of a node group. |
|
647 |
|
|
648 |
This function uses the query client to find out which nodes are in the node |
|
649 |
group. |
|
650 |
|
|
651 |
@type qcl: @C{luxi.Client} |
|
652 |
@param qcl: luxi client for queries |
|
653 |
@type uuid: string |
|
654 |
@param uuid: UUID of the node group |
|
655 |
|
|
656 |
""" |
|
657 |
what = constants.QR_NODE |
|
658 |
fields = ["name", "bootid", "offline"] |
|
659 |
qfilter = [qlang.OP_EQUAL, "group.uuid", uuid] |
|
660 |
|
|
661 |
result = qcl.Query(what, fields, qfilter) |
|
662 |
return result |
|
663 |
|
|
664 |
|
|
665 |
def _GetGroupData(cl, qcl, uuid): |
|
646 | 666 |
"""Retrieves instances and nodes per node group. |
647 | 667 |
|
648 | 668 |
""" |
669 |
# FIXME: This is an intermediate state where some queries are done via |
|
670 |
# the old and some via the new query implementation. This will be beautiful |
|
671 |
# again when the transition is complete for all queries. |
|
672 |
node_result = _GetAllNodesInGroup(qcl, uuid) |
|
673 |
|
|
649 | 674 |
job = [ |
650 | 675 |
# Get all primary instances in group |
651 | 676 |
opcodes.OpQuery(what=constants.QR_INSTANCE, |
652 | 677 |
fields=["name", "status", "disks_active", "snodes", |
653 | 678 |
"pnode.group.uuid", "snodes.group.uuid"], |
654 | 679 |
qfilter=[qlang.OP_EQUAL, "pnode.group.uuid", uuid], |
655 |
use_locking=True), |
|
656 |
|
|
657 |
# Get all nodes in group |
|
658 |
opcodes.OpQuery(what=constants.QR_NODE, |
|
659 |
fields=["name", "bootid", "offline"], |
|
660 |
qfilter=[qlang.OP_EQUAL, "group.uuid", uuid], |
|
661 |
use_locking=True), |
|
680 |
use_locking=True) |
|
662 | 681 |
] |
663 |
|
|
664 | 682 |
job_id = cl.SubmitJob(job) |
665 | 683 |
results = map(objects.QueryResponse.FromDict, |
666 | 684 |
cli.PollJob(job_id, cl=cl, feedback_fn=logging.debug)) |
685 |
results.append(node_result) |
|
667 | 686 |
cl.ArchiveJob(job_id) |
668 | 687 |
|
669 | 688 |
results_data = map(operator.attrgetter("data"), results) |
... | ... | |
751 | 770 |
try: |
752 | 771 |
# Connect to master daemon |
753 | 772 |
client = GetLuxiClient(False) |
773 |
query_client = GetLuxiClient(False, query=True) |
|
754 | 774 |
|
755 | 775 |
_CheckMaster(client) |
756 | 776 |
|
757 |
(nodes, instances) = _GetGroupData(client, group_uuid) |
|
777 |
(nodes, instances) = _GetGroupData(client, query_client, group_uuid)
|
|
758 | 778 |
|
759 | 779 |
# Update per-group instance status file |
760 | 780 |
_UpdateInstanceStatus(inst_status_path, instances.values()) |
Also available in: Unified diff