aboutsummaryrefslogtreecommitdiffstats
path: root/src/dashboard
diff options
context:
space:
mode:
Diffstat (limited to 'src/dashboard')
-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))