From 703ff3bf83dfd1b5788ca9e5f043a2c9b8aea335 Mon Sep 17 00:00:00 2001 From: Gonzalo Rafuls Date: Fri, 3 Apr 2020 16:00:05 +0200 Subject: [PATCH] fix: host being added to existing assignment with no wipe is now being added as validated closes: https://github.com/redhat-performance/quads/issues/320 Change-Id: Ia46d86122c50b527601bb462e2defa086b67c836 --- quads/api_v2.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/quads/api_v2.py b/quads/api_v2.py index 49fd91004..53d3f1bad 100644 --- a/quads/api_v2.py +++ b/quads/api_v2.py @@ -409,21 +409,25 @@ def POST(self, **data): result.append("Host is not available during that time frame") else: try: - schedule = model.Schedule() if model.Schedule.is_host_available(host=_host, start=_start, end=_end): - data["cloud"] = cloud_obj - schedule.insert_schedule(**data) - cherrypy.response.status = "201 Resource Created" - result.append( - "Added schedule for %s on %s" % (data["host"], cloud_obj.name) - ) + if self.model.current_schedule(cloud=cloud_obj) and cloud_obj.validated: + if not cloud_obj.wipe: + _host_obj.update(validated=True) notification_obj = model.Notification.objects( cloud=cloud_obj, ticket=cloud_obj.ticket ).first() if notification_obj: notification_obj.update(success=False) + + schedule = model.Schedule() + data["cloud"] = cloud_obj + schedule.insert_schedule(**data) + cherrypy.response.status = "201 Resource Created" + result.append( + "Added schedule for %s on %s" % (data["host"], cloud_obj.name) + ) else: result.append("Host is not available during that time frame")