Revision 53bd7366
b/lib/confd/querylib.py | ||
---|---|---|
23 | 23 |
|
24 | 24 |
""" |
25 | 25 |
|
26 |
import logging |
|
27 |
|
|
26 | 28 |
from ganeti import constants |
27 | 29 |
|
28 | 30 |
# constants for some common errors to return from a query |
... | ... | |
112 | 114 |
|
113 | 115 |
return constants.CONFD_REPL_STATUS_OK, answer |
114 | 116 |
|
117 |
|
|
118 |
class InstanceIpToNodePrimaryIpQuery(ConfdQuery): |
|
119 |
"""An empty confd query. |
|
120 |
|
|
121 |
It will return success on an empty argument, and an error on any other argument. |
|
122 |
|
|
123 |
""" |
|
124 |
def Exec(self, query): |
|
125 |
"""EmptyQuery main execution |
|
126 |
|
|
127 |
""" |
|
128 |
instance_ip = query |
|
129 |
instance = self.reader.GetInstanceByIp(instance_ip) |
|
130 |
if instance is None: |
|
131 |
return QUERY_UNKNOWN_ENTRY_ERROR |
|
132 |
|
|
133 |
pnode = self.reader.GetInstancePrimaryNode(instance) |
|
134 |
if pnode is None: |
|
135 |
# this shouldn't happen |
|
136 |
logging.error("Internal configuration inconsistent (instance-to-pnode)") |
|
137 |
return QUERY_INTERNAL_ERROR |
|
138 |
|
|
139 |
pnode_primary_ip = self.reader.GetNodePrimaryIp(pnode) |
|
140 |
if pnode_primary_ip is None: |
|
141 |
# this shouldn't happen |
|
142 |
logging.error("Internal configuration inconsistent (node-to-primary-ip)") |
|
143 |
return QUERY_INTERNAL_ERROR |
|
144 |
|
|
145 |
return constants.CONFD_REPL_STATUS_OK, pnode_primary_ip |
|
146 |
|
b/lib/confd/server.py | ||
---|---|---|
45 | 45 |
DISPATCH_TABLE = { |
46 | 46 |
constants.CONFD_REQ_PING: querylib.PingQuery, |
47 | 47 |
constants.CONFD_REQ_NODE_ROLE_BYNAME: querylib.NodeRoleQuery, |
48 |
constants.CONFD_REQ_NODE_PIP_BY_INSTANCE_IP: querylib.ConfdQuery, |
|
48 |
constants.CONFD_REQ_NODE_PIP_BY_INSTANCE_IP: |
|
49 |
querylib.InstanceIpToNodePrimaryIpQuery, |
|
49 | 50 |
} |
50 | 51 |
|
51 | 52 |
def __init__(self, reader): |
Also available in: Unified diff