diff options
author | Sawyer Bergeron <sbergeron@iol.unh.edu> | 2020-12-09 20:40:58 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2020-12-09 20:40:58 +0000 |
commit | f8f11647db0502737c3e17d13dbc68f523185d55 (patch) | |
tree | c0eb542219496520c583f70755e14171d391e618 /src/dashboard/admin_utils.py | |
parent | 14ad65c2e83f680246c1bf06573e3fcb19cdaa06 (diff) | |
parent | 27703248432fd81182e1583d2319424033f731b1 (diff) |
Merge "Updates to admin utils"2.1.0-rc2
Diffstat (limited to 'src/dashboard/admin_utils.py')
-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)) |