handle the situation where the IP address (desired or actual) is null
This commit is contained in:
parent
ca26d4b2af
commit
57c62a7abc
@ -114,21 +114,28 @@ def index():
|
|||||||
|
|
||||||
virt_vms_by_id = get_all_vms_from_hosts()
|
virt_vms_by_id = get_all_vms_from_hosts()
|
||||||
|
|
||||||
pprint.pprint(db_vms_by_id)
|
current_app.logger.info(pprint.pformat(db_vms_by_id))
|
||||||
|
|
||||||
|
current_app.logger.info("\n\n\n\n")
|
||||||
|
|
||||||
pprint.pprint(virt_vms_by_id)
|
current_app.logger.info(pprint.pformat(virt_vms_by_id))
|
||||||
|
|
||||||
|
current_app.logger.info("\n\n\n\n")
|
||||||
|
|
||||||
virt_vm_id_by_ipv4 = dict()
|
virt_vm_id_by_ipv4 = dict()
|
||||||
for vm_id, virt_vm in virt_vms_by_id.items():
|
for vm_id, virt_vm in virt_vms_by_id.items():
|
||||||
|
if 'public_ipv4' in virt_vm and virt_vm['public_ipv4'] != "":
|
||||||
virt_vm_id_by_ipv4[virt_vm['public_ipv4']] = vm_id
|
virt_vm_id_by_ipv4[virt_vm['public_ipv4']] = vm_id
|
||||||
|
|
||||||
db_vm_id_by_ipv4 = dict()
|
db_vm_id_by_ipv4 = dict()
|
||||||
for vm_id, db_vm in db_vms_by_id.items():
|
for vm_id, db_vm in db_vms_by_id.items():
|
||||||
|
if 'public_ipv4' in db_vm and db_vm['public_ipv4'] != "":
|
||||||
db_vm_id_by_ipv4[db_vm['public_ipv4']] = vm_id
|
db_vm_id_by_ipv4[db_vm['public_ipv4']] = vm_id
|
||||||
|
|
||||||
in_db_but_not_in_virt = []
|
in_db_but_not_in_virt = []
|
||||||
state_not_equal_to_desired_state = []
|
state_not_equal_to_desired_state = []
|
||||||
|
has_no_desired_ip_address = []
|
||||||
|
has_not_aquired_ip_address_yet = []
|
||||||
stole_someone_elses_ip_and_own_ip_avaliable = []
|
stole_someone_elses_ip_and_own_ip_avaliable = []
|
||||||
stole_someone_elses_ip_but_own_ip_also_stolen = []
|
stole_someone_elses_ip_but_own_ip_also_stolen = []
|
||||||
has_wrong_ip = []
|
has_wrong_ip = []
|
||||||
@ -139,7 +146,11 @@ def index():
|
|||||||
elif virt_vms_by_id[vm_id]['state'] != db_vm["desired_state"]:
|
elif virt_vms_by_id[vm_id]['state'] != db_vm["desired_state"]:
|
||||||
db_vm["state"] = virt_vms_by_id[vm_id]['state']
|
db_vm["state"] = virt_vms_by_id[vm_id]['state']
|
||||||
state_not_equal_to_desired_state.append(db_vm)
|
state_not_equal_to_desired_state.append(db_vm)
|
||||||
elif virt_vms_by_id[vm_id]['public_ipv4'] != db_vm["public_ipv4"]:
|
elif 'public_ipv4' not in db_vm or db_vm["public_ipv4"] == "":
|
||||||
|
has_no_desired_ip_address.append(db_vm)
|
||||||
|
elif db_vm["desired_state"] == "running" and 'public_ipv4' not in virt_vms_by_id[vm_id] or virt_vms_by_id[vm_id]['public_ipv4'] == "":
|
||||||
|
has_not_aquired_ip_address_yet.append(db_vm)
|
||||||
|
elif db_vm["desired_state"] == "running" and virt_vms_by_id[vm_id]['public_ipv4'] != db_vm["public_ipv4"]:
|
||||||
db_vm["desired_ipv4"] = db_vm["public_ipv4"]
|
db_vm["desired_ipv4"] = db_vm["public_ipv4"]
|
||||||
db_vm["current_ipv4"] = virt_vms_by_id[vm_id]['public_ipv4']
|
db_vm["current_ipv4"] = virt_vms_by_id[vm_id]['public_ipv4']
|
||||||
if virt_vms_by_id[vm_id]['public_ipv4'] in db_vm_id_by_ipv4:
|
if virt_vms_by_id[vm_id]['public_ipv4'] in db_vm_id_by_ipv4:
|
||||||
@ -165,9 +176,10 @@ def index():
|
|||||||
network_display_width_px=network_display_width_px,
|
network_display_width_px=network_display_width_px,
|
||||||
csp_inline_style_nonce=csp_inline_style_nonce,
|
csp_inline_style_nonce=csp_inline_style_nonce,
|
||||||
inline_style='\n'.join(inline_styles),
|
inline_style='\n'.join(inline_styles),
|
||||||
|
|
||||||
in_db_but_not_in_virt=in_db_but_not_in_virt,
|
in_db_but_not_in_virt=in_db_but_not_in_virt,
|
||||||
state_not_equal_to_desired_state=state_not_equal_to_desired_state,
|
state_not_equal_to_desired_state=state_not_equal_to_desired_state,
|
||||||
|
has_no_desired_ip_address=has_no_desired_ip_address,
|
||||||
|
has_not_aquired_ip_address_yet=has_not_aquired_ip_address_yet,
|
||||||
stole_someone_elses_ip_and_own_ip_avaliable=stole_someone_elses_ip_and_own_ip_avaliable,
|
stole_someone_elses_ip_and_own_ip_avaliable=stole_someone_elses_ip_and_own_ip_avaliable,
|
||||||
stole_someone_elses_ip_but_own_ip_also_stolen=stole_someone_elses_ip_but_own_ip_also_stolen,
|
stole_someone_elses_ip_but_own_ip_also_stolen=stole_someone_elses_ip_but_own_ip_also_stolen,
|
||||||
has_wrong_ip=has_wrong_ip
|
has_wrong_ip=has_wrong_ip
|
||||||
|
@ -76,6 +76,34 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
{% if has_no_desired_ip_address|length > 0 %}
|
||||||
|
<div class="third-margin">
|
||||||
|
<div class="row">
|
||||||
|
<h1>🐣 has no desired ip address 🐣</h1>
|
||||||
|
</div>
|
||||||
|
{% for vm in has_no_desired_ip_address %}
|
||||||
|
<div class="row">
|
||||||
|
{{vm['id']}}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
<hr/>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
{% if has_not_aquired_ip_address_yet|length > 0 %}
|
||||||
|
<div class="third-margin">
|
||||||
|
<div class="row">
|
||||||
|
<h1>🏃 hasn't aquired an ip address yet 🏃</h1>
|
||||||
|
</div>
|
||||||
|
{% for vm in has_not_aquired_ip_address_yet %}
|
||||||
|
<div class="row">
|
||||||
|
{{vm['id']}} desired_ipv4={{vm['public_ipv4']}}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
<hr/>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if stole_someone_elses_ip_and_own_ip_avaliable|length > 0 %}
|
{% if stole_someone_elses_ip_and_own_ip_avaliable|length > 0 %}
|
||||||
<div class="third-margin">
|
<div class="third-margin">
|
||||||
|
Loading…
Reference in New Issue
Block a user