summaryrefslogtreecommitdiffstats
path: root/src/resource_inventory/resource_manager.py
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2019-01-18 16:30:27 +0000
committerGerrit Code Review <gerrit@opnfv.org>2019-01-18 16:30:27 +0000
commit9fc7bfe1b88a720b381ef49bb98cc594924de605 (patch)
treed22b902a67a0cb9c9c6f49d0bfe05e390080e327 /src/resource_inventory/resource_manager.py
parent184dd8ad3a2e2b58f7d25ac6fa1e7ac80c1c5511 (diff)
parentd8e2dbb57cc90ebdffb9ca463b91948b9b634918 (diff)
Merge "Add Quick-Booking Workflow"
Diffstat (limited to 'src/resource_inventory/resource_manager.py')
-rw-r--r--src/resource_inventory/resource_manager.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/resource_inventory/resource_manager.py b/src/resource_inventory/resource_manager.py
index 9282580..812fcd7 100644
--- a/src/resource_inventory/resource_manager.py
+++ b/src/resource_inventory/resource_manager.py
@@ -17,7 +17,7 @@ from dashboard.exceptions import (
ResourceProvisioningException,
ModelValidationException,
)
-from resource_inventory.models import Host, HostConfiguration, ResourceBundle
+from resource_inventory.models import Host, HostConfiguration, ResourceBundle, HostProfile
class ResourceManager:
@@ -33,6 +33,11 @@ class ResourceManager:
ResourceManager.instance = ResourceManager()
return ResourceManager.instance
+ def getAvailableHostTypes(self, lab):
+ hostset = Host.objects.filter(lab=lab).filter(booked=False).filter(working=True)
+ hostprofileset = HostProfile.objects.filter(host__in=hostset, labs=lab)
+ return set(hostprofileset)
+
# public interface
def deleteResourceBundle(self, resourceBundle):
for host in Host.objects.filter(bundle=resourceBundle):
@@ -70,12 +75,12 @@ class ResourceManager:
physical_hosts.append(physical_host)
self.configureNetworking(physical_host)
- except:
+ except Exception:
self.fail_acquire(physical_hosts)
raise ResourceProvisioningException("Network configuration failed.")
try:
physical_host.save()
- except:
+ except Exception:
self.fail_acquire(physical_hosts)
raise ModelValidationException("Saving hosts failed")