Convert MetadataAPIInstance to new zkhandler
This commit is contained in:
parent
abd619a3c1
commit
d6a8cf9780
|
@ -780,7 +780,7 @@ if enable_networking:
|
||||||
# Create an instance of the DNS Aggregator and Metadata API if we're a coordinator
|
# Create an instance of the DNS Aggregator and Metadata API if we're a coordinator
|
||||||
if config['daemon_mode'] == 'coordinator':
|
if config['daemon_mode'] == 'coordinator':
|
||||||
dns_aggregator = DNSAggregatorInstance.DNSAggregatorInstance(config, logger)
|
dns_aggregator = DNSAggregatorInstance.DNSAggregatorInstance(config, logger)
|
||||||
metadata_api = MetadataAPIInstance.MetadataAPIInstance(zkhandler.zk_conn, config, logger)
|
metadata_api = MetadataAPIInstance.MetadataAPIInstance(zkhandler, config, logger)
|
||||||
else:
|
else:
|
||||||
dns_aggregator = None
|
dns_aggregator = None
|
||||||
metadata_api = None
|
metadata_api = None
|
||||||
|
|
|
@ -36,8 +36,8 @@ class MetadataAPIInstance(object):
|
||||||
mdapi = flask.Flask(__name__)
|
mdapi = flask.Flask(__name__)
|
||||||
|
|
||||||
# Initialization function
|
# Initialization function
|
||||||
def __init__(self, zk_conn, config, logger):
|
def __init__(self, zkhandler, config, logger):
|
||||||
self.zk_conn = zk_conn
|
self.zkhandler = zkhandler
|
||||||
self.config = config
|
self.config = config
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
self.thread = None
|
self.thread = None
|
||||||
|
@ -158,15 +158,15 @@ class MetadataAPIInstance(object):
|
||||||
# VM details function
|
# VM details function
|
||||||
def get_vm_details(self, source_address):
|
def get_vm_details(self, source_address):
|
||||||
# Start connection to Zookeeper
|
# Start connection to Zookeeper
|
||||||
_discard, networks = pvc_network.get_list(self.zk_conn, None)
|
_discard, networks = pvc_network.get_list(self.zkhandler, None)
|
||||||
|
|
||||||
# Figure out which server this is via the DHCP address
|
# Figure out which server this is via the DHCP address
|
||||||
host_information = dict()
|
host_information = dict()
|
||||||
networks_managed = (x for x in networks if x.get('type') == 'managed')
|
networks_managed = (x for x in networks if x.get('type') == 'managed')
|
||||||
for network in networks_managed:
|
for network in networks_managed:
|
||||||
network_leases = pvc_network.getNetworkDHCPLeases(self.zk_conn, network.get('vni'))
|
network_leases = pvc_network.getNetworkDHCPLeases(self.zkhandler, network.get('vni'))
|
||||||
for network_lease in network_leases:
|
for network_lease in network_leases:
|
||||||
information = pvc_network.getDHCPLeaseInformation(self.zk_conn, network.get('vni'), network_lease)
|
information = pvc_network.getDHCPLeaseInformation(self.zkhandler, network.get('vni'), network_lease)
|
||||||
try:
|
try:
|
||||||
if information.get('ip4_address', None) == source_address:
|
if information.get('ip4_address', None) == source_address:
|
||||||
host_information = information
|
host_information = information
|
||||||
|
@ -177,7 +177,7 @@ class MetadataAPIInstance(object):
|
||||||
client_macaddr = host_information.get('mac_address', None)
|
client_macaddr = host_information.get('mac_address', None)
|
||||||
|
|
||||||
# Find the VM with that MAC address - we can't assume that the hostname is actually right
|
# Find the VM with that MAC address - we can't assume that the hostname is actually right
|
||||||
_discard, vm_list = pvc_vm.get_list(self.zk_conn, None, None, None)
|
_discard, vm_list = pvc_vm.get_list(self.zkhandler, None, None, None)
|
||||||
vm_details = dict()
|
vm_details = dict()
|
||||||
for vm in vm_list:
|
for vm in vm_list:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue