Exemple #1
0
def run_profile(profile_name, tag_name):
    registry = config.get_env(profile_name, 'docker_registry')
    vol_mapping = config.get_env(profile_name, 'vol_mapping')
    port_mapping = config.get_env(profile_name, 'port_mapping')
    env_vars = config.get_env(profile_name, 'env_vars')

    command = "docker run -d "
    command += '--name ' + profile_name
    command += ' -p ' + port_mapping
    command += ' -v ' + vol_mapping
    command += ' -e ' + env_vars
    tag = 'latest'
    if tag_name == '':
        logger.log_bl('\nGetting top 5 available tags of ' + profile_name +
                      ' from Amazon ECR registry...')
        tag_list = utils.cmd_exec(
            "aws ecr describe-images --repository-name " + profile_name +
            " --output text --query 'sort_by(imageDetails,& imagePushedAt)[*].imageTags[*]' | tr '\t' '\n' | tail -5"
        )
        tag_list = list(reversed(tag_list.split('\n')))
        tag = click.prompt(logger.style('\nSelect an tag to deploy: ?'),
                           type=click.Choice(tag_list))
    logger.log_g('\nYou have selected tag: [ ' + tag +
                 ' ]  for your application')
    command += ' ' + registry + '/' + profile_name + ':' + tag
    logger.debug('final command : ' + command)
    logger.log_y('\nKilling old container if exist')
    utils.cmd_exec('docker rm -f ' + profile_name)
    utils.cmd_exec(command)
    logger.log_g("\nSuccessfully started " + profile_name +
                 " application . Please check logs using: ")
    logger.log_cy("\n                 docker logs -f " + profile_name +
                  "                          \n")
Exemple #2
0
def run_all():
    profiles = config.get_profiles()
    for profile in profiles:
        if profile == 'default':
            continue
        logger.log_g("\n******************** Running Profile " + profile +
                     " ********************")
        run_profile(profile, '')
Exemple #3
0
def execute(input_path, defaultTimePage):
    logger.log_r("Printing the entire list")
    # index =0
    # creating list        
    list = []
    index = 0
    with open(input_path, 'r') as f:
        for url in f:
            # openUrlAndTakeScreenshot(url, defaultTimePage, str(index) + '.png')
            list.append(ResultRow(index, url)) 
            logger.log_g(str(index))
            index = index+1
    
    logger.log_r("Printing the entire list")

    for obj in list: 
        percentage = compareImages('0.png', str(obj.index) + '.png')
        logger.log_g("percentage : " + str(percentage))
        obj.imgPer = percentage
        print(obj.index, obj.url, obj.imgPer, sep =' ' )

    print_results(list)
Exemple #4
0
def login_ecs():
    logger.log_y("Logging into ECS")
    login = utils.cmd_exec("aws ecr get-login   | sed  's/-e none//g'")
    utils.cmd_exec(login)
    logger.log_g("Login successful")
Exemple #5
0
def clean_up(search_pattern):
    logger.log_c('\nCleaning Old Images  matching pattern : ', search_pattern)
    logger.debug('\n----------  Cleaning Old Images ---- \n')
    utils.cmd_exec("docker images -a | grep " + search_pattern +
                   " | awk '{print $3}' | xargs docker rmi -f")
    logger.log_g("\nCleaned images successfully")