ocs_ci.deployment.helpers package

Submodules

ocs_ci.deployment.helpers.external_cluster_helpers module

This module contains helpers functions needed for external cluster deployment.

class ocs_ci.deployment.helpers.external_cluster_helpers.ExternalCluster(host, user, password=None, ssh_key=None)

Bases: object

Helper for External RHCS cluster

create_object_store_user()

Create object store user on external cluster and update access_key and secret_key to config

enable_secure_connection_mode()

Enables secure connection mode for RHCS cluster

get_admin_keyring()

Fetches admin keyring from external RHCS cluster and updates to config.EXTERNAL_MODE

get_ceph_fs()

Fetches the ceph filesystem name

Returns:

ceph filesystem name

Return type:

str

Raises:

ExternalClusterCephfsMissing – in case of ceph filesystem doesn’t exist

get_external_cluster_details()

Gets the external RHCS cluster details and updates to config.EXTERNAL_MODE

Raises:

ExternalClusterExporterRunFailed – If exporter script failed to run on external RHCS cluster

get_object_store_user_secrets(user)

Get the access and secret key for user

Returns:

tuple which contains access_key and secret_key

Return type:

tuple

get_rgw_endpoint_api_port()

Fetches rgw endpoint api port.

For ceph 6.x, get port information from cephadm ls, for ceph 5.x, get port information from ceph config dump and for ceph 4.x, get port information from ceph.conf on rgw node

Returns:

RGW endpoint port

Return type:

str

get_rhel_version()

Fetches the RHEL version on external RHCS cluster

Returns:

RHEL version

Return type:

str

is_object_store_user_exists(user, realm=None)

Checks whether user exists in external cluster

Parameters:
  • user (str) – Object store user name

  • realm (str) – Name of realm to check

Returns:

True if user exists, otherwise false

Return type:

bool

is_rgw_user_exists(user)

Checks whether RGW user exists or not

Parameters:

user (str) – RGW user name

Returns:

True incase user exists, otherwise False

Return type:

bool

remove_rbd_images(images, pool)

Removes rbd images from external RHCS cluster

Parameters:
  • images (list) – List of rbd images to delete

  • pool (str) – rbd pool name

remove_rgw_user(user=None)

Remove RGW user if it exists

Parameters:

user (str) – RGW user name

run_exporter_script(params)

Runs the exporter script on RHCS cluster

Parameters:

params (str) – Parameter to pass to exporter script

Returns:

output of exporter script

Return type:

str

update_permission_caps(user=None)

Update permission caps on the external RHCS cluster

upload_exporter_script()

Upload exporter script to RHCS cluster

Returns:

absolute path to exporter script

Return type:

str

upload_rgw_cert_ca()

Upload RGW Cert CA to RHCS cluster

Returns:

absolute path to the CA Cert

Return type:

str

ocs_ci.deployment.helpers.external_cluster_helpers.generate_exporter_script()

Generates exporter script for RHCS cluster

Returns:

path to the exporter script

Return type:

str

ocs_ci.deployment.helpers.external_cluster_helpers.get_and_apply_rgw_cert_ca()

Downloads CA Certificate of RGW if SSL is used and apply it to be trusted by the OCP cluster

Returns:

path to the downloaded RGW Cert CA

Return type:

str

ocs_ci.deployment.helpers.external_cluster_helpers.get_external_cluster_client()

Finding the client role node IP address.

Returns:

IP address, user, password of the client, ssh key

Return type:

tuple

Raises:

ExternalClusterCephSSHAuthDetailsMissing – In case one of SSH key or password is not provided.

ocs_ci.deployment.helpers.external_cluster_helpers.get_node_by_role(nodes, role, user, password, ssh_key)

Get a node (a tuple with ip, user, password, ssh_key)

Parameters:
  • nodes (list) – List of nodes participating

  • role (str) – Specific role of the nodes we are looking for

  • user (str) – Login user name for the node

  • password (str) – Login password for the node

  • ssh_key (str) – Path to ssh key

Returns:

(ip_address, user, password, ssh_key)

Return type:

Tuple

Raises:

ExternalClusterNodeRoleNotFound (Exception) – if no node found with the desired role

ocs_ci.deployment.helpers.external_cluster_helpers.get_rgw_endpoint()

Fetches rgw endpoint

Returns:

rgw endpoint

Return type:

str

Raises:

ExternalClusterRGWEndPointMissing – in case of rgw endpoint missing

ocs_ci.deployment.helpers.external_cluster_helpers.remove_csi_users()

Remove csi users from external RHCS cluster

