Example #1
0
def aws():
    """
    Test AWS connectivity
    """
    OUTPUT.info('TEST: Validating AWS connectivity')

    try:
        monitortask = MonitorTasks(runargs=TESTARGS)
        OUTPUT.info('Testing AWS connectivity')
        monitortask.instantiate_aws()
        OUTPUT.echo('AWS Test Success!', color='green')

    except Exception as awsawareexception:
        raise awsawareexception
Example #2
0
    def show_monitors(self):
        """Prints information about current monitors to console"""
        try:
            OUTPUT.info('Loading and displaying monitors')

            outlines = []
            outlines.append([
                'name', 'thresholdtype', 'warn_thresh', 'alert_thresh',
                'enabled'
            ])
            for monitor in self.monitorjobs:
                outlines.append(monitor.show())

            col_width = max(len(word) for row in outlines for word in row) + 2
            # padding
            for row in outlines:
                OUTPUT.echo("".join(word.ljust(col_width) for word in row))

        except Exception as monitorexception:
            OUTPUT.error('Unable to print monitor output')
            raise monitorexception
Example #3
0
def awsdownload(sourcefile, destpath=None):
    """
    Test aws ability to download a specific file
    """
    OUTPUT.info('TEST: Validating aws file download ability')
    if destpath is None:
        destpath = os.path.join(os.path.abspath(os.path.curdir), sourcefile)
        OUTPUT.info(
            'Using current directory and source file name as destination file path: {0}'
            .format(destpath))
    else:
        destpath = os.path.abspath(destpath)

    try:
        monitortask = MonitorTasks(runargs=TESTARGS)
        OUTPUT.info('Connecting to aws')
        monitortask.instantiate_aws()
        OUTPUT.echo('..Connected to AWS', color='green')
    except Exception as awsawareexception:
        raise awsawareexception

    s3fullfilepath = '{0}/{1}'.format(TESTARGS['s3path'], sourcefile)
    OUTPUT.info('Attempting to download file - {0}'.format(s3fullfilepath))
    s3url = urlparse(s3fullfilepath)
    downloaded = monitortask.aws.download_s3_file(bucket=s3url.netloc,
                                                  path=s3url.path.lstrip('/'),
                                                  destpath=destpath)

    if downloaded:
        OUTPUT.echo('..SUCCESS!', color='green')
    else:
        OUTPUT.echo('..FAILED!', color='red')