aboutsummaryrefslogtreecommitdiffstats
path: root/src/resource_inventory
diff options
context:
space:
mode:
Diffstat (limited to 'src/resource_inventory')
-rw-r--r--src/resource_inventory/models.py18
-rw-r--r--src/resource_inventory/pdf_templater.py6
2 files changed, 20 insertions, 4 deletions
diff --git a/src/resource_inventory/models.py b/src/resource_inventory/models.py
index c918513..01da8bb 100644
--- a/src/resource_inventory/models.py
+++ b/src/resource_inventory/models.py
@@ -12,6 +12,7 @@ from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import Q
+import traceback
import re
from collections import Counter
@@ -201,10 +202,20 @@ class ResourceBundle(models.Model):
def release(self):
for pn in PhysicalNetwork.objects.filter(bundle=self).all():
- pn.release()
+ try:
+ pn.release()
+ except Exception as e:
+ print("Exception occurred while trying to release resource ", pn.vlan_id)
+ print(e)
+ traceback.print_exc()
for resource in self.get_resources():
- resource.release()
+ try:
+ resource.release()
+ except Exception as e:
+ print("Exception occurred while trying to release resource ", resource)
+ print(e)
+ traceback.print_exc()
def get_template_name(self):
if not self.template:
@@ -343,6 +354,7 @@ class Server(Resource):
return list(self.interfaces.all().order_by('bus_address'))
def release(self):
+ self.bundle = None
self.booked = False
self.save()
@@ -408,7 +420,7 @@ class Network(models.Model):
class PhysicalNetwork(models.Model):
vlan_id = models.IntegerField()
generic_network = models.ForeignKey(Network, on_delete=models.CASCADE)
- bundle = models.ForeignKey(ResourceBundle, null=True, on_delete=models.CASCADE)
+ bundle = models.ForeignKey(ResourceBundle, null=True, blank=True, on_delete=models.CASCADE)
def get_configuration(self, state):
"""
diff --git a/src/resource_inventory/pdf_templater.py b/src/resource_inventory/pdf_templater.py
index 86d84aa..c4b22fe 100644
--- a/src/resource_inventory/pdf_templater.py
+++ b/src/resource_inventory/pdf_templater.py
@@ -22,7 +22,11 @@ class PDFTemplater:
template = "dashboard/pdf.yaml"
info = {}
info['details'] = cls.get_pdf_details(booking.resource)
- info['jumphost'] = cls.get_pdf_jumphost(booking)
+ try:
+ info['jumphost'] = cls.get_pdf_jumphost(booking)
+ except Exception:
+ # filling in jumphost info can be optional in some cases, this shouldn't be a hard error
+ info['jumphost'] = {}
info['nodes'] = cls.get_pdf_nodes(booking)
return render_to_string(template, context=info)