ocs_ci.ocs.resources package

Submodules

ocs_ci.ocs.resources.backingstore module

class ocs_ci.ocs.resources.backingstore.BackingStore(name, method, type, uls_name=None, secret_name=None, mcg_obj=None, vol_num=None, vol_size=None)

Bases: object

A class that represents BackingStore objects

delete()
ocs_ci.ocs.resources.backingstore.backingstore_factory(request, cld_mgr, mcg_obj, cloud_uls_factory)

Create a Backing Store factory. Calling this fixture creates a new Backing Store(s).

Parameters
  • request (object) – Pytest built-in fixture

  • cld_mgr (CloudManager) – Cloud Manager object containing all connections to clouds

  • mcg_obj (MCG) – MCG object containing data and utils related to MCG

  • cloud_uls_factory – Factory for underlying storage creation

Returns

Factory method - each call to this function creates

a backingstore

Return type

func

ocs_ci.ocs.resources.bucket_policy module

class ocs_ci.ocs.resources.bucket_policy.HttpResponseParser(http_response)

Bases: object

A simple class for parsing HTTP responses

class ocs_ci.ocs.resources.bucket_policy.NoobaaAccount(mcg, name, email, buckets, admin_access=False, s3_access=True, full_bucket_access=True, backingstore_name='noobaa-default-backing-store')

Bases: object

Class for Noobaa account

access_key = None
access_key_id = None
account_name = None
email_id = None
s3_endpoint = None
s3_resource = None
token = None
ocs_ci.ocs.resources.bucket_policy.gen_bucket_policy(user_list, actions_list, resources_list, effect='Allow', sid='statement')

Function prepares bucket policy parameters in syntax and format provided by AWS bucket policy

Parameters
  • user_list (list) – List of user accounts to access bucket policy

  • actions_list (list) – List of actions in bucket policy eg: Get, Put objects etc

  • resources_list (list) – List of resources. Eg: Bucket name, specific object in a bucket etc

  • effect (str) – Permission given to the bucket policy ie: Allow(default) or Deny

  • sid (str) – Statement name. Can be any string. Default: “Statement”

Returns

Bucket policy in json format

Return type

dict

ocs_ci.ocs.resources.bucketclass module

class ocs_ci.ocs.resources.bucketclass.BucketClass(name, backingstores, namespacestores, placement_policy, namespace_policy)

Bases: object

A class that represents BucketClass objects

delete()
ocs_ci.ocs.resources.bucketclass.bucket_class_factory(request, mcg_obj, backingstore_factory, namespace_store_factory)

Create a bucket class factory. Calling this fixture creates a new custom bucket class. For a custom backingstore(s), provide the ‘backingstore_dict’ parameter.

Parameters
  • request (object) – Pytest built-in fixture

  • mcg_obj (MCG) – An MCG object containing the MCG S3 connection credentials

  • backingstore_factory – Factory for backing store creation

ocs_ci.ocs.resources.cache_drop module

class ocs_ci.ocs.resources.cache_drop.OSDCashDrop

Bases: ocs_ci.ocs.ocp.OCP

This module is for deploying pod which enable to drop the OSD’s cache.

Usage:

import OSDCashDrop

cd = OSDCashDrop() # create new cache_drop object cd.deploy() # deploy the cache_drop pod …. # run test cd.drop_cache() # drop the OSD’s cache …. # run the test again cd.cleanup() # delete the cache_drop pod

cleanup()

Delete the pod from the cluster

deploy()

Deploy the cache drop pod and wait until it is up

drop_cache()

Drop the OSD’s cache by sending http request to the pod

Raises

exception – if the request to drop the cache failed

property ip

return the cache drop IP

ocs_ci.ocs.resources.catalog_source module

CatalogSource related functionalities

class ocs_ci.ocs.resources.catalog_source.CatalogSource(resource_name='', namespace=None, *args, **kwargs)

Bases: ocs_ci.ocs.ocp.OCP

This class represent CatalogSource and contains all related methods we need to do with it.

check_state(state)

Check state of catalog source

Parameters

state (str) – State of CatalogSource object

Returns

True if state of object is the same as desired one, False

otherwise.

Return type

bool

get_image_name()

Fetch image name from catalog source resource

Returns

especially version info extracted from image

name

Return type

image info (str)

get_image_url()

Fetch image url from catalog source resource

Returns

URL of image

Return type

image url (str)

wait_for_state(state, timeout=480, sleep=5)

Wait till state of catalog source resource is the same as required one passed in the state parameter.

Parameters
  • state (str) – Desired state of catalog source object

  • timeout (int) – Timeout in seconds to wait for desired state

  • sleep (int) – Time in seconds to sleep between attempts

Raises

ResourceWrongStatusException – In case the catalog source is not in expected state.

ocs_ci.ocs.resources.cloud_manager module

class ocs_ci.ocs.resources.cloud_manager.AzureClient(account_name=None, credential=None, auth_dict=None, *args, **kwargs)

Bases: ocs_ci.ocs.resources.cloud_manager.CloudClient

Implementation of a Azure Client using the Azure API

create_azure_secret()

Create a Kubernetes secret to allow NooBaa to create Azure-based backingstores

get_all_uls_names()

Returns a set containing all the container names that the client has access to

internal_create_uls(name, region)

Creates the Underlying Storage using the Azure API

Parameters

name (str) – The Underlying Storage name to be created

internal_delete_uls(name)

Deletes the Underlying Storage using the Azure API

Parameters

name (str) – The Underlying Storage name to be deleted

verify_uls_exists(uls_name)

Verifies whether a Underlying Storage with the given uls_name exists

Parameters

uls_name (str) – The Underlying Storage name to be verified

Returns

True if Underlying Storage exists, False otherwise

Return type

bool

class ocs_ci.ocs.resources.cloud_manager.CloudClient(*args, **kwargs)

Bases: abc.ABC

Base abstract class for Cloud based API calls

client = None
create_uls(name, region)

Super method that first logs the Underlying Storage creation and then calls the appropriate implementation

delete_uls(name)

Super method that first logs the Underlying Storage deletion and then calls the appropriate implementation

get_all_uls_names()
abstract internal_create_uls(name, region)
abstract internal_delete_uls(name)
verify_uls_exists(uls_name)
verify_uls_state(uls_name, is_available)
class ocs_ci.ocs.resources.cloud_manager.CloudManager

Bases: abc.ABC

Class containing all client types

class ocs_ci.ocs.resources.cloud_manager.GoogleClient(auth_dict, *args, **kwargs)

Bases: ocs_ci.ocs.resources.cloud_manager.CloudClient

Implementation of a Google Client using the Google API

create_gcp_secret()

Create a Kubernetes secret to allow NooBaa to create Google-based backingstores

get_all_uls_names()

Returns a set containing all the bucket names that the client has access to

internal_create_uls(name, region=None)

Creates the Underlying Storage using the Google API

Parameters
  • name (str) – The Underlying Storage name to be created

  • region (str) – The region to create the Underlying Storage

internal_delete_uls(name)

Deletes the Underlying Storage using the Google API

Parameters

name (str) – The Underlying Storage name to be deleted

verify_uls_exists(uls_name)

Verifies whether a Underlying Storage with the given uls_name exists

Parameters

uls_name (str) – The Underlying Storage name to be verified

Returns

True if Underlying Storage exists, False otherwise

Return type

bool

class ocs_ci.ocs.resources.cloud_manager.S3Client(auth_dict, verify=True, endpoint='https://s3.amazonaws.com', *args, **kwargs)

Bases: ocs_ci.ocs.resources.cloud_manager.CloudClient

Implementation of a S3 Client using the S3 API

create_s3_secret(secret_prefix, data_prefix)

Create a Kubernetes secret to allow NooBaa to create AWS-based backingstores

get_all_uls_names()

Returns a set containing all the bucket names that the client has access to

internal_create_uls(name, region=None)

Creates the Underlying Storage using the S3 API

Parameters
  • name (str) – The Underlying Storage name to be created

  • region (str) – The region to create the Underlying Storage,

  • none will be created on us-east-1 (if) –

  • **IMPORTANT**

  • us-east-1 as the region will cause an error if used since it is (Passing) –

  • default region for AWS (the) –

internal_delete_uls(name)

Deletes the Underlying Storage using the S3 API

Parameters

name (str) – The Underlying Storage name to be deleted

