def __validate_rook_vols(k8s_conf):
    """
    Validation of the configured kubernetes volumes
    :param k8s_conf: the k8s configuration used to deploy the cluster
    :raises Exception
    """
    logger.info('Validate K8s Rook Volumes')
    if config_utils.is_rook_enabled(k8s_conf):
        pv_names = __get_pv_names(k8s_conf)
        logger.debug('pv_names - %s', pv_names)
        for name, size, path in config_utils.get_rook_vol_info(k8s_conf):
            logger.debug('name - %s, size - %s, path - %s', name, size, path)
            if name not in pv_names:
                raise ClusterDeploymentException(
                    'Rook PV [{}] not found'.format(name))
            else:
                pv_attrs = __get_pv_attrs(k8s_conf, name)
                if not pv_attrs[0].startswith(str(size)):
                    raise ClusterDeploymentException(
                        'PV [{}] expected size is [{}] not [{}]'.format(
                            name, size, pv_attrs[0]))
                if not pv_attrs[1] is not path:
                    raise ClusterDeploymentException(
                        'PV [{}] expected path is [{}] not [{}]'.format(
                            name, path, pv_attrs[1]))
Example #2
0
def __install_rook(k8s_conf):
    if config_utils.is_rook_enabled(k8s_conf):
        ansible_utils.apply_playbook(
            consts.INSTALL_ROOK_PB,
            variables={
                'ROOK_OPERATOR_J2': consts.K8S_ROOK_OPERATOR_J2,
                'ROOK_CLUSTER_J2': consts.K8S_ROOK_CLUSTER_J2,
                'ROOK_STO_CLASS_J2': consts.K8S_ROOK_STO_CLASS_J2,
                'ROOK_PV_J2': consts.ROOK_PV_J2,
                'PROJ_ARTIFACT_DIR': config_utils.get_project_artifact_dir(
                    k8s_conf),
                'rook_volumes': config_utils.get_rook_vols(k8s_conf),
            })