ocs_ci.deployment.helpers.hypershift_base module

class ocs_ci.deployment.helpers.hypershift_base.HyperShiftBase

Bases: object

Class to handle HyperShift hosted cluster management

create_kubevirt_ocp_cluster(name: str = None, nodepool_replicas: int = 2, memory: str = '12Gi', cpu_cores: int = 6, root_volume_size: str = 40, ocp_version=None, cp_availability_policy=None, disable_default_sources=None)

Create HyperShift hosted cluster. Default parameters have minimal requirements for the cluster.

Parameters:
  • name (str) – Name of the cluster

  • nodepool_replicas (int) – Number of nodes in the cluster

  • memory (str) – Memory size of the cluster, minimum 12Gi

  • cpu_cores (str) – CPU cores of the cluster, minimum 6

  • ocp_version (str) – OCP version of the cluster

  • root_volume_size (str) – Root volume size of the cluster, default 40 (Gi is not required)

  • cp_availability_policy (str) – Control plane availability policy, default HighlyAvailable, if no value

  • created (provided and argument is not used in the command the single replica mode cluster will be) –

  • disable_default_sources (bool) – Disable default sources on hosted cluster, such as ‘redhat-operators’

Returns:

Name of the hosted cluster

Return type:

str

delete_hcp_and_hypershift()

Delete hcp binary

delete_hcp_podman_container()

Delete hcp podman container. This method will not fail if the container does not exist.

destroy_kubevirt_cluster(name)

Destroy HyperShift hosted cluster

Parameters:

name (str) – Name of the cluster

download_hcp_binary_with_podman()

Download hcp binary to bin_dir

download_hosted_cluster_kubeconfig(name: str, hosted_cluster_path: str)

Download HyperShift hosted cluster kubeconfig :param name: name of the cluster :type name: str :param hosted_cluster_path: path to create auth_path folder and download kubeconfig there :type hosted_cluster_path: str

Returns:

path to the downloaded kubeconfig, None if failed

Return type:

str

get_current_nodepool_size(name)

Get existing nodepool of HyperShift hosted cluster :param name: name of the cluster :type name: str

Returns:

number of nodes in the nodepool

Return type:

int

get_desired_nodepool_size(name: str)

Get desired nodepool of HyperShift hosted cluster :param name: of the cluster :type name: str

Returns:

number of nodes in the nodepool

Return type:

int

get_hosted_cluster_kubeconfig_name(name: str)

Get HyperShift hosted cluster kubeconfig, for example ‘hcp414-bm2-a-admin-kubeconfig’ :param name: name of the cluster

Returns:

hosted cluster kubeconfig name

Return type:

str

get_hosted_cluster_progress(name: str)

Get HyperShift hosted cluster creation progress :param name: name of the cluster :type name: str

Returns:

progress status; ‘Completed’ is expected in most cases

Return type:

str

get_hypershift_csv_version()

Get hypershift operator version :returns: hypershift operator version :rtype: str

get_mce_version()

Get multicluster engine version :returns: multicluster engine version :rtype: str

hcp_binary_exists()

Check if hcp binary exists :returns: True if hcp binary exists, False otherwise :rtype: bool

hypershift_binary_exists()

Check if hypershift binary exists :returns: True if hypershift binary exists, False otherwise :rtype: bool

hypershift_clusters_exist()

Check if hypershift is installed on the cluster :returns: True if hypershift is installed, False otherwise :rtype: bool

install_hcp_and_hypershift_from_git()

Install hcp binary from git

install_hypershift_upstream_on_cluster()

Install hypershift on the cluster :returns: True if hypershift is installed, False otherwise :rtype: bool

save_mirrors_list_to_file()

Save ICSP mirrors list to a file

update_hcp_binary()

Update hcp binary

update_mirrors_list_to_file()

Update ICSP list to a file

verify_hosted_ocp_cluster_from_provider(name)

Verify HyperShift hosted cluster from provider :param name: hosted OCP cluster name :type name: str

Returns:

True if hosted OCP cluster is verified, False otherwise

Return type:

bool

wait_for_worker_nodes_to_be_ready(name: str, timeout=2400)

Wait for worker nodes to be ready for HyperShift hosted cluster :param name: name of the cluster :type name: str :param timeout: timeout in seconds

Returns:

True if worker nodes are ready, False otherwise

Return type:

bool

wait_hosted_cluster_completed(name: str, timeout=3600)

Wait for HyperShift hosted cluster creation to complete :param name: name of the cluster :param timeout: timeout in seconds

Returns:

True if cluster creation completed, False otherwise

Return type:

bool

