clean up and add email display to admin panel

This commit is contained in:
forest 2021-12-09 15:11:03 -06:00
parent 57c62a7abc
commit 1e9043bbf2
3 changed files with 15 additions and 15 deletions

View File

@ -114,13 +114,13 @@ def index():
virt_vms_by_id = get_all_vms_from_hosts() virt_vms_by_id = get_all_vms_from_hosts()
current_app.logger.info(pprint.pformat(db_vms_by_id)) # current_app.logger.info(pprint.pformat(db_vms_by_id))
current_app.logger.info("\n\n\n\n") # current_app.logger.info("\n\n\n\n")
current_app.logger.info(pprint.pformat(virt_vms_by_id)) # current_app.logger.info(pprint.pformat(virt_vms_by_id))
current_app.logger.info("\n\n\n\n") # 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():

View File

@ -59,7 +59,7 @@ class DBModel:
# ------ VM & ACCOUNT MANAGEMENT --------- # ------ VM & ACCOUNT MANAGEMENT ---------
def non_deleted_vms_by_host_and_network(self, host_id): def non_deleted_vms_by_host_and_network(self, host_id):
query = "SELECT id, desired_state, host, network_name, public_ipv4, public_ipv6 FROM vms WHERE deleted IS NULL" query = "SELECT id, email, desired_state, host, network_name, public_ipv4, public_ipv6 FROM vms WHERE deleted IS NULL"
if host_id is None: if host_id is None:
self.cursor.execute(query) self.cursor.execute(query)
else: else:
@ -73,15 +73,15 @@ class DBModel:
hosts = dict() hosts = dict()
for row in self.cursor.fetchall(): for row in self.cursor.fetchall():
host_id = row[2] host_id = row[3]
network_name = row[3] network_name = row[4]
if host_id not in hosts: if host_id not in hosts:
hosts[host_id] = dict() hosts[host_id] = dict()
if network_name not in hosts[host_id]: if network_name not in hosts[host_id]:
hosts[host_id][network_name] = [] hosts[host_id][network_name] = []
hosts[host_id][network_name].append( hosts[host_id][network_name].append(
dict(id=row[0], desired_state=row[1], public_ipv4=row[4], public_ipv6=row[5]) dict(id=row[0], email=row[1], desired_state=row[2], public_ipv4=row[5], public_ipv6=row[6])
) )
return hosts return hosts

View File

@ -45,7 +45,7 @@
</div> </div>
{% for vm in in_db_but_not_in_virt %} {% for vm in in_db_but_not_in_virt %}
<div class="row"> <div class="row">
{{vm['id']}} {{vm['public_ipv4']}} {{vm['id']}} ({{vm['email']}}) {{vm['public_ipv4']}}
</div> </div>
{% endfor %} {% endfor %}
<hr/> <hr/>
@ -61,7 +61,7 @@
</div> </div>
{% for vm in state_not_equal_to_desired_state %} {% for vm in state_not_equal_to_desired_state %}
<div class="row"> <div class="row">
<div>{{vm['id']}}: state={{vm['state']}} desired_state={{vm['desired_state']}}</div> <div>{{vm['id']}} ({{vm['email']}}): state={{vm['state']}} desired_state={{vm['desired_state']}}</div>
<form method="post"> <form method="post">
<input type="hidden" name="action" value="set_state"></input> <input type="hidden" name="action" value="set_state"></input>
<input type="hidden" name="id" value="{{vm['id']}}"></input> <input type="hidden" name="id" value="{{vm['id']}}"></input>
@ -83,7 +83,7 @@
</div> </div>
{% for vm in has_no_desired_ip_address %} {% for vm in has_no_desired_ip_address %}
<div class="row"> <div class="row">
{{vm['id']}} {{vm['id']}} ({{vm['email']}})
</div> </div>
{% endfor %} {% endfor %}
<hr/> <hr/>
@ -98,7 +98,7 @@
</div> </div>
{% for vm in has_not_aquired_ip_address_yet %} {% for vm in has_not_aquired_ip_address_yet %}
<div class="row"> <div class="row">
{{vm['id']}} desired_ipv4={{vm['public_ipv4']}} {{vm['id']}} ({{vm['email']}}) desired_ipv4={{vm['public_ipv4']}}
</div> </div>
{% endfor %} {% endfor %}
<hr/> <hr/>
@ -112,7 +112,7 @@
</div> </div>
{% for vm in stole_someone_elses_ip_and_own_ip_avaliable %} {% for vm in stole_someone_elses_ip_and_own_ip_avaliable %}
<div class="row"> <div class="row">
<div>{{vm['id']}}: current_ipv4={{vm['current_ipv4']}} desired_ipv4={{vm['desired_ipv4']}}</div> <div>{{vm['id']}} ({{vm['email']}}): current_ipv4={{vm['current_ipv4']}} desired_ipv4={{vm['desired_ipv4']}}</div>
<form method="post"> <form method="post">
<input type="hidden" name="action" value="dhcp_reset"></input> <input type="hidden" name="action" value="dhcp_reset"></input>
<input type="hidden" name="id" value="{{vm['id']}}"></input> <input type="hidden" name="id" value="{{vm['id']}}"></input>
@ -132,7 +132,7 @@
</div> </div>
{% for vm in has_wrong_ip %} {% for vm in has_wrong_ip %}
<div class="row"> <div class="row">
<div>{{vm['id']}}: current_ipv4={{vm['current_ipv4']}} desired_ipv4={{vm['desired_ipv4']}}</div> <div>{{vm['id']}} ({{vm['email']}}): current_ipv4={{vm['current_ipv4']}} desired_ipv4={{vm['desired_ipv4']}}</div>
<form method="post"> <form method="post">
<input type="hidden" name="action" value="dhcp_reset"></input> <input type="hidden" name="action" value="dhcp_reset"></input>
<input type="hidden" name="id" value="{{vm['id']}}"></input> <input type="hidden" name="id" value="{{vm['id']}}"></input>
@ -153,7 +153,7 @@
</div> </div>
{% for vm in stole_someone_elses_ip_but_own_ip_also_stolen %} {% for vm in stole_someone_elses_ip_but_own_ip_also_stolen %}
<div class="row"> <div class="row">
<div>{{vm['id']}}: current_ipv4={{vm['current_ipv4']}} desired_ipv4={{vm['desired_ipv4']}}</div> <div>{{vm['id']}} ({{vm['email']}}): current_ipv4={{vm['current_ipv4']}} desired_ipv4={{vm['desired_ipv4']}}</div>
<form method="post"> <form method="post">
<input type="hidden" name="action" value="stop_and_expire"></input> <input type="hidden" name="action" value="stop_and_expire"></input>
<input type="hidden" name="id" value="{{vm['id']}}"></input> <input type="hidden" name="id" value="{{vm['id']}}"></input>