From 27703248432fd81182e1583d2319424033f731b1 Mon Sep 17 00:00:00 2001 From: Sawyer Bergeron Date: Mon, 7 Dec 2020 17:04:16 -0500 Subject: Updates to admin utils Signed-off-by: Sawyer Bergeron Change-Id: Ic52ed229621656118cd9321390cc26a1de548267 Signed-off-by: Sawyer Bergeron --- src/dashboard/admin_utils.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'src') 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)) -- cgit 1.2.3-korg