Skip to content

Commit

Permalink
fix: host being added to existing assignment with no wipe
Browse files Browse the repository at this point in the history
is now being added as validated

closes: #320
Change-Id: Ia46d86122c50b527601bb462e2defa086b67c836
  • Loading branch information
grafuls committed Apr 3, 2020
1 parent 31fee10 commit 703ff3b
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions quads/api_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 703ff3b

Please sign in to comment.