Skip to content
Permalink
Browse files

Merge "feat: added debug option to validate_env"

  • Loading branch information
sadsfae authored and gerritforge-ltd committed Dec 2, 2019
2 parents 83391f7 + 96807b4 commit 4163427d2a503c5f7af033bd9715bed1d0f42633
Showing with 19 additions and 5 deletions.
  1. +19 −5 quads/tools/validate_env.py
@@ -1,4 +1,5 @@
#!/usr/bin/python3
import argparse
import asyncio
import logging
import os
@@ -7,6 +8,7 @@
from datetime import datetime
from jinja2 import Template
from paramiko import SSHException
from paramiko.ssh_exception import NoValidConnectionsError

from quads.config import conf, TEMPLATES_PATH, INTERFACES
from quads.model import Cloud, Schedule, Host, Notification
@@ -16,7 +18,6 @@
from quads.tools.ssh_helper import SSHHelper

logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO, format="%(message)s")


class Validator(object):
@@ -124,8 +125,9 @@ def post_network_test(self):
test_host = host
try:
ssh_helper = SSHHelper(test_host.name)
except SSHException:
logger.exception("Could not establish connection with host: %s." % test_host.name)
except (SSHException, NoValidConnectionsError, socket.timeout) as ex:
logger.debug(ex)
logger.error("Could not establish connection with host: %s." % test_host.name)
self.report = self.report + "Could not establish connection with host: %s.\n" % test_host.name
return False
host_list = " ".join([host.name for host in self.hosts])
@@ -162,6 +164,7 @@ def post_network_test(self):
return True

def validate_env(self):
logger.info(f"Validating {self.cloud.name}")
notification_obj = Notification.objects(
cloud=self.cloud,
ticket=self.cloud.ticket
@@ -193,12 +196,23 @@ def validate_env(self):


if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Validate Quads assignments')
parser.add_argument('--debug', action='store_true', default=False, help='Show debugging information.')
args = parser.parse_args()

level = logging.INFO
if args.debug:
level = logging.DEBUG

logging.basicConfig(level=level, format="%(message)s")

clouds = Cloud.objects(validated=False, name__ne="cloud01")
for _cloud in clouds:
_schedule_count = Schedule.current_schedule(cloud=_cloud).count()
if _schedule_count and _cloud.wipe:
validator = Validator(_cloud)
try:
validator.validate_env()
except Exception:
logger.exception("Failed validation for %s" % _cloud.name)
except Exception as ex:
logger.debug(ex)
logger.info("Failed validation for %s" % _cloud.name)

0 comments on commit 4163427

Please sign in to comment.
You can’t perform that action at this time.