trying to fix bugs in get_all_by_host_and_network
This commit is contained in:
parent
1748b869f1
commit
089cb4d696
@ -168,7 +168,7 @@ class ShellScriptSpoke(VirtualizationInterface):
|
|||||||
try:
|
try:
|
||||||
vms_with_macs = json.load(macs_json_file)
|
vms_with_macs = json.load(macs_json_file)
|
||||||
except:
|
except:
|
||||||
raise Exception(f"failed to parse the JSON file '{macs_json_filename}'")
|
current_app.logger.warn(f"failed to parse the JSON file '{macs_json_filename}'")
|
||||||
|
|
||||||
for vm in vms_with_macs:
|
for vm in vms_with_macs:
|
||||||
for mac in vm['macs']:
|
for mac in vm['macs']:
|
||||||
@ -184,7 +184,7 @@ class ShellScriptSpoke(VirtualizationInterface):
|
|||||||
else:
|
else:
|
||||||
current_app.logger.info(f"get_all_by_host_and_network: '{vm['domain']}' not in vm_state_by_id, defaulting to 'shut off'")
|
current_app.logger.info(f"get_all_by_host_and_network: '{vm['domain']}' not in vm_state_by_id, defaulting to 'shut off'")
|
||||||
|
|
||||||
vms_by_id[vm['domain']] = dict(macs=dict(), state=vm_state)
|
vms_by_id[vm['domain']] = dict(macs=dict(), state=vm_state, network=network['name'])
|
||||||
|
|
||||||
vms_by_id[vm['domain']]['macs'][mac] = True
|
vms_by_id[vm['domain']]['macs'][mac] = True
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ class ShellScriptSpoke(VirtualizationInterface):
|
|||||||
try:
|
try:
|
||||||
statuses = json.load(status_json_file)
|
statuses = json.load(status_json_file)
|
||||||
except:
|
except:
|
||||||
raise Exception(f"failed to parse the JSON file '{status_json_filename}'")
|
current_app.logger.warn(f"failed to parse the JSON file '{status_json_filename}'")
|
||||||
|
|
||||||
for status in statuses:
|
for status in statuses:
|
||||||
if status['mac-address'] in vm_id_by_mac:
|
if status['mac-address'] in vm_id_by_mac:
|
||||||
@ -203,7 +203,11 @@ class ShellScriptSpoke(VirtualizationInterface):
|
|||||||
else:
|
else:
|
||||||
current_app.logger.info(f"get_all_by_host_and_network: {status['mac-address']} not in vm_id_by_mac")
|
current_app.logger.info(f"get_all_by_host_and_network: {status['mac-address']} not in vm_id_by_mac")
|
||||||
|
|
||||||
networks[network['name']] = vms_by_id
|
networks = dict()
|
||||||
|
for vm in vms_by_id:
|
||||||
|
if vm['network'] not in networks:
|
||||||
|
networks[vm['network']] = []
|
||||||
|
networks[vm['network']].append(vm)
|
||||||
|
|
||||||
to_return = dict()
|
to_return = dict()
|
||||||
to_return[current_app.config['SPOKE_HOST_ID']] = networks
|
to_return[current_app.config['SPOKE_HOST_ID']] = networks
|
||||||
|
Loading…
Reference in New Issue
Block a user