toggle_aws_bucket_readwrite(aws_bucket_name, block=True)

Toggles a bucket’s IO using a bucket policy

Parameters
  • aws_bucket_name – The name of the bucket that should be manipulated

  • block – Whether to block RW or un-block. True | False

verify_uls_exists(uls_name)

Verifies whether a Underlying Storage with the given uls_name exists

Parameters

uls_name (str) – The Underlying Storage name to be verified

Returns

True if Underlying Storage exists, False otherwise

Return type

bool

ocs_ci.ocs.resources.cloud_uls module

ocs_ci.ocs.resources.cloud_uls.cloud_uls_factory(request, cld_mgr)

Create an Underlying Storage factory. Calling this fixture creates a new underlying storage(s).

Parameters
  • request (object) – Pytest built-in fixture

  • cld_mgr (CloudManager) – Cloud Manager object containing all connections to clouds

Returns

Factory method - each call to this function creates

an Underlying Storage factory

Return type

func

ocs_ci.ocs.resources.csv module

CSV related functionalities

class ocs_ci.ocs.resources.csv.CSV(resource_name='', *args, **kwargs)

Bases: ocs_ci.ocs.ocp.OCP

This class represent ClusterServiceVersion (CSV) and contains all related methods we need to do with CSV.

ocs_ci.ocs.resources.csv.get_csvs_start_with_prefix(csv_prefix, namespace)

Get CSVs start with prefix

Parameters
  • csv_prefix (str) – prefix from name

  • namespace (str) – namespace of CSV

Returns

found CSVs

Return type

list

ocs_ci.ocs.resources.fips module

ocs_ci.ocs.resources.fips.check_fips_enabled(fips_location='/proc/sys/crypto/fips_enabled')

Checks if FIPS is activated on all pods

Args:
fips_location: File that refers to fips, written 1 if enabled,

0 otherwise

Raises:
FipsNotInstalledException:
If the value of fips location file does not include 1

in all pods within the given namespace.

ocs_ci.ocs.resources.install_plan module

Install plan related functionalities

class ocs_ci.ocs.resources.install_plan.InstallPlan(resource_name='', namespace=None, *args, **kwargs)

Bases: ocs_ci.ocs.ocp.OCP

This class represent InstallPlan and contains all the related functionality.

approve()

Approve install plan.

ocs_ci.ocs.resources.install_plan.get_install_plans_for_approve(namespace, raise_exception=False)

Get all install plans for approve

Parameters
  • namespace (str) – namespace of CSV

  • raise_exception (bool) – True if the function should raise the exception when no install plan found for approve.

Returns

found install plans for approve

Return type

list

Raises

NoInstallPlanForApproveFoundException – in case raise_exception is True and no install plan for approve found.

ocs_ci.ocs.resources.install_plan.wait_for_install_plan_and_approve(namespace, timeout=960)

Wait for install plans ready for approve and approve them.

Parameters
  • namespace (str) – namespace of install plan.

  • timeout (int) – timeout in seconds.

Raises

TimeoutExpiredError – in case no install plan found in specified timeout.

ocs_ci.ocs.resources.mcg module

class ocs_ci.ocs.resources.mcg.MCG(*args, **kwargs)

Bases: object

Wrapper class for the Multi Cloud Gateway’s S3 service

access_key = None
access_key_id = None
check_backingstore_state(backingstore_name, desired_state, timeout=600)

Checks whether the backing store reached a specific state :param backingstore_name: Name of the backing store to be checked :type backingstore_name: str :param desired_state: The desired state of the backing store :type desired_state: str :param timeout: Number of seconds for timeout which will be used :type timeout: int :param in the checks used in this function.:

Returns

Whether the backing store has reached the desired state

Return type

bool

check_data_reduction(bucketname, expected_reduction_in_bytes)

Checks whether the data reduction on the MCG server works properly :param bucketname: An example bucket name that contains compressed/deduped data :param expected_reduction_in_bytes: amount of data that is supposed to be reduced after data :param compression and deduplication.:

Returns

True if the data reduction mechanics work, False otherwise

Return type

bool

check_if_mirroring_is_done(bucket_name, timeout=140)

Check whether all object chunks in a bucket are mirrored across all backing stores.

Parameters
  • bucket_name – The name of the bucket that should be checked

  • timeout – timeout in seconds to check if mirroring

Returns

Whether mirroring finished successfully

Return type

bool

check_ns_resource_validity(ns_resource_name, target_bucket_name, endpoint)

Check namespace resource validity

Parameters
  • ns_resource_name (str) – The name of the to be verified namespace resource

  • target_bucket_name (str) – The name of the expected target bucket (uls)

  • endpoint – The expected endpoint path

cli_create_bucketclass(name, backingstores, placement=None, namespace_policy=None)

Creates a new NooBaa bucket class using the noobaa cli :param name: The name to be given to the bucket class :type name: str :param backingstores: The backing stores to use as part of the policy :type backingstores: list :param placement: The placement policy to be used - Mirror | Spread :type placement: str :param namespace_policy: The namespace policy to be used :type namespace_policy: dict

Returns

The bucket class resource

Return type

OCS

cli_get_all_bucket_names()
Returns

A set of all bucket names

Return type

set

cli_verify_bucket_exists(bucketname)

Verifies whether a bucket with the given bucketname exists :param bucketname: The bucket name to be verified

Returns

True if bucket exists, False otherwise

Return type

bool

create_connection(cld_mgr, platform, conn_name=None)

Creates a new NooBaa connection to an AWS backend

Parameters
  • cld_mgr (obj) – A cloud manager instance

  • platform (str) – Platform to use for new connection

  • conn_name (str) – The connection name to be used If None provided then the name will be generated

Returns

False if the connection creation failed

Return type

bool

create_namespace_resource(ns_resource_name, conn_name, region, cld_mgr, cloud_uls_factory, platform)

Creates a new namespace resource

Parameters
  • ns_resource_name (str) – The name to be given to the new namespace resource

  • conn_name (str) – The external connection name to be used

  • region (str) – The region name to be used

  • cld_mgr – A cloud manager instance

  • cloud_uls_factory – The cloud uls factory

  • platform (str) – The platform resource name

Returns

The name of the created target_bucket_name (cloud uls)

Return type

str

create_namespace_store(nss_name, region, cld_mgr, cloud_uls_factory, platform)

Creates a new namespace store

Parameters
  • nss_name (str) – The name to be given to the new namespace store

  • region (str) – The region name to be used

  • cld_mgr – A cloud manager instance

  • cloud_uls_factory – The cloud uls factory

  • platform (str) – The platform resource name

Returns

The name of the created target_bucket_name (cloud uls)

Return type

str

delete_ns_connection(ns_connection_name)

Delete external connection

Parameters

ns_connection_name (str) – The name of the to be deleted external connection

delete_ns_resource(ns_resource_name)

Delete namespace resource

Parameters

ns_resource_name (str) – The name of the to be deleted namespace resource

exec_mcg_cmd(cmd, namespace=None, **kwargs)

Executes an MCG CLI command through the noobaa-operator pod’s CLI binary

Parameters
  • cmd (str) – The command to run

  • namespace (str) – The namespace to run the command in

Returns

stdout of the command

Return type

str

get_bucket_info(bucket_name)
Parameters

bucket_name (str) – Name of searched bucket

Returns

Information about the bucket

Return type

dict

mgmt_endpoint = None
namespace = None
noobaa_password = None
noobaa_token = None
noobaa_user = None
oc_create_bucketclass(name, backingstores, placement, namespace_policy)

Creates a new NooBaa bucket class using a template YAML :param name: The name to be given to the bucket class :type name: str :param backingstores: The backing stores to use as part of the policy :type backingstores: list :param placement: The placement policy to be used - Mirror | Spread :type placement: str :param namespace_policy: The namespace policy to be used :type namespace_policy: dict

Returns

The bucket class resource

Return type

OCS

oc_verify_bucket_exists(bucketname)

Verifies whether a bucket with the given bucketname exists :param bucketname: The bucket name to be verified

Returns

True if bucket exists, False otherwise

Return type

bool

ocp_resource = None
read_system()
Returns

A dictionary with information about MCG resources

Return type

dict

region = None
request_aws_credentials()

Uses a CredentialsRequest CR to create an AWS IAM that allows the program to interact with S3

Returns

The CredentialsRequest resource

Return type

OCS

