Exemple #1
0
 def test_get_ceph_osds(self):
     """
     Ensures the Ceph OSD host settings are properly parsed
     """
     ceph_osds = config_utils.get_ceph_osds(self.config)
     ceph_osds_cfg = list()
     for ceph_host in self.persis_vol[consts.CEPH_VOLUME_KEY]:
         if ceph_host[consts.HOST_KEY][
                 consts.NODE_TYPE_KEY] == consts.CEPH_OSD_TYPE:
             ceph_osds_cfg.append(ceph_host[consts.HOST_KEY])
     self.assertEqual(ceph_osds_cfg, ceph_osds)
Exemple #2
0
def launch_ceph_kubernetes(k8s_conf):
    """
    This function is used for deploy the ceph
    TODO/FIXME - Ceph and should be removed and Rook/Ceph should be used
    """
    # Setup Ceph OSD hosts
    ceph_osds = config_utils.get_ceph_osds(k8s_conf)
    for ceph_osd in ceph_osds:
        ip = ceph_osd[consts.IP_KEY]
        pb_vars = {
            'osd_host_name': ceph_osd[consts.HOSTNAME_KEY],
            'user_id': ceph_osd[consts.USER_KEY],
            'passwd': ceph_osd[consts.PASSWORD_KEY],
            'osd_ip': ip,
        }
        ansible_utils.apply_playbook(consts.INSTALL_CEPH, [ip],
                                     config_utils.get_node_user(k8s_conf),
                                     variables=pb_vars)

    proxy_dict = config_utils.get_proxy_dict(k8s_conf)
    ceph_hosts_info = config_utils.get_ceph_hosts_info(k8s_conf)
    ceph_master_host = ceph_hosts_info[0][0]
    ceph_master_ip = ceph_hosts_info[0][1]
    ceph_osds_info = config_utils.get_ceph_osds_info(k8s_conf)
    for host_name, ip, host_type in ceph_osds_info:
        pb_vars = {
            'host_name': host_name,
            'master_host_ip': ceph_master_ip,
        }
        pb_vars.update(proxy_dict)
        logger.info('Executing CEPH deploy play. IP - %s, '
                    'Host Type - %s', ip, host_type)
        ansible_utils.apply_playbook(consts.CEPH_DEPLOY, [host_name],
                                     config_utils.get_node_user(k8s_conf),
                                     variables=pb_vars)

    ansible_utils.apply_playbook(consts.CEPH_MON, [ceph_master_ip],
                                 config_utils.get_node_user(k8s_conf),
                                 variables=proxy_dict)

    for ceph_host in ceph_osds:
        second_storage = ceph_host.get(consts.STORAGE_TYPE_KEY)
        if second_storage and isinstance(second_storage, list):
            for storage in second_storage:
                pb_vars = {
                    'host_name': ceph_host[consts.HOSTNAME_KEY],
                    'master_host_name': ceph_master_host,
                    'storage': storage,
                }
                pb_vars.update(proxy_dict)
                ansible_utils.apply_playbook(
                    consts.CEPH_STORAGE_NODE, [ceph_host[consts.IP_KEY]],
                    config_utils.get_node_user(k8s_conf),
                    variables=pb_vars)
                ansible_utils.apply_playbook(
                    consts.CEPH_STORAGE_HOST, [ceph_master_host],
                    config_utils.get_node_user(k8s_conf),
                    variables=pb_vars)

    for host_name, ip, host_type in ceph_hosts_info:
        pb_vars = {
            'host_name': host_name,
            'master_host_name': ceph_master_host,
        }
        pb_vars.update(proxy_dict)
        ansible_utils.apply_playbook(consts.CEPH_DEPLOY_ADMIN, [ip],
                                     config_utils.get_node_user(k8s_conf),
                                     variables=pb_vars)

        pb_vars = {
            'master_host_name': ceph_master_host,
        }
        pb_vars.update(proxy_dict)
        ansible_utils.apply_playbook(consts.CEPH_MDS, [ip],
                                     config_utils.get_node_user(k8s_conf),
                                     variables=pb_vars)

    proxy_dict = config_utils.get_kubespray_proxy_dict(k8s_conf)
    pb_vars = {
        'PROJ_ARTIFACT_DIR': config_utils.get_project_artifact_dir(k8s_conf),
        'CEPH_FAST_RDB_YML': consts.K8S_CEPH_RDB_J2,
        'ceph_controller_ip': ceph_master_ip,
    }
    pb_vars.update(proxy_dict)
    ansible_utils.apply_playbook(consts.KUBERNETES_CEPH_CLASS,
                                 [ceph_master_ip],
                                 config_utils.get_node_user(k8s_conf),
                                 variables=pb_vars)

    ceph_claims = config_utils.get_ceph_claims(k8s_conf)
    for claim in ceph_claims:
        pb_vars = {
            'PROJ_ARTIFACT_DIR':
            config_utils.get_project_artifact_dir(k8s_conf),
            'ceph_storage_size': claim[consts.CEPH_STORAGE_KEY],
            'ceph_claim_name': claim[consts.CEPH_CLAIM_NAME_KEY],
            'CEPH_VC_YML': consts.K8S_CEPH_VC_J2,
        }
        pb_vars.update(proxy_dict)
        ansible_utils.apply_playbook(consts.KUBERNETES_CEPH_CLAIM,
                                     variables=pb_vars)