aboutsummaryrefslogtreecommitdiffstats
path: root/src/resource_inventory/resource_manager.py
diff options
context:
space:
mode:
authorParker Berberian <pberberian@iol.unh.edu>2019-11-12 12:54:20 -0500
committerBrandon Lo <lobrandon1217@gmail.com>2020-01-28 13:28:34 -0500
commit899e1a4baa95d0bc6f0eef34de66f0e257174878 (patch)
tree2fbc99070b2fe2d75135ca5f899ed14b12639856 /src/resource_inventory/resource_manager.py
parent30a535d7e9bdc0e3cf637207c0c100a16db81586 (diff)
Begin Resource Refactor
Begins the Resource Refactor by creating new interfaces to the resources through a Resource super class and using that new interface in the api Change-Id: I15a8179bfe915d2cde6d658d056e11cbd2c70e43 Signed-off-by: Parker Berberian <pberberian@iol.unh.edu>
Diffstat (limited to 'src/resource_inventory/resource_manager.py')
-rw-r--r--src/resource_inventory/resource_manager.py14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/resource_inventory/resource_manager.py b/src/resource_inventory/resource_manager.py
index e94b4ec..7df4263 100644
--- a/src/resource_inventory/resource_manager.py
+++ b/src/resource_inventory/resource_manager.py
@@ -50,7 +50,7 @@ class ResourceManager:
# count up hosts
profile_count = {}
- for host in grb.getHosts():
+ for host in grb.getResources():
if host.profile not in profile_count:
profile_count[host.profile] = 0
profile_count[host.profile] += 1
@@ -71,7 +71,7 @@ class ResourceManager:
# public interface
def deleteResourceBundle(self, resourceBundle):
for host in Host.objects.filter(bundle=resourceBundle):
- self.releaseHost(host)
+ host.release()
resourceBundle.delete()
def get_vlans(self, genericResourceBundle):
@@ -93,7 +93,7 @@ class ResourceManager:
Takes in a GenericResourceBundle and 'converts' it into a ResourceBundle
"""
resource_bundle = ResourceBundle.objects.create(template=genericResourceBundle)
- generic_hosts = genericResourceBundle.getHosts()
+ generic_hosts = genericResourceBundle.getResources()
physical_hosts = []
vlan_map = self.get_vlans(genericResourceBundle)
@@ -154,12 +154,6 @@ class ResourceManager:
host.save()
return host
- def releaseHost(self, host):
- host.template = None
- host.bundle = None
- host.booked = False
- host.save()
-
def releaseNetworks(self, grb, vlan_manager, vlans):
for net_name, vlan_id in vlans.items():
net = Network.objects.get(name=net_name, bundle=grb)
@@ -172,7 +166,7 @@ class ResourceManager:
vlan_manager = grb.lab.vlan_manager
self.releaseNetworks(grb, vlan_manager, vlans)
for host in hosts:
- self.releaseHost(host)
+ host.release()
class HostNameValidator(object):