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(retry=True, timeout=120)
Deletes the current backingstore by using OC/CLI commands
- Parameters:
retry (bool) – Whether to retry the deletion if it fails
timeout (int) – Timeout to wait if retry is true
- 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=None, 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, replication_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:
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:
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.catalog_source.disable_default_sources()
Disable default sources
- ocs_ci.ocs.resources.catalog_source.disable_specific_source(source_name)
Disable specific default source
- Parameters:
source_name (str) – Source name (e.g. redhat-operators)
- ocs_ci.ocs.resources.catalog_source.enable_default_sources()
Enable default sources
- ocs_ci.ocs.resources.catalog_source.enable_specific_source(source_name)
Enable specific default source
- Parameters:
source_name (str) – Source name (e.g. redhat-operators)
ocs_ci.ocs.resources.cloud_manager module
- class ocs_ci.ocs.resources.cloud_manager.AwsSTSClient(auth_dict, verify=True, endpoint='https://s3.amazonaws.com', *args, **kwargs)
Bases:
S3Client
- class ocs_ci.ocs.resources.cloud_manager.AzureClient(account_name=None, credential=None, auth_dict=None, *args, **kwargs)
Bases:
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
- Returns:
True if deleted successfully
- Return type:
bool
- 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.AzureWithLogsClient(account_name=None, credential=None, auth_dict=None, *args, **kwargs)
Bases:
AzureClient
Implementation of an Azure Client using the Azure API to an existing storage account with bucket logs enabled
- create_azure_secret()
Create a Kubernetes secret to allow NooBaa to create Azure-based backingstores
Note that this method overides the parent method to include the additional fields that are needed for the bucket logs feature
- class ocs_ci.ocs.resources.cloud_manager.CloudClient(*args, **kwargs)
Bases:
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
Class containing all client types
- class ocs_ci.ocs.resources.cloud_manager.GoogleClient(auth_dict, *args, **kwargs)
Bases:
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
- Returns:
True if deleted successfully
- Return type:
bool
- 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:
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,
us-east-1 (if none will be created on) –
**IMPORTANT** –
is (Passing us-east-1 as the region will cause an error if used since it) –
AWS (the default region for) –
- internal_delete_uls(name)
Deletes the Underlying Storage using the S3 API
- Parameters:
name (str) – The Underlying Storage name to be deleted
- Returns:
True if deleted successfully
- Return type:
bool
- 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:
OCP
This class represent ClusterServiceVersion (CSV) and contains all related methods we need to do with CSV.
- ocs_ci.ocs.resources.csv.check_all_csvs_are_succeeded(namespace, timeout=600)
Check if all CSVs in namespace are in succeeded phase
- Parameters:
namespace (str) – namespace of CSV
- Returns:
True if all CSVs are in succeeded phase
- Return type:
bool
- ocs_ci.ocs.resources.csv.get_csv_name_start_with_prefix(csv_prefix, namespace)
Get CSV name start with prefix
- Parameters:
csv_prefix (str) – prefix from name
namespace (str) – namespace of CSV
- Returns:
CSV name
- Return type:
str
- 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.deployment module
General Deployment object
- class ocs_ci.ocs.resources.deployment.Deployment(**kwargs)
Bases:
OCS
A basic Deployment kind resource
- property available_replicas
Returns number of available replicas for the deployment
- Returns:
Number of replicas
- Return type:
int
- property pods
Returns list of pods of the Deployment resource
- Returns:
Deployment’s pods
- Return type:
list
- property replicas
Returns number of replicas for the deployment as defined in its spec
- Returns:
Number of replicas
- Return type:
int
- property revision
Returns revision of a Deployment resource
- Returns:
revision number
- Return type:
str
- scale(replicas, resource_name=None)
Scale deployment to required number of replicas
- Parameters:
replicas (int) – number of required replicas
resource_name (str) – name of resouce to querry the revision
- set_revision(revision, resource_name=None)
Set revision to a Deployment or a similar resource that supports kubernetes revisions.
- Parameters:
revision (int) – revision number of the resource
resource_name (str) – name of resouce to querry the revision
- wait_for_available_replicas(timeout=15, sleep=3)
Wait for number of available replicas reach number of desired replicas.
- Parameters:
timeout (int) – Timeout in seconds
sleep (int) – Sleep interval in seconds
- ocs_ci.ocs.resources.deployment.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.deployment.get_mon_deployments(mon_label='app=rook-ceph-mon', namespace=None)
Fetches info about mon deployments in the cluster
- Parameters:
mon_label (str) – label associated with mon deployments (default: defaults.MON_APP_LABEL)
namespace (str) – Namespace in which ceph cluster lives (default: config.ENV_DATA[“cluster_namespace”])
- Returns:
Mon deployment OCS instances
- Return type:
list
- ocs_ci.ocs.resources.deployment.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: config.ENV_DATA[“cluster_namespace”])
- Returns:
OSD deployment OCS instances
- Return type:
list
ocs_ci.ocs.resources.drpc module
DRPlacementControl related functionalities
- class ocs_ci.ocs.resources.drpc.DRPC(namespace, resource_name='', *args, **kwargs)
Bases:
OCP
This class represent DRPlacementControl (DRPC) and contains all related methods we need to do with DRPC.
- property drpolicy
- property drpolicy_obj
- get_peer_ready_status()
- wait_for_peer_ready_status()
- ocs_ci.ocs.resources.drpc.get_drpc_name(namespace)
Get the DRPC resource name in the given namespace
- Parameters:
namespace (str) – Name of the namespace
- Returns:
DRPC resource name
- Return type:
str
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:
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.job module
- ocs_ci.ocs.resources.job.get_all_jobs(namespace=None)
Get all the jobs in a specific namespace
- Parameters:
namespace (str) – Name of cluster namespace(default: config.ENV_DATA[“cluster_namespace”])
- Returns:
list of dictionaries of the job OCS instances.
- Return type:
list
- ocs_ci.ocs.resources.job.get_job_obj(name, namespace=None)
Get OCS instance for job of 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_ci.ocs.resources.job.get_job_pods(job_name, namespace, names_only=False)
Get list of pods of given job (via job-name pod selector).
- Parameters:
job_name (str) – name of the job to wait for
namespace (str) – name of the namespace where the job is running
- Returns:
list of pod names (if names_only is True) or full item dicts
- Return type:
list
- ocs_ci.ocs.resources.job.get_jobs_with_prefix(prefix, namespace=None)
Get all the jobs that start with a specific prefix
- Parameters:
prefix (str) – The prefix to search in the job names
namespace (str) – Name of cluster namespace (default: config.ENV_DATA[“cluster_namespace”] if None provided)
- Returns:
list of dictionaries of the job OCS instances that start with the prefix
- Return type:
list
- ocs_ci.ocs.resources.job.log_output_of_job_pods(job_name, namespace)
Log (via standard logger) output of all pods of given job. Expected to be used in case of error, when evidence needs to be captured in logs.
- Parameters:
job_name (str) – name of the job to wait for
namespace (str) – name of the namespace where the job is running
- ocs_ci.ocs.resources.job.wait_for_job_completion(job_name, namespace, timeout=600, sleep_time=30)
Wait for given k8s Job to complete.
- Parameters:
job_name (str) – name of the job to wait for
namespace (str) – name of the namespace where the job is running
timeout (int) – timeout in seconds
sleep_time (int) – sleep time between consequent job status checks in seconds
- Raises:
TimeoutExpiredError – When job fails to complete in given time
ocs_ci.ocs.resources.machineconfig module
- ocs_ci.ocs.resources.machineconfig.deploy_machineconfig(tmp_path, mc_name, mc_dict, mcp_num=2)
Deploy given
MachineConfig
dict and wait for the configuration to be deployed on all MachineConfigPools. By default we assume there are just two pools.- Parameters:
tmp_path (pathlib.Path) – Directory where a temporary yaml file will be created. In test context, use pytest fixture tmp_path.
mc_name (str) – name prefix for object config yaml file which will be created for the machineconfig before it’s deployment
mc_dict (list) – list of dictionaries with MachineConfig resource(s) to deploy
mcp_num (int) – number of MachineConfigPool resources in the cluster
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=300)
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
- Raises:
AssertionError – In case mirroring is not done in defined time.
- 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_policy, namespace_policy=None, replication_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_policy: The placement policy to be used - Mirror | Spread :type placement_policy: str :param namespace_policy: The namespace policy to be used :type namespace_policy: dict :param replication_policy: The replication policy dictionary :type replication_policy: dict
- Returns:
The bucket class resource
- Return type:
- 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
- data_to_mask = None
- 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, use_yes=False, **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_admin_default_resource_name()
Get the default resource name of the admin account
- Returns:
The default resource name
- Return type:
str
- get_bucket_info(bucket_name)
- Parameters:
bucket_name (str) – Name of searched bucket
- Returns:
Information about the bucket
- Return type:
dict
- get_default_bc_backingstore_name()
Get the default backingstore name of the default bucketclass
- Returns:
The default backingstore name
- Return type:
str
- get_mcg_cli_version()
Get the MCG CLI version by parsing the output of the mcg-cli version command.
Example output of the mcg-cli version command:
INFO[0000] CLI version: 5.12.0 INFO[0000] noobaa-image: noobaa/noobaa-core:master-20220913 INFO[0000] operator-image: noobaa/noobaa-operator:5.12.0
- Returns:
Object of semantic version.
- Return type:
semantic_version.base.Version
- get_noobaa_admin_credentials_from_secret()
Get the NooBaa admin credentials from the OCP secret
- Returns:
- Dictionary containing the following keys:
AWS_ACCESS_KEY_ID (str): NooBaa admin S3 access key ID AWS_SECRET_ACCESS_KEY (str): NooBaa admin S3 secret access key email (str): NooBaa admin user email password (str): NooBaa admin user password
- Return type:
credentials_dict (dict)
- mgmt_endpoint = None
- namespace = None
- noobaa_password = None
- noobaa_token = None
- noobaa_user = None
- oc_create_bucketclass(name, backingstores, placement_policy, namespace_policy, replication_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_policy: The placement policy to be used - Mirror | Spread :type placement_policy: str :param namespace_policy: The namespace policy to be used :type namespace_policy: dict :param replication_policy: The replication policy dictionary :type replication_policy: dict
- Returns:
The bucket class resource
- Return type:
- 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:
- reset_admin_pw(new_password)
Reset the NooBaa admin password
- Parameters:
new_password (str) – New password to set for the NooBaa admin user
- reset_core_pod()
Delete the noobaa-core pod and wait for it to come up again
- retrieve_nb_token(timeout=300, sleep=30)
Try to retrieve a NB RPC token and decode its JSON
- 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
- 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
- update_s3_creds()
Set the S3 credentials of the NooBaa admin user from the noobaa-admin secret, and update the S3 resource and client
ocs_ci.ocs.resources.mcg_lifecycle_policies module
- class ocs_ci.ocs.resources.mcg_lifecycle_policies.ExpirationRule(days, filter={}, use_date=False, is_enabled=True, expire_solo_delete_markers=False)
Bases:
LifecycleRule
A class for handling the parsing of an MCG object expiration rule
- as_dict()
- class ocs_ci.ocs.resources.mcg_lifecycle_policies.LifecycleFilter(prefix=None, tags=None, minBytes=None, maxBytes=None)
Bases:
object
A class for handling S3 lifecycle filter parsing
- as_dict()
ocs_ci.ocs.resources.mcg_params module
- class ocs_ci.ocs.resources.mcg_params.NSFS(method: str = 'CLI', pvc_name: str | None = None, pvc_size: int = 20, sub_path: str | None = None, fs_backend: str | None = None, mount_existing_dir: bool = False, existing_dir_mode: int = 777, mount_path: str = '/nsfs', uid: int = 5678, gid: int = 1234, interface_pod: Pod | None = None, bucket_obj: ObjectBucket | None = None, bucket_name: str | None = None, mounted_bucket_path: str | None = None, s3_creds: dict | None = None, nss: NamespaceStore | None = None)
Bases:
object
An NSFS dataclass to represent NSFS test parametrization and provide a central state store
- Parametrization parameters:
method (str): The method to use for namespacestore creation. OC | CLI pvc_name (str): Name of the PVC that will host the namespace filesystem pvc_size (int): Size of the PVC in Gi sub_path (str): The path to a sub directory inside the PVC FS which the NSS will use as its root directory mount_existing_dir (bool): Whether to mount an existing directory or create a new one existing_dir_mode (int): The mode of the existing directory fs_backend (str): The file system backend type - CEPH_FS | GPFS | NFSv4. Defaults to None. mount_path (str): The path to the mount point of the NSFS uid (int): The UID of the user that will be used to create the NSFS gid (int): The GID of the user that will be used to create the NSFS
- bucket_name: str = None
- bucket_obj: ObjectBucket = None
- existing_dir_mode: int = 777
- fs_backend: str = None
- gid: int = 1234
State parameters; These should not be modified unless needed, and will be (over/)written after the NSFS object will be passed to the bucket factory.
interface_pod (Pod): The pod that will be used to interact with the NSFS bucket_name (str): The name of the NSFS bucket mounted_bucket_path (str): The path to where the bucket is “mounted” in the FS s3_creds (str): The NSFS S3 credentials nss (NamespaceStore): The namespacestore that the NSFS uses
- method: str = 'CLI'
- mount_existing_dir: bool = False
- mount_path: str = '/nsfs'
- mounted_bucket_path: str = None
- nss: NamespaceStore = None
- pvc_name: str = None
- pvc_size: int = 20
- s3_creds: dict = None
- sub_path: str = None
- uid: int = 5678
ocs_ci.ocs.resources.mcg_replication_policy module
- class ocs_ci.ocs.resources.mcg_replication_policy.AwsLogBasedReplicationPolicy(destination_bucket, sync_deletions=False, logs_bucket='', prefix='', logs_location_prefix='')
Bases:
LogBasedReplicationPolicy
A class to handle the AWS log-based bucket replication policy JSON structure.
- to_dict()
- class ocs_ci.ocs.resources.mcg_replication_policy.AzureLogBasedReplicationPolicy(destination_bucket, sync_deletions=False, prefix='')
Bases:
LogBasedReplicationPolicy
A class to handle the Azure log-based bucket replication policy JSON structure.
- to_dict()
- class ocs_ci.ocs.resources.mcg_replication_policy.LogBasedReplicationPolicy(destination_bucket, sync_deletions=False, prefix='')
Bases:
McgReplicationPolicy
,ABC
An abstract subclass of ReplicationPolicy that includes log-based replication information.
- abstract to_dict()
ocs_ci.ocs.resources.mockup_bucket_logger module
- class ocs_ci.ocs.resources.mockup_bucket_logger.MockupBucketLogger(awscli_pod, mcg_obj, bucket_factory, platform, region)
Bases:
object
This class facilitates S3 operations on an MCG bucket while writing corresponding mockup logs directly to a ULS bucket via a Namespacestore MCG bucket.
The use of a Namespacestore MCG bucket for the logs enables storage provider agnosticity.
- delete_all_objects_and_log(bucket_name)
Deletes all objects from the MCG bucket and write matching mockup logs
- delete_objs_and_log(bucket_name, objs)
Delete list of objects from the MCG bucket and write matching mockup logs
- Parameters:
bucket_name (str) – Name of the MCG bucket
objs (list) – List of the objects to delete
- property standard_test_obj_list
- upload_arbitrary_object_and_log(bucket_name)
Uploads an arbitrary object to the MCG bucket and upload a matching mockup log
- upload_test_objs_and_log(bucket_name)
Uploads files from files_dir to the MCG bucket and write matching mockup logs to the logs bucket
- Parameters:
files_dir (str) – Full path to a directory on awscli_pod
- class ocs_ci.ocs.resources.mockup_bucket_logger.S3MockupLog(bucket_name, object_key, operation)
Bases:
object
This class represents a mockup log file in the AWS log file format
- OP_CODES = {'DELETE': 204, 'GET': 206, 'PUT': 200}
- property bucket_name
- property file_name
- property object_key
- property operation
- property time
Get the time in the AWS logs format. i.e “[06/Feb/2019:00:00:38 +0000]”
- Returns:
The current time in the AWS bucket log format
- Return type:
str
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(retry=True)
Deletes the current namespacestore by using OC/CLI commands
- Parameters:
retry (bool) – Whether to retry the deletion if it fails
- 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=180, 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.cli_create_namespacestore(nss_name, platform, mcg_obj, uls_name=None, cld_mgr=None, nss_tup=None)
Create a namespace filesystem namespacestore using YAMLs
- Parameters:
nss_name (str) – Name of the namespacestore
platform (str) – Platform to create the namespacestore on
mcg_obj (MCG) – An MCG object used for executing the MCG CLI commands
uls_name (str) – Name of the ULS bucket / PVC to use for the namespacestore
cld_mgr (CloudManager) – CloudManager object used for supplying the needed connection credentials
nss_tup (tuple) – A tuple containing the NSFS namespacestore details, in this order: pvc_name (str): Name of the PVC that will host the namespace filesystem pvc_size (int): Size in Gi of the PVC that will host the namespace filesystem sub_path (str): The path to a sub directory inside the PVC FS which the NSS will use as the root directory fs_backend (str): The file system backend type - CEPH_FS | GPFS | NFSv4. Defaults to None.
- ocs_ci.ocs.resources.namespacestore.namespace_store_factory(request, cld_mgr, mcg_obj_session, cloud_uls_factory_session, pvc_factory_session)
Create a NamespaceStore 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.namespacestore.oc_create_namespacestore(nss_name, platform, mcg_obj, uls_name=None, cld_mgr=None, nss_tup=None, nsfs_pvc_name=None)
Create a namespacestore using the MCG CLI
- Parameters:
nss_name (str) – Name of the namespacestore
platform (str) – Platform to create the namespacestore on
mcg_obj (MCG) – A redundant MCG object, used for uniformity between OC and CLI calls
uls_name (str) – Name of the ULS bucket to use for the namespacestore
cld_mgr (CloudManager) – CloudManager object used for supplying the needed connection credentials
nss_tup (tuple) – A tuple containing the NSFS namespacestore details, in this order: pvc_name (str): Name of the PVC that will host the namespace filesystem pvc_size (int): Size in Gi of the PVC that will host the namespace filesystem sub_path (str): The path to a sub directory inside the PVC FS which the NSS will use as the root directory fs_backend (str): The file system backend type - CEPH_FS | GPFS | NFSv4. Defaults to None.
- ocs_ci.ocs.resources.namespacestore.template_pvc(name, namespace='openshift-storage', storageclass='ocs-storagecluster-cephfs', access_mode='ReadWriteMany', size=20)
Create a PVC using the MCG CLI
- Parameters:
name (str) – Name of the PVC
namespace (str) – Namespace to create the PVC in
access_mode (str) – Access mode for the PVC
size (str) – Size of the PVC in GiB
ocs_ci.ocs.resources.objectbucket module
- class ocs_ci.ocs.resources.objectbucket.MCGCLIBucket(*args, **kwargs)
Bases:
ObjectBucket
Implementation of an MCG bucket using the NooBaa CLI
- internal_delete()
Deletes the bucket using the NooBaa CLI
- Raises:
NotFoundError – In case the OBC was not found
- 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:
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:
OCBucket
Implementation of an MCG bucket using the OC CLI
- class ocs_ci.ocs.resources.objectbucket.MCGS3Bucket(*args, **kwargs)
Bases:
ObjectBucket
Implementation of an MCG bucket using the S3 API
- internal_delete()
Deletes the bucket using the S3 API
- Raises:
NotFoundError – In case the bucket was not found
- 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:
ObjectBucket
- internal_delete(verify=True)
Deletes the bucket using the OC CLI
- Raises:
NotFoundError – In case the OBC was not found
- 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, replication_policy=None, quota=None, *args, **kwargs)
Bases:
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, **kwargs)
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
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.
- apply(namespace=None)
Run
oc apply
on in this object file.- Parameters:
namespace (str) – Name of the namespace where to deploy, overriding
specify (self.project.namespace value (in a similar way how you can) –
apply. (any value to -n option of oc) –
- create(namespace=None)
Run
oc create
on in this object file.- Parameters:
namespace (str) – Name of the namespace where to deploy, overriding
specify (self.project.namespace value (in a similar way how you can) –
create. (any value to -n option of oc) –
- delete(namespace=None)
Run
oc delete
on in this object file.- Parameters:
namespace (str) – Name of the namespace where to deploy, overriding
specify (self.project.namespace value (in a similar way how you can) –
delete. (any value to -n option of oc) –
- describe(namespace=None)
Run
oc describe
on in this object file.- Parameters:
namespace (str) – Name of the namespace where to deploy, overriding
specify (self.project.namespace value (in a similar way how you can) –
describe. (any value to -n option of oc) –
- get(namespace=None)
Run
oc get
on in this object file.- Parameters:
namespace (str) – Name of the namespace where to deploy, overriding
specify (self.project.namespace value (in a similar way how you can) –
get. (any value to -n option of oc) –
- wait_for_delete(resource_name='', timeout=60, sleep=3, namespace=None)
Wait for a resource to be deleted
- Parameters:
resource_name (str) – The name of the resource to wait for (e.g.kube_obj_name)
timeout (int) – Time in seconds to wait
sleep (int) – Sampling time in seconds
namespace (str) – Name of the namespace where to deploy, overriding self.project.namespace value (in a similar way how you can specify any value to
-n
option ofoc get
.
- Raises:
CommandFailed – If failed to verify the resource deletion
TimeoutError – If resource is not deleted within specified timeout
- Returns:
True in case resource deletion is successful
- Return type:
bool
- ocs_ci.ocs.resources.objectconfigfile.link_spec_volume(spec_dict, volume_name, pvc_name)
Find volume of given name in given spec dict, and set given pvc name as a pvc for the volume in the spec.
- Parameters:
spec_dict (dict) – dictionary with a container/template spec
volume_name (str) – name of the volume in the spec dict to link
pvc_name (str) – name of the target pvc (for the given volume)
- Raises:
NotFoundError when given volume is not found in given spec –
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.
- set_deleted()
- 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_ocs_csv()
Get the OCS CSV object
- Returns:
OCS CSV object
- Return type:
- Raises:
CSVNotFound – In case no CSV found.
- ocs_ci.ocs.resources.ocs.get_version_info(namespace=None)
ocs_ci.ocs.resources.osd_resize module
- ocs_ci.ocs.resources.osd_resize.base_ceph_verification_steps_post_resize_osd(old_osd_pods, old_osd_pvcs, old_osd_pvs, expected_storage_size)
Check the Ceph verification steps post resize OSD. It will perform the following steps: 1. Check the resources state post resize OSD 2. Check the resources size post resize OSD 3. Check the Ceph state post resize OSD
- Parameters:
old_osd_pods (list) – The old osd pod objects before resizing the osd
old_osd_pvcs (list) – The old osd PVC objects before resizing the osd
old_osd_pvs (list) – The old osd PV objects before resizing the osd
expected_storage_size (str) – The expected storage size after resizing the osd
- Raises:
StorageSizeNotReflectedException – If the current storage size, PVCs, PVs, and ceph capacity are not in the expected size
- ocs_ci.ocs.resources.osd_resize.ceph_verification_steps_post_resize_osd(old_osd_pods, old_osd_pvcs, old_osd_pvs, expected_storage_size, num_of_tries=6)
Try to execute the function ‘base_ceph_verification_steps_post_resize_osd’ a number of tries until success, ignoring the exception ‘StorageSizeNotReflectedException’. In every iteration, if we get the exception ‘StorageSizeNotReflectedException’, it will restart the osd pods and try again until it reaches the maximum tries.
- Parameters:
old_osd_pods (list) – The old osd pod objects before resizing the osd
old_osd_pvcs (list) – The old osd PVC objects before resizing the osd
old_osd_pvs (list) – The old osd PV objects before resizing the osd
expected_storage_size (str) – The expected storage size after resizing the osd
num_of_tries (int) – The number of tries to try executing the function ‘base_ceph_verification_steps_post_resize_osd’.
- Raises:
StorageSizeNotReflectedException – If the current storage size, PVCs, PVs, and ceph capacity are not in the expected size
- ocs_ci.ocs.resources.osd_resize.check_ceph_health_after_resize_osd(ceph_health_tries=40, ceph_rebalance_timeout=900)
Check Ceph health after resize osd
- Parameters:
ceph_health_tries (int) – The number of tries to wait for the Ceph health to be OK.
ceph_rebalance_timeout (int) – The time to wait for the Ceph cluster rebalanced.
- ocs_ci.ocs.resources.osd_resize.check_ceph_state_post_resize_osd()
Check the Ceph state post resize osd. The function checks the Ceph device classes and osd tree.
- Raises:
CephHealthException – In case the Ceph device classes and osd tree checks didn’t finish successfully
- ocs_ci.ocs.resources.osd_resize.check_resources_state_post_resize_osd(old_osd_pods, old_osd_pvcs, old_osd_pvs)
Check that the pods, PVCs, and PVs are in the expected state post resizing the osd. It will perform the following steps: 1. Check that the old osd pods are in a terminating state or deleted 2. Check that the new osd pods running, and we have exactly the same number of osd pods as the old ones. 3. Check that the PVCs are in a Bound state 4. Check that the old PVC and PV names are equal to the current PVC and PV names
- Parameters:
old_osd_pods (list) – The old osd pod objects before resizing the osd
old_osd_pvcs (list) – The old osd PVC objects before resizing the osd
old_osd_pvs (list) – The old osd PV objects before resizing the osd
- Raises:
ResourceWrongStatusException – If the following occurs: 1. The OSD pods failed to reach the status Terminated or to be deleted 2. The old PVC and PV names are not equal to the current PVC and PV names
- ocs_ci.ocs.resources.osd_resize.check_storage_size_is_reflected(expected_storage_size)
Check that the expected storage size is reflected in the current storage size, PVCs, PVs, and ceph capacity.
- Parameters:
expected_storage_size (str) – The expected storage size
- Raises:
StorageSizeNotReflectedException – If the current storage size, PVCs, PVs, and ceph capacity are not in the expected size
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:
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:
ResourceNameNotSpecifiedException – in case the name is not specified.
ChannelNotFound – in case the required channel doesn’t exist.
- 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:
CSVNotFound – In case no CSV found from approved install plans.
NoInstallPlanForApproveFoundException – In case no install plan for approve found.
- wait_for_resource(resource_name='', timeout=60, sleep=3, label=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
- Raises:
ResourceNameNotSpecifiedException – in case the name is not specified.
TimeoutExpiredError – in case the resource not found in timeout
- 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
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_from_pod_oc_exec(target_path, src_path, timeout=600, chunk_size=2000)
Copies to local path file from the pod using standard output stream via ‘oc exec’. Good for log/json/yaml/text files, not good for large files/binaries with one-line plain string * Hand data from the pod over oc exec cat, other standard output ways will fail for the files > 1 Mb
- Parameters:
target_path (str) – local path
src_path (str) – path within pod what you want to copy
timeout (int) – timeout in seconds until size of the local file will not reach the initial file size. 2000 lines is a maximum chunk size tested successfully
chunk_size (int) – file will be copied by chunks, by number of lines
- copy_to_pod_cat(src_path, target_path, timeout=60)
Copies to pod path from the local path file using standard output stream
- Parameters:
src_path (str) – local path
target_path (str) – path within pod where you want to copy
timeout (int) – timeout in seconds
- Returns:
stdout of the command
- Return type:
str
- copy_to_pod_rsync(src_path, target_path, container=None)
Copies to pod path from the local path
- Parameters:
src_path (str) – local path
target_path (str) – path within pod where you want to copy
container (str) – if multi-container pod you can specify the container name, by default its None
- Returns:
stdout of the command
- Return type:
str
- 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', out_yaml_format=True, timeout=600)
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
out_yaml_format (bool) – whether to return yaml loaded python object OR to return raw output
timeout (int) – timeout for the exec_cmd_on_pod, defaults to 600 seconds
- 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, container_name=None, cluster_config=None, **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
container_name (str) – The container name
cluster_config (MultiClusterConfig) – In case of multicluser scenario, this object will hold specific cluster’s Config
- 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', timeout=600, **kwargs)
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
timeout (int) – timeout for the exec_oc_cmd, defaults to 600 seconds
- Returns:
stdout of the command
- Return type:
str
- fillup_fs(size, fio_filename=None, performance_pod=False)
Execute FIO on a pod to fillup a file This will run sequential 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
performance_pod (bool) – True if this pod is the performance pod created with PERF_POD_YAML
- 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, invalidate=None, buffer_compress_percentage=None, buffer_pattern=None, readwrite=None, direct=0, verify=False, fio_installed=False, timeout=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
invalidate (bool) – Invalidate the buffer/page cache parts of the files to be used prior to starting I/O
buffer_compress_percentage (int) – If this is set, then fio will attempt to provide I/O buffer content (on WRITEs) that compresses to the specified level
buffer_pattern (str) – fio will fill the I/O buffers with this pattern
readwrite (str) – Type of I/O pattern default is randrw from yaml
direct (int) – If value is 1, use non-buffered I/O. This is usually O_DIRECT. Fio default is 0.
verify (bool) – This method verifies file contents after each iteration of the job. e.g. crc32c, md5
fio_installed (bool) – True if fio is already installed on the pod
timeout (int) – The timeout in seconds to wait for fio to be completed
- wait_for_pod_delete(resource_name=None, timeout=60)
Waits for the pod delete
- Parameters:
resource_name (str) – name of the pod
timeout (int) – time to wait in seconds
- Returns:
True
- Return type:
bool
- workload_setup(storage_type, jobs=1, fio_installed=False)
Do setup on pod for running FIO
- Parameters:
storage_type (str) – ‘fs’ or ‘block’
jobs (int) – Number of jobs to execute FIO
fio_installed (bool) – True if fio is already installed on the pod
- ocs_ci.ocs.resources.pod.cal_md5sum(pod_obj, file_name, block=False, raw_path=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.
raw_path (bool) – True if file_name includes the filepath and should be used as-is i.e. - a pod without a PVC attached to it
- Returns:
The md5sum of the file
- Return type:
str
- ocs_ci.ocs.resources.pod.calculate_md5sum_of_pod_files(pods_for_integrity_check, pod_file_name)
Calculate the md5sum of the pod files, and save it in the pod objects
- Parameters:
pods_for_integrity_check (list) – The list of the pod objects to calculate the md5sum
pod_file_name (str) – The pod file name to save the md5sum
- ocs_ci.ocs.resources.pod.check_ceph_cmd_execute_successfully()
Check that a Ceph command executes successfully
- Returns:
True, if the Ceph command executed successfully. False, otherwise
- Return type:
bool
- 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', pod_names=None, raise_pod_not_found_error=False, skip_for_status=None)
Checks whether the pods in a given namespace are in Running state or not. The pods which are in ‘Completed’ state will be skipped when checking for all pods in the namespace openshift-storage. ‘Completed’ will be the expected state of such pods.
- Parameters:
namespace (str) – Name of cluster namespace(default: config.ENV_DATA[“cluster_namespace”])
pod_names (list) – List of the pod names to check. If not provided, it will check all the pods in the given namespace
raise_pod_not_found_error (bool) – If True, it raises an exception, if one of the pods in the pod names are not found. If False, it ignores the case of pod not found and returns the pod objects of the rest of the pod names. The default value is False
skip_for_status (list) – List of pod status that should be skipped. If the status of a pod is in the given list, the check for ‘Running’ status of that particular pod will be skipped. eg: [“Pending”, “Completed”]
- Returns:
True, if all pods in Running state. False, otherwise
- Return type:
Boolean
- ocs_ci.ocs.resources.pod.check_pods_in_statuses(expected_statuses, pod_names=None, namespace='openshift-storage', raise_pod_not_found_error=False, exclude_pod_name_prefixes=None)
checks whether the pods in a given namespace are in the expected statuses or not
- Parameters:
expected_statuses (list) – The expected statuses of the pods
pod_names (list) – List of the pod names to check. If not provided, it will check all the pods in the given namespace
namespace (str) – Name of cluster namespace(default: config.ENV_DATA[“cluster_namespace”])
raise_pod_not_found_error (bool) – If True, it raises an exception, if one of the pods in the pod names are not found. If False, it ignores the case of pod not found and check the pod objects of the rest of the pod names. The default value is False
exclude_pod_name_prefixes (list) – The list of the pod name prefixes to exclude from the pods to check
- Returns:
True, if the pods are in the expected statuses. False, otherwise
- Return type:
Boolean
- ocs_ci.ocs.resources.pod.check_safe_to_destroy_status(osd_id)
check if it is safe to destroy the osd
- Parameters:
osd_id (str) – osd id
- Returns:
True, if it is safe to destroy the osd. False, otherwise
- Return type:
bool
- 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_all_osd_removal_jobs(namespace='openshift-storage')
Delete all the osd removal jobs in a specific namespace
- Parameters:
namespace (str) – Name of cluster namespace(default: config.ENV_DATA[“cluster_namespace”])
- Returns:
True, if all the jobs deleted successfully. False, otherwise
- Return type:
bool
- 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, cluster_config=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.exit_osd_maintenance_mode(osd_deployment)
Exit from osd maintenance mode
- Parameters:
osd_deployment (OCS) – List of OSD deployment OCS instances
- 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_alertmanager_managed_ocs_alertmanager_pods(label='alertmanager=managed-ocs-alertmanager', namespace=None)
Get alertmanager-managed-ocs-alertmanager pods in the cluster
- Parameters:
label (str) – Label associated with alertmanager-managed-ocs-alertmanager pods
namespace (str) – Namespace in which alertmanager-managed-ocs-alertmanager pods are residing
- Returns:
Pod objects of alertmanager-managed-ocs-alertmanager pods
- Return type:
list
- ocs_ci.ocs.resources.pod.get_all_pods(namespace=None, selector=None, selector_label='app', exclude_selector=False, wait=False, field_selector=None)
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
field_selector (str) – Selector (field query) to filter on, supports ‘=’, ‘==’, and ‘!=’. (e.g. status.phase=Running)
- Returns:
List of Pod objects
- Return type:
list
- ocs_ci.ocs.resources.pod.get_ceph_daemon_id(pod_obj)
Get Ceph Daemon ID of osd, mds, mon, rgw, mgr
- Parameters:
pod_obj (POD Obj) – pod object
- Returns:
ceph_daemon_id
- Return type:
str
- ocs_ci.ocs.resources.pod.get_ceph_tools_pod(skip_creating_pod=False, wait=False, namespace=None)
Get the Ceph tools pod
- Parameters:
skip_creating_pod (bool) – True if user doesn’t want to create new tool box if it doesn’t exist
wait (bool) – True if you want to wait for the tool pods to be Running
namespace – Namespace of OCS
- Returns:
The Ceph tools pod object
- Return type:
Pod object
- Raises:
ToolBoxNotFoundException – In case of tool box not found
- 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: config.ENV_DATA[“cluster_namespace”])
- Returns:
csi-cephfsplugin-provisioner Pod objects
- Return type:
list
- ocs_ci.ocs.resources.pod.get_containers_names_by_pod(pod: OCP) set
Gets the names of all containers in given pod or pods
- Parameters:
pod (ocp.OCP) – instance of OCP object that represents a pod (kind=POD)
- Returns:
hash set of names of all containers in given pod or pods
- Return type:
set
- ocs_ci.ocs.resources.pod.get_crashcollector_pods(crashcollector_label='app=rook-ceph-crashcollector', namespace=None)
Fetches info about crashcollector pods in the cluster
- Parameters:
crashcollector_label (str) – label associated with mon pods (default: defaults.CRASHCOLLECTOR_APP_LABEL)
namespace (str) – Namespace in which ceph cluster lives (default: config.ENV_DATA[“cluster_namespace”])
- Returns:
of crashcollector 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_debug_pods(debug_nodes, namespace='openshift-storage')
Get debug pods created for the nodes in debug
- Parameters:
debug_nodes (list) – List of nodes in debug mode
namespace (str) – By default ‘openshift-storage’ namespace
- Returns:
of Pod objects
- Return type:
List
- 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_device_path(pod_obj)
get device path from pod in block mode :param pod_obj: The object of the pod :type pod_obj: Pod
- Returns:
device path
- Return type:
str
- 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_lvm_operator_pod(label='app.kubernetes.io/name=lvms-operator', namespace='openshift-storage')
Get lvm operator controller manager pod in the lvm cluster
- Parameters:
label (str) – Label associated with lvm operator controller manager pod
namespace (str) – Namespace in which lvm operator controler manager pod is residing
- Returns:
Pod object of lvm operator controller manager pod
- Return type:
- ocs_ci.ocs.resources.pod.get_lvm_vg_manager_pod(label='app.kubernetes.io/name=vg-manager', namespace='openshift-storage')
Get vg manager pod in the lvm cluster
- Parameters:
label (str) – Label associated with vg manager pod
namespace (str) – Namespace in which vg manager pod is residing
- Returns:
Pod object of vg manager pod
- Return type:
- 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: config.ENV_DATA[“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: config.ENV_DATA[“cluster_namespace”])
- Returns:
of mgr pod objects
- Return type:
list
- ocs_ci.ocs.resources.pod.get_mon_label(mon_pod_obj)
Gets the mon pod label
- Parameters:
mon_pod_obj (Pod) – The pod object
- Returns:
The mon pod label (eg: a)
- Return type:
str
- ocs_ci.ocs.resources.pod.get_mon_pod_by_pvc_name(pvc_name: str)
Function to get monitor pod by pvc_name label
- Parameters:
pvc_name (str) – name of the pvc the monitor pod is related to
- ocs_ci.ocs.resources.pod.get_mon_pod_id(mon_pod)
Get the mon pod id
- Parameters:
mon_pod (ocs_ci.ocs.resources.pod.Pod) – The mon pod object
- Returns:
The mon pod id
- Return type:
str
- 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: config.ENV_DATA[“cluster_namespace”])
- Returns:
of mon pod objects
- Return type:
list
- ocs_ci.ocs.resources.pod.get_noobaa_core_pod()
Fetches Noobaa core pod details
- Returns:
Noobaa core pod object
- Return type:
Pod object
- ocs_ci.ocs.resources.pod.get_noobaa_db_pod()
Get noobaa db pod obj
- Returns:
Noobaa db pod object
- Return type:
Pod object
- ocs_ci.ocs.resources.pod.get_noobaa_endpoint_pods()
Fetches noobaa endpoint pod details
- Returns:
List containing noobaa endpoint pod objects
- Return type:
List
- ocs_ci.ocs.resources.pod.get_noobaa_operator_pod(ocs_label='noobaa-operator=deployment', namespace=None)
Fetches info about noobaa operator pod in the cluster
- Parameters:
ocs_label (str) – label associated with noobaa_operator pod (default: defaults.NOOBAA_OPERATOR_POD_LABEL)
namespace (str) – Namespace in which ceph cluster lives (default: none)
- Returns:
noobaa_operator pod object
- Return type:
Pod object
- 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: config.ENV_DATA[“cluster_namespace”])
- Returns:
of noobaa pod objects
- Return type:
list
- ocs_ci.ocs.resources.pod.get_not_running_pods(selector=None, namespace='openshift-storage')
Get all the non-running pods in a given namespace and give selector
- Returns:
all the pods that are not Running
- 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_ocs_osd_controller_manager_pod(label='control-plane=controller-manager', namespace=None)
Get ocs-osd-controller-manager pod in the cluster
- Parameters:
label (str) – Label associated with ocs-osd-controller-manager pod
namespace (str) – Namespace in which ocs-osd-controller-manager pod is residing
- Returns:
Pod object of ocs-osd-controller-manager pod
- Return type:
- ocs_ci.ocs.resources.pod.get_ocs_provider_server_pod(label='app=ocsProviderApiServer', namespace=None)
Get ocs-provider-server pod in the cluster
- Parameters:
label (str) – Label associated with ocs-provider-server pod
namespace (str) – Namespace in which ocs-provider-server pod is residing
- Returns:
Pod object of ocs-provider-server pod
- Return type:
- ocs_ci.ocs.resources.pod.get_odf_operator_controller_manager(ocs_label='control-plane=controller-manager', namespace=None)
Fetches info about odf operator control manager pod in the cluster
- Parameters:
ocs_label (str) – label associated with ocs_operator pod (default: defaults.ODF_OPERATOR_CONTROL_MANAGER_LABEL)
namespace (str) – Namespace in which ceph cluster lives (default: none)
- Returns:
odf_operator_controller_manager 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: config.ENV_DATA[“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: config.ENV_DATA[“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: config.ENV_DATA[“cluster_namespace”])
- Returns:
OSD prepare pod objects
- Return type:
list
- ocs_ci.ocs.resources.pod.get_osd_removal_pod_name(timeout=60)
Get the osd removal pod name
- Parameters:
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:
- 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_ip(pod_obj)
Get the pod ip
- Parameters:
pod_obj (Pod) – The pod object
- Returns:
The pod ip
- Return type:
str
- ocs_ci.ocs.resources.pod.get_pod_logs(pod_name, container=None, namespace='openshift-storage', previous=False, all_containers=False, since=None)
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. all_containers (bool): fetch logs from all containers of the resource since (str): only return logs newer than a relative duration like 5s, 2m, or 3h.
- 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:
- Raises:
NotFoundError when the node name is not found –
- 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_objs(pod_names, raise_pod_not_found_error=False, namespace='openshift-storage')
Get the pod objects of the specified pod names
- Parameters:
pod_names (list) – The list of the pod names to get their pod objects
namespace (str) – Name of cluster namespace(default: config.ENV_DATA[“cluster_namespace”])
raise_pod_not_found_error (bool) – If True, it raises an exception, if one of the pods in the pod names are not found. If False, it ignores the case of pod not found and returns the pod objects of the rest of the pod names. The default value is False
- Returns:
The pod objects of the specified pod names
- Return type:
list
- Raises:
ResourceNotFoundError – If ‘raise_pod_not_found_error’ is True, and not all the pod names were found
- ocs_ci.ocs.resources.pod.get_pod_restarts_count(namespace='openshift-storage', label=None)
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='openshift-storage', cluster_config=None, statuses=None)
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
cluster_config (MultiClusterConfig) – In case of multicluster, this object will hold specif cluster config
statuses (list) – List of pod statuses. Fetch only pods in any of the status mentioned in the statuses list
- Returns:
of pods info
- Return type:
list
- ocs_ci.ocs.resources.pod.get_pods_in_statuses(status_options, namespace='openshift-storage', exclude_pod_name_prefixes=None)
Get all the pods in specific statuses
- Parameters:
status_options (list) – The list of the status options.
namespace (str) – Name of cluster namespace(default: config.ENV_DATA[“cluster_namespace”])
exclude_pod_name_prefixes (list) – The list of the pod name prefixes to exclude from the pods to get
- Returns:
All the pods that their status in the ‘status_options’ list.
- Return type:
list
- ocs_ci.ocs.resources.pod.get_prometheus_managed_ocs_prometheus_pod(label='prometheus=managed-ocs-prometheus', namespace=None)
Get prometheus-managed-ocs-prometheus pod in the cluster
- Parameters:
label (str) – Label associated with prometheus-managed-ocs-prometheus pod
namespace (str) – Namespace in which prometheus-managed-ocs-prometheus pod is residing
- Returns:
Pod object of prometheus-managed-ocs-prometheus pod
- Return type:
- ocs_ci.ocs.resources.pod.get_prometheus_operator_pod(label='app.kubernetes.io/name=prometheus-operator', namespace=None)
Get prometheus-operator pod in the cluster
- Parameters:
label (str) – Label associated with prometheus-operator pod
namespace (str) – Namespace in which prometheus-operator pod is residing
- Returns:
Pod object of prometheus-operator pod
- Return type:
- 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: config.ENV_DATA[“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_rook_ceph_pod_names()
Get all the rook ceph pod names
- Returns:
List of the rook ceph pod names
- 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_topolvm_controller_pod(label='app.kubernetes.io/component=topolvm-controller', namespace='openshift-storage')
Get topolvm controller pod in the lvm cluster
- Parameters:
label (str) – Label associated with topolvm controller pod
namespace (str) – Namespace in which topolvm controler pod is residing
- Returns:
Pod object of topolvm controller pod
- Return type:
- ocs_ci.ocs.resources.pod.get_topolvm_node_pod(label='app.kubernetes.io/component=topolvm-node', namespace='openshift-storage')
Get topolvm node pod in the lvm cluster
- Parameters:
label (str) – Label associated with topolvm node pod
namespace (str) – Namespace in which topolvm node pod is residing
- Returns:
Pod object of topolvm node pod
- Return type:
- 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.pod_resource_utilization_raw_output_from_adm_top(namespace='openshift-storage')
Gets the pod’s memory utilization using adm top command.
- Parameters:
namespace (str) – The pod’s namespace where the adm top command has to be run
- Returns:
Raw output of adm top pods command
- Return type:
str
- ocs_ci.ocs.resources.pod.restart_pods_having_label(label, namespace='openshift-storage')
Restart the pods having particular label
- Parameters:
label (str) – Label of the pod
namespace (str) – namespace where the pods are running
- ocs_ci.ocs.resources.pod.restart_pods_in_statuses(status_options, namespace='openshift-storage', wait=True)
Restart all the pods in specific statuses
- Parameters:
status_options (list) – The list of the status options.
namespace (str) – Name of cluster namespace(default: config.ENV_DATA[“cluster_namespace”])
wait (bool) – Determines if the delete command should wait for completion
- Returns:
Restart all the pods that their status in the ‘status_options’ list.
- 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_ids=None)
Run the ocs-osd-removal job
- Parameters:
osd_ids (list) – The osd IDs.
- Returns:
The ocs-osd-removal job object
- Return type:
- ocs_ci.ocs.resources.pod.search_pattern_in_pod_logs(pod_name, pattern, namespace='openshift-storage', container=None, all_containers=False)
Searches for the given regular expression pattern in the logs of a pod and returns all matching lines.
- Parameters:
pod_name (str) – The name of the pod.
pattern (str) – The regular expression pattern to search for.
namespace (str, optional) – The namespace of the pod. Defaults to None.
container (str, optional) – The name of the container to search logs for. Defaults to None.
all_containers (bool, optional) – Whether to search logs for all containers in the pod. Defaults to False.
- Returns:
A list of matched lines with the pattern.
- ocs_ci.ocs.resources.pod.set_osd_maintenance_mode(osd_deployment)
Set osd in maintenance mode for running ceph-objectstore commands
- Parameters:
osd_deployment (OCS) – List of OSD deployment OCS instances
- 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_data_integrity_after_expansion_for_block_pvc(pod_obj, pvc_obj, fio_size)
Verifies data integrity the block PVC obj, by comparing the md5sum of data written using FIO before expansion and after expansion.
- ocs_ci.ocs.resources.pod.verify_data_integrity_for_multi_pvc_objs(pod_objs, pvc_objs, file_name)
Verifies existence and md5sum of file created during IO, for all the pods.
- Parameters:
pod_objs (list) – List of POD objects for which existence and md5sum of file created during IO needs to be verified.
pvc_objs (list) – List of original PVC objects.
file_name (str) – The name of the file for which md5sum is to be calculated.
- Raises:
AssertionError – Raises an exception if current md5sum does not match the original md5sum.
- ocs_ci.ocs.resources.pod.verify_md5sum_on_pod_files(pods_for_integrity_check, pod_file_name)
Verify the md5sum of the pod files
- Parameters:
pods_for_integrity_check (list) – The list of the pod objects to verify the md5sum
pod_file_name (str) – The pod file name to verify its md5sum
- 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_ceph_cmd_execute_successfully(timeout=300)
Wait for a Ceph command to execute successfully
- Parameters:
timeout (int) – The time to wait for a Ceph command to execute successfully
- Returns:
True, if the Ceph command executed successfully. False, otherwise
- Return type:
bool
- ocs_ci.ocs.resources.pod.wait_for_change_in_pods_statuses(pod_names, current_statuses=None, namespace='openshift-storage', timeout=300, sleep=20)
Wait for the pod statuses in a specific namespace to change.
- Parameters:
pod_names (list) – List of the pod names to check if their status changed.
namespace (str) – the namespace ot the pods
current_statuses (list) – The current pod statuses. These are the pod statuses to check if they changed during each iteration.
timeout (int) – time to wait for pod statuses to change
sleep (int) – Time in seconds to sleep between attempts
- Returns:
True, if the pod statuses have changed. False, otherwise
- Return type:
bool
- 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_noobaa_pods_running(timeout=300, sleep=10)
Wait until all the noobaa pods have reached status RUNNING
- Parameters:
timeout (int) – Timeout in seconds
- ocs_ci.ocs.resources.pod.wait_for_osd_pods_having_ids(osd_ids, timeout=180, sleep=10)
Wait for the osd pods having specific ids
- Parameters:
osd_ids (list) – The list of the osd ids
timeout (int) – Time to wait for the osd pods having the specified ids
sleep (int) – Time in seconds to sleep between attempts
- Returns:
The osd pods having the specified ids
- Return type:
list
- Raises:
TimeoutExpiredError – In case it didn’t find all the osd pods with the specified ids
- ocs_ci.ocs.resources.pod.wait_for_pods_by_label_count(label, exptected_count, namespace='openshift-storage', timeout=200, sleep=10)
Wait for the expected number of pods with the given selector.
- Parameters:
selector (str) – The resource selector to search with
exptected_count (int) – The expected number of pods with the given selector
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
- ocs_ci.ocs.resources.pod.wait_for_pods_deletion(label, timeout=120, sleep=5, namespace='openshift-storage')
Wait for the pods with particular label to be deleted until the given timeout
- Parameters:
label (str) – Pod label
timeout (int) – Timeout
namespace (str) – Namespace in which pods are running
- Raises:
- ocs_ci.ocs.resources.pod.wait_for_pods_to_be_in_statuses(expected_statuses, pod_names=None, namespace='openshift-storage', raise_pod_not_found_error=False, exclude_pod_name_prefixes=None, timeout=180, sleep=10)
Wait for the pods in a given namespace to be in the expected statuses
- Parameters:
expected_statuses (list) – The expected statuses of the pods
pod_names (list) – List of the pod names to check. If not provided, it will check all the pods in the given namespace
namespace (str) – Name of cluster namespace(default: config.ENV_DATA[“cluster_namespace”])
raise_pod_not_found_error (bool) – If True, it raises an exception, if one of the pods in the pod names are not found. If False, it ignores the case of pod not found and check the pod objects of the rest of the pod names. The default value is False
exclude_pod_name_prefixes (list) – The list of the pod name prefixes to exclude from the pods to check
timeout (int) – time to wait for the pods to be in the expected statuses
sleep (int) – Time in seconds to sleep between attempts
- Returns:
True, if all pods are in the expected statuses. False, otherwise
- Return type:
Boolean
- ocs_ci.ocs.resources.pod.wait_for_pods_to_be_running(namespace='openshift-storage', pod_names=None, raise_pod_not_found_error=False, timeout=200, sleep=10)
Wait for all the pods in a specific namespace to be running.
- Parameters:
namespace (str) – the namespace ot the pods
pod_names (list) – List of the pod names to check. If not provided, it will check all the pods in the given namespace
raise_pod_not_found_error (bool) – If True, it raises an exception(in the function ‘check_pods_in_running_state’), if one of the pods in the pod names are not found. If False, it ignores the case of pod not found and returns the pod objects of the rest of the pod names. The default value is False
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.check_pvs_present_for_ocs_expansion(sc='localblock')
Check for pvs present for OCS cluster expansion
- Parameters:
sc (str) – Name of SC
- Returns:
True if pv present false if not
- Return type:
bool
- 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(selector=None)
Gets all pv in openshift-storage namespace
- Parameters:
selector (str) – The Selector name
- Returns:
Dict of all pv in openshift-storage namespace
- Return type:
dict
- ocs_ci.ocs.resources.pv.get_node_pv_objs(sc_name, node_name)
Get the pv objects that associated to a node in a specific Storage class
- Parameters:
sc_name (str) – The storage class name
node_name (str) – The node name
- Returns:
list of dictionaries of the pv objects that associated to the node name
- Return type:
list
- 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, convert_size=1024)
Get the size of a pv object in GB
- Parameters:
pv_obj (dict) – A dictionary that represent the pv object
convert_size (int) – set convert by 1024 or 1000
- 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_pvs_available_in_sc(old_pv_objs, sc_name, num_of_new_pvs=1, 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
num_of_new_pvs (int) – Number of the new pvs that should be available in 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
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:
- property backed_sc
Returns the storage class of pvc object in namespace
- Returns:
Storage class name
- Return type:
str
- create_reclaim_space_cronjob(schedule=None)
Create ReclaimSpaceCronJob to invoke reclaim space operation on RBD volume
- Returns:
An OCS object representing ReclaimSpaceCronJob
- Return type:
- create_reclaim_space_job()
Create ReclaimSpaceJob to invoke reclaim space operation on RBD volume
- Returns:
An OCS object representing ReclaimSpaceJob
- Return type:
- 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:
- 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_pv_volume_handle_name
Fetch volume handle name from PV
- Returns:
volume handle name from pv
- Return type:
str
- property get_pvc_access_mode
Function to get pvc access_mode
- Returns:
The accessModes Value of pvc_obj
- Return type:
(str)
- property get_pvc_vol_mode
Function to get pvc volume_mode
- Returns:
The volumeMode Value of pvc_obj
- Return type:
str
- property get_rbd_image_name
Fetch image name associated with the RBD PVC
- Returns:
Image name associated with the RBD PVC
- 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, namespace, 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.
namespace (str) – Namespace of the parent pvc
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:
- ocs_ci.ocs.resources.pvc.create_pvc_snapshot(pvc_name, snap_yaml, snap_name, namespace, 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
namespace (str) – The namespace for the snapshot creation
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/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:
- 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.pvc.get_pvc_objs(pvc_names, namespace='openshift-storage')
Get the PVC objects of the specified names
- Parameters:
pvc_names (list) – The list of the pvc names to get their objects
namespace (str) – Name of cluster namespace(default: config.ENV_DATA[“cluster_namespace”])
- Returns:
The PVC objects of the specified names
- Return type:
list
- ocs_ci.ocs.resources.pvc.get_pvc_size(pvc_obj, convert_size=1024)
Returns the PVC size in GB
- Parameters:
pvc_obj (ocs_ci.ocs.resources.ocs.OCS) – The pvc object
convert_size (int) – set convert by 1024 or 1000
- Returns:
PVC size
- Return type:
int
- ocs_ci.ocs.resources.pvc.scale_down_pods_and_remove_pvcs(sc_name)
Removes the mon and osd pods and also removes PVC’s
- Parameters:
sc_name (str) – Name of storage class backing PVC
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:
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_extra_disk_to_existing_worker=True)
Add storage capacity to the cluster
- Parameters:
osd_size_capacity_requested (int) – Requested osd size capacity
add_extra_disk_to_existing_worker (bool) – Add Disk if True
- 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.add_capacity_lso(ui_flag=False)
Add capacity on LSO cluster.
In this procedure we need to add the disk before add capacity via UI. Because the UI backend check the pv and available state and base on it change the count param on StorageCluster.
- Parameters:
ui_flag (bool) – add capacity via ui [true] or via cli [false]
- ocs_ci.ocs.resources.storage_cluster.basic_verification(ocs_registry_image=None)
Basic verification which is needed for Full deployment and MCG only deployment
- Parameters:
ocs_registry_image (str) – Specific image to check if it was installed properly.
- ocs_ci.ocs.resources.storage_cluster.ceph_config_dump()
Get the ‘ceph config dump’ output.
- Returns:
The output of the ‘ceph config dump’ command as a dict.
- Return type:
dict
- ocs_ci.ocs.resources.storage_cluster.ceph_mon_dump()
Get the ‘ceph mon dump’ output.
- Returns:
The output of the ‘ceph mon dump’ command as a dictionary.
- Return type:
dict
- ocs_ci.ocs.resources.storage_cluster.check_custom_storageclass_presence(interface=None)
Verify if the custom-defined storage class names are present in the oc get sc output.
- Returns:
Returns True if all custom-defined storage class names are present in the oc get sc output , otherwise False.
- Return type:
bool
- 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_ceph_clients()
Get the yamls of all ceph clients. Runs on provider cluster
- Returns:
yamls of all ceph clients
- Return type:
list
- ocs_ci.ocs.resources.storage_cluster.get_consumer_storage_provider_endpoint()
Get the consumer “storageProviderEndpoint” from the ocs storage cluster
- Returns:
The consumer “storageProviderEndpoint”
- Return type:
str
- ocs_ci.ocs.resources.storage_cluster.get_device_class()
Fetches the device class from storage cluster
- Returns:
Device class name
- Return type:
str
- 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_in_transit_encryption_config_state()
Returns the state of in-transit encryption for the OCS cluster.
- Returns:
True if in-transit encryption is enabled, False if it is disabled, or None if an error occurred.
- Return type:
bool
- 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_replica_count()
Get OSD replication count from storagecluster cr
- Returns:
Returns OSD replication count
- Return type:
replica_count (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_rook_ceph_mon_per_endpoint_ip()
Get a dictionary of the rook ceph mon per endpoint ip
- Returns:
A dictionary of the rook ceph mon per endpoint ip
- Return type:
dict
- ocs_ci.ocs.resources.storage_cluster.get_storage_cluster(namespace=None)
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.get_storage_cluster_state(sc_name, namespace=None)
Get the storage cluster state
- Parameters:
sc_name (str) – The storage cluster name
namespace (str) – Namespace of the resource. The default value is: ‘config.ENV_DATA[“cluster_namespace”]’ if None provided
- Returns:
The storage cluster state
- Return type:
str
- ocs_ci.ocs.resources.storage_cluster.get_storage_size()
Get the storagecluster storage size
- Returns:
The storagecluster storage size
- Return type:
str
- ocs_ci.ocs.resources.storage_cluster.get_storageclass_names_from_storagecluster_spec()
Retrieve storage class names from the storage cluster’s spec.
This function queries the storage cluster’s specification and returns a dictionary containing the storage class names for various resources, such as cephFilesystems, cephObjectStores, cephBlockPools, cephNonResilientPools, nfs, and encryption.
- Returns:
- A dictionary containing the storage class names for various resources.
The keys are the names of the resources, and the values are the respective storage class names. If a resource does not have a storage class name, it will be set to None.
- Return type:
dict
- ocs_ci.ocs.resources.storage_cluster.in_transit_encryption_verification()
Verifies in-transit encryption is enabled and ceph mons are configured with ‘v2’ protocol version.
- Raises:
ValueError – if in-transit encryption is not configured or ceph mon protocol is not configured with ‘v2’ version.
- ocs_ci.ocs.resources.storage_cluster.mcg_only_install_verification(ocs_registry_image=None)
Verification for successful MCG only deployment
- Parameters:
ocs_registry_image (str) – Specific image to check if it was installed properly.
- 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:
UnsupportedFeatureError – OCS version is smaller than 4.6
EnvironmentError – The OSD is not encrypted
- ocs_ci.ocs.resources.storage_cluster.patch_storage_cluster_for_custom_storage_class(storage_class_type, storage_class_name=None, action='add')
Patch the storage cluster for a custom storage class.
This function updates the storage cluster’s storage class settings based on the provided storage class type.
- Parameters:
storage_class_type (str) – The type of storage class (“nfs”, “encryption”, etc.).
storage_class_name (str, optional) – The name of the custom storage class to be set. If None, a default name will be generated.
action (str, optional) – The action to perform (“add” or “remove”).
- Returns:
Result of the patch operation.
- Return type:
bool
- ocs_ci.ocs.resources.storage_cluster.resize_osd(new_osd_size, check_size=True)
Resize the OSD(e.g., from 512 to 1024, 1024 to 2048, etc.)
- Parameters:
new_osd_size (str) – The new osd size(e.g, 512Gi, 1024Gi, 1Ti, 2Ti, etc.)
check_size (bool) – Check that the given osd size is valid
- Returns:
True in case if changes are applied. False otherwise
- Return type:
bool
- Raises:
ValueError – In case the osd size is not valid(start with digits and follow by string) or the new osd size is less than the current osd size
- ocs_ci.ocs.resources.storage_cluster.set_deviceset_count(count)
Set osd count for Storage cluster.
- Parameters:
count (int) – the count param is storagecluster
- ocs_ci.ocs.resources.storage_cluster.set_in_transit_encryption(enabled=True)
Enable or disable in-transit encryption for the default storage cluster.
- Parameters:
enabled (bool, optional) – A boolean indicating whether to enable or disable in-transit encryption. Defaults to True, i.e., enabling in-transit encryption.
- Returns:
True if in-transit encryption was successfully enabled or disabled, False otherwise.
- Return type:
bool
- 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.storage_cluster.validate_serviceexport()
validate the serviceexport resource Number of osds and mons should match
- ocs_ci.ocs.resources.storage_cluster.verify_backing_store()
Verify backingstore
- ocs_ci.ocs.resources.storage_cluster.verify_consumer_resources()
Verify resources specific to managed OCS consumer: 1. MGR endpoint 2. monitoring endpoint in cephcluster yaml 3. Verify the default Storageclassclaims
- ocs_ci.ocs.resources.storage_cluster.verify_consumer_storagecluster(sc_data)
Verify that Storagecluster is has: 1. externalStorage: enable: true 2. storageProviderEndpoint: IP:31659 3. onboardingTicket is present 4. catsrc existence 5. requested capacity matches granted capacity 6. requested and granted capacity fields have a valid value
Args: sc_data (dict): storagecluster data dictionary
- ocs_ci.ocs.resources.storage_cluster.verify_device_class_in_osd_tree(ct_pod, device_class)
Verifies device class in ceph osd tree output
- Parameters:
ct_pod (
OCP
) – Object of the Ceph tools poddevice_class (str) – Name of the device class
- ocs_ci.ocs.resources.storage_cluster.verify_kms_ca_only()
Verify KMS deployment with only CA Certificate without Client Certificate and without Client Private Key
- ocs_ci.ocs.resources.storage_cluster.verify_managed_secrets()
Verify that ocs-converged-pagerduty, ocs-converged-smtp, ocs-converged-deadmanssnitch, addon-ocs-provider-parameters, alertmanager-managed-ocs-alertmanager-generated, rook-ceph-mon secrets exist in openshift-storage namespace. For a provider cluster verify existence of onboarding-ticket-key and ocs-provider-server secrets. For a consumer cluster verify existence of 5 rook-ceph-client secrets
- ocs_ci.ocs.resources.storage_cluster.verify_managed_service_networkpolicy()
Verify Networkpolicy and EgressNetworkpolicy creation Temporarily left out for V2 offering
- ocs_ci.ocs.resources.storage_cluster.verify_managed_service_resources()
Verify creation and status of resources specific to OSD and ROSA deployments: 1. ocs-operator, ose-prometheus-operator csvs are Succeeded 2. 1 prometheus and 1 alertmanager pods are in Running state 3. Managedocs components alertmanager, prometheus, storageCluster are in Ready state 4. Verify that noobaa-operator replicas is set to 0 5. Verify managed ocs secrets 6. If cluster is Provider, verify resources specific to provider clusters 7. Verify that version of Prometheus is 4.10 8. Verify security restrictions are in place 9. [temporarily left out] Verify Networkpolicy and EgressNetworkpolicy creation
- ocs_ci.ocs.resources.storage_cluster.verify_managedocs_security()
Check ocs-osd-deployer-operator permissions: 1. Verify runAsUser is not 0 2. Verify SecurityContext.allowPrivilegeEscalation is set to false 3. Verify SecurityContext.capabilities.drop contains ALL
- ocs_ci.ocs.resources.storage_cluster.verify_max_openshift_version()
Verify the maximum OpenShift version supported for ODF
- ocs_ci.ocs.resources.storage_cluster.verify_mcg_only_pods()
Verify pods in MCG Only deployment
- ocs_ci.ocs.resources.storage_cluster.verify_multus_network()
Verify Multus network(s) created successfully and are present on relevant pods.
- ocs_ci.ocs.resources.storage_cluster.verify_networks_in_ceph_pod(pod_networks, net_name, net_namespace)
Verify network configuration on ceph pod
- Parameters:
pod_networks (str) – the value of k8s.v1.cni.cncf.io/networks param
net_name (str) – the network-attachment-definitions name
net_namespace (str) – the network-attachment-definitions namespace
- Returns:
return True if net_name and net_namespce exist in pod_networks otherwise False
- Return type:
bool
- ocs_ci.ocs.resources.storage_cluster.verify_noobaa_endpoint_count()
Verify noobaa endpoints
- ocs_ci.ocs.resources.storage_cluster.verify_ocs_csv(ocs_registry_image=None)
OCS CSV verification ( succeeded state )
- Parameters:
ocs_registry_image (str) – Specific image to check if it was installed properly.
- ocs_ci.ocs.resources.storage_cluster.verify_osd_tree_schema(ct_pod, deviceset_pvcs)
Verify Ceph OSD tree schema
- Parameters:
ct_pod (
OCP
) – Object of the Ceph tools poddeviceset_pvcs (list) – List of strings of deviceset PVC names
- ocs_ci.ocs.resources.storage_cluster.verify_provider_resources()
Verify resources specific to managed OCS provider: 1. Ocs-provider-server pod is Running 2. cephcluster is Ready and its hostNetworking is set to True 3. Security groups are set up correctly
- ocs_ci.ocs.resources.storage_cluster.verify_provider_storagecluster(sc_data)
Verify that storagecluster of the provider passes the following checks: 1. allowRemoteStorageConsumers: true 2. hostNetwork: true 3. matchExpressions: key: node-role.kubernetes.io/worker operator: Exists key: node-role.kubernetes.io/infra operator: DoesNotExist 4. storageProviderEndpoint: IP:31659 5. annotations: uninstall.ocs.openshift.io/cleanup-policy: delete uninstall.ocs.openshift.io/mode: graceful
- Parameters:
sc_data (dict) – storagecluster data dictionary
- ocs_ci.ocs.resources.storage_cluster.verify_sc_images(storage_cluster)
Verifying images in storage cluster such as ceph, noobaaDB and noobaaCore
- Parameters:
storage_cluster (obj) – storage_cluster ocp object
- ocs_ci.ocs.resources.storage_cluster.verify_storage_cluster()
Verify storage cluster status
- ocs_ci.ocs.resources.storage_cluster.verify_storage_cluster_images()
Verify images in storage cluster
- ocs_ci.ocs.resources.storage_cluster.verify_storage_cluster_version(storage_cluster)
Verifies the storage cluster version
- Parameters:
storage_cluster (obj) – storage cluster object
- ocs_ci.ocs.resources.storage_cluster.verify_storage_device_class(device_class)
Verifies the parameters of storageClassDeviceSets in CephCluster.
For internal deployments, if user is not specified any DeviceClass in the StorageDeviceSet, then tunefastDeviceClass will be true and crushDeviceClass will set to “ssd”
- Parameters:
device_class (str) – Name of the device class
- ocs_ci.ocs.resources.storage_cluster.verify_storage_system()
Verify storage system status
- ocs_ci.ocs.resources.storage_cluster.wait_for_consumer_rook_ceph_mon_endpoints_in_provider_wnodes(timeout=180, sleep=10)
Wait for the rook ceph mon endpoint ips to be found in the provider worker node ips
- Parameters:
timeout (int) – The time to wait for the rook ceph mon endpoint ips to be found in the provider worker node ips
sleep (int) – Time in seconds to sleep between attempts
- Returns:
- True, If all the rook ceph mon endpoint ips are found in the
provider worker nodes. False, otherwise.
- Return type:
bool
- ocs_ci.ocs.resources.storage_cluster.wait_for_consumer_storage_provider_endpoint_in_provider_wnodes(timeout=180, sleep=10)
Wait for the consumer “storageProviderEndpoint” ip to be found in the provider worker node ips
- Parameters:
timeout (int) – timeout in seconds to wait for the consumer “storageProviderEndpoint” ip to be found in the provider worker node ips
sleep (int) – Time in seconds to sleep between attempts
- Returns:
- True, if the consumer “storageProviderEndpoint” ip is found in the
provider worker node ips. False, otherwise.
ocs_ci.ocs.resources.storageclassclaim module
StorageClassClaim related functionalities
- class ocs_ci.ocs.resources.storageclassclaim.StorageClassClaim(**kwargs)
Bases:
OCS
StorageClassClaim kind resource
- property status
Returns the storageclassclaim status
- Returns:
Storageclassclaim status
- Return type:
str
- property storageclassclaim_type
Returns the type of the storageclassclaim
- Returns:
Storageclassclaim type
- Return type:
str
- ocs_ci.ocs.resources.storageclassclaim.create_storageclassclaim(interface_type, storage_class_claim_name=None, namespace=None, storageclient_name=None, storageclient_namespace=None)
Create a storageclassclaim
- Parameters:
interface_type (str) – The type of the interface (e.g. CephBlockPool, CephFileSystem)
storage_class_claim_name (str) – The name of storageclassclaim to create
namespace (str) – The namespace in which the storageclassclaim should be created
storageclient_name (str) – Name of the storageclient
storageclient_namespace (str) – Namespace of storageclient
- Returns:
An OCS instance for the storageclassclaim
- Return type:
ocs_ci.ocs.resources.storageconsumer module
A module for all StorageConsumer functionalities and abstractions.
- class ocs_ci.ocs.resources.storageconsumer.StorageConsumer(consumer_name, consumer_context=None)
Bases:
object
Base StorageConsumer class
- get_heartbeat_cronjob()
- Returns:
status reporter cronjob OCS object
- Return type:
object
- get_ocs_version()
Get ocs version from storageconsumer resource.
- Returns:
consumer ocs version
- Return type:
string
- resume_heartbeat()
Resume status reporter cron job.
- set_ocs_version(version)
Update ocs consumer version in storageconsumer resource. This change assumes that the hearthbeat is stopped so that the version is not overwritten by it.
- Parameters:
version (str) – OCS version to be set
- stop_heartbeat()
Suspend status reporter cron job.
ocs_ci.ocs.resources.stretchcluster module
- class ocs_ci.ocs.resources.stretchcluster.StretchCluster(**kwargs)
Bases:
OCS
A basic StrethCluster class to objectify stretch cluster related operations, methods and properties
- cephfs_failure_checks(start_time, end_time, wait_for_read_completion=True)
Checks cephFs workloads for write or read pause between start_time and end_time
- Parameters:
start_time (datetime) – Start time of the failure
end_time (datetime) – End time of the failure
wait_for_read_completion (bool) – True if needs to be waited for the read operation to complete else False
- property cephfs_log_file_map
- property cephfs_logreader_pods
- property cephfs_logwriter_pods
- property cephfs_old_log
- check_ceph_accessibility(timeout, delay=5, grace=15)
Check for ceph access for the ‘timeout’ seconds
- Parameters:
timeout (int) – timeout in seconds
delay (int) – how often ceph access should be checked in seconds
grace (int) – grace time to wait for the ceph to respond in seconds
- Returns:
True of no ceph accessibility issues else False
- Return type:
Bool
- check_for_data_corruption(label, namespace='sc-project')
Check for data corruption
- Parameters:
label (str) – Label for workload type
namespace (str) – namespace
- Returns:
True if no data corruption else False
- Return type:
Bool
- check_for_data_loss(label)
Check for data loss
- Parameters:
label (str) – Label for workload type
- Returns:
True if no data loss else False
- Return type:
Bool
- check_for_read_pause(label, start_time, end_time)
This checks for any read pause has occurred during the given window of start_time and end_time
- Parameters:
label (str) – label for the workload (RBD or CephFS)
start_time (datetime) – datetime object representing the start time
end_time (datetime) – datetime object representing the end time
- Returns:
number of logreader instances has seen read pause
- Return type:
Int
- check_for_write_pause(label, start_time, end_time)
Checks for write pause between start time and end time
- Parameters:
label (str) – Label for the workload
start_time (datetime) – datetime object representing the start time
end_time (datetime) – datetime object representing the end time
- Returns:
number of instances has seen write pause
- Return type:
Int
- get_logfile_map(label)
Update map of logfiles created by each workload types
- Parameters:
label (str) – Label for the workload
- get_logwriter_reader_pods(label, exp_num_replicas=None, statuses=None, namespace='sc-project')
Update logwriter and reader pods for the mentioned workload type
- Parameters:
label (str) – Label for the workload type
exp_num_replicas (int) – Expected number of replicas
statuses (List) – List of statuses that is expected
namespace (str) – namespace
- get_nodes_in_zone(zone)
This will return the list containing OCS objects represeting the nodes having mentioned label
- Parameters:
zone (str) – string represeting zone that node
to (belongs) –
- Returns:
Node (OCS) objects
- Return type:
List
- get_ocs_nodes_in_zone(zone)
Get the OCS nodes in a particular zone
- Parameters:
zone (str) – Zone that node belongs to
- Returns:
Node(OCS) objects
- Return type:
List
- get_out_of_quorum_nodes()
Get the zone nodes where the mon’s are not in quorum
- Returns:
List of non-quorum node names
- get_workload_pvc_obj(workload_label)
Gets the PVC object for the volume attached to the workload type mentioned by label
- Parameters:
workload_label (str) – Label for the workload
- Returns:
PVC object
- post_failure_checks(start_time, end_time, types=['rbd', 'cephfs'], wait_for_read_completion=True)
Post failure checks that will check for any failure during start_time and end_time
- Parameters:
start_time (datetime) – Start time of the failure
end_time (datetime) – End time of the failure
types (list) – List containing workload types, default., [“rbd”, “cephfs”]
wait_for_read_completion (bool) – True if needs to be waited for the read operation to complete else False
- rbd_failure_checks(start_time, end_time, **kwargs)
Checks RBD workloads for write or read pause between start_time and end_time
- Parameters:
start_time (datetime) – Start time of the failure
end_time (datetime) – End time of the failure
- property rbd_log_file_map
- property rbd_logwriter_pods
- property rbd_old_log
- reset_conn_score()
Reset connection scores for all the mon’s
- validate_conn_score(conn_score_map, quorum_ranks)
Validate connection score of each mons from the connection score map
- Parameters:
conn_score_map (dict) – Dict map representing connection score for each mons
quorum_ranks (list) – Expected mon quorum ranks at the moment
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()
ocs_ci.ocs.resources.topology module
- ocs_ci.ocs.resources.topology.drop_topology_constraint(spec_dict, topology_key)
Removes constraints for given topology key from given dict spec with topologySpreadConstraints. If the constraint is not present, the spec dict is not changed.
- Parameters:
tsc_dict (dict) – topologySpreadConstraints spec
topology_key (string) – name of the topology key