Object of type dict_keys is not JSON serializable

This commit is contained in:
forest 2021-12-09 17:41:28 -06:00
parent 37babae903
commit 1cdd918e28

View File

@ -72,7 +72,7 @@ def index():
try:
if request.form['desired_state'] == "running":
if 'macs' in virt_vm and len(virt_vm['macs'].keys()) > 0:
current_app.config["HUB_MODEL"].net_set_dhcp(email=session['account'], host_id=virt_vm['host'], network_name=virt_vm['network_name'], macs=virt_vm['macs'].keys(), add_ipv4=db_vm['public_ipv4'])
current_app.config["HUB_MODEL"].net_set_dhcp(email=session['account'], host_id=virt_vm['host'], network_name=virt_vm['network_name'], macs=list(virt_vm['macs'].keys()), add_ipv4=db_vm['public_ipv4'])
current_app.config["HUB_MODEL"].vm_state_command(email=session['account'], id=id, command="start")
elif request.form['desired_state'] == "shut off":
@ -97,7 +97,7 @@ def index():
try:
current_app.config["HUB_MODEL"].vm_state_command(email=session['account'], id=id, command="force-stop")
current_app.config["HUB_MODEL"].net_set_dhcp(email=session['account'], host_id=virt_vm['host'], network_name=virt_vm['network_name'], macs=virt_vm['macs'].keys(), remove_ipv4=virt_vm['public_ipv4'], add_ipv4=db_vm['public_ipv4'])
current_app.config["HUB_MODEL"].net_set_dhcp(email=session['account'], host_id=virt_vm['host'], network_name=virt_vm['network_name'], macs=list(virt_vm['macs'].keys()), remove_ipv4=virt_vm['public_ipv4'], add_ipv4=db_vm['public_ipv4'])
current_app.config["HUB_MODEL"].vm_state_command(email=session['account'], id=id, command="start")
except:
flash(f"""error during dhcp_reset of {id}: {my_exec_info_message(sys.exc_info())}""")
@ -116,7 +116,7 @@ def index():
#db_vm = db_vms_by_id[id]
current_app.config["HUB_MODEL"].vm_state_command(email=session['account'], id=id, command="force-stop")
current_app.config["HUB_MODEL"].net_set_dhcp(email=session['account'], host_id=virt_vm['host'], network_name=virt_vm['network_name'], macs=virt_vm['macs'].keys(), remove_ipv4=virt_vm['public_ipv4'])
current_app.config["HUB_MODEL"].net_set_dhcp(email=session['account'], host_id=virt_vm['host'], network_name=virt_vm['network_name'], macs=list(virt_vm['macs'].keys()), remove_ipv4=virt_vm['public_ipv4'])
return redirect(f"{url_for('admin.index')}")