From a6befd926b6b80505bd857d9b6c83f9c7501232f Mon Sep 17 00:00:00 2001 From: Sean Smith Date: Mon, 24 Aug 2020 15:02:27 -0400 Subject: [PATCH] Fix non allocation issues Signed-off-by: Sean Smith Change-Id: Ifcd47f8f5e00940ec472ab13fa0b3371c77a9cb7 --- src/resource_inventory/models.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/resource_inventory/models.py b/src/resource_inventory/models.py index c918513..fd2ef9d 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.valid_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() -- 2.16.6