worker_nodes_deployed(name: str)

Check if worker nodes are deployed for HyperShift hosted cluster :param name: name of the cluster :type name: str

Returns:

True if worker nodes are deployed, False otherwise

Return type:

bool

ocs_ci.deployment.helpers.hypershift_base.get_binary_hcp_version()

Get hcp version output. Handles hcp 4.16 and 4.17 cmd differences

Returns:

hcp version output

Return type:

str

ocs_ci.deployment.helpers.hypershift_base.get_hosted_cluster_names()

Get HyperShift hosted cluster names :returns: the list of hosted cluster names :rtype: list

ocs_ci.deployment.helpers.hypershift_base.kubeconfig_exists_decorator(func)

Decorator to check if the kubeconfig exists before executing the decorated method :param func: func to decorate; should be used only for methods of class having ‘cluster_kubeconfig’ attribute ! :return: wrapper

ocs_ci.deployment.helpers.icsp_parser module

class ocs_ci.deployment.helpers.icsp_parser.ImageContentItem(apiVersion=None, kind=None, metadata=None, spec=None, **kwargs)

Bases: object

ImageContentItem object to parse the ImageContentSourcePolicy CR in dict format to a file

class ocs_ci.deployment.helpers.icsp_parser.ImageContentMetadata(annotations=None, creationTimestamp=None, generation=None, name=None, resourceVersion=None, uid=None, **kwargs)

Bases: object

ImageContentMetadata object to parse the ImageContentSourcePolicy CR in dict format to a file

class ocs_ci.deployment.helpers.icsp_parser.ImageContentSourcePolicy(apiVersion=None, items=None, kind=None, metadata=None, **kwargs)

Bases: object

ImageContentSourcePolicy object to parse the ImageContentSourcePolicy CR in dict format to a file Main purpose is to use parse_ICSP_json_to_mirrors_file and create a file with mirrors and their sources in format required for the ‘hcp’ or ‘hypershift’ binaries

class ocs_ci.deployment.helpers.icsp_parser.ImageContentSpec(repositoryDigestMirrors, **kwargs)

Bases: object

ImageContentSpec object to parse the ImageContentSourcePolicy CR in dict format to a file

class ocs_ci.deployment.helpers.icsp_parser.RepositoryDigestMirror(mirrors=None, source=None, **kwargs)

Bases: object

RepositoryDigestMirror object to parse the ImageContentSourcePolicy CR in dict format to a file

ocs_ci.deployment.helpers.icsp_parser.parse_ICSP_json_to_mirrors_file(icsp_json_dict, file_path)

Parse the ImageContentSourcePolicy object to a file :param icsp_json_dict: ImageContentSourcePolicy CR in dict format :param file_path: file path to write the mirrors to

ocs_ci.deployment.helpers.icsp_parser.parse_image_content_source_policy(image_content_source_policy)

Parse the image content source policy :param image_content_source_policy: image content source policy

Returns:

ImageContentSourcePolicy object

ocs_ci.deployment.helpers.icsp_parser.write_mirrors_to_file(file_path, mirrors_to_source_list)

Write the mirrors to a file :param file_path: file path to write the mirrors to :param mirrors_to_source_list: mirrors and their sources to write to the file, list of mirrors and their sources

ocs_ci.deployment.helpers.lso_helpers module

This module contains helpers functions needed for LSO ( local storage operator ) deployment.

ocs_ci.deployment.helpers.lso_helpers.add_disk_for_rhv_platform()

Add disk for RHV platform

ocs_ci.deployment.helpers.lso_helpers.add_disk_for_vsphere_platform()

Add RDM/VMDK disk for vSphere platform

ocs_ci.deployment.helpers.lso_helpers.create_optional_operators_catalogsource_non_ga(force=False)

Creating optional operators CatalogSource and ImageContentSourcePolicy for non-ga OCP.

Parameters:

force (bool) – enable/disable lso catalog setup

ocs_ci.deployment.helpers.lso_helpers.get_device_paths(worker_names)

Retrieve a list of the device paths for each worker node

Parameters:

worker_names (list) – worker node names

Returns:

device path ids

Return type:

list

ocs_ci.deployment.helpers.lso_helpers.setup_local_storage(storageclass)

Setup the necessary resources for enabling local storage.

Parameters:

storageclass (string) – storageClassName value to be used in LocalVolume CR based on LOCAL_VOLUME_YAML

ocs_ci.deployment.helpers.lso_helpers.verify_pvs_created(expected_pvs, storageclass, exact_count_pvs=True)

Verify that PVs were created and are in the Available state

