aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSawyer Bergeron <sbergeron@iol.unh.edu>2020-12-09 20:40:58 +0000
committerGerrit Code Review <gerrit@opnfv.org>2020-12-09 20:40:58 +0000
commitf8f11647db0502737c3e17d13dbc68f523185d55 (patch)
treec0eb542219496520c583f70755e14171d391e618
parent14ad65c2e83f680246c1bf06573e3fcb19cdaa06 (diff)
parent27703248432fd81182e1583d2319424033f731b1 (diff)
Merge "Updates to admin utils"2.1.0-rc2
-rw-r--r--src/dashboard/admin_utils.py21
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))