diff options
author | Sawyer Bergeron <sbergeron@iol.unh.edu> | 2020-12-07 17:04:16 -0500 |
---|---|---|
committer | Sawyer Bergeron <sbergeron@iol.unh.edu> | 2020-12-07 17:12:33 -0500 |
commit | 27703248432fd81182e1583d2319424033f731b1 (patch) | |
tree | d9b8445a8f5bfbcf60bf28d84d0b62d4e23dc1c4 /src | |
parent | 38152cc83eba4f8aa457dd35c824d042124cddd6 (diff) |
Updates to admin utils
Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
Change-Id: Ic52ed229621656118cd9321390cc26a1de548267
Signed-off-by: Sawyer Bergeron <sbergeron@iol.unh.edu>
Diffstat (limited to 'src')
-rw-r--r-- | src/dashboard/admin_utils.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/dashboard/admin_utils.py b/src/dashboard/admin_utils.py index fd427f5..e12671a 100644 --- a/src/dashboard/admin_utils.py +++ b/src/dashboard/admin_utils.py @@ -4,9 +4,12 @@ from resource_inventory.models import ( Server, ResourceBundle, ResourceProfile, - InterfaceProfile + InterfaceProfile, + PhysicalNetwork ) +import json + from django.contrib.auth.models import User from account.models import Lab @@ -207,3 +210,19 @@ def force_release_booking(booking_id): for task in tasks: task.status = JobStatus.DONE task.save() + + +def get_network_metadata(booking_id: int): + booking = Booking.objects.get(id=booking_id) + bundle = booking.resource + pnets = PhysicalNetwork.objects.filter(bundle=bundle).all() + metadata = {} + for pnet in pnets: + net = pnet.generic_network + mdata = {"vlan_id": pnet.vlan_id, "netname": net.name, "public": net.is_public} + metadata[net.name] = mdata + return metadata + + +def print_dict_pretty(a_dict): + print(json.dumps(a_dict, sort_keys=True, indent=4)) |