Parameters:
  • expected_pvs (int) – number of PVs to verify

  • storageclass (str) – Name of storageclass

  • exact_count_pvs (bool) – True if expected_pvs should match exactly with PVs created, False, if PVs created is more than or equal to expected_pvs

Raises:

AssertionError – if any PVs are not in the Available state or if the number of PVs does not match the given parameter.

ocs_ci.deployment.helpers.mcg_helpers module

This module contains helper functions which is needed for MCG only deployment

ocs_ci.deployment.helpers.mcg_helpers.check_if_mcg_root_secret_public()

Verify if MCG root secret is public

Returns:

False if the secrets are not public and True otherwise

ocs_ci.deployment.helpers.mcg_helpers.mcg_only_deployment()

Creates cluster with MCG only deployment

ocs_ci.deployment.helpers.mcg_helpers.mcg_only_post_deployment_checks()

Verification of MCG only after deployment

ocs_ci.deployment.helpers.odf_deployment_helpers module

This module contains helpers functions needed for ODF deployment.

ocs_ci.deployment.helpers.odf_deployment_helpers.get_required_csvs()

Get the mandatory CSVs needed for the ODF cluster

Returns:

list of CSVs needed

Return type:

list

ocs_ci.deployment.helpers.prechecks module

This module contains the pre-checks needed for deployment. Some of the common pre-checks are memory, CPU and storage. If the minimum requirements are not satisfied in the target environment, there is no need to proceed with deployment. This module is mainly intended for on-prem platforms.

class ocs_ci.deployment.helpers.prechecks.BareMetalPreChecks

Bases: PreChecks

pre-checks for Bare Metal platform (PSI environment)

cpu_check()

CPU checks

get_all_checks()

Aggregate all the checks needed for BM platform

memory_check()

Memory checks

network_check()

Network related checks

storage_check()

Storage checks

class ocs_ci.deployment.helpers.prechecks.PreChecks

Bases: object

A base class for pre-checks. Should be inherited by specific platform classes

cpu_check()
memory_check()
network_check()
storage_check()
class ocs_ci.deployment.helpers.prechecks.VSpherePreChecks

Bases: PreChecks

Pre-checks for vSphere platform

cpu_check()

CPU checks

get_all_checks()

Aggregate all the checks needed for vSphere platform

memory_check()

Memory checks

network_check()

Network related checks

pre_req()

Pre-Requisites for vSphere checks

storage_check()

Checks for storage capacity in the datastore

Raises:

StorageNotSufficientException – In case if there is no sufficient storage in Datastore.

template_check()

Checks whether template exists in Datacenter or not for UPI deployments

Raises:

TemplateNotFound – If template not found in Datacenter.

ocs_ci.deployment.helpers.rosa_prod_cluster_helpers module

This module contains helpers class related to Managed Service ROSA Clusters in production environment

class ocs_ci.deployment.helpers.rosa_prod_cluster_helpers.ROSAProdEnvCluster(cluster)

Bases: object

A helper class for Managed Service ROSA Cluster in Production Environment

cluster_admin_login(skip_tls_verify=False)

Login to production cluster

Parameters:

skip_tls_verify (bool) – True to bypass the certificate check and use insecure connections

Returns:

output of oc login command

Return type:

str

create_admin_and_login()

creates admin account for cluster and login

generate_kubeadmin_password_file(path=None)

creates kubeadmin password file for cluster

Parameters:

path (str) – Path to create kubeadmin password file

generate_kubeconfig_file(path=None, skip_tls_verify=False)

creates kubeconfig file for the cluster

Parameters:
  • path (str) – Path to create kubeconfig file

  • skip_tls_verify (bool) – True to bypass the certificate check and use insecure connections

wait_for_cluster_admin_login_successful()

Waits for the admin to login successfully

Raises:

ROSAProdAdminLoginFailedException – in case of admin failed to log in cluster

ocs_ci.deployment.helpers.vsphere_helpers module

This module contains helpers functions needed for deployment of clusters on vsphere platform.

class ocs_ci.deployment.helpers.vsphere_helpers.VSPHEREHELPERS

Bases: object

Helper class for vSphere

generate_cluster_info()

Generates the cluster information file

generate_config_yaml()

Generate config yaml file

generate_terraform_vars_for_scaleup(rhcos_ips)

Generates the terraform variables file for scaling nodes

get_host_file_for_time_sync()

Fetches the host file for time sync

Returns:

host file

Return type:

str

modify_scaleup_repo()

Modify the scale-up repo. Considering the user experience, removing the access and secret keys and variable from appropriate location in the scale-up repo

Module contents