Beispiel #1
0
def docker_client_missing_package_installation(clients, agent):
    """
    Use to install the missing packages of puppet agent and katello-agent
    :param dict clients: The dictionary containing client_name as key and
        container_id as value
    :param string agent: puppet-agent / katello-agent
    """
    for hostname, container in tuple(clients.items()):
        logger.info(f'Installing client {hostname} on docker container: {container}')
        try:
            for _ in range(1, 15):
                yum_status = docker_execute_command(container, 'pgrep yum', True)
                if yum_status == '':
                    break
                logger.info("yum command is running wait fot 60 seconds...")
                time.sleep(60)
            command_output = docker_execute_command(container, f'rpm -q {agent}', True)
            if re.search(f'package {agent} is not installed', command_output):
                logger.warn(f"base version of {agent} package missed(because of timeout) on "
                            f"{container} so installing it separately")
                docker_execute_command(container, f'yum install -y {agent}', True)
                command_output = docker_execute_command(container, f'rpm -q {agent}', True)
                if re.search(f'package {agent} is not installed', command_output):
                    logger.warn(f"failed to install package {agent} on {container}")
                else:
                    logger.info(f"base version of {agent} package {command_output} installed "
                                f"successfully on {container}")
            else:
                logger.info(f"{agent} package {command_output} is available before "
                            f"upgrade on {container}")
        except Exception as ex:
            logger.warn(ex)
Beispiel #2
0
def docker_clients_upgrade(old_repo, clients, agent):
    """Helper function to run upgrade on docker containers as clients

    :param string old_repo: The old tools repo to disable before updating
        katello-agent package
    :param dict clients: The dictionary containing client_name as key and
        container_id as value
    :param string agent: puppet-agent / katello-agent
    """
    for hostname, container in tuple(clients.items()):
        logger.info(f'Upgrading client {hostname} on docker container: {container}')
        docker_execute_command(container, f'subscription-manager repos --disable {old_repo}')
        docker_execute_command(container, f'yum update -y {agent}', True)
Beispiel #3
0
def docker_clients_upgrade(old_repo, clients):
    """Helper function to run upgrade on docker containers as clients

    :param string old_repo: The old tools repo to disable before updating
        katello-agent package
    :param dict clients: The dictionary containing client_name as key and
        container_id as value
    """
    for hostname, container in clients.items():
        logger.info('Upgrading client {0} on docker container: {1}'.format(
            hostname, container))
        docker_execute_command(
            container,
            'subscription-manager repos --disable {}'.format(old_repo))
        docker_execute_command(container, 'yum update -y katello-agent', True)
Beispiel #4
0
def docker_clients_upgrade(old_repo, clients, puppet=False):
    """Helper function to run upgrade on docker containers as clients

    :param string old_repo: The old tools repo to disable before updating
        katello-agent package
    :param dict clients: The dictionary containing client_name as key and
        container_id as value
    :param bool puppet: clients are puppet clients or not, default no
    """
    agent = 'puppet' if puppet else 'katello'
    for hostname, container in clients.items():
        logger.info('Upgrading client {0} on docker container: {1}'.format(
            hostname, container))
        docker_execute_command(
            container,
            'subscription-manager repos --disable {}'.format(old_repo))
        docker_execute_command(container,
                               'yum update -y {}-agent'.format(agent), True)
Beispiel #5
0
def docker_clients_katello_agent_version(clients):
    """Determines and returns the katello-agent version on docker clients

    :param dict clients: The dictionary containing client_name as key and
        container_id as value
    :returns dict: The dict of docker clients hostname as key and
        its katello-agent version as value
    """
    clients_dict = {}
    for hostname, container in clients.items():
        pst = katello_agent_version_filter(
            docker_execute_command(container, 'rpm -q katello-agent'))
        clients_dict[hostname] = pst
    return clients_dict
def docker_clients_agent_version(clients, agent):
    """Determines and returns the katello or puppet agent version on docker
    clients

    :param dict clients: The dictionary containing client_name as key and
        container_id as value
    :param string agent: puppet/ puppet-agent / katello-agent
    :returns dict: The dict of docker clients hostname as key and
        its katello or puppet agent version as value
    """
    clients_dict = {}
    for hostname, container in clients.items():
        pst = version_filter(
            docker_execute_command(container, 'rpm -q {}'.format(agent)))
        clients_dict[hostname] = pst
    return clients_dict
Beispiel #7
0
def docker_clients_agent_version(clients, puppet=False):
    """Determines and returns the katello or puppet agent version on docker
    clients

    :param dict clients: The dictionary containing client_name as key and
        container_id as value
    :returns dict: The dict of docker clients hostname as key and
        its katello or puppet agent version as value
    :param bool puppet: get puppet agent version if true
    """
    clients_dict = {}
    agent = 'puppet' if puppet else 'katello'
    for hostname, container in clients.items():
        pst = version_filter(
            docker_execute_command(container, 'rpm -q {}-agent'.format(agent)))
        clients_dict[hostname] = pst
    return clients_dict
Beispiel #8
0
def docker_clients_agent_version(clients, agent):
    """Determines and returns the katello or puppet agent version on docker
    clients

    :param dict clients: The dictionary containing client_name as key and
        container_id as value
    :param string agent: puppet/ puppet-agent / katello-agent
    :returns dict: The dict of docker clients hostname as key and
        its katello or puppet agent version as value
    """
    clients_dict = {}
    for hostname, container in tuple(clients.items()):
        try:
            command_output = docker_execute_command(container, f'rpm -q {agent}')
            pst = version_filter(command_output)
            clients_dict[hostname] = pst
        except Exception as ex:
            logger.warn(ex)
            clients_dict[hostname] = f"{agent} package not updated"
    return clients_dict