diff options
author | Sawyer Bergeron <sbergeron@iol.unh.edu> | 2020-03-17 12:52:21 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2020-03-17 12:52:21 +0000 |
commit | 287a9e199abf29c4872390e4ff15db5f87382e20 (patch) | |
tree | 01948e75db2eb3c398de4ae9d266fc6c60da59e9 /src/dashboard/tasks.py | |
parent | c8998d426cbf12afb2d2e68059e0969388b50c95 (diff) | |
parent | e90f13e0413594d95e50256b1206ffd64217f2da (diff) |
Merge "Quick Deploy Fixes." into resource
Diffstat (limited to 'src/dashboard/tasks.py')
-rw-r--r-- | src/dashboard/tasks.py | 40 |
1 files changed, 6 insertions, 34 deletions
diff --git a/src/dashboard/tasks.py b/src/dashboard/tasks.py index ac4d36f..b980799 100644 --- a/src/dashboard/tasks.py +++ b/src/dashboard/tasks.py @@ -15,43 +15,15 @@ from booking.models import Booking from notifier.manager import NotificationHandler from api.models import Job, JobStatus, SoftwareRelation, HostHardwareRelation, HostNetworkRelation, AccessRelation from resource_inventory.resource_manager import ResourceManager +from resource_inventory.models import ConfigState @shared_task def booking_poll(): - def cleanup_hardware(qs): + def cleanup_resource_task(qs): for hostrelation in qs: - config = hostrelation.config - config.clear_delta() - config.power = "off" - config.save() - hostrelation.status = JobStatus.NEW - hostrelation.save() - - def cleanup_network(qs): - for hostrelation in qs: - network = hostrelation.config - network.interfaces.clear() - host = hostrelation.host - network.clear_delta() - vlans = [] - for interface in host.interfaces.all(): - for vlan in interface.config.all(): - if vlan.public: - try: - host.lab.vlan_manager.release_public_vlan(vlan.vlan_id) - except Exception: # will fail if we already released in this loop - pass - else: - vlans.append(vlan.vlan_id) - - # release all vlans - if len(vlans) > 0: - host.lab.vlan_manager.release_vlans(vlans) - - interface.config.clear() - network.add_interface(interface) - network.save() + hostrelation.config.state = ConfigState.CLEAN + hostrelation.config.save() hostrelation.status = JobStatus.NEW hostrelation.save() @@ -78,8 +50,8 @@ def booking_poll(): if not booking.job.complete: job = booking.job cleanup_software(SoftwareRelation.objects.filter(job=job)) - cleanup_hardware(HostHardwareRelation.objects.filter(job=job)) - cleanup_network(HostNetworkRelation.objects.filter(job=job)) + cleanup_resource_task(HostHardwareRelation.objects.filter(job=job)) + cleanup_resource_task(HostNetworkRelation.objects.filter(job=job)) cleanup_access(AccessRelation.objects.filter(job=job)) job.complete = True job.save() |