Commit 53bd7366 authored by Guido Trotter's avatar Guido Trotter
Browse files

InstanceIpToNodePrimaryIpQuery



This implements CONFD_REQ_NODE_PIP_BY_INSTANCE_IP, and maps instance ips
to primary node ips.
Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent 7189e790
......@@ -23,6 +23,8 @@
"""
import logging
from ganeti import constants
# constants for some common errors to return from a query
......@@ -112,3 +114,33 @@ class NodeRoleQuery(ConfdQuery):
return constants.CONFD_REPL_STATUS_OK, answer
class InstanceIpToNodePrimaryIpQuery(ConfdQuery):
"""An empty confd query.
It will return success on an empty argument, and an error on any other argument.
"""
def Exec(self, query):
"""EmptyQuery main execution
"""
instance_ip = query
instance = self.reader.GetInstanceByIp(instance_ip)
if instance is None:
return QUERY_UNKNOWN_ENTRY_ERROR
pnode = self.reader.GetInstancePrimaryNode(instance)
if pnode is None:
# this shouldn't happen
logging.error("Internal configuration inconsistent (instance-to-pnode)")
return QUERY_INTERNAL_ERROR
pnode_primary_ip = self.reader.GetNodePrimaryIp(pnode)
if pnode_primary_ip is None:
# this shouldn't happen
logging.error("Internal configuration inconsistent (node-to-primary-ip)")
return QUERY_INTERNAL_ERROR
return constants.CONFD_REPL_STATUS_OK, pnode_primary_ip
......@@ -45,7 +45,8 @@ class ConfdProcessor(object):
DISPATCH_TABLE = {
constants.CONFD_REQ_PING: querylib.PingQuery,
constants.CONFD_REQ_NODE_ROLE_BYNAME: querylib.NodeRoleQuery,
constants.CONFD_REQ_NODE_PIP_BY_INSTANCE_IP: querylib.ConfdQuery,
constants.CONFD_REQ_NODE_PIP_BY_INSTANCE_IP:
querylib.InstanceIpToNodePrimaryIpQuery,
}
def __init__(self, reader):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment