Skip to content
Permalink
Browse files
feat: validation for hosts added to already validated cloud
added logic to reset cloud object validation status to false if new
hosts are added to ongoing assignment and to only validate over the
new hosts.

Change-Id: Idc6473147be3e362beee313d8f442a9f8a430224
  • Loading branch information
grafuls committed Dec 13, 2019
1 parent 425ae92 commit cc5737d303c78c3e58580b7bd009b0c10d252b46
Showing with 15 additions and 4 deletions.
  1. +1 −1 bin/quads-cli
  2. +8 −0 quads/api_v2.py
  3. +1 −0 quads/model.py
  4. +2 −2 quads/tools/move_and_rebuild_hosts.py
  5. +3 −1 quads/tools/validate_env.py
@@ -474,7 +474,7 @@ def main(_args):
if not _args.dryrun:
try:
if _args.movecommand == default_move_command:
fn = functools.partial(move_and_rebuild, host, current, new, semaphore, cloud.wipe)
fn = functools.partial(move_and_rebuild, host, new, semaphore, cloud.wipe)
tasks.append(fn)
switch_tasks.append(functools.partial(switch_config, host, current, new))
else:
@@ -399,6 +399,14 @@ def POST(self, **data):
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:
cloud_obj.update(validated=False)
notification_obj = model.Notification.objects(
cloud=cloud_obj,
ticket=cloud_obj.ticket
).first()
if notification_obj:
notification_obj.update(success=False)
else:
result.append("Host is not available during that time frame")

@@ -177,6 +177,7 @@ class Host(Document):
interfaces = ListField(EmbeddedDocumentField(Interface))
nullos = BooleanField(default=True)
build = BooleanField(default=False)
validated = BooleanField(default=False)
last_build = DateTimeField()
meta = {
'indexes': [
@@ -112,7 +112,7 @@ async def ipmi_reset(host, semaphore):
await execute_ipmi(host, ipmi_on, semaphore)


async def move_and_rebuild(host, old_cloud, new_cloud, semaphore, rebuild=False, loop=None):
async def move_and_rebuild(host, new_cloud, semaphore, rebuild=False, loop=None):
build_start = datetime.now()
logger.debug("Moving and rebuilding host: %s" % host)

@@ -228,5 +228,5 @@ async def move_and_rebuild(host, old_cloud, new_cloud, semaphore, rebuild=False,
schedule.save()

logger.debug("Updating host: %s")
_host_obj.update(cloud=_new_cloud_obj, build=False, last_build=datetime.now())
_host_obj.update(cloud=_new_cloud_obj, build=False, last_build=datetime.now(), validated=False)
return True
@@ -24,7 +24,7 @@ class Validator(object):
def __init__(self, cloud):
self.cloud = cloud
self.report = ""
self.hosts = Host.objects(cloud=self.cloud)
self.hosts = Host.objects(cloud=self.cloud, validated=False)
self.hosts = [host for host in self.hosts if Schedule.current_schedule(host=host)]

def notify_failure(self):
@@ -186,6 +186,8 @@ def validate_env(self):
self.notify_success()
notification_obj.update(success=True, fail=False)

for host in self.hosts:
host.update(validated=True)
self.cloud.update(validated=True)

if failed and not notification_obj.fail:

0 comments on commit cc5737d

Please sign in to comment.