Revision 6daf26a0 lib/confd/querylib.py
b/lib/confd/querylib.py | ||
---|---|---|
75 | 75 |
|
76 | 76 |
return status, answer |
77 | 77 |
|
78 |
|
|
79 |
class NodeRoleQuery(ConfdQuery): |
|
80 |
"""An empty confd query. |
|
81 |
|
|
82 |
It will return success on an empty argument, and an error on any other argument. |
|
83 |
|
|
84 |
""" |
|
85 |
def Exec(self, query): |
|
86 |
"""EmptyQuery main execution |
|
87 |
|
|
88 |
""" |
|
89 |
node = query |
|
90 |
if self.reader.GetMasterNode() == node: |
|
91 |
status = constants.CONFD_REPL_STATUS_OK |
|
92 |
answer = constants.CONFD_NODE_ROLE_MASTER |
|
93 |
return status, answer |
|
94 |
flags = self.reader.GetNodeStatusFlags(node) |
|
95 |
if flags is None: |
|
96 |
status = constants.CONFD_REPL_STATUS_ERROR |
|
97 |
answer = constants.CONFD_ERROR_UNKNOWN_ENTRY |
|
98 |
return status, answer |
|
99 |
|
|
100 |
master_candidate, drained, offline = flags |
|
101 |
if master_candidate: |
|
102 |
answer = constants.CONFD_NODE_ROLE_CANDIDATE |
|
103 |
elif drained: |
|
104 |
answer = constants.CONFD_NODE_ROLE_DRAINED |
|
105 |
elif offline: |
|
106 |
answer = constants.CONFD_NODE_ROLE_OFFLINE |
|
107 |
else: |
|
108 |
answer = constants.CONFD_NODE_ROLE_REGULAR |
|
109 |
|
|
110 |
return constants.CONFD_REPL_STATUS_OK, answer |
|
111 |
|
Also available in: Unified diff