From 4bfa2fa78c487bd8a0453de847ffcb27af526425 Mon Sep 17 00:00:00 2001 From: Brandon Lo Date: Thu, 30 Jan 2020 13:35:34 -0500 Subject: Fix booking errors This implements Host model's "release" method and replaces an instance of Network to PhysicalNetwork. Change-Id: I99b0bedbde2dcd63411cbb1fbf9b4905fc9570b1 Signed-off-by: Brandon Lo --- src/resource_inventory/models.py | 4 ++++ src/resource_inventory/resource_manager.py | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/resource_inventory') diff --git a/src/resource_inventory/models.py b/src/resource_inventory/models.py index d152698..1e2e547 100644 --- a/src/resource_inventory/models.py +++ b/src/resource_inventory/models.py @@ -424,6 +424,10 @@ class Host(Resource): "ipmi_create": str(ipmi) } + def release(self): + self.booked = False + self.save() + class Interface(models.Model): id = models.AutoField(primary_key=True) diff --git a/src/resource_inventory/resource_manager.py b/src/resource_inventory/resource_manager.py index 7df4263..4fd344c 100644 --- a/src/resource_inventory/resource_manager.py +++ b/src/resource_inventory/resource_manager.py @@ -20,7 +20,8 @@ from resource_inventory.models import ( ResourceBundle, HostProfile, Network, - Vlan + Vlan, + PhysicalNetwork, ) @@ -131,12 +132,16 @@ class ResourceManager: generic_interface = generic_interfaces[int_num] physical_interface.config.clear() for connection in generic_interface.connections.all(): + physicalNetwork = PhysicalNetwork.objects.create( + vlan_id=vlan_map[connection.network.name], + generic_network=connection.network + ) physical_interface.config.add( Vlan.objects.create( vlan_id=vlan_map[connection.network.name], tagged=connection.vlan_is_tagged, public=connection.network.is_public, - network=connection.network + network=physicalNetwork ) ) -- cgit 1.2.3-korg