retrieve_nb_token()

Try to retrieve a NB RPC token and decode its JSON

retrieve_noobaa_cli_binary()

Copy the NooBaa CLI binary from the operator pod if it wasn’t found locally, or if the hashes between the two don’t match.

s3_endpoint = None
s3_get_all_bucket_names()
Returns

A set of all bucket names

Return type

set

s3_get_all_buckets()
Returns

A list of all s3.Bucket objects

Return type

list

s3_internal_endpoint = None
s3_list_all_objects_in_bucket(bucketname)
Returns

A list of all bucket objects

Return type

list

s3_resource = None
s3_verify_bucket_exists(bucketname)

Verifies whether a bucket with the given bucketname exists :param bucketname: The bucket name to be verified

Returns

True if bucket exists, False otherwise

Return type

bool

send_rpc_query(api, method, params=None)

Templates and sends an RPC query to the MCG mgmt endpoint

Parameters
  • api – The name of the API to use

  • method – The method to use inside the API

  • params – A dictionary containing the command payload

Returns

The server’s response

property status

Verify the status of NooBaa, and its default backing store and bucket class

Returns

return False if any of the above components of noobaa is not in READY state

Return type

bool

ocs_ci.ocs.resources.namespacestore module

class ocs_ci.ocs.resources.namespacestore.NamespaceStore(name, method, uls_name=None, secret_name=None, mcg_obj=None)

Bases: object

A class that represents NamespaceStore objects

cli_verify_health()

Verify the health of the namespace store by running the noobaa namespacestore status command

Returns

Based on whether the namespace store is healthy or not

Return type

bool

delete()

Deletes the current namespacestore by using OC/CLI commands

oc_verify_health()

Verify the health of the namespace store by checking the status of the CR

Returns

Based on whether the namespace store is healthy or not

Return type

bool

verify_health(timeout=60, interval=5)

Health verification function that tries to verify a namespacestores’s health until a given time limit is reached

Parameters
  • timeout (int) – Timeout for the check, in seconds

  • interval (int) – Interval to wait between checks, in seconds

Returns

True if the bucket is healthy, False otherwise

Return type

(bool)

ocs_ci.ocs.resources.namespacestore.namespace_store_factory(request, cld_mgr, mcg_obj, cloud_uls_factory)

Create a Backing Store factory. Calling this fixture lets the user create namespace stores.

Parameters
  • request (object) – Pytest built-in fixture

  • cld_mgr (CloudManager) – Cloud Manager object containing all connections to clouds

  • mcg_obj (MCG) – MCG object containing data and utils related to MCG

  • cloud_uls_factory – Factory for creation of underlying storage

Returns

Factory method - allows the user to create namespace stores

Return type

func

ocs_ci.ocs.resources.objectbucket module

class ocs_ci.ocs.resources.objectbucket.MCGCLIBucket(*args, **kwargs)

Bases: ocs_ci.ocs.resources.objectbucket.ObjectBucket

Implementation of an MCG bucket using the NooBaa CLI

internal_delete()

Deletes the bucket using the NooBaa CLI

property internal_status

Returns the OBC status as printed by the NB CLI

Returns

OBC status

Return type

str

internal_verify_deletion()

Abstract deletion verification method

internal_verify_health()

Verifies that the bucket is healthy using the CLI

Returns

True if the bucket is healthy, False otherwise

Return type

bool

class ocs_ci.ocs.resources.objectbucket.MCGNamespaceBucket(*args, **kwargs)

Bases: ocs_ci.ocs.resources.objectbucket.ObjectBucket

Implementation of an MCG bucket using the S3 API

internal_delete()

Deletes the bucket using the S3 API

property internal_status

Returns the OBC mode as shown in the NB UI and retrieved via RPC

Returns

The bucket’s mode

Return type

str

internal_verify_deletion()

Abstract deletion verification method

internal_verify_health()

Verifies that the bucket is healthy by checking its mode

Returns

True if the bucket is healthy, False otherwise

Return type

bool

class ocs_ci.ocs.resources.objectbucket.MCGOCBucket(*args, **kwargs)

Bases: ocs_ci.ocs.resources.objectbucket.OCBucket

Implementation of an MCG bucket using the OC CLI

class ocs_ci.ocs.resources.objectbucket.MCGS3Bucket(*args, **kwargs)

Bases: ocs_ci.ocs.resources.objectbucket.ObjectBucket

Implementation of an MCG bucket using the S3 API

internal_delete()

Deletes the bucket using the S3 API

property internal_status

Returns the OBC mode as shown in the NB UI and retrieved via RPC

Returns

The bucket’s mode

Return type

str

internal_verify_deletion()

Abstract deletion verification method

internal_verify_health()

Verifies that the bucket is healthy by checking its mode

Returns

True if the bucket is healthy, False otherwise

Return type

bool

class ocs_ci.ocs.resources.objectbucket.OBC(obc_name)

Bases: object

Wrapper class for Object Bucket Claim credentials

access_key = None
access_key_id = None
bucket_name = None
namespace = None
ob_name = None
obc_account = None
obc_name = None
s3_endpoint = None
s3_resource = None
class ocs_ci.ocs.resources.objectbucket.OCBucket(*args, **kwargs)

Bases: ocs_ci.ocs.resources.objectbucket.ObjectBucket

internal_delete(verify=True)

Deletes the bucket using the OC CLI

property internal_status

Returns the OBC’s phase

Returns

OBC phase

Return type

str

internal_verify_deletion()

Abstract deletion verification method

internal_verify_health()

Verifies that the bucket is healthy by checking its phase

Returns

True if the bucket is healthy, False otherwise

Return type

bool

class ocs_ci.ocs.resources.objectbucket.ObjectBucket(name, mcg=None, rgw=None, bucketclass=None, *args, **kwargs)

Bases: abc.ABC

Base abstract class for MCG buckets

delete(verify=True)

Super method that first logs the bucket deletion and then calls the appropriate implementation

abstract internal_delete()

Abstract internal deletion method

abstract internal_status()

Abstract status method

abstract internal_verify_deletion()

Abstract deletion verification method

abstract internal_verify_health()

Abstract health verification method

mcg = None
name = None
property status

A method that first logs the bucket’s status and then calls the appropriate implementation

verify_deletion(timeout=60, interval=5)

Super method used for logging the deletion verification process and then calls the appropriate implementatation

verify_health(timeout=60, interval=5)

Health verification function that tries to verify the a bucket’s health by using its appropriate internal_verify_health function until a given time limit is reached

Parameters
  • timeout (int) – Timeout for the check, in seconds

  • interval (int) – Interval to wait between checks, in seconds

class ocs_ci.ocs.resources.objectbucket.RGWOCBucket(*args, **kwargs)

Bases: ocs_ci.ocs.resources.objectbucket.OCBucket

Implementation of an RGW bucket using the S3 API

ocs_ci.ocs.resources.objectconfigfile module

Representation of general Kubernetes/OpenShift objects config file.

This allows one to work with multiple objects of different kind at once, as explained in Imperative Management of Kubernetes Objects Using Configuration Files.

Usage:

First you prepare list of dictionaries of k8s objects such as Deployment or PVC which describes your workload/project to be deployed in OCP. Then create instance of ObjectConfFile class with the list to be able to create the resource in the cluster (to run it), or delete it later when it’s no longer needed.

class ocs_ci.ocs.resources.objectconfigfile.ObjectConfFile(name, obj_dict_list, project, tmp_path)

Bases: object

This class represents particular k8s object config file which describes multiple k8s resources.

Methods of this class implements Imperative Management of Kubernetes Objects Using Configuration Files.

create(namespace=None)

Run oc create on in this object file.

Parameters
  • namespace (str) – Name of the namespace where to deploy, overriding

  • value (in a similar way how you can specify (self.project.namespace) –

  • value to -n option of oc create. (any) –

delete(namespace=None)

Run oc delete on in this object file.

Parameters
  • namespace (str) – Name of the namespace where to deploy, overriding

  • value (in a similar way how you can specify (self.project.namespace) –

  • value to -n option of oc delete. (any) –

get(namespace=None)

Run oc get on in this object file.

Parameters
  • namespace (str) – Name of the namespace where to deploy, overriding

  • value (in a similar way how you can specify (self.project.namespace) –

  • value to -n option of oc get. (any) –

ocs_ci.ocs.resources.ocs module

General OCS object

class ocs_ci.ocs.resources.ocs.OCS(**kwargs)

Bases: object

Base OCSClass

add_label(label)

Addss a new label

Parameters

label (str) – New label to be assigned for this pod E.g: “label=app=’rook-ceph-mds’”

property api_version
apply(**data)
create(do_reload=True)
delete(wait=True, force=False)

Delete the OCS object if its not already deleted (using the internal is_deleted flag)

Parameters
  • wait (bool) – Wait for object to be deleted

  • force (bool) – Force delete object

Returns

True if deleted, False otherwise

Return type

bool

delete_temp_yaml_file()
describe()
get(out_yaml_format=True)
property is_deleted
property kind
property name
property namespace
reload()

Reloading the OCS instance with the new information from its actual data. After creating a resource from a yaml file, the actual yaml file is being changed and more information about the resource is added.

status()
ocs_ci.ocs.resources.ocs.check_if_cluster_was_upgraded()

Check whether the OCS cluster went through upgrade

Returns

True if the OCS cluster went through upgrade, False otherwise

Return type

bool

ocs_ci.ocs.resources.ocs.get_job_obj(name, namespace='openshift-storage')

Get the job instance for the given job name

Parameters
  • name (str) – The name of the job

  • namespace (str) – The namespace to look in

Returns

A job OCS instance

Return type

OCS

ocs_ci.ocs.resources.ocs.get_ocs_csv()

Get the OCS CSV object

Returns

OCS CSV object

Return type

CSV

Raises

CSVNotFound – In case no CSV found.

ocs_ci.ocs.resources.ocs.get_version_info(namespace=None)

ocs_ci.ocs.resources.packagemanifest module

Package manifest related functionalities

class ocs_ci.ocs.resources.packagemanifest.PackageManifest(resource_name='', namespace='openshift-marketplace', install_plan_namespace=None, subscription_plan_approval='Automatic', **kwargs)

Bases: ocs_ci.ocs.ocp.OCP

This class represent PackageManifest and contains all related methods.

get(**kwargs)

Overloaded get method from OCP class.

Raises

ResourceNotFoundError – In case the selector and resource_name specified and no such resource found.

get_channels()

Returns channels for package manifest

Returns

available channels for package manifest

Return type

list

Raises

ResourceNameNotSpecifiedException – in case the name is not specified.

get_current_csv(channel=None, csv_pattern='ocs-operator')

Returns current csv for default or specified channel

Parameters
  • channel (str) – Channel of the CSV

  • csv_pattern (str) – CSV name pattern - needed for manual subscription plan

Returns

Current CSV name

Return type

str

Raises
get_default_channel()

Returns default channel for package manifest

Returns

default channel name

Return type

str

Raises

ResourceNameNotSpecifiedException – in case the name is not specified.

get_installed_csv_from_install_plans(pattern)

Get currently installed CSV out latest approved install plans.

Parameters

patter (str) – pattern of CSV name to look for.

Raises
wait_for_resource(resource_name='', timeout=60, sleep=3, label=None, selector=None)

Wait for a packagemanifest exists.

Parameters
  • resource_name (str) – The name of the resource to wait for. If not specified the self.resource_name will be used. At least on of those has to be set!

  • timeout (int) – Time in seconds to wait

  • sleep (int) – Sampling time in seconds

  • selector (str) – The resource selector to search with.

Raises
ocs_ci.ocs.resources.packagemanifest.get_selector_for_ocs_operator()

This is the helper function which returns selector for package manifest. It’s needed because of conflict with live content and multiple package manifests with the ocs-operator name. In case we are using internal builds we label catalog source or operator source and using the same selector for package manifest.

Returns

Selector for package manifest if we are on internal

builds, otherwise it returns None

Return type

str

ocs_ci.ocs.resources.pod module

Pod related functionalities and context info

Each pod in the openshift cluster will have a corresponding pod object

class ocs_ci.ocs.resources.pod.Pod(**kwargs)

Bases: ocs_ci.ocs.resources.ocs.OCS

Handles per pod related context

add_role(role)

Adds a new role for this pod

Parameters

role (str) – New role to be assigned for this pod

copy_to_server(server, authkey, localpath, remotepath, user=None)

Upload a file from pod to server

Parameters
  • server (str) – Name of the server to upload

  • authkey (str) – Authentication file (.pem file)

  • localpath (str) – Local file/dir in pod to upload

  • remotepath (str) – Target path on the remote server

  • user (str) – User name to connect to server

exec_ceph_cmd(ceph_cmd, format='json-pretty')

Execute a Ceph command on the Ceph tools pod

Parameters
  • ceph_cmd (str) – The Ceph command to execute on the Ceph tools pod

  • format (str) – The returning output format of the Ceph command

Returns

Ceph command output

Return type

dict

Raises

CommandFailed – In case the pod is not a toolbox pod

exec_cmd_on_node(server, authkey, cmd, user=None)

Run command on a remote server from pod

Parameters
  • server (str) – Name of the server to run the command

  • authkey (str) – Authentication file (.pem file)

  • cmd (str) – command to run on server from pod

  • user (str) – User name to connect to server

exec_cmd_on_pod(command, out_yaml_format=True, secrets=None, timeout=600, **kwargs)

Execute a command on a pod (e.g. oc rsh)

Parameters
  • command (str) – The command to execute on the given pod

  • out_yaml_format (bool) – whether to return yaml loaded python object OR to return raw output

  • secrets (list) – A list of secrets to be masked with asterisks This kwarg is popped in order to not interfere with subprocess.run(**kwargs)

  • timeout (int) – timeout for the exec_oc_cmd, defaults to 600 seconds

Returns

This object represents a returned yaml file

Return type

Munch Obj

exec_s3_cmd_on_pod(command, mcg_obj=None)

Execute an S3 command on a pod

Parameters
  • mcg_obj (MCG) – An MCG object containing the MCG S3 connection credentials

  • command (str) – The command to execute on the given pod

Returns

This object represents a returned yaml file

Return type

Munch Obj

exec_sh_cmd_on_pod(command, sh='bash')

Execute a pure bash command on a pod via oc exec where you can use bash syntaxt like &&, ||, ;, for loop and so on.

Parameters

command (str) – The command to execute on the given pod

Returns

stdout of the command

Return type

str

fillup_fs(size, fio_filename=None)

Execute FIO on a pod to fillup a file This will run sequantial IO of 1MB block size to fill up the fill with data This operation will run in background and will store the results in ‘self.thread.result()’. In order to wait for the output and not continue with the test until FIO is done, call self.thread.result() right after calling run_io. See tests/manage/test_pvc_deletion_during_io.py::test_run_io for usage of FIO

Parameters
  • size (str) – Size in MB, e.g. ‘200M’

  • fio_filename (str) – Name of fio file created on app pod’s mount point

get_fio_results(timeout=600)

Get FIO execution results

Returns

Dictionary represents the FIO execution results

Return type

dict

Raises

Exception – In case of exception from FIO

get_labels()

Get labels from pod

Raises

NotFoundError – If resource not found

Returns

All the openshift labels on a given pod

Return type

dict

get_memory(container_name)

Get the pod memory size

Parameters

container_name (str) – The name of the container to look for

Returns

The container memory size (e.g. ‘5Gi’)

Return type

str

get_node()

Gets the node name

Returns

Node name

Return type

str

get_storage_path(storage_type='fs')

Get the pod volume mount path or device path

Returns

The mount path of the volume on the pod (e.g. /var/lib/www/html/) if storage_type is fs

else device path of raw block pv

Return type

str

install_packages(packages)

Install packages in a Pod

Parameters

packages (list) – List of packages to install

property labels
property name
property namespace
property restart_count
property roles
run_git_clone(skip_install=True)

Execute git clone on a pod to simulate a Jenkins user

Parameters

skip_install (bool) – By default True, skips git package installation in pod

run_io(storage_type, size, io_direction='rw', rw_ratio=75, jobs=1, runtime=60, depth=4, rate='1m', rate_process='poisson', fio_filename=None, bs='4K', end_fsync=0)

Execute FIO on a pod This operation will run in background and will store the results in ‘self.thread.result()’. In order to wait for the output and not continue with the test until FIO is done, call self.thread.result() right after calling run_io. See tests/manage/test_pvc_deletion_during_io.py::test_run_io for usage of FIO

Parameters
  • storage_type (str) – ‘fs’ or ‘block’

  • size (str) – Size in MB, e.g. ‘200M’

  • io_direction (str) – Determines the operation: ‘ro’, ‘wo’, ‘rw’ (default: ‘rw’)

  • rw_ratio (int) – Determines the reads and writes using a <rw_ratio>%/100-<rw_ratio>% (e.g. the default is 75 which means it is 75%/25% which equivalent to 3 reads are performed for every 1 write)

  • jobs (int) – Number of jobs to execute FIO

  • runtime (int) – Number of seconds IO should run for

  • depth (int) – IO depth

  • rate (str) – rate of IO default 1m, e.g. 16k

  • rate_process (str) – kind of rate process default poisson, e.g. poisson

  • fio_filename (str) – Name of fio file created on app pod’s mount point

  • bs (str) – Block size, e.g. 4K

  • end_fsync (int) – If 1, fio will sync file contents when a write stage has completed. Fio default is 0

workload_setup(storage_type, jobs=1)

Do setup on pod for running FIO

Parameters
  • storage_type (str) – ‘fs’ or ‘block’

  • jobs (int) – Number of jobs to execute FIO

ocs_ci.ocs.resources.pod.cal_md5sum(pod_obj, file_name, block=False)

Calculates the md5sum of the file

Parameters
  • pod_obj (Pod) – The object of the pod

  • file_name (str) – The name of the file for which md5sum to be calculated

  • block (bool) – True if the volume mode of PVC used on pod is ‘Block’. file_name will be the devicePath in this case.

Returns

The md5sum of the file

Return type

str

ocs_ci.ocs.resources.pod.check_file_existence(pod_obj, file_path)

Check if file exists inside the pod

Parameters
  • pod_obj (Pod) – The object of the pod

  • file_path (str) – The full path of the file to look for inside the pod

Returns

True if the file exist, False otherwise

Return type

bool

ocs_ci.ocs.resources.pod.check_pods_after_node_replacement()

Check the pods status after the node replacement process.

Returns

True if all the pods are running after a specific time. False otherwise.

Return type

bool

ocs_ci.ocs.resources.pod.check_pods_in_running_state(namespace='openshift-storage')

checks whether all the pods in a given namespace are in Running state or not

Returns

True, if all pods in Running state. False, otherwise

Return type

Boolean

ocs_ci.ocs.resources.pod.check_toleration_on_pods(toleration_key='node.ocs.openshift.io/storage')

Function to check toleration on pods

Parameters

toleration_key (str) – The toleration key to check

ocs_ci.ocs.resources.pod.delete_deploymentconfig_pods(pod_obj)

Delete a DeploymentConfig pod and all the pods that are controlled by it

Parameters

pod_obj (Pod) – Pod object

ocs_ci.ocs.resources.pod.delete_osd_removal_job(osd_id)

Delete the ocs-osd-removal job.

Parameters

osd_id (str) – The osd id

Returns

True, if the ocs-osd-removal job deleted successfully. False, otherwise

Return type

bool

ocs_ci.ocs.resources.pod.delete_pods(pod_objs, wait=True)

Deletes list of the pod objects

Parameters
  • pod_objs (list) – List of the pod objects to be deleted

  • wait (bool) – Determines if the delete command should wait for completion

ocs_ci.ocs.resources.pod.download_file_from_pod(pod_name, remotepath, localpath, namespace=None)

Download a file from a pod

Parameters
  • pod_name (str) – Name of the pod

  • remotepath (str) – Target path on the pod

  • localpath (str) – Local file to upload

  • namespace (str) – The namespace of the pod

ocs_ci.ocs.resources.pod.get_admin_key_from_ceph_tools()

Fetches admin key secret from ceph :returns: admin keyring encoded with base64 as a string

ocs_ci.ocs.resources.pod.get_all_pods(namespace=None, selector=None, selector_label='app', exclude_selector=False, wait=False)

Get all pods in a namespace.

Parameters
  • namespace (str) – Name of the namespace If namespace is None - get all pods

  • selector (list) – List of the resource selector to search with. Example: [‘alertmanager’,’prometheus’]

  • selector_label (str) – Label of selector (default: app).

  • exclude_selector (bool) – If list of the resource selector not to search with

Returns

List of Pod objects

Return type

list

ocs_ci.ocs.resources.pod.get_ceph_tools_pod()

Get the Ceph tools pod

Returns

The Ceph tools pod object

Return type

Pod object

ocs_ci.ocs.resources.pod.get_cephfsplugin_provisioner_pods(cephfsplugin_provisioner_label='app=csi-cephfsplugin-provisioner', namespace=None)

Fetches info about CSI Cephfs plugin provisioner pods in the cluster

Parameters
  • cephfsplugin_provisioner_label (str) – label associated with cephfs provisioner pods (default: defaults.CSI_CEPHFSPLUGIN_PROVISIONER_LABEL)

  • namespace (str) – Namespace in which ceph cluster lives (default: defaults.ROOK_CLUSTER_NAMESPACE)

Returns

csi-cephfsplugin-provisioner Pod objects

Return type

list

ocs_ci.ocs.resources.pod.get_csi_provisioner_pod(interface)

Get the provisioner pod based on interface :returns: The provisioner pod object based on iterface :rtype: Pod object

ocs_ci.ocs.resources.pod.get_csi_snapshoter_pod()

Get the csi snapshot controller pod

Returns

csi snapshot controller pod

Return type

Pod object

ocs_ci.ocs.resources.pod.get_deployment_name(pod_name)

Get the deployment of the pod.

Parameters

pod_name (str) – The pod’s name.

Returns

The deployment of the specific pod name

ocs_ci.ocs.resources.pod.get_deployments_having_label(label, namespace)

Fetches deployment resources with given label in given namespace

Parameters
  • label (str) – label which deployments might have

  • namespace (str) – Namespace in which to be looked up

Returns

deployment OCP instances

Return type

list

ocs_ci.ocs.resources.pod.get_file_path(pod_obj, file_name)

Get the full path of the file

Parameters
  • pod_obj (Pod) – The object of the pod

  • file_name (str) – The name of the file for which path to get

Returns

The full path of the file

Return type

str

ocs_ci.ocs.resources.pod.get_fio_rw_iops(pod_obj)

Execute FIO on a pod

Parameters

pod_obj (Pod) – The object of the pod

ocs_ci.ocs.resources.pod.get_mds_pods(mds_label='app=rook-ceph-mds', namespace=None)

Fetches info about mds pods in the cluster

Parameters
  • mds_label (str) – label associated with mds pods (default: defaults.MDS_APP_LABEL)

  • namespace (str) – Namespace in which ceph cluster lives (default: defaults.ROOK_CLUSTER_NAMESPACE)

Returns

of mds pod objects

Return type

list

ocs_ci.ocs.resources.pod.get_mgr_pods(mgr_label='app=rook-ceph-mgr', namespace=None)

Fetches info about mgr pods in the cluster

Parameters
  • mgr_label (str) – label associated with mgr pods (default: defaults.MGR_APP_LABEL)

  • namespace (str) – Namespace in which ceph cluster lives (default: defaults.ROOK_CLUSTER_NAMESPACE)

Returns

of mgr pod objects

Return type

list

ocs_ci.ocs.resources.pod.get_mon_pods(mon_label='app=rook-ceph-mon', namespace=None)

Fetches info about mon pods in the cluster

Parameters
  • mon_label (str) – label associated with mon pods (default: defaults.MON_APP_LABEL)

  • namespace (str) – Namespace in which ceph cluster lives (default: defaults.ROOK_CLUSTER_NAMESPACE)

Returns

of mon pod objects

Return type

list

ocs_ci.ocs.resources.pod.get_noobaa_pods(noobaa_label='app=noobaa', namespace=None)

Fetches info about noobaa pods in the cluster

Parameters
  • noobaa_label (str) – label associated with osd pods (default: defaults.NOOBAA_APP_LABEL)

  • namespace (str) – Namespace in which ceph cluster lives (default: defaults.ROOK_CLUSTER_NAMESPACE)

Returns

of noobaa pod objects

Return type

list

ocs_ci.ocs.resources.pod.get_ocs_operator_pod(ocs_label='name=ocs-operator', namespace=None)

Fetches info about rgw pods in the cluster

Parameters
  • ocs_label (str) – label associated with ocs_operator pod (default: defaults.OCS_OPERATOR_LABEL)

  • namespace (str) – Namespace in which ceph cluster lives (default: none)

Returns

ocs_operator pod object

Return type

Pod object

ocs_ci.ocs.resources.pod.get_operator_pods(operator_label='app=rook-ceph-operator', namespace=None)

Fetches info about rook-ceph-operator pods in the cluster

Parameters
  • operator_label (str) – Label associated with rook-ceph-operator pod

  • namespace (str) – Namespace in which ceph cluster lives

Returns

of rook-ceph-operator pod objects

Return type

list

ocs_ci.ocs.resources.pod.get_osd_deployments(osd_label='app=rook-ceph-osd', namespace=None)

Fetches info about osd deployments in the cluster

Parameters
  • osd_label (str) – label associated with osd deployments (default: defaults.OSD_APP_LABEL)

  • namespace (str) – Namespace in which ceph cluster lives (default: defaults.ROOK_CLUSTER_NAMESPACE)

Returns

OSD deployment OCS instances

Return type

list

ocs_ci.ocs.resources.pod.get_osd_pod_id(osd_pod)

Get the osd pod id

Parameters

osd_pod (ocs_ci.ocs.resources.pod.Pod) – The osd pod object

Returns

The osd pod id

Return type

str

ocs_ci.ocs.resources.pod.get_osd_pods(osd_label='app=rook-ceph-osd', namespace=None)

Fetches info about osd pods in the cluster

Parameters
  • osd_label (str) – label associated with osd pods (default: defaults.OSD_APP_LABEL)

  • namespace (str) – Namespace in which ceph cluster lives (default: defaults.ROOK_CLUSTER_NAMESPACE)

Returns

of osd pod objects

Return type

list

ocs_ci.ocs.resources.pod.get_osd_pods_having_ids(osd_ids)

Get the osd pods having specific ids

Parameters

osd_ids (list) – The list of the osd ids

Returns

The osd pods having the osd ids

Return type

list

ocs_ci.ocs.resources.pod.get_osd_prepare_pods(osd_prepare_label='app=rook-ceph-osd-prepare', namespace='openshift-storage')

Fetches info about osd prepare pods in the cluster

Parameters
  • osd_prepare_label (str) – label associated with osd prepare pods (default: constants.OSD_PREPARE_APP_LABEL)

  • namespace (str) – Namespace in which ceph cluster lives (default: defaults.ROOK_CLUSTER_NAMESPACE)

Returns

OSD prepare pod objects

Return type

list

ocs_ci.ocs.resources.pod.get_osd_removal_pod_name(osd_id, timeout=60)

Get the osd removal pod name

Parameters
  • osd_id (int) – The osd’s id to get the osd removal pod name

  • timeout (int) – The time to wait for getting the osd removal pod name

Returns

The osd removal pod name

Return type

str

ocs_ci.ocs.resources.pod.get_plugin_pods(interface, namespace=None)

Fetches info of csi-cephfsplugin pods or csi-rbdplugin pods

Parameters
  • interface (str) – Interface type. eg: CephBlockPool, CephFileSystem

  • namespace (str) – Name of cluster namespace

Returns

csi-cephfsplugin pod objects or csi-rbdplugin pod objects

Return type

list

ocs_ci.ocs.resources.pod.get_plugin_provisioner_leader(interface, namespace=None, leader_type='provisioner')

Get csi-cephfsplugin-provisioner or csi-rbdplugin-provisioner leader pod

Parameters
  • interface (str) – Interface type. eg: CephBlockPool, CephFileSystem

  • namespace (str) – Name of cluster namespace

  • leader_type (str) – Parameter to check the lease. eg: ‘snapshotter’ to select external-snapshotter leader holder

Returns

csi-cephfsplugin-provisioner or csi-rbdplugin-provisioner leader

pod

Return type

Pod

ocs_ci.ocs.resources.pod.get_pod_ceph_daemon_type(pod_obj)

Get the ceph daemon type of the pod object

Parameters

pod_obj (Pod) – the pod object

Returns

The pod’s ceph daemon type

Return type

str

ocs_ci.ocs.resources.pod.get_pod_count(label, namespace=None)
ocs_ci.ocs.resources.pod.get_pod_logs(pod_name, container=None, namespace='openshift-storage', previous=False)

Get logs from a given pod

pod_name (str): Name of the pod container (str): Name of the container namespace (str): Namespace of the pod previous (bool): True, if pod previous log required. False otherwise.

Returns

Output from ‘oc get logs <pod_name> command

Return type

str

ocs_ci.ocs.resources.pod.get_pod_node(pod_obj)

Get the node that the pod is running on

Parameters

pod_obj (OCS) – The pod object

Returns

The node object

Return type

ocs_ci.ocs.ocp.OCP

ocs_ci.ocs.resources.pod.get_pod_obj(name, namespace=None)

Returns the pod obj for the given pod

Parameters

name (str) – Name of the resources

Returns

A pod object

Return type

obj

ocs_ci.ocs.resources.pod.get_pod_restarts_count(namespace='openshift-storage')

Gets the dictionary of pod and its restart count for all the pods in a given namespace

Returns

dictionary of pod name and its corresponding restart count

Return type

dict

ocs_ci.ocs.resources.pod.get_pods_having_label(label, namespace)

Fetches pod resources with given label in given namespace

Parameters
  • label (str) – label which pods might have

  • namespace (str) – Namespace in which to be looked up

Returns

of pods info

Return type

list

ocs_ci.ocs.resources.pod.get_pods_in_statuses(status_options, namespace='openshift-storage')

Get all the pods in specific statuses

Parameters
  • status_options (list) – The list of the status options.

  • namespace (str) – Name of cluster namespace(default: defaults.ROOK_CLUSTER_NAMESPACE)

Returns

All the pods that their status in the ‘status_options’ list.

Return type

list

ocs_ci.ocs.resources.pod.get_pvc_name(pod_obj)

Function to get pvc_name from pod_obj

Parameters

pod_obj (str) – The pod object

Returns

The pvc name of a given pod_obj,

Return type

str

Raises

UnavailableResourceException – If no pvc attached

ocs_ci.ocs.resources.pod.get_rbdfsplugin_provisioner_pods(rbdplugin_provisioner_label='app=csi-rbdplugin-provisioner', namespace=None)

Fetches info about CSI Cephfs plugin provisioner pods in the cluster

Parameters
  • rbdplugin_provisioner_label (str) – label associated with RBD provisioner pods (default: defaults.CSI_RBDPLUGIN_PROVISIONER_LABEL)

  • namespace (str) – Namespace in which ceph cluster lives (default: defaults.ROOK_CLUSTER_NAMESPACE)

Returns

csi-rbdplugin-provisioner Pod objects

Return type

list

ocs_ci.ocs.resources.pod.get_rgw_pods(rgw_label='app=rook-ceph-rgw', namespace=None)

Fetches info about rgw pods in the cluster

Parameters
  • rgw_label (str) – label associated with rgw pods (default: defaults.RGW_APP_LABEL)

  • namespace (str) – Namespace in which ceph cluster lives (default: none)

Returns

Pod objects of rgw pods

Return type

list

ocs_ci.ocs.resources.pod.get_running_state_pods(namespace='openshift-storage')

Checks the running state pods in a given namespace.

Returns:

List: all the pod objects that are in running state only

ocs_ci.ocs.resources.pod.get_used_space_on_mount_point(pod_obj)

Get the used space on a mount point

Parameters

pod_obj (POD) – The pod object

Returns

Percentage represent the used space on the mount point

Return type

int

ocs_ci.ocs.resources.pod.list_ceph_images(pool_name='rbd')
Parameters

pool_name (str) – Name of the pool to get the ceph images

Returns (List): List of RBD images in the pool

ocs_ci.ocs.resources.pod.list_of_nodes_running_pods(selector, namespace='openshift-storage')

The function returns the list of nodes for the given selector

Parameters

selector (str) – The resource selector to search with

Returns

a list of nodes that runs the given selector pods

Return type

list

ocs_ci.ocs.resources.pod.run_io_and_verify_mount_point(pod_obj, bs='10M', count='950')

Run I/O on mount point

Parameters
  • pod_obj (Pod) – The object of the pod

  • bs (str) – Read and write up to bytes at a time

  • count (str) – Copy only N input blocks

Returns

Used percentage on mount point

Return type

used_percentage (str)

ocs_ci.ocs.resources.pod.run_io_in_bg(pod_obj, expect_to_fail=False, fedora_dc=False)

Run I/O in the background

Parameters
  • pod_obj (Pod) – The object of the pod

  • expect_to_fail (bool) – True for the command to be expected to fail (disruptive operations), False otherwise

  • fedora_dc (bool) – set to False by default. If set to True, it runs IO in background on a fedora dc pod.

Returns

A thread of the I/O execution

Return type

Thread

ocs_ci.ocs.resources.pod.run_osd_removal_job(osd_id)

Run the ocs-osd-removal job

Parameters

osd_id (str) – The osd id

Returns

The ocs-osd-removal job object

Return type

ocs_ci.ocs.resources.ocs.OCS

ocs_ci.ocs.resources.pod.upload(pod_name, localpath, remotepath, namespace=None)

Upload a file to pod

Parameters
  • pod_name (str) – Name of the pod

  • localpath (str) – Local file to upload

  • remotepath (str) – Target path on the pod

ocs_ci.ocs.resources.pod.validate_pods_are_respinned_and_running_state(pod_objs_list)

Verifies the list of the pods are respinned and in running state

Parameters

pod_objs_list (list) – List of the pods obj

Returns

True if the pods are respinned and running, False otherwise

Return type

bool

Raises

ResourceWrongStatusException – In case the resources hasn’t reached the Running state

ocs_ci.ocs.resources.pod.verify_data_integrity(pod_obj, file_name, original_md5sum, block=False)

Verifies existence and md5sum of file created from first pod

Parameters
  • pod_obj (Pod) – The object of the pod

  • file_name (str) – The name of the file for which md5sum to be calculated

  • original_md5sum (str) – The original md5sum of the file

  • block (bool) – True if the volume mode of PVC used on pod is ‘Block’. file_name will be the devicePath in this case.

Returns

True if the file exists and md5sum matches

Return type

bool

Raises

AssertionError – If file doesn’t exist or md5sum mismatch

ocs_ci.ocs.resources.pod.verify_node_name(pod_obj, node_name)

Verifies that the pod is running on a particular node

Parameters
  • pod_obj (Pod) – The pod object

  • node_name (str) – The name of node to check

Returns

True if the pod is running on a particular node, False otherwise

Return type

bool

ocs_ci.ocs.resources.pod.verify_osd_removal_job_completed_successfully(osd_id)

Verify that the ocs-osd-removal job completed successfully

Parameters

osd_id (str) – The osd id

Returns

True, if the ocs-osd-removal job completed successfully. False, otherwise

Return type

bool

ocs_ci.ocs.resources.pod.verify_pods_upgraded(old_images, selector, count=1, timeout=720)

Verify that all pods do not have old image.

Parameters
  • old_images (set) – Set with old images.

  • selector (str) – Selector (e.g. app=ocs-osd)

  • count (int) – Number of resources for selector.

  • timeout (int) – Timeout in seconds to wait for pods to be upgraded.

Raises

TimeoutException – If the pods didn’t get upgraded till the timeout.

ocs_ci.ocs.resources.pod.wait_for_dc_app_pods_to_reach_running_state(dc_pod_obj, timeout=120, exclude_state=None)

Wait for DC app pods to reach running state

Parameters
  • dc_pod_obj (list) – list of dc app pod objects

  • timeout (int) – Timeout in seconds to wait for pods to be in Running state.

  • exclude_state (str) – A resource state to ignore

ocs_ci.ocs.resources.pod.wait_for_new_osd_pods_to_come_up(number_of_osd_pods_before)
ocs_ci.ocs.resources.pod.wait_for_pods_to_be_running(namespace='openshift-storage', timeout=200, sleep=10)

Wait for all the pods in a specific namespace to be running.

Parameters
  • namespace (str) – the namespace ot the pods

  • timeout (int) – time to wait for pods to be running

  • sleep (int) – Time in seconds to sleep between attempts

Returns

True, if all pods in Running state. False, otherwise

Return type

bool

ocs_ci.ocs.resources.pod.wait_for_storage_pods(timeout=200)

Check all OCS pods status, they should be in Running or Completed state

Parameters

timeout (int) – Number of seconds to wait for pods to get into correct state

ocs_ci.ocs.resources.pv module

ocs_ci.ocs.resources.pv.delete_released_pvs_in_sc(sc_name)

Delete the released PVs in a specific Storage class

Parameters

sc_name (str) – The storage class name

Returns

The number of PVs that have been deleted successfully.

Return type

int

ocs_ci.ocs.resources.pv.get_all_pvs()

Gets all pv in openshift-storage namespace

Returns

Dict of all pv in openshift-storage namespace

Return type

dict

ocs_ci.ocs.resources.pv.get_pv_name(pv_obj)

Get the name of the pv object

Parameters

pv_obj (dict) – A dictionary that represent the pv object

Returns

The status of the pv object

Return type

str

ocs_ci.ocs.resources.pv.get_pv_objs_in_sc(sc_name)

Get the pv objects in a specific Storage class

Parameters

sc_name (str) – The storage class name

Returns

list of dictionaries of the pv objects

Return type

list

ocs_ci.ocs.resources.pv.get_pv_size(pv_obj)

Get the size of a pv object

Parameters

pv_obj (dict) – A dictionary that represent the pv object

Returns

The size of the pv object

Return type

int

ocs_ci.ocs.resources.pv.get_pv_status(pv_obj)

Get the status of the pv object

Parameters

pv_obj (dict) – A dictionary that represent the pv object

Returns

The status of the pv object

Return type

str

ocs_ci.ocs.resources.pv.verify_new_pv_available_in_sc(old_pv_objs, sc_name, timeout=120)

Verify that the new pv, that has been created in a specific storage class, is available.

Parameters
  • old_pv_objs (list) – List of dictionaries of the pv objects

  • sc_name (str) – The name of the storage class

  • timeout (int) – time to wait for the new pv to come up

Returns

True if the new pv is available. False, otherwise.

Return type

bool

ocs_ci.ocs.resources.pvc module

General PVC object

class ocs_ci.ocs.resources.pvc.PVC(**kwargs)

Bases: ocs_ci.ocs.resources.ocs.OCS

A basic PersistentVolumeClaim kind resource

property backed_pv

Returns the backed PV name of pvc_name in namespace

Returns

PV name

Return type

str

property backed_pv_obj

Returns the backed PV object of pvc_name in namespace

Returns

An OCS instance for PV

Return type

OCS

property backed_sc

Returns the storage class of pvc object in namespace

Returns

Storage class name

Return type

str

create_snapshot(snapshot_name=None, wait=False)

Take snapshot of the PVC

Parameters
  • snapshot_name (str) – Name to be provided for snapshot

  • wait (bool) – True to wait for snapshot to be ready, False otherwise

Returns

Kind Snapshot

Return type

OCS

get_attached_pods()

Get the pods attached to the PVC represented by this object instance

Returns

A list of pod objects attached to the PVC

Return type

list

property get_pvc_access_mode

Function to get pvc access_mode

Returns

The accessModes Value of pvc_obj

Return type

(str)

property image_uuid

Fetch image uuid associated with PVC

Returns

Image uuid associated with PVC

Return type

str

property provisioner
property reclaim_policy

Get the reclaim policy of PV associated with the PVC

Returns

Reclaim policy. eg: Reclaim, Delete

Return type

str

resize_pvc(new_size, verify=False)

Modify the capacity of PVC

Parameters
  • new_size (int) – New size of PVC in Gi

  • verify (bool) – True to verify the change is reflected on PVC, False otherwise

Returns

True if operation succeeded, False otherwise

Return type

bool

property size

Returns the PVC size pvc_name in namespace

Returns

PVC size

Return type

int

property status

Returns the PVC status

Returns

PVC status

Return type

str

ocs_ci.ocs.resources.pvc.create_pvc_clone(sc_name, parent_pvc, clone_yaml, pvc_name=None, do_reload=True, storage_size=None, access_mode=None, volume_mode=None)

Create a cloned pvc from existing pvc

Parameters
  • sc_name (str) – The name of storage class.

  • parent_pvc (str) – Name of the parent pvc, whose clone is to be created.

  • pvc_name (str) – The name of the PVC being created

  • do_reload (bool) – True for wait for reloading PVC after its creation, False otherwise

  • storage_size (str) – Size of the clone, if not passed will use the default “storage” value from pvc-clone.yaml. eg: ‘5Gi’

  • access_mode (str) – This decides the access mode to be used for the cloned PVC. eg: ReadWriteOnce, ReadOnlyMany, ReadWriteMany

  • volume_mode (str) – Volume mode for PVC. This should match the volume mode of parent PVC

Returns

PVC instance

Return type

PVC

ocs_ci.ocs.resources.pvc.create_pvc_snapshot(pvc_name, snap_yaml, snap_name, sc_name=None, wait=False)

Create snapshot of a PVC

Parameters
  • pvc_name (str) – Name of the PVC

  • snap_yaml (str) – The path of snapshot yaml

  • snap_name (str) – The name of the snapshot to be created

  • sc_name (str) – The name of the snapshot class

  • wait (bool) – True to wait for snapshot to be ready, False otherwise

Returns

OCS object

ocs_ci.ocs.resources.pvc.create_restore_pvc(sc_name, snap_name, namespace, size, pvc_name, volume_mode=None, restore_pvc_yaml='/home/docs/checkouts/readthedocs.org/user_builds/ocs-ci-pbalogh/checkouts/latest/ocs_ci/templates/CSI/rbd/pvc-restore.yaml', access_mode='ReadWriteOnce')

Create PVC from snapshot

Parameters
  • sc_name (str) – The name of the storageclass

  • snap_name (str) – The name of the snapshot from which pvc would

  • created (be) –

  • namespace (str) – The namespace for the PVC creation

  • size (str) – Size of pvc being created

  • pvc_name (str) – The name of the PVC being created

  • volume_mode (str) – Volume mode for rbd RWX pvc i.e. ‘Block’

  • restore_pvc_yaml (str) – The location of pvc-restore.yaml

  • access_mode (str) – The access mode to be used for the PVC

Returns

PVC instance

Return type

PVC

ocs_ci.ocs.resources.pvc.delete_pvcs(pvc_objs, concurrent=False)

Deletes list of the pvc objects

Parameters
  • pvc_objs (list) – List of the pvc objects to be deleted

  • concurrent (bool) – Determines if the delete operation should be executed with multiple thread in parallel

Returns

True if deletion is successful

Return type

bool

ocs_ci.ocs.resources.pvc.get_all_pvc_objs(namespace=None, selector=None)

Gets all PVCs objects in given namespace

Parameters
  • namespace (str) – Name of namespace

  • selector (str) – The label selector to look for

Returns

Instances of PVC

Return type

list

ocs_ci.ocs.resources.pvc.get_all_pvcs(namespace=None, selector=None)

Gets all pvc in given namespace

Parameters
  • namespace (str) – Name of namespace (‘all-namespaces’ to get all namespaces)

  • selector (str) – The label selector to look for

Returns

Dict of all pvc in namespaces

Return type

dict

ocs_ci.ocs.resources.pvc.get_all_pvcs_in_storageclass(storage_class)

This function returen all the PVCs in a given storage class

Parameters

storage_class (str) – name of the storage class

Returns

list of PVC objects

Return type

out

ocs_ci.ocs.resources.pvc.get_deviceset_pvcs()

Get the deviceset PVCs

Returns

The deviceset PVCs OCS objects

Return type

list

Raises

AssertionError – In case the deviceset PVCs are not found

ocs_ci.ocs.resources.pvc.get_deviceset_pvs()

Get the deviceset PVs

Returns

the deviceset PVs OCS objects

Return type

list

Raises

AssertionError – In case the deviceset PVCs are not found

ocs_ci.ocs.resources.rgw module

class ocs_ci.ocs.resources.rgw.RGW(namespace=None)

Bases: object

Wrapper class for interaction with a cluster’s RGW service

get_credentials(secret_name='rook-ceph-object-user-ocs-storagecluster-cephobjectstore-noobaa-ceph-objectstore-user')

Get Endpoint, Access key and Secret key from OCS secret. Endpoint is taken from rgw exposed service. Use rgw_endpoint fixture in test to get it exposed.

Parameters

secret_name (str) – Name of secret to be used for getting RGW credentials

Returns

Endpoint, Access key, Secret key

Return type

tuple

ocs_ci.ocs.resources.storage_cluster module

StorageCluster related functionalities

class ocs_ci.ocs.resources.storage_cluster.StorageCluster(resource_name='', *args, **kwargs)

Bases: ocs_ci.ocs.ocp.OCP

This class represent StorageCluster and contains all related methods we need to do with StorageCluster.

ocs_ci.ocs.resources.storage_cluster.add_capacity(osd_size_capacity_requested)

Add storage capacity to the cluster

Parameters

osd_size_capacity_requested (int) – Requested osd size capacity

Returns

Returns True if all OSDs are in Running state

Return type

new storage device set count (int)

Note: “StoragedeviceSets->count” represents the set of 3 OSDs. That is, if there are 3 OSDs in the system then count will be 1. If there are 6 OSDs then count is 2 and so on. By changing this value,we can add extra devices to the cluster. For example, if we want to expand the cluster by 3 more osds in a cluster that already has 3 osds, we can set count as 2. So, with each increase of count by 1, we get 3 OSDs extra added to the cluster. This is how we are going to ‘add capacity’ via automation. As we know that OCS has 3 way replica. That is, same data is placed in 3 OSDs. Because of this, the total usable capacity for apps from 3 OSDs will be the size of one OSD (all osds are of same size). If we want to add more capacity to the cluster then we need to add 3 OSDs of same size as that of the original OSD. add_capacity needs to accept the ‘capacity_to_add’ as an argument. From this we need to arrive at storagedeviceSets -> count and then “Patch” this count to get the required capacity to add. To do so, we use following formula: storageDeviceSets->count = (capacity reqested / osd capacity ) + existing count storageDeviceSets

ocs_ci.ocs.resources.storage_cluster.get_all_storageclass()

Function for getting all storageclass excluding ‘gp2’ and ‘flex’

Returns

list of storageclass

Return type

list

ocs_ci.ocs.resources.storage_cluster.get_deviceset_count()

Get storageDeviceSets count from storagecluster

Returns

storageDeviceSets count

Return type

int

ocs_ci.ocs.resources.storage_cluster.get_osd_count()

Get osd count from Storage cluster.

Returns

osd count (In the case of external mode it returns 0)

Return type

int

ocs_ci.ocs.resources.storage_cluster.get_osd_size()

Get osd size from Storage cluster

Returns

osd size

Return type

int

ocs_ci.ocs.resources.storage_cluster.get_storage_cluster(namespace='openshift-storage')

Get storage cluster name

Parameters

namespace (str) – Namespace of the resource

Returns

Storage cluster object handler

Return type

storage cluster (obj)

ocs_ci.ocs.resources.storage_cluster.ocs_install_verification(timeout=600, skip_osd_distribution_check=False, ocs_registry_image=None, post_upgrade_verification=False, version_before_upgrade=None)

Perform steps necessary to verify a successful OCS installation

Parameters
  • timeout (int) – Number of seconds for timeout which will be used in the checks used in this function.

  • skip_osd_distribution_check (bool) – If true skip the check for osd distribution.

  • ocs_registry_image (str) – Specific image to check if it was installed properly.

  • post_upgrade_verification (bool) – Set to True if this function is called after upgrade.

  • version_before_upgrade (float) – Set to OCS version before upgrade

ocs_ci.ocs.resources.storage_cluster.osd_encryption_verification()

Verify if OSD encryption at rest if successfully deployed on OCS

Raises
ocs_ci.ocs.resources.storage_cluster.setup_ceph_debug()

Set Ceph to run in debug log level using a ConfigMap. This functionality is available starting OCS 4.7.

ocs_ci.ocs.resources.test_packagemanifest module

ocs_ci.ocs.resources.test_packagemanifest.test_no_resource_found_for_packagemanifest()

Test that when we run into issue #1338, when no PackageManifest object found.

This unit test serves two purposes: - to show what exactly happens to PackageManifest during issue #1338 - demonstrate that PackageManifest API remains unchanged

ocs_ci.ocs.resources.test_packagemanifest.test_pm_null()

Test that creation of PackageManifest object without any constructor agruments works (object is created, no exceptions are raised).

ocs_ci.ocs.resources.test_packagemanifest.test_pm_null_get_default_channel()

Module contents