Exemple #1
0
def __manage_keys(config):
    """
    Creates and pushes SSH keys when necessary
    """
    logger.info('Managing SSH keys')
    nodes_info = config_utils.get_nodes_ip_name_type(config)
    for hostname, ip, node_type in nodes_info:
        ssh_client = ssh_utils.ssh_client(ip, 'root')
        if not ssh_client:
            logger.debug('Creating and injecting key to %s', ip)
            password = config_utils.get_node_password(config, hostname)
            ansible_utils.apply_playbook(consts.MANAGE_KEYS,
                                         variables={
                                             'ip': ip,
                                             'password': password
                                         })
        else:
            logger.debug('Key already exists')

    docker_repo = config_utils.get_docker_repo(config)
    if docker_repo and isinstance(docker_repo, dict):
        ip = docker_repo[consts.IP_KEY]
        ssh_client = ssh_utils.ssh_client(ip, 'root')
        if not ssh_client:
            logger.debug('Creating and injecting key to %s', ip)
            password = docker_repo[consts.PASSWORD_KEY]
            ansible_utils.apply_playbook(consts.MANAGE_KEYS,
                                         variables={
                                             'ip': ip,
                                             'password': password
                                         })
        else:
            logger.debug('Key already exists')
Exemple #2
0
 def test_get_docker_repo(self):
     """
     Ensures the Docker Repo settings are properly parsed
     """
     docker_repo = config_utils.get_docker_repo(self.config)
     expected = self.config[consts.K8S_KEY][consts.DOCKER_REPO_KEY]
     self.assertEqual(expected, docker_repo)
def validate_docker_repo_params(config):
    """
    Checks the presence of docker repo parameters
    """
    logger.info("checking docker repo  params")
    docker_repo_params = config_utils.get_docker_repo(config)
    validate_dict_data(docker_repo_params, consts.IP_KEY)
    validate_dict_data(docker_repo_params, consts.PASSWORD_KEY)
    validate_dict_data(docker_repo_params, consts.USER_KEY)
    validate_dict_data(docker_repo_params, consts.PORT_KEY)