コード例 #1
0
ファイル: deployment.py プロジェクト: XDsubhash/ocs-ci
    def deploy_with_external_mode(self):
        """
        This function handles the deployment of OCS on
        external/indpendent RHCS cluster

        """
        live_deployment = config.DEPLOYMENT.get('live_deployment')
        logger.info("Deploying OCS with external mode RHCS")
        logger.info("Creating namespace and operator group")
        run_cmd(f"oc create -f {constants.OLM_YAML}")
        if not live_deployment:
            self.create_ocs_operator_source()
        self.subscribe_ocs()
        operator_selector = get_selector_for_ocs_operator()
        package_manifest = PackageManifest(
            resource_name=defaults.OCS_OPERATOR_NAME,
            selector=operator_selector,
        )
        package_manifest.wait_for_resource(timeout=300)
        channel = config.DEPLOYMENT.get('ocs_csv_channel')
        csv_name = package_manifest.get_current_csv(channel=channel)
        csv = CSV(resource_name=csv_name, namespace=self.namespace)
        csv.wait_for_phase("Succeeded", timeout=720)

        # Create secret for external cluster
        secret_data = templating.load_yaml(
            constants.EXTERNAL_CLUSTER_SECRET_YAML)
        external_cluster_details = config.EXTERNAL_MODE.get(
            'external_cluster_details', '')
        if not external_cluster_details:
            raise ExternalClusterDetailsException(
                "No external cluster data found")
        secret_data['data']['external_cluster_details'] = (
            external_cluster_details)
        secret_data_yaml = tempfile.NamedTemporaryFile(
            mode='w+', prefix='external_cluster_secret', delete=False)
        templating.dump_data_to_temp_yaml(secret_data, secret_data_yaml.name)
        logger.info("Creating external cluster secret")
        run_cmd(f"oc create -f {secret_data_yaml.name}")

        cluster_data = templating.load_yaml(
            constants.EXTERNAL_STORAGE_CLUSTER_YAML)
        cluster_data['metadata']['name'] = config.ENV_DATA[
            'storage_cluster_name']
        cluster_data_yaml = tempfile.NamedTemporaryFile(
            mode='w+', prefix='external_cluster_storage', delete=False)
        templating.dump_data_to_temp_yaml(cluster_data, cluster_data_yaml.name)
        run_cmd(f"oc create -f {cluster_data_yaml.name}", timeout=2400)
        self.external_post_deploy_validation()
        setup_ceph_toolbox()
コード例 #2
0
ファイル: utils.py プロジェクト: MeridianExplorer/ocs-ci
def get_external_mode_rhcs():
    """
    Get external cluster info from config and obtain
    external cluster object


    Returns:
        external_ceph.Ceph object

    """
    external_rhcs_info = ocsci_config.EXTERNAL_MODE.get(
        "external_cluster_node_roles", "")
    if not external_rhcs_info:
        log.error("No external RHCS cluster info found")
        raise ExternalClusterDetailsException()

    return get_cluster_object(external_rhcs_info)
コード例 #3
0
ファイル: deployment.py プロジェクト: shyRozen/ocs-ci
def create_external_secret(ocs_version=None, apply=False):
    """
    Creates secret data for external cluster

    Args:
         ocs_version (str): OCS version
         apply (bool): True if want to use apply instead of create command

    """
    ocs_version = ocs_version or config.ENV_DATA["ocs_version"]
    secret_data = templating.load_yaml(constants.EXTERNAL_CLUSTER_SECRET_YAML)
    external_cluster_details = config.EXTERNAL_MODE.get(
        "external_cluster_details", "")
    if not external_cluster_details:
        raise ExternalClusterDetailsException("No external cluster data found")
    secret_data["data"]["external_cluster_details"] = external_cluster_details
    secret_data_yaml = tempfile.NamedTemporaryFile(
        mode="w+", prefix="external_cluster_secret", delete=False)
    templating.dump_data_to_temp_yaml(secret_data, secret_data_yaml.name)
    logger.info(
        f"Creating external cluster secret for OCS version: {ocs_version}")
    oc_type = "apply" if apply else "create"
    run_cmd(f"oc {oc_type} -f {secret_data_yaml.name}")