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:
objectA class that represents BackingStore objects
- delete(retry=True, timeout=240)
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, cluster_context=<class 'ocs_ci.framework.MultiClusterConfig.RunWithProviderConfigContextIfAvailable'>)
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
cluster_context (object) – context object in which the bucket will be created. Default is provider context.
- Returns:
- Factory method - each call to this function creates
a backingstore
- Return type:
func
- ocs_ci.ocs.resources.backingstore.clone_bs_dict_from_backingstore(protype_backingstore_name, namespace=None)
Create a backingstore of the same kind and specs as an existing backingstore.
- Parameters:
protype_backingstore_name (str) – Name of the existing backingstore to clone
backingstore_factory (function) – an backingstore factory instance
mcg_obj (MCG) – MCG object containing data and utils related to MCG
method (str) – Method to use for creating the backingstore (oc or cli)
namespace (str) – Namespace of the backingstore to clone
- Raises:
UnavailableResourceException – If the backingstore to clone does not exist
UnaknownCloneTypeException – If the prototype backingstore is of an unknown type
- Returns:
A dictionary containing the specs needed to create a copy of the prototype backingstore
- Return type:
clone_bs_dict (dict)
- ocs_ci.ocs.resources.backingstore.get_backingstore()
Fetches the backingstore
- Returns:
backingstore details
- Return type:
dict
ocs_ci.ocs.resources.bucket_logging_manager module
- class ocs_ci.ocs.resources.bucket_logging_manager.BucketLoggingManager(mcg_obj=None, awscli_pod=None)
Bases:
objectThis class facilitates MCG bucket logs management
- await_and_verify_bucket_logs(logs_bucket, source_bucket, expected_ops, check_intent=False, timeout=600, sleep=10)
Poll the target logs bucket until all expected operations are found in the logs.
Unlike await_interm_logs_transfer, this method checks the final destination directly, avoiding a race where intermediate logs are transferred before the first poll.
- Parameters:
logs_bucket (str) – Name of the logs bucket
source_bucket (str) – Name of the source bucket to filter by
expected_ops (list) – A list of tuples representing operations. I.E [(‘PUT’, ‘object1’), (‘GET’, ‘object2’)]
check_intent (bool) – Whether to also verify intent logs
timeout (int) – The maximum time to wait for the logs
sleep (int) – Time to sleep between each check
- Returns:
The verified list of log dicts from the logs bucket
- Return type:
list
- Raises:
TimeoutError – If the expected logs were not found in time
- await_interm_logs_transfer(logs_bucket, timeout=600, sleep=10)
Wait for intermediate logs to be moved from the logging PVC to their final destination in a specified logs bucket
- Parameters:
logs_bucket (str) – Name of the logs bucket
timeout (int) – The maximum time to wait for the logs to be moved
sleep (int) – Time to sleep between each check
- Raises:
TimeoutError – If the logs were not transferred in time
- cur_logs_pvc = 'noobaa-bucket-logging-pvc'
- disable_bucket_logging_on_cr()
Unset the guaranteed bucket logs feature
- enable_bucket_logging_on_cr(logs_pvc=None)
Set the guaranteed bucket logs feature
- Parameters:
logs_pvc (str|optional) – Name of the bucket logs PVC
Note – If not provided, a PVC will be automatically be created by MCG when first enabling the feature.
- get_bucket_logging(bucket_name)
Get the logging configuration for a given bucket
- Parameters:
bucket_name (str) – Name of the bucket
- Returns:
Logging configuration for the bucket
- Return type:
dict
- get_bucket_logs(logs_bucket, source_bucket=None)
Get the logs from a logs bucket
- Parameters:
logs_bucket (str) – Name of the logs bucket
source_bucket (str|optional) – Filter logs by source bucket
- Returns:
A list of dicts, deserialized from the JSON logs
- Return type:
list
- get_interm_logs(source_bucket=None, logs_bucket=None)
Get the logs from the logging PVC via the noobaa-core pod
- Parameters:
source_bucket (str|optional) – Filter logs by source bucket
logs_bucket (str|optional) – Filter logs by logs bucket
- Returns:
A list of dicts, deserialized from the JSON logs
- Return type:
list
- get_logging_config_from_cr()
Return the NooBaa bucket logging configuration
- Returns:
Bucket logging configuration
- Return type:
dict
- property nb_config_resource
Return the NooBaa configuration resource Note that this might change in the future.
- Returns:
OCP instance of the NooBaa configuration resource
- Return type:
- put_bucket_logging(bucket_name, logs_bucket_name, prefix='', verify=True)
Set the logs bucket on the source bucket using the AWS CLI
- Parameters:
bucket_name (str) – Name of the source bucket
logs_bucket_name (str) – Name of the logs bucket
prefix (str) – Prefix for the logs
verify (bool) – Whether to verify and wait for the config to propogate
- remove_bucket_logging(bucket_name)
Remove the logging configuration from a bucket
- Parameters:
bucket_name (str) – Name of the bucket
- verify_logs_integrity(logs, expected_ops, check_intent=False)
Check whether all the expected operations are present in the logs, including intent logs if specified.
Note that this implementation assumes that each operation was only made once.
- Parameters:
logs (list) – A list of dicts, deserialized from the JSON logs
expected_ops (list) – A list of tuples representing operations. I.E [(‘PUT’, ‘object1’), (‘GET’, ‘object2’)]
check_intent (bool) – Whether to check for intent logs
- Returns:
True if all the expected operations are present, False otherwise
- Return type:
bool
- wait_for_logs_pvc_mount_status(mount_status_expected=True, timeout=300)
Wait for the noobaa-core and noobaa-endpoint pods to mount or unmount the bucket logs PVC.
- Parameters:
mount_status_expected (bool) – If True, wait for the pods to mount the PVC, otherwise wait for them to unmount it.
timeout (int) – The maximum time to wait for the pods to change the logs PVC status.
- Returns:
True if all the pods have mounted/unmounted the PVC, False otherwise.
- Return type:
bool
ocs_ci.ocs.resources.bucket_notifications_manager module
- class ocs_ci.ocs.resources.bucket_notifications_manager.BucketNotificationsManager
Bases:
objectA class to manage the MCG bucket notifications feature
- add_notif_conn_to_noobaa_cr(secret, wait=True)
Add a connection secret to list of bucket notifications connections in the NooBaa CR.
- Parameters:
secret (ocs_ci.ocs.ocp.OCP) – OCP instance of the secret to add
wait (bool) – Whether to wait for the NooBaa resources to be ready
- cleanup()
Clean up the resources created by the BucketNotificationsManager 1. Disable bucket notifications on the NooBaa CR 2. Delete connection secrets 3. Delete Kafka topics 4. Clean up the AMQ cluster
- create_and_register_kafka_topic_with_noobaa(topic_name='', wait=True)
Create a Kafka topic and register it with NooBaa via a connection secret
- Parameters:
topic_name (str|optional) – Name of the Kafka topic
wait (bool) – Whether to wait for the NooBaa resources to be ready
- Returns:
Kafka topic name and MCG’s Path to the connection config file
- Return type:
tuple
- create_kafka_conn_secret(topic)
Create secret from a JSON file that defines the Kafka connection for NooBaa to use
- Parameters:
topic (str) – Name of the Kafka topic
- Returns:
OCP instance of the created secret conn_config_path: MCG’s Path to the connection config file
- Return type:
secret_ocp_obj
- create_kafka_topic(topic_name='')
Create a KafkaTopic - a receiver of bucket notifications
- Parameters:
topic_name (str|optional) – Name of the Kafka topic
- Returns:
Name of the created Kafka topic
- Return type:
str
- disable_bucket_logging_on_cr()
Unset the bucket notifications feature on the NooBaa CR
- enable_bucket_notifs_on_cr(use_provided_pvc=False)
Set the bucket notifications feature on the NooBaa CR
- Parameters:
use_provided_pvc (bool) – Whether to set a custom PVC or use NooBaa’s default.
Note that if use_provided_pvc is set to True, a PVC factory must be set to the pvc_factory attribute of the BucketNotificationsManager instance.
- get_bucket_notification_configuration(awscli_pod, mcg_obj, bucket)
Get the bucket notification configuration of a bucket
- get_events(topic, timeout_in_ms=15000)
Query a Kafka topic for events
- Parameters:
topic (str) – Name of the Kafka topic
timeout_in_ms (int) – How long to wait for events
- Returns:
List of event dictionaries
- Return type:
list
- property nb_config_resource
- put_bucket_notification(awscli_pod, mcg_obj, bucket, events, conn_config_path, wait=True)
Configure bucket notifications on a bucket using the AWS CLI
- Parameters:
- setup_kafka()
Deploy an AMQ cluster and set up Kafka
ocs_ci.ocs.resources.bucket_policy module
- class ocs_ci.ocs.resources.bucket_policy.HttpResponseParser(http_response)
Bases:
objectA simple class for parsing HTTP responses
- class ocs_ci.ocs.resources.bucket_policy.NoobaaAccount(mcg, name, email, allow_bucket_creation=True, buckets=None, admin_access=False, s3_access=True, full_bucket_access=True, backingstore_name='noobaa-default-backing-store')
Bases:
objectClass for Noobaa account
- access_key = None
- access_key_id = None
- account_name = None
- delete_account()
Delete the noobaa account
- Returns:
Response for noobaa delete_account api call
- email_id = None
- s3_endpoint = None
- s3_resource = None
- token = None
- update_account_email(new_email)
Update the noobaa account with new email
- Returns:
Response for noobaa ‘update_account’ api call
- ocs_ci.ocs.resources.bucket_policy.gen_bucket_policy(user_list, actions_list, resources_list, effect=None, sid='statement', principal_property=None, action_property=None, resource_property=None)
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”
principal_property (str) – Element to specify the principal to allow/deny access to a resource.
action_property (str) – Element describes the specific action(s) that will be allowed or denied.
resource_property (str) – Element specifies the object(s) that the statement covers
- Returns:
Bucket policy in json format
- Return type:
dict
- ocs_ci.ocs.resources.bucket_policy.gen_bucket_policy_ui_compatible(user_list, actions_list, resources_list, effect=None, sid='statement', principal_property=None, action_property=None, resource_property=None)
Function prepares bucket policy parameters in syntax and format compatible with UI validation. This function handles principal formatting correctly for AWS S3 bucket policy standards.
- Parameters:
user_list (str|list) – User account(s) to access bucket policy. “*” for public access, string for single account, list for multiple accounts
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”
principal_property (str) – Element to specify the principal to allow/deny access to a resource.
action_property (str) – Element describes the specific action(s) that will be allowed or denied.
resource_property (str) – Element specifies the object(s) that the statement covers
- Returns:
Bucket policy in json format compatible with UI validation
- 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:
objectA class that represents BucketClass objects
- delete()
- ocs_ci.ocs.resources.bucketclass.bucket_class_factory(request, mcg_obj, backingstore_factory, namespace_store_factory, cluster_context=<class 'ocs_ci.framework.MultiClusterConfig.RunWithProviderConfigContextIfAvailable'>)
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
cluster_context (object) – context object in which the bucket will be created. Default is provider context.
ocs_ci.ocs.resources.cache_drop module
- class ocs_ci.ocs.resources.cache_drop.OSDCashDrop
Bases:
OCPThis 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:
OCPThis 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.catalog_source.get_odf_tag_from_redhat_catsrc()
Get the ODF tag from the default redhat-operators Catalog Source
- Returns:
ODF tag from redhat-operators Catalog Source
- Return type:
str
ocs_ci.ocs.resources.clientprofile module
- class ocs_ci.ocs.resources.clientprofile.ClientProfile(client_profile_name, consumer_context)
Bases:
objectBase ClientProfile class
- create_client_profile(name, ceph_connection_reference, ceph_fs_map: dict, rbd_map: dict, nfs_map: dict)
Create a client profile
- Returns:
ClientProfile
- Return type:
dict
- get_ceph_connection_reference()
Get the CephConnectionReference name
- Returns:
CephConnectionReference name
- Return type:
str
- get_ceph_fs_map()
Get the CephFSMap from the client profile
SubVolumeGroup string json:”subVolumeGroup,omitempty” KernelMountOptions map[string] string json:”kernelMountOptions,omitempty” FuseMountOptions map[string] string json:”fuseMountOptions,omitempty”
Starting from ODF 4.19 (Converged) this CR has optional Spec field RadosNamespace. It is to ensure ceph fs has namespace for storing metadata (OMAP data) RadosNamespace string(can be nil) json:”radosNamespace,omitempty”
- Returns:
CephFSMap
- Return type:
dict
- get_nfs_map()
Get the NFSMap from the client profile
- Returns:
NFSMap
- Return type:
dict
- get_rbd_map()
Get the RBDMap from the client profile
- Returns:
RBDMap
- Return type:
dict
ocs_ci.ocs.resources.cloud_manager module
- class ocs_ci.ocs.resources.cloud_manager.AwsClient(auth_dict, verify=True, endpoint='https://s3.amazonaws.com', *args, **kwargs)
Bases:
S3ClientImplementation of a S3 Client using the S3 API for AWS buckets
- 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
- class ocs_ci.ocs.resources.cloud_manager.AwsSTSClient(full_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:
CloudClientImplementation 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:
AzureClientImplementation 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:
ABCBase 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:
ABCClass containing all client types
- class ocs_ci.ocs.resources.cloud_manager.GoogleClient(auth_dict, *args, **kwargs)
Bases:
CloudClientImplementation 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.IbmCosClient(auth_dict, verify=True, endpoint='https://s3.amazonaws.com', *args, **kwargs)
Bases:
S3ClientImplementation of a S3 Client using the S3 API for IBM COS buckets
- class ocs_ci.ocs.resources.cloud_manager.RgwClient(auth_dict=None, verify=True, *args, **kwargs)
Bases:
S3ClientImplementation of a S3 Client using the S3 API for RGW buckets
- class ocs_ci.ocs.resources.cloud_manager.S3Client(auth_dict, verify=True, endpoint='https://s3.amazonaws.com', *args, **kwargs)
Bases:
CloudClientImplementation 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
- 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, cluster_context=<class 'ocs_ci.framework.MultiClusterConfig.RunWithProviderConfigContextIfAvailable'>)
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
cluster_context (object) – context object in which the bucket will be created. Default is provider context.
- Returns:
- Factory method - each call to this function creates
an Underlying Storage factory
- Return type:
func
ocs_ci.ocs.resources.csi_addons module
Helpers for interacting with the csi-addons-config ConfigMap.
Provides generic get/set operations for any key in the ConfigMap. Used by set_schedule_precedence() in helpers.py and by stagger tests.
- ocs_ci.ocs.resources.csi_addons.get_csi_addons_config_value(key: str, default: str = '') str
Read a value from the ‘csi-addons-config’ ConfigMap.
Returns the default if the ConfigMap does not exist, the key is missing, or the read operation fails.
- Parameters:
key (str) – The ConfigMap data key to read (e.g. ‘cronjob-stagger-window’).
default (str) – Fallback value when the key is absent. Defaults to “”.
- Returns:
The value from the ConfigMap, or default if unavailable.
- Return type:
str
- ocs_ci.ocs.resources.csi_addons.remove_csi_addons_config_key(key: str) None
Remove a key from the ‘csi-addons-config’ ConfigMap and restart the CSI Addons controller manager so the change is picked up.
No-op if the ConfigMap does not exist or the key is already absent.
- Parameters:
key (str) – The ConfigMap data key to remove.
- Raises:
CommandFailed – If the patch operation fails for a reason other than the key already being absent.
- ocs_ci.ocs.resources.csi_addons.update_csi_addons_config(key: str, value: str) None
Create or update a key in the ‘csi-addons-config’ ConfigMap and restart the CSI Addons controller manager so the change is picked up.
Handles both cases: ConfigMap exists / does not exist. Uses JSON merge patch to preserve existing keys.
- Parameters:
key (str) – The ConfigMap data key to set (e.g. ‘cronjob-stagger-window’).
value (str) – The value to assign to the key.
- Raises:
CommandFailed – If the ConfigMap patch or create operation fails.
ocs_ci.ocs.resources.csv module
CSV related functionalities
- class ocs_ci.ocs.resources.csv.CSV(resource_name='', *args, **kwargs)
Bases:
OCPThis 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, cluster_kubeconfig='')
Check if all CSVs in namespace are in succeeded phase
- Parameters:
namespace (str) – namespace of CSV
timeout (int) – Timeout in seconds to wait for CSV to reach succeeded phase ! currently not used !
cluster_kubeconfig (str) – Kubeconfig of the cluster
- Returns:
True if all CSVs are in succeeded phase
- Return type:
bool
- ocs_ci.ocs.resources.csv.check_operatorcondition_upgradeable_false(operator_name, csv_name, namespace, timeout=300, reason=None, message_pattern=None)
Check if OperatorCondition shows Upgradeable=False with specified reason.
- Parameters:
operator_name (str) – Name of the operator (for logging)
csv_name (str) – CSV name of the operator
namespace (str) – Namespace where OperatorCondition is located
timeout (int) – Timeout in seconds to wait for condition
reason (str) – Expected reason in OperatorCondition. If None, checks for any reason when Upgradeable=False
message_pattern (str) – Expected message pattern in OperatorCondition. If None, only reason is checked
- Returns:
True if condition is met, False otherwise
- 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.csv.get_operator_csv_names(namespace=None)
Get CSV names for OCS and ODF operators.
- Parameters:
namespace (str) – Namespace where CSVs are located. Defaults to openshift-storage namespace.
- Returns:
(ocs_csv_name, odf_csv_name)
- Return type:
tuple
ocs_ci.ocs.resources.daemonset module
DaemonSet related functionalities
- class ocs_ci.ocs.resources.daemonset.DaemonSet(*args, **kwargs)
Bases:
OCPThis class represent DaemonSet and contains methods for operations with DaemonSets.
- get_status()
Get infromation related to resource status.
- Returns:
DaemonSet resource status
- Return type:
dict
- get_update_strategy()
Get infromation related to update strategy.
- Returns:
DaemonSet resource update strategy
- Return type:
dict
ocs_ci.ocs.resources.deployment module
General Deployment object
- class ocs_ci.ocs.resources.deployment.Deployment(**kwargs)
Bases:
OCSA 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=360, 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='', switch_ctx=None, *args, **kwargs)
Bases:
OCPThis class represent DRPlacementControl (DRPC) and contains all related methods we need to do with DRPC.
- property drpolicy
- property drpolicy_obj
- get_clusterdataprotected_status()
Get clusterdataproctected status from drpc
- get_last_group_sync_time()
Fetch lastGroupSyncTime from DRPC
- Returns:
lastGroupSyncTime
- Return type:
str
- get_last_kubeobject_protection_time()
Fetch lastKubeObjectProtectionTime from DRPC
- Returns:
lastKubeObjectProtectionTime
- Return type:
str
- get_peer_ready_status()
- get_progression_status(status_to_check=None)
- wait_for_clusterdataprotected_status()
Verify clusterdataproctected status from drpc is set to True, otherwise raise assert error
- wait_for_peer_ready_status()
- wait_for_progression_status(status)
- ocs_ci.ocs.resources.drpc.get_drpc_name(namespace, switch_ctx=None)
Get the DRPC resource name in the given namespace
- Parameters:
namespace (str) – Name of the namespace
switch_ctx (int) – The cluster index by the cluster name
- 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
- Parameters:
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:
OCPThis 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
ResourceNotFoundError – When job is not found in the cluster
CommandFailed – When other command errors occur
ocs_ci.ocs.resources.keda module
- class ocs_ci.ocs.resources.keda.KEDA(workload_namespace, keda_namespace='keda')
Bases:
objectA class to manage KEDA installation and configuration.
KEDA is an operator that scales workloads using metrics from external sources such as Prometheus, instead of relying only on CPU or memory.
Prerequisites: - The Helm CLI must be available for installing/uninstalling KEDA
- can_read_thanos_metrics()
Check if the token and CA that KEDA is configured to use are valid by using them to query the Thanos Querier internal address from one of the Prometheus pods and checking the response.
- Returns:
True if KEDA is configured to read Thanos metrics, False otherwise.
- Return type:
bool
- cleanup()
Cleanup KEDA
- create_thanos_metric_scaled_object(config_dict)
Create and register a KEDA ScaledObject driven by a Thanos metric. A ScaledObject defines how KEDA should scale a workload: which target to scale, what metric to watch, and the conditions that trigger scaling.
- Parameters:
config_dict (dict) – A dictionary containing the configuration for the ScaledObject.
keys. (See ScaledObject.KEYS_TO_YAML_PATH for valid) –
- Returns:
The configured ScaledObject instance.
- Return type:
- install()
Install KEDA via the Helm CLI
- Raises:
- FileNotFoundError – If Helm is not installed.
- CommandFailed or AssertionError – If KEDA installation fails.
- is_installed()
Check if KEDA is installed
- Returns:
True if KEDA is installed, False otherwise.
- Return type:
bool
- setup_access_to_thanos_metrics()
Setup access to Thanos metrics for KEDA
This creates a service account, a secret with a token, and a secret with the CA bundle. It then creates a TriggerAuthentication that points KEDA to the token + CA bundle:
Create a service account for KEDA and grant it read access
Mint a token for the service account and store it in a secret
Extract the cluster CA bundle so KEDA can verify Thanos TLS
Create a secret with the CA bundle
Create a TriggerAuthentication that points KEDA to the token + CA bundle
- uninstall()
Cleanup KEDA via the Helm CLI
- class ocs_ci.ocs.resources.keda.ScaledObject(config_dict)
Bases:
objectA class for managing scaled objects for KEDA.
- KEYS_TO_YAML_PATH = {'authenticationRef': ('spec', 'triggers', 0, 'authenticationRef', 'name'), 'cooldownPeriod': ('spec', 'cooldownPeriod'), 'maxReplicaCount': ('spec', 'maxReplicaCount'), 'minReplicaCount': ('spec', 'minReplicaCount'), 'name': ('metadata', 'name'), 'namespace': ('metadata', 'namespace'), 'pollingInterval': ('spec', 'pollingInterval'), 'query': ('spec', 'triggers', 0, 'metadata', 'query'), 'scaleTargetRef': ('spec', 'scaleTargetRef'), 'serverAddress': ('spec', 'triggers', 0, 'metadata', 'serverAddress'), 'threshold': ('spec', 'triggers', 0, 'metadata', 'threshold')}
- property is_created
- update_from_dict(config_dict)
Updates the ScaledObject from a dictionary
- Parameters:
config_dict (dict) – A dictionary containing the configuration for the ScaledObject.
keys. (See ScaledObject.KEYS_TO_YAML_PATH for valid) –
- Raises:
ValueError – If the config_dict is invalid.
ocs_ci.ocs.resources.machineconfig module
- ocs_ci.ocs.resources.machineconfig.deploy_machineconfig(tmp_path, mc_name, mc_dict, mcp_num=2)
Deploy given
MachineConfigdict 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.machineconfig.machineconfig_exists(mc_name)
Check if a MachineConfig with the given name exists.
- Parameters:
mc_name (str) – Name of the MachineConfig to check
- Returns:
True if MachineConfig exists, False otherwise
- Return type:
bool
ocs_ci.ocs.resources.mcg module
- class ocs_ci.ocs.resources.mcg.MCG(*args, **kwargs)
Bases:
objectWrapper class for the Multi Cloud Gateway’s S3 service
- access_key = None
- access_key_id = None
- assign_sts_role(account_id, role_config)
Assign STS role to a Noobaa account
- Parameters:
account_id (str) – Name/email/id of the noobaa account
role_config (dict) – Role config consisting of role name, role policy etc
- 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=900)
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_over_backingstores(name, backingstores, placement_policy, replication_policy=None)
Creates a new NooBaa bucket class using the noobaa cli over backingstores :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 replication_policy: The replication policy dictionary :type replication_policy: dict
- Returns:
The bucket class resource
- Return type:
- cli_create_bucketclass_over_namespacestores(name, namespacestores, namespace_policy)
Creates a new NooBaa bucket class using the noobaa cli over namespace stores :param name: The name to be given to the bucket class :type name: str :param namespacestores: The namespaces stores to use as part of the policy :type namespacestores: list :param namespace_policy: The namespace policy to be used. The supported namespace policy types are :type namespace_policy: dict :param Single: :param Cache and Multi. For Cache NSS: :param default backing store is used as the cache.: :param In the case of Multi namespace policy type: :param first namespace store is used as the write resource.:
- Returns:
The bucket class resource
- Return type:
- cli_get_all_bucket_names()
- Returns:
A set of all bucket names
- Return type:
set
- cli_list_all_buckets() list[str]
- Returns:
A list of all bucket names
- Return type:
list[str]
- 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
- determine_s3_endpoint()
Get external mcg S3 endpoint if the cluster is in multicluster environment. Get internal endpoint otherwise.
- Returns:
S3 endpoint URI
- Return type:
string
- exec_mcg_cmd(cmd, namespace=None, use_yes=False, ignore_error=False, **kwargs)
Executes a NooBaa CLI command through the appropriate CLI binary
For OCS >= 4.20: Uses odf-cli noobaa <command> via ODFCliRunner For OCS < 4.20: Uses mcg-cli <command> directly
- Parameters:
cmd (str) – The command to run
namespace (str) – The namespace to run the command in
use_yes (bool) – If True, pipe ‘yes’ to the command
ignore_error (bool) – If True, don’t raise exception on non-zero exit
**kwargs – Additional arguments to pass to exec_cmd
- Returns:
Result object with stdout and stderr as decoded strings
- Return type:
CompletedProcess
- 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 NooBaa CLI version by parsing the output of the 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
- Example output of the odf-cli noobaa version command:
CLI version: 5.20.0 noobaa-image: noobaa/noobaa-core:master-20240101 operator-image: noobaa/noobaa-operator:5.20.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)
- property iam_client
- mgmt_endpoint = None
- namespace = None
- noobaa_password = None
- noobaa_user = None
- oc_create_bucketclass(name, backingstores, placement_policy, namespace_policy, replication_policy, vector_policy=None)
Creates a new NooBaa bucket class using a template YAML
- Parameters:
name (str) – The name to be given to the bucket class
backingstores (list) – The backing stores to use as part of the policy
placement_policy (str) – The placement policy to be used - Mirror | Spread
namespace_policy (dict) – The namespace policy to be used
replication_policy (dict) – The replication policy dictionary
vector_policy (dict) – The vector policy for vector buckets with resource and vectorDBType fields
- 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
- remove_sts_role(account_id)
Remove STS role from a Noobaa account
- Parameters:
account_id (str) – Name/email/id of the noobaa account
- 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
- reset_endpoint_pods()
Delete the noobaa endpoint pod and wait for it to come up again
- s3_endpoint = None
- s3_get_all_bucket_names()
- Returns:
A set of all bucket names
- Return type:
set
- s3_get_all_buckets()
- Returns:
A list of all s3.Bucket objects
- Return type:
list
- s3_internal_endpoint = None
- s3_list_all_objects_in_bucket(bucketname)
- Returns:
A list of all bucket objects
- Return type:
list
- s3_resource = None
- s3_verify_bucket_exists(bucketname)
Verifies whether a bucket with the given bucketname exists :param bucketname: The bucket name to be verified
- Returns:
True if bucket exists, False otherwise
- Return type:
bool
- send_rpc_query(api, method, params=None)
Templates and sends an RPC query to the MCG mgmt endpoint
- Parameters:
api – The name of the API to use
method – The method to use inside the API
params – A dictionary containing the command payload
- Returns:
The server’s response
- property status
Expose the status check of NooBaa as a property
- update_s3_creds()
Set the S3 credentials of the NooBaa admin user from the noobaa-admin secret, and update the S3 resource and client
- vectors_endpoint = None
- vectors_internal_endpoint = None
- static wait_for_ready_status(timeout=600)
Wait for NooBaa’s resources to reach the ‘Ready’ status
- Parameters:
timeout (int) – Number of seconds to wait for the status
- Raises:
TimeoutExpiredError – If the status is not reached within the timeout
ocs_ci.ocs.resources.mcg_lifecycle_policies module
- class ocs_ci.ocs.resources.mcg_lifecycle_policies.AbortIncompleteMultipartUploadRule(days_after_initiation, filter={}, is_enabled=True)
Bases:
LifecycleRuleA class for handling the parsing of an MCG object expiration rule
- as_dict()
Returns the rule as a dictionary that matches the expected S3 lifecycle policy JSON format
- class ocs_ci.ocs.resources.mcg_lifecycle_policies.ExpirationRule(days=None, filter={}, use_date=False, is_enabled=True)
Bases:
LifecycleRuleA class for handling the parsing of an MCG object expiration rule
- as_dict()
Returns the rule as a dictionary that matches the expected S3 lifecycle policy JSON format
- class ocs_ci.ocs.resources.mcg_lifecycle_policies.ExpiredObjectDeleteMarkerRule(filter={}, is_enabled=True, expire_object_delete_marker=True)
Bases:
LifecycleRuleA class for handling the parsing of an MCG expired object delete marker rule
Note the separation from ExpirationRule is due to the fact that Expiration.ExpiredObjectDeleteMarker cannot be specified with Days or Date in a Lifecycle Expiration Policy: https://docs.aws.amazon.com/AmazonS3/latest/API/API_LifecycleExpiration.html
- as_dict()
Returns the rule as a dictionary that matches the expected S3 lifecycle policy JSON format
- class ocs_ci.ocs.resources.mcg_lifecycle_policies.LifecycleFilter(prefix=None, tags=None, minBytes=None, maxBytes=None)
Bases:
objectA class for handling S3 lifecycle filter parsing
- as_dict()
Returns the rule as a dictionary that matches the expected S3 lifecycle policy JSON format
- class ocs_ci.ocs.resources.mcg_lifecycle_policies.LifecyclePolicy(*args)
Bases:
objectA class for handling MCG lifecycle policy config parsing
- as_dict()
Returns the lifecycle policy as a dictionary that matches the expected S3 lifecycle policy JSON format.
Note that the objects in self.rules are expected to have their own as_dict() implementation.
- as_xml()
Convert the lifecycle policy to XML format
- Returns:
XML string representation of the lifecycle policy
- Return type:
str
- class ocs_ci.ocs.resources.mcg_lifecycle_policies.LifecycleRule(filter={}, is_enabled=True)
Bases:
ABCAn abstract class for handling MCG lifecycle rule parsing
- as_dict()
Returns the rule as a dictionary that matches the expected S3 lifecycle policy JSON format
- property id
- class ocs_ci.ocs.resources.mcg_lifecycle_policies.NoncurrentVersionExpirationRule(non_current_days=None, newer_non_current_versions=None, filter={}, is_enabled=True)
Bases:
LifecycleRuleA class for handling the parsing of an MCG non-current version expiration rule
- as_dict()
Returns the rule as a dictionary that matches the expected S3 lifecycle policy JSON format
ocs_ci.ocs.resources.mcg_params module
- class ocs_ci.ocs.resources.mcg_params.NSFS(method: str = 'CLI', pvc_name: str = None, pvc_size: int = 20, sub_path: str = None, fs_backend: str = 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, bucket_obj: ObjectBucket = None, bucket_name: str = None, mounted_bucket_path: str = None, s3_creds: dict = None, nss: NamespaceStore = None, nsfs_only: bool = False)
Bases:
objectAn 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
- nsfs_only: bool = False
- 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='', sync_versions=False)
Bases:
LogBasedReplicationPolicyA 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:
LogBasedReplicationPolicyA 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, sync_versions=False, prefix='')
Bases:
McgReplicationPolicy,ABCAn abstract subclass of ReplicationPolicy that includes log-based replication information.
- abstract to_dict()
- class ocs_ci.ocs.resources.mcg_replication_policy.McgReplicationPolicy(destination_bucket, prefix='')
Bases:
objectA class to handle the MCG bucket replication policy JSON structure.
- to_dict()
- class ocs_ci.ocs.resources.mcg_replication_policy.ReplicationPolicyWithVersioning(target_bucket, sync_versions=True, prefix='')
Bases:
McgReplicationPolicyA class to handle the MCG bucket replication policy JSON structure with versioning.
- 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:
objectThis 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, prefix='')
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_random_objects_and_log(bucket_name, file_dir, obj_list, prefix=None)
Uploads randomly generated objects to the bucket and upload a matching mockup log
- Parameters:
bucket_name (str) – Name of the bucket
file_dir (str) – File directory where the objects are present
obj_list (list) – List of the objects
prefix (str) – Prefix under which object needs to be uploaded
- 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:
objectThis 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:
objectA 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=360, 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, cluster_context=<class 'ocs_ci.framework.MultiClusterConfig.RunWithProviderConfigContextIfAvailable'>)
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
cluster_context (object) – context object in which the namespacestore will be created. Default is provider context.
- 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 subdirectory 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=None, 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:
ObjectBucketImplementation 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:
ObjectBucketImplementation 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:
OCBucketImplementation of an MCG bucket using the OC CLI
- class ocs_ci.ocs.resources.objectbucket.MCGS3Bucket(*args, **kwargs)
Bases:
ObjectBucketImplementation 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:
objectWrapper class for Object Bucket Claim credentials
- access_key = None
- access_key_id = None
- bucket_name = None
- property id_for_policy_principal
Returns the ID for the OBC account to be used in bucket policies, based on the OCS version.
- Returns:
The ID for the OBC account to be used in bucket policies.
- Return type:
str
- 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:
ABCBase 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=180, interval=5)
Super method used for logging the deletion verification process and then calls the appropriate implementatation
- verify_health(timeout=800, 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
- class ocs_ci.ocs.resources.objectbucket.RGWOCBucket(*args, **kwargs)
Bases:
OCBucketImplementation of an RGW bucket using the S3 API
- class ocs_ci.ocs.resources.objectbucket.VectorOCBucket(*args, **kwargs)
Bases:
OCBucketImplementation of an MCG Vector bucket using the OC CLI
- ocs_ci.ocs.resources.objectbucket.get_s3_credentials_from_obc(obc_name, namespace)
Extract S3 credentials from ObjectBucketClaim Secret and ConfigMap.
This helper extracts all necessary information to create an S3 client from an OBC’s associated Secret and ConfigMap resources.
- Parameters:
obc_name (str) – Name of the ObjectBucketClaim
namespace (str) – Namespace containing the OBC
- Returns:
- Dictionary containing S3 connection details:
bucket_name (str): Name of the S3 bucket
endpoint (str): S3 endpoint URL
access_key_id (str): AWS access key ID
secret_access_key (str): AWS secret access key
region (str): AWS region (if available)
- Return type:
dict
- Raises:
AssertionError – If bucket name is not found in ConfigMap
Example
>>> from ocs_ci.ocs.resources.objectbucket import get_s3_credentials_from_obc >>> import boto3 >>> creds = get_s3_credentials_from_obc("my-obc", "openshift-storage") >>> s3_client = boto3.client( ... "s3", ... aws_access_key_id=creds["access_key_id"], ... aws_secret_access_key=creds["secret_access_key"], ... endpoint_url=f"https://{creds['endpoint']}", ... verify=False ... )
- ocs_ci.ocs.resources.objectbucket.wait_for_obc_phase(obc_name, namespace, phase, timeout=300)
Wait for ObjectBucketClaim to reach specified phase.
This is a generic helper for waiting on OBC phase transitions, particularly useful for client cluster scenarios where OCP.wait_for_phase() doesn’t work due to ObjectBucketClaim not having _has_phase=True.
- Parameters:
obc_name (str) – Name of the ObjectBucketClaim
namespace (str) – Namespace containing the OBC
phase (str) – Desired phase (e.g., “Bound”)
timeout (int) – Timeout in seconds (default: 300)
- Raises:
TimeoutExpiredError – If OBC doesn’t reach desired phase within timeout
Example
>>> from ocs_ci.ocs.resources.objectbucket import wait_for_obc_phase >>> from ocs_ci.ocs import constants >>> wait_for_obc_phase("my-obc", "openshift-storage", constants.STATUS_BOUND)
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
ObjectConfFileclass 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:
objectThis 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 applyon 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 createon 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 deleteon 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 describeon 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 geton 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
-noption 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:
objectBase 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’”
- annotate(annotation)
Add annotation to the OCS Object.
- Parameters:
annotation (str) – New annotation to the OCS object.
- 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)
Get OCS versions and DR operator versions
- Parameters:
namespace (str) – the CSVs namespace
- Returns:
the ocs versions and DR operator versions
- Return type:
dict
ocs_ci.ocs.resources.ocsconfigmaps module
- class ocs_ci.ocs.resources.ocsconfigmaps.OcsOperatorConfigMap(**kwargs)
Bases:
OCSClass to interact with OCS Operator ConfigMap
- check_configmap_exists(timeout=120)
Check if the OCS Operator ConfigMap exists. Does not raise TimeoutExpiredError exception.
- Parameters:
timeout (int) – Time to wait for resource to exist (default: 120)
- Returns:
True if ConfigMap exists, False otherwise
- Return type:
bool
- get_creation_timestamp()
Get the creation timestamp.
- Returns:
The creation timestamp.
- Return type:
str
- get_csi_cluster_name()
Get the CSI cluster name.
- Returns:
The CSI cluster name.
- Return type:
str
- get_csi_enable_topology()
Get the CSI enable topology.
- Returns:
The CSI enable topology.
- Return type:
str
- get_csi_topology_domain_labels()
Get the CSI topology domain labels.
- Returns:
The CSI topology domain labels.
- Return type:
str
- get_owner_references()
Get the owner references.
- Returns:
The owner references.
- Return type:
list
- get_resource_version()
Get the resource version.
- Returns:
The resource version.
- Return type:
str
- get_rook_csi_disable_driver()
Get the Rook CSI disable driver.
- Returns:
The Rook CSI disable driver.
- Return type:
str
- get_rook_csi_enable_cephfs()
Get the Rook CSI enable CephFS.
- Returns:
The Rook CSI enable CephFS.
- Return type:
str
- get_rook_csi_enable_nfs()
Get the Rook CSI enable NFS.
- Returns:
The Rook CSI enable NFS.
- Return type:
str
- get_rook_current_namespace_only()
Get the Rook current namespace only.
- Returns:
The Rook current namespace only.
- Return type:
str
- get_uid()
Get the UID.
- Returns:
The UID.
- Return type:
str
- set_csi_cluster_name(value)
Set the CSI cluster name.
- Parameters:
value (str) – The CSI cluster name.
- set_csi_enable_topology(value)
Set the CSI enable topology.
- Parameters:
value (str) – The CSI enable topology.
- set_csi_topology_domain_labels(value)
Set the CSI topology domain labels.
- Parameters:
value (str) – The CSI topology domain labels.
- set_rook_csi_enable_cephfs(value)
Set the Rook CSI enable CephFS.
- Parameters:
value (str) – The Rook CSI enable CephFS.
- set_rook_csi_enable_nfs(value)
Set the Rook CSI enable NFS.
- Parameters:
value (str) – The Rook CSI enable NFS.
- set_rook_current_namespace_only(value)
Set the Rook current namespace only.
- Parameters:
value (str) – The Rook current namespace only.
- class ocs_ci.ocs.resources.ocsconfigmaps.OcsStorageConsumerConfigMap(**kwargs)
Bases:
OCSClass to interact with OCS Storage Consumer ConfigMap
- check_configmap_exists(timeout=120)
Check if the OCS Storage Consumer ConfigMap exists. Does not raise TimeoutExpiredError exception.
- Parameters:
timeout (int) – Time to wait for resource to exist (default: 120)
- Returns:
True if ConfigMap exists, False otherwise
- Return type:
bool
- get_cephfs_subvolumegroup()
Get the cephfs subvolumegroup.
- Returns:
The cephfs subvolumegroup.
- Return type:
str
- get_cephfs_subvolumegroup_rados_ns()
Get the cephfs subvolumegroup rados namespace.
- Returns:
The cephfs subvolumegroup rados namespace.
- Return type:
str
- get_creation_timestamp()
Get the creation timestamp.
- Returns:
The creation timestamp.
- Return type:
str
- get_csi_cephfs_node_secret()
Get the csi cephfs node secret.
- Returns:
The csi cephfs node secret.
- Return type:
str
- get_csi_cephfs_provisioner_secret()
Get the csi cephfs provisioner secret.
- Returns:
The csi cephfs provisioner secret.
- Return type:
str
- get_csi_rbd_node_secret()
Get the csi rbd node secret.
- Returns:
The csi rbd node secret.
- Return type:
str
- get_csi_rbd_provisioner_secret()
Get the csi rbd provisioner secret.
- Returns:
The csi rbd provisioner secret.
- Return type:
str
- get_csiop_cephfs_client_profile()
Get the csiop cephfs client profile.
- Returns:
The csiop cephfs client profile.
- Return type:
str
- get_csiop_rbd_client_profile()
Get the csiop rbd client profile.
- Returns:
The csiop rbd client profile.
- Return type:
str
- get_owner_references()
Get the owner references.
- Returns:
The owner references.
- Return type:
list
- get_rbd_rados_ns()
Get the rbd rados namespace.
- Returns:
The rbd rados namespace.
- Return type:
str
- get_resource_version()
Get the resource version.
- Returns:
The resource version.
- Return type:
str
- get_uid()
Get the UID.
- Returns:
The UID.
- Return type:
str
- set_cephfs_subvolumegroup(value)
Set the cephfs subvolumegroup.
- Parameters:
value (str) – The cephfs subvolumegroup.
- set_cephfs_subvolumegroup_rados_ns(value)
Set the cephfs subvolumegroup rados namespace.
- Parameters:
value (str) – The cephfs subvolumegroup rados namespace.
- set_csi_cephfs_node_secret(value)
Set the csi cephfs node secret.
- Parameters:
value (str) – The csi cephfs node secret.
- set_csi_cephfs_provisioner_secret(value)
Set the csi cephfs provisioner secret.
- Parameters:
value (str) – The csi cephfs provisioner secret.
- set_csi_rbd_node_secret(value)
Set the csi rbd node secret.
- Parameters:
value (str) – The csi rbd node secret.
- set_csi_rbd_provisioner_secret(value)
Set the csi rbd provisioner secret.
- Parameters:
value (str) – The csi rbd provisioner secret.
- set_csiop_cephfs_client_profile(value)
Set the csiop cephfs client profile.
- Parameters:
value (str) – The csiop cephfs client profile.
- set_csiop_rbd_client_profile(value)
Set the csiop rbd client profile.
- Parameters:
value (str) – The csiop rbd client profile.
- set_rbd_rados_ns(value)
Set the rbd rados namespace.
- Parameters:
value (str) – The rbd rados namespace.
- ocs_ci.ocs.resources.ocsconfigmaps.get_ocs_operator_configmap_obj()
Get OCS Operator ConfigMap instance
- Returns:
OCS Operator ConfigMap instance
- Return type:
- ocs_ci.ocs.resources.ocsconfigmaps.get_ocs_storage_consumer_configmap_obj(storageconsumer_name)
Get OCS Storage Consumer ConfigMap instance
- Parameters:
storageconsumer_name (str) – Name of the storage consumer
- Returns:
OCS Storage Consumer ConfigMap instance
- Return type:
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:
OCPThis 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, approved_only=False)
Get currently installed CSV out latest approved install plans.
- Parameters:
patter (str) – pattern of CSV name to look for.
approved_only (bool) – it will ignore if there is no non approved install plan
- 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 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:
OCSHandles 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_file_with_base64(target_path, src_path, container='')
!!!Important Note!!! Due to implemented https://url.corp.redhat.com/RHSTOR-3411 task ‘tar’, ‘yum’ utilities were removed from ceph pods to trim an image size. oc cp command depends on ‘tar’ utility, see https://linuxhint.com/use-kubectl-cp-command/ and oc cp –help
Function to copy a file to a pod using base64 tool. Example: 1) oc exec -n odf-storage rook-ceph-osd-0-68d76f868c-s25sw -c osd – base64 /var/log/ceph/pg_log_1.30.txt > pg_log_1.30.txt.base64 2) cat pg_log_1.30.txt.base64 | base64 -d > pg_log_1.30.txt
- Parameters:
src_path (str) – The source file to copy
target_path (str) – The target file to copy to
container (str) – The container to copy to
- copy_from_pod_oc_exec(target_path, src_path, timeout=2400, chunk_size=2000)
!!!Important Note!!! Due to implemented https://url.corp.redhat.com/RHSTOR-3411 task ‘tar’, ‘yum’ utilities were removed from ceph pods to trim an image size. oc cp command depends on ‘tar’ utility, see https://linuxhint.com/use-kubectl-cp-command/ and oc cp –help
This function is a workaround to copy files from the pod to the local path file using standard input stream 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) – total 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_container_data(container_name)
Get the container data for a requested container.
- Parameters:
container_name (str) – The name of the container to look for
- Returns:
The container data
- Return type:
list
- get_csi_pod_log_details(logs_dir, log_file_name)
Gets csi pod log files details
- Parameters:
logs_dir (str) – Directory where the logs are looked for
log_file_name (str) – Current log file name
- Returns:
Number of compressed log files current_log_file_size (int) Size of the current log file
- Return type:
gz_logs_num (int)
- 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 or str) – 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.base_wait_for_ceph_cmd_execute_successfully(timeout=300, sleep=20)
Wait for a Ceph command to execute successfully
- Parameters:
timeout (int) – The time to wait for a Ceph command to execute successfully
sleep (int) – Time to sleep between the iterations
- Returns:
True, if the Ceph command executed successfully. False, otherwise
- Return type:
bool
- 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=None, pod_names=None, raise_pod_not_found_error=False, skip_for_status=None, cluster_kubeconfig='')
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”]
cluster_kubeconfig (str) – The kubeconfig file to use for the oc command
- 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=None, 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
- Raises:
TolerationNotFoundException – Exception raised when a required toleration is not found in the pods.
- ocs_ci.ocs.resources.pod.check_toleration_on_subscriptions(toleration_key='node.ocs.openshift.io/storage')
Function to check toleration on subscriptions
- Parameters:
toleration_key (str) – The toleration key to check
- Raises:
TolerationNotFoundException – Exception raised when a required toleration is not found in the pods.
- ocs_ci.ocs.resources.pod.delete_all_osd_removal_jobs(namespace=None)
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_deployment_pods(pod_obj)
Delete a Deployment and all the pods that are controlled by it
- Parameters:
pod_obj (Pod) – Pod object
- 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=None)
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_pod_by_phase(pod_phase, namespace=None)
Delete the pods in a specific phase :param pod_status: The pod status to delete :type pod_status: str :param namespace: Name of cluster namespace(default: config.ENV_DATA[“cluster_namespace”]) :type namespace: str
- Returns:
True, if the pods 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.fetch_rgw_pod_restart_count(namespace=None)
This method fetches the restart count of rgw pod
- Arg:
namespace(str): namespace where rgw pd is running. default value is, config.ENV_DATA[“cluster_namespace”]
- Returns:
restart count for rgw pod
- Return type:
rgw_pod_restart_count
- 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, cluster_kubeconfig='')
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)
wait (bool) – True if you want to wait for the pods to be Running
cluster_kubeconfig (str) – Path to the kubeconfig file for the cluster
- Returns:
List of Pod objects
- Return type:
list
- ocs_ci.ocs.resources.pod.get_ceph_csi_controller_manager(label='control-plane=ceph-csi-op-controller-manager', namespace=None)
Get ceph-csi-controller-manager pod from the cluster
- Parameters:
label (str) – Label associated with ceph-csi-controller-manager pod
namespace (str) – Namespace in which ceph-csi-controller-manager pod is residing
- Returns:
Pod object of ceph-csi-controller-manager pod
- Return type:
- ocs_ci.ocs.resources.pod.get_ceph_csi_ctrl_pods(namespace=None)
Fetches info about the ceph csi ctrl pods in the cluster
- Parameters:
namespace (str) – Namespace in which ceph cluster lives (default: config.ENV_DATA[“cluster_namespace”])
- Returns:
The list of the ceph csi ctrl 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_running_pods=True)
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
get_running_pods (bool) – If True, get only the ceph tool pods in a Running status. If False, get the ceph tool pods even if they are not in a Running status.
- 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_container_images(pod_obj)
Get all container images (both containers and initContainers) from the pod object
- Parameters:
pod_obj (Pod) – The pod object
- Returns:
Set of the container images from the pod object
- Return type:
set
- Raises:
ValueError – In case we didn’t find the containers or images for the pod
- 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_addons_controller_manager_pod()
Get csi_addons_controller_manager_pod pod
- Returns:
The schedule precedence value
- Return type:
list
- ocs_ci.ocs.resources.pod.get_csi_addons_pod()
Find a CSI addon pod that contains the ‘csi-addons’ container.
In ODF 4.20, CSI addon functionality is in dedicated pods with the label ‘app=openshift-storage.rbd.csi.ceph.com-nodeplugin-csi-addons’.
- Returns:
A Pod object that contains the ‘csi-addons’ container
- Return type:
- Raises:
AssertionError – If no CSI addon pod with ‘csi-addons’ container is found
- 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=None)
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_deviceclass_osd_pods(deviceclass_name, namespace=None)
Get the deviceclass osd pods
- Parameters:
deviceclass_name (str) – The deviceclass name
namespace (str) – Namespace in which ceph cluster lives (default: config.ENV_DATA[“cluster_namespace”])
- Returns:
The deviceclass osd pod objects
- Return type:
list
- ocs_ci.ocs.resources.pod.get_file_path(pod_obj, file_name)
Get the full path of the file
- Parameters:
pod_obj (Pod) – The object of the pod
file_name (str) – The name of the file for which path to get
- Returns:
The full path of the file
- Return type:
str
- ocs_ci.ocs.resources.pod.get_fio_rw_iops(pod_obj)
Execute FIO on a pod
- Parameters:
pod_obj (Pod) – The object of the pod
- ocs_ci.ocs.resources.pod.get_lvm_operator_pod(label='app.kubernetes.io/name=lvms-operator', namespace=None)
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=None)
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_lvs_osd_pods(lvs_name)
Get the LocalVolumeSet osd pods
- Parameters:
lvs_name (str) – The LocalVolumeSet name
- Returns:
List of the osd pods
- Return type:
list
- ocs_ci.ocs.resources.pod.get_machine_config_controller_pod(label='k8s-app=machine-config-controller', namespace='openshift-machine-config-operator', retry=4)
Fetches the Machine Config Controller pod object. Retries until the pod is found or the timeout is reached.
- Parameters:
label (str) – Label associated with the machine_config_controller pod. (default: constants.MACINE_CONFIG_CONTROLLER_LABEL)
namespace (str) – Namespace where the MCC pod lives. (default: constants.OPENSHIFT_MACHINE_CONFIG_OPERATOR_NAMESPACE)
timeout (int) – Total time in seconds to wait for the pod to be found.
retry_delay (int) – Time in seconds to wait between retry attempts.
- Returns:
The first Machine Config Controller pod object found, or None if timed out.
- Return type:
Pod object
- 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_id(mon_id, namespace=None)
Function to get monitor pod by mon_id label
- Parameters:
mon_id (str) – mon id of the monitor pod
namespace (str) – Namespace in which monitor pod is running
- Returns:
Pod object of the monitor pod
- Return type:
- 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=None)
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_client_operator_controller_manager(label='app=ocs-client-operator', namespace=None)
Get ocs-client-operator-controller-manager pod from the cluster
- Parameters:
label (str) – Label associated with ocs-client-operator-controller-manager pod
namespace (str) – Namespace in which ocs-client-operator-controller-manager pod is residing
- Returns:
Pod object of ocs-client-operator-controller-manager pod
- Return type:
- 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_external_snapshotter_leader(namespace=None)
Get ODF external snapshotter operator leader pod
- Parameters:
namespace (str) – Name of cluster namespace
- Returns:
ODF external snapshotter operator leader pod
- Return type:
- ocs_ci.ocs.resources.pod.get_odf_operator_controller_manager(ocs_label='app.kubernetes.io/name=odf-operator', 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=None)
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=None, previous=False, all_containers=False, since=None, tail=None, grep=None, regex=False, case_senitive=False, context=0, return_empty_string=True, first_match_only=True)
Get logs from a given pod
- Parameters:
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.
tail (str) – number of lines to tail
grep (str) – filter the logs by the given string
regex (bool) – True, if the grep is a regex. False otherwise. Applicable only if grep is provided.
case_senitive (bool) – True, if the grep is case sensitive. False otherwise. Applicable only if grep is provided.
context (int) – number of lines to show before and after the matching line Applicable only if grep is provided.
return_empty_string (bool) – True, if the function should return an empty string if no logs are found. Applicable only if grep is provided. Default value is True.
first_match_only (bool) – True, if the function should return the first match only. False otherwise. Applicable only if grep is provided. Default value is True.
- Returns:
Output from ‘oc get logs <pod_name> command
- Return type:
str
- ocs_ci.ocs.resources.pod.get_pod_metrics(pod_name, namespace=None)
Get memory and CPU metrics for a specific pod using oc adm top.
- Parameters:
pod_name (str) – Name of the pod
namespace (str) – Namespace where the pod is located
- Returns:
Dictionary with ‘memory_mib’ and ‘cpu_millicores’ keys
- Return type:
dict
- 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=None, cluster_kubeconfig='')
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
cluster_kubeconfig (str) – The kubeconfig file to use for the oc command
- 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=None, label=None, list_of_pods=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_pod_used_memory_in_mebibytes(podname)
Get a pod’s used memory in MiB
- Parameters:
podname – (str) name of the pod to get used memory of it
- Returns:
the used memory of the pod in Mebibytes (MiB)
- Return type:
int
- ocs_ci.ocs.resources.pod.get_pods_aggregated_metrics(pod_objs)
Get aggregated metrics for multiple pods.
- Parameters:
pod_objs (list) – List of Pod objects
- Returns:
- Dictionary with aggregated metrics including:
total_memory_mib: Sum of memory across all pods
total_cpu_millicores: Sum of CPU across all pods
max_memory_mib: Maximum memory among all pods
max_cpu_millicores: Maximum CPU among all pods
pod_count: Number of pods
- Return type:
dict
- ocs_ci.ocs.resources.pod.get_pods_having_label(label, namespace=None, retry=0, 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=None, 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_pods_pvcs(pod_objs, namespace=None)
Get the PVC objects of the given pod objects
- Parameters:
pod_objs (list) – List of the pod objects
namespace (str) – Name of namespace
- Returns:
The PVC objects
- 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_prometheus_pods(prometheus_label='app.kubernetes.io/name=prometheus', namespace='openshift-monitoring')
Fetches info about prometheus pods in the cluster
- Parameters:
prometheus_label (str) – label associated with prometheus pods
namespace (str) – Namespace in which prometheus pods lives
- Returns:
of prometheus pod objects
- Return type:
list
- ocs_ci.ocs.resources.pod.get_pvc_name(pod_obj)
Get the PVC name from a pod object.
This function retrieves the PVC name from a given pod object by checking all volumes attached to the pod. It will return the first PVC found or raise an exception if no PVC is attached.
- Parameters:
pod_obj (Pod) – The pod object to get the PVC name.
- Returns:
The PVC name attached to the pod.
- Return type:
str
- Raises:
UnavailableResourceException – If no PVC is attached to the pod.
- 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=None, ignore_selector=None)
Checks the running state pods in a given namespace.
- Parameters:
namespace (str) – Cluster namespace where pods are running
ignore_selector (list) – List of pod selectors to ignore ( eg: [“rook-ceph-mgr”, “rook-ceph-detect-version”] )
- Returns:
all the pod objects that are in running state only
- Return type:
List
- ocs_ci.ocs.resources.pod.get_topolvm_controller_pod(label='app.kubernetes.io/component=topolvm-controller', namespace=None)
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=None)
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.is_pod_owned_by_job(pod_obj)
Check if pod is owned by Job controller.
- Parameters:
pod_obj – Pod object to check
- Returns:
True if pod is owned by Job controller, False otherwise
- Return type:
bool
- 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=None)
The function returns the list of nodes for the given selector
- Parameters:
selector (str) – The resource selector to search with
namespace (str) – the namespace ot the pods
- 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=None, selector=None)
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
selector (str) – selector to filter the pods. Ex: for noobaa, selector=’app=noobaa’
- Returns:
Raw output of adm top pods command
- Return type:
str
- ocs_ci.ocs.resources.pod.restart_pods_having_label(label, namespace=None)
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=None, 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 | None) – The osd IDs.
- Returns:
The ocs-osd-removal job object, or None if no OSDs provided
- Return type:
ocs_ci.ocs.resources.ocs.OCS | None
- ocs_ci.ocs.resources.pod.search_pattern_in_pod_logs(pod_name, pattern, namespace=None, container=None, all_containers=False, since=None)
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.
since (str, optional) – Only return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to None.
- 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, ignore_psql_12_verification=False)
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.
ignore_psql_12_verification (bool) – If True, psql 12 image is removed from current_images for verification
- 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, sleep=20, num_of_retries=1, restart_tool_pod_before_retry=True)
Wait for the Ceph command to execute successfully in the given timeout and number of retries. For, example, if the timeout is 300 and ‘num_of_retries’ is 2, we will wait 600 seconds for the ceph command to execute successfully.
- Parameters:
timeout (int) – The time to wait for a Ceph command to execute successfully
sleep (int) – Time to sleep between the iterations
num_of_retries (int) – The number of retries to wait for the Ceph command to execute successfully.
restart_tool_pod_before_retry (bool) – If True, restart the rook-ceph-tool pod before the next retry. False, otherwise.
- 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=None, 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_matching_pattern_in_pod_logs(pod_name, pattern, namespace=None, container=None, all_containers=False, since=None, timeout=300, sleep=20)
Waits for a matching pattern in the logs of a pod until timeout is reached.
- 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.
since (str, optional) – Only return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to None.
timeout (int) – Maximum time to wait for the pattern to appear in seconds.
sleep (int) – Time in seconds to sleep between attempts.
- Returns:
The list of matched lines with the pattern if found within timeout, else False.
- Return type:
list
- Raises:
TimeoutExpiredError – If the pattern is not found within the specified timeout.
- 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, expected_count, namespace=None, timeout=200, sleep=10)
Wait for the expected number of pods with the given selector.
- Parameters:
selector (str) – The resource selector to search with
expected_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=None)
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=None, 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_in_statuses_concurrently(app_selectors_to_resource_count_list, namespace, timeout=1200, status='Running', cluster_kubeconfig='')
Verify pods are running in the namespace using app selectors. This method is using concurrent futures to speed up execution and will be blocking until all pods are running or timeout is reached
- Parameters:
app_selectors_to_resource_count_list –
namespace – namespace of the pods expected to run
timeout – time to wait for the pods to be running in seconds
status – status of the pods to wait for
cluster_kubeconfig – The kubeconfig file to use for the oc command
- Returns:
True if all pods are running, False otherwise
- Return type:
bool
- ocs_ci.ocs.resources.pod.wait_for_pods_to_be_running(namespace=None, pod_names=None, raise_pod_not_found_error=False, timeout=200, sleep=10, cluster_kubeconfig='', skip_for_status=None)
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
cluster_kubeconfig (str) – The kubeconfig file to use for the oc command
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:
bool
- ocs_ci.ocs.resources.pod.wait_for_storage_pods(timeout=200, skip_job_pods=False)
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
skip_job_pods (bool) – If True, skip pods owned by Job controllers (useful for tests that expect ephemeral job pods to be cleaned up)
ocs_ci.ocs.resources.probe module
Probe resource related functionalities
- class ocs_ci.ocs.resources.probe.Probe(**kwargs)
Bases:
OCSHandles Probe resource operations for monitoring
- get_probe_config(probe_name, namespace=None)
Get the probe configuration.
- Parameters:
probe_name (str) – Name of the probe resource
namespace (str, optional) – Namespace of the probe. Defaults to openshift-storage if not provided.
- Returns:
Probe configuration as a dictionary
- Return type:
dict
- get_static_targets(probe_config)
Extract static target IPs from the probe configuration.
- Parameters:
probe_config (dict) – Probe configuration dictionary
- Returns:
List of IP addresses configured as static targets in the probe
- Return type:
list
- Raises:
RuntimeError – If unable to extract IPs from probe configuration
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_in_status(storage_class, status='Bound')
It looks for pv with particular storageclass in particular status
- Parameters:
storage_class (str) – storage class
status (str) – status of the pv
- Returns:
list of pv objects
- 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.get_pvs_by_names(pv_names)
Get the pv objects by their names
- Parameters:
pv_names (list) – The list of PV names to be retrieved.
- Returns:
List of pv objects that match the provided names.
- Return type:
list
- 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.pv.wait_for_new_pvs_status(current_pv_objs, sc_name, expected_status, num_of_new_pvs=1, timeout=120, sleep=10)
Wait for the new pvs, that has been created in a specific storage class, to reach the expected status.
- Parameters:
current_pv_objs (list) – List of dictionaries of the current pv objects before creating the new pvs (to be used to identify the new pvs)
sc_name (str) – The name of the storage class of the pv objects
num_of_new_pvs (int) – Number of the new pvs that should be in the expected status
expected_status (str) – The expected status of the new pvs
timeout (int) – time to wait for the new pv to come up
sleep (int) – time to sleep between iterations
- Returns:
True if the new pvs are in the expected status. False, otherwise.
- Return type:
bool
- ocs_ci.ocs.resources.pv.wait_for_pvs_in_lvs_to_reach_status(lvs_name, pv_count, expected_status, timeout=180, sleep=10)
Wait for the Persistent Volumes (PVs) associated with a specific LocalVolumeSet (LVS) to reach the expected status within a given timeout.
- Parameters:
lvs_name (str) – The LocalVolumeSet name whose PVs are being monitored.
pv_count (int) – The number of PVs expected to reach the desired status.
expected_status (str) – The expected status of the PVs (e.g., “Bound”, “Available”).
timeout (int) – Maximum time to wait for the PVs to reach the expected status, in seconds.
sleep (int) – Interval between successive checks, in seconds.
- Returns:
True if all PVs reach the expected status within the timeout, False otherwise.
- Return type:
bool
- Raises:
TimeoutExpiredError – If the PVs do not reach the expected status within the specified timeout.
ResourceWrongStatusException – If any PV enters an unexpected or error status.
- ocs_ci.ocs.resources.pv.wait_for_pvs_to_reach_status(pv_names, expected_status, timeout=180, sleep=10)
Wait for the Persistent Volumes (PVs) to reach the expected status within a given timeout.
- Parameters:
pv_names (list) – The list of PV names to be monitored.
expected_status (str) – The expected status of the PVs (e.g., “Bound”, “Available”).
timeout (int) – Maximum time to wait for the PVs to reach the expected status, in seconds.
sleep (int) – Interval between successive checks, in seconds.
- Returns:
True if all PVs reach the expected status within the timeout, False otherwise.
- Return type:
bool
- Raises:
TimeoutExpiredError – If the PVs do not reach the expected status within the specified timeout.
ResourceWrongStatusException – If any PV enters an unexpected or error status.
ocs_ci.ocs.resources.pvc module
General PVC object
- class ocs_ci.ocs.resources.pvc.PVC(**kwargs)
Bases:
OCSA 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, timeout=60)
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
timeout (int) – Timeout in seconds to wait for snapshot to be ready (default: 60)
- 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_cephfs_subvolume_name
Fetch subvolume name associated with the CephFS PVC
- Returns:
Subvolume name associated with the CephFS PVC
- Return type:
str
- 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, timeout=240)
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
timeout – Time to wait for the verification. To be used with verify=True
- 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, timeout=60)
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
timeout (int) – Timeout in seconds to wait for snapshot to be ready (default: 60)
- 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.flatten_image(clone_obj)
Flatten the image of clone
- Parameters:
clone_obj – Object of clone of which image to be flatten
- 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_deviceclass_pvcs(deviceclass_name, namespace=None)
Get the Persistent Volume Claims (PVCs) associated with a specific DeviceClass.
- Parameters:
deviceclass_name (str) – The DeviceClass name whose PVCs are being retrieved.
namespace (str) – The namespace where the DeviceClass PVCs are located.
- Returns:
List of PVC objects associated with the specified DeviceClass.
- Return type:
list
- 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.get_pvcs_in_deviceset(deviceset_name, namespace=None)
Get the Persistent Volume Claims (PVCs) associated with a specific Deviceset.
- Parameters:
deviceset_name (str) – The Deviceset name whose PVCs are being retrieved.
namespace (str) – The namespace where the Deviceset PVCs are located.
- Returns:
List of PVC objects associated with the specified Deviceset.
- Return type:
list
- ocs_ci.ocs.resources.pvc.get_pvcs_using_storageclass(storageclass_name: str, namespace: str = None) list[dict]
Find all PVCs using a specific StorageClass
- Parameters:
storageclass_name (str) – Name of the StorageClass to search for
namespace (str) – Namespace to search in. If None, searches all namespaces
- Returns:
- List of PVC information dictionaries containing name, namespace,
storageclass, status, and size
- Return type:
list[dict]
- Raises:
ValueError – If storageclass_name is empty or None
CommandFailed – If OCP API call fails
- 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.pvc.wait_for_pvcs_in_deviceset_to_reach_status(deviceset_name, pvc_count, expected_status, namespace=None, timeout=180, sleep=10)
Wait for the Persistent Volume Claims (PVCs) associated with a specific Deviceset to reach the expected status within a given timeout.
- Parameters:
deviceset_name (str) – The Deviceset name whose PVCs are being monitored.
pvc_count (int) – The number of PVCs expected to reach the desired status.
expected_status (str) – The expected status of the PVCs (e.g., “Bound”, “Available”).
namespace (str) – The namespace where the Deviceset PVCs are located.
timeout (int) – Maximum time to wait for the PVCs to reach the expected status, in seconds.
sleep (int) – Interval between successive checks, in seconds.
- Returns:
True, if the PVCs reach the expected status within the specified timeout. False, otherwise.
- Return type:
bool
- ocs_ci.ocs.resources.pvc.wait_for_pvcs_in_lvs_to_reach_status(lvs_name, pvc_count, expected_status, timeout=180, sleep=10)
Wait for the Persistent Volume Claims (PVCs) associated with a specific LocalVolumeSet (LVS) to reach the expected status within a given timeout.
- Parameters:
lvs_name (str) – The LocalVolumeSet name whose PVCs are being monitored.
pvc_count (int) – The number of PVCs expected to reach the desired status.
expected_status (str) – The expected status of the PVCs (e.g., “Bound”, “Available”).
timeout (int) – Maximum time to wait for the PVCs to reach the expected status, in seconds.
sleep (int) – Interval between successive checks, in seconds.
- Returns:
True, if the PVCs reach the expected status within the specified timeout. False, otherwise.
- Return type:
bool
ocs_ci.ocs.resources.rgw module
- class ocs_ci.ocs.resources.rgw.RGW(namespace=None)
Bases:
objectWrapper 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.rgw.create_ec_cephobjectstore()
Create an erasure-coded CephObjectStore with a replicated metadata pool and an erasure-coded data pool, then create the corresponding bucket StorageClass.
- Erasure coding parameters are read from config.DEPLOYMENT:
ec_data_chunks (int): number of data chunks, k value (default: 2) ec_coding_chunks (int): number of coding chunks, m value (default: 1) ec_failure_domain (str): failure domain (default: “host”)
ocs_ci.ocs.resources.s3_batch_deleter module
- class ocs_ci.ocs.resources.s3_batch_deleter.S3BatchDeleter(s3_resource, bucket_name)
Bases:
objectThis class offers two ways to clear all objects from an S3 bucket:
1. Sequentially: Deletes objects in batches of 1000 sequentially. Use this for typical cases with manageable object counts.
2. In parallel: Deletes objects in batches of 1000 using multiple threads. This method is designed for extreme cases where the bucket has hundreds of thousands of objects, and should only be used for scale and cleanup purposes.
- MAX_BATCH_SIZE = 1000
- delete_in_parallel()
Delete all objects from the S3 bucket in parallel using multiple threads.
This method is designed for extreme cases where the bucket has hundreds of thousands of objects and should only be used for scale and cleanup purposes.
This method uses a ThreadPoolExecutor to process batches of objects concurrently. It is designed to optimize deletion performance by leveraging multiple threads, while also managing memory usage to avoid excessive resource consumption.
- Raises:
Exception – If any objects fail to delete after a retry attempt.
- delete_sequentially()
Delete all objects from the S3 bucket in batches sequentially.
This method is designed for normal use cases and should be used when the bucket has a manageable number of objects.
ocs_ci.ocs.resources.storage_client module
Storage client related functions
- class ocs_ci.ocs.resources.storage_client.StorageClient
Bases:
objectThis class contains the functions for Storage Client page
- create_native_storage_client(namespace_to_create_storage_client='openshift-storage')
This method creates native storage client
- Parameters:
namespace_to_create_storage_client (str) – namespace where the storageclient will be created
- create_network_policy(namespace_to_create_storage_client=None, resource_name=None)
This method creates network policy for the namespace where Storage Client will be created
Inputs: namespace_to_create_storage_client (str): Namespace where the storage client will be created
- create_storage_client(storage_provider_endpoint=None, onboarding_token=None)
This method creates storage clients
Inputs: storage_provider_endpoint (str): storage provider endpoint details. onboarding_token (str): onboarding token
- create_storageclaim(storageclaim_name, type, storage_client_name, namespace_of_storageclient=None, storageprofile=None)
This method creates storageclaims.
- Parameters:
storageclaim_name (str) – name of the storageclaim/storageclassclaim to create
type – type of the storageclaim for ODF 4.16 >= : type = block/sharedfile for ODF 4.14 & 4.15 : type =blockpool/sharedfilesystem
storage_client_name (str) – name of the storageclient for which storageclaim is created
namespace_of_storageclient (str) – namespace where the storageclient is created
storageprofile (str) – blcokpool name, optional field
- fetch_provider_endpoint()
This method fetches storage provider endpoint
Returns: storage_provider_endpoint(str): storage provider endpoint details
- fetch_storage_client_status(namespace=None, storageclient_name=None)
Fetch storageclient status
- Inputs:
namespace(str): Namespace where the storage client is created storageclient_name(str): name of the storageclient
- Returns:
storageclient phase
- Return type:
storageclient_status(str)
- get_storageclient_name(namespace, timeout=300, sleep=10)
This method fetches the first storageclient name. Suits well only for native storage client wait and fetch
- Parameters:
namespace (str) – Namespace where the storageclient is created
timeout (int) – Time to wait for the storageclient
sleep (int) – Time to sleep between each iteration
- Returns:
name of the storageclient
- Return type:
storageclient_name(str)
- odf_installation_on_client(catalog_yaml=False, enable_console=False, subscription_yaml='/home/docs/checkouts/readthedocs.org/user_builds/ocs-ci/checkouts/latest/ocs_ci/templates/provider-client-deployment/native_storage_client.yaml', channel_to_client_subscription=None, client_subcription_image=None)
This method creates odf subscription on clients
Inputs: catalog_yaml (bool): If enabled then constants.OCS_CATALOGSOURCE_YAML will be created.
enable_console (bool): If enabled then odf-client-console will be enabled
subscription_yaml: subscription yaml which needs to be created. default value, constants.NATIVE_STORAGE_CLIENT_YAML
- channel(str): ENV_DATA:
channel_to_client_subscription: “4.16”
- client_subcription_image(str): ENV DATA
image details for client subscription
- verify_native_storageclient()
This method verifies that native client is created successfully, in ‘Connected’ status. storageclaims, associated storageclasses and storagerequests are created successfully.
- verify_storage_claim_status(storageclient_name=None, namespace=None, expected_status='Ready')
This method checks that the storageclaims are in expected status for a storageclient
- Parameters:
storageclient_name (str) – Name of the storageclient to be verified.
namespace (str) – Namespace where the storageclient is present.
expected_status (str) – Expected status of the storageclaim
- verify_storageclient_status(storageclient_name, namespace=None, expected_storageclient_status='Connected')
- Parameters:
storageclient_name (str) – Name of the storageclient to be verified.
namespace (str) – Namespace where the storageclient is present. Default value will be taken from ENV_DATA[“cluster_namespace”]
expected_storageclient_status (str) – expected storageclient phase; default value is ‘Connected’
- Returns:
- returns true if the
storageclient_phase == expected_storageclient_status
- Return type:
storageclient_phase (bool)
- verify_storagerequest_exists(storageclient_name=None, namespace=None)
Fetch storagerequests for storageclient
- Parameters:
storageclient_name (str) – Name of the storageclient to be verified.
namespace (str) – Namespace where the storageclient is present.
- verify_version_of_odf_client_operator(only_major_minor=True)
This method verifies the odf client operator version is as per provider odf version
ocs_ci.ocs.resources.storage_cluster module
StorageCluster related functionalities
- class ocs_ci.ocs.resources.storage_cluster.StorageCluster(resource_name='', *args, **kwargs)
Bases:
OCPThis 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.add_new_deviceset_in_storagecluster(device_class, name, count=3, replica=1, access_modes=None, device_type='SSD', sc_name=None, storage_size=None)
Add a new DeviceSet to the StorageCluster.
- Parameters:
device_class (str) – Device class for the DeviceSet.
name (str) – Name of the DeviceSet.
count (int) – Number of devices in the DeviceSet.
replica (int) – Number of replicas.
access_modes (list) – List of access modes.
device_type (str) – Device type for the DeviceSet.
sc_name (str) – The storage class name for the DeviceSet. If None, use device_class name.
storage_size (str) – Storage size for the DeviceSet.
- Returns:
True if the patch was applied successfully, False otherwise.
- Return type:
bool
- 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.check_underlying_resource_exists(storage_class_type)
Check if the underlying Ceph resource exists for a given storage class type.
- Parameters:
storage_class_type (str) – The type of storage class (e.g., “cephFilesystems”, “cephBlockPools”, “cephObjectStores”, “nfs”, “encryption”)
- Returns:
- True if the underlying resource exists or if it’s a type that doesn’t
need verification (nfs/encryption), False otherwise.
- Return type:
bool
- ocs_ci.ocs.resources.storage_cluster.check_unnecessary_pods_present()
Based on configuration, check that pods that are not necessary are not present.
- ocs_ci.ocs.resources.storage_cluster.delete_storageclass_and_deregister(sc_name, sc_ocp=None, timeout=180)
- Fully clean up a test-created StorageClass:
Deregister from StorageConsumer (prevents reconciler recreation)
Label with is-external (prevents gRPC serving)
Delete the SC
Verify it stays deleted (not recreated by operator)
- Parameters:
sc_name (str) – Name of the StorageClass.
sc_ocp (
OCP, optional) – OCP instance for StorageClass. Created if None.timeout (int) – Seconds to wait for deletion confirmation.
- Raises:
TimeoutExpiredError – If the SC keeps getting recreated.
- ocs_ci.ocs.resources.storage_cluster.get_all_device_sets()
Get all the device classes in the storagecluster
- Returns:
The device classes in the storagecluster
- Return type:
list
- 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_client_storage_provider_endpoint()
Get the client “storageProviderEndpoint” from the storage-client
- Returns:
The client “storageProviderEndpoint”
- Return type:
str
- 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_csi_images_for_client_ocp_version(ocp_version=None)
Get the csi images of the specified ocp version
- Parameters:
ocp_version (str) – The ocp version of the csi images. If not provided, it will get the current ocp cluster version
- Returns:
The list of the csi images of the specified ocp version
- Return type:
list
- ocs_ci.ocs.resources.storage_cluster.get_default_deviceclass()
Get the default deviceclass from the storagecluster
- Returns:
The default deviceclass
- Return type:
str
- ocs_ci.ocs.resources.storage_cluster.get_default_storagecluster(namespace=None)
Get the default storage cluster
- Returns:
The default storage cluster
- Return type:
- 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_deviceclass_name(device_set)
Get the deviceclass name from the device set dict
- Parameters:
device_set (dict) – The device set dict
- Returns:
The deviceclass name
- Return type:
str
- ocs_ci.ocs.resources.storage_cluster.get_deviceset_count()
Get the first storageDeviceSet count from storagecluster
- Returns:
The count of the first storageDeviceSet
- Return type:
int
- ocs_ci.ocs.resources.storage_cluster.get_deviceset_name_per_count()
Get the deviceset name per count dict
- Returns:
The deviceset name per count dict
- Return type:
dict
- ocs_ci.ocs.resources.storage_cluster.get_deviceset_name_per_deviceclass()
Get the deviceset name per deviceclass dict
- Returns:
The deviceset name per deviceclass dict
- Return type:
dict
- ocs_ci.ocs.resources.storage_cluster.get_deviceset_sc_name(device_set)
Get the deviceset storageclass name from the device set dict
- Parameters:
device_set (dict) – The device set dict
- Returns:
The deviceset storageclass name
- Return type:
str
- ocs_ci.ocs.resources.storage_cluster.get_deviceset_sc_name_per_count()
Get the deviceset storageclass name per count dict from the storagecluster
- Returns:
The deviceset storageclass name per count dict
- Return type:
dict
- ocs_ci.ocs.resources.storage_cluster.get_deviceset_sc_name_per_deviceclass()
Get the deviceset storageclass name per deviceclass name dict
- Returns:
The deviceset storageclass name per deviceclass name dict
- Return type:
dict
- ocs_ci.ocs.resources.storage_cluster.get_first_sc_name_from_storagecluster()
Get the first storageclass name from the storagecluster
- Returns:
The first storageclass name from the storagecluster
- Return type:
str
- 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_id_per_deviceclass()
Get the osd id per deviceclass dict
- Returns:
The osd id per deviceclass dict
- Return type:
dict
- 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_client()
Get the StorageClient OCP object for the configured storage client.
- Returns:
- StorageClient OCP object with resource_name set
to the storage client name from config.
- Return type:
- ocs_ci.ocs.resources.storage_cluster.get_storage_cluster(namespace=None)
Get storage cluster object (from provider cluster if run on multicluster environment)
- 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.get_total_deviceset_count()
Get the total storageDeviceSets count from storagecluster, summed across all storageDeviceSets.
- Returns:
Total count across all storageDeviceSets
- Return type:
int
- 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.patch_storageclass_ocs_external_label(resource_name)
Merge-patch
storageclass.ocs.openshift.io/is-external: "true"on a StorageClass if it exists.Used before deleting StorageClasses so the provider-side gRPC server excludes the SC from the GetDesiredClientState() response. Applies to all deployment types since ODF 4.22 uses the provider/consumer model even for internal deployments.
- ocs_ci.ocs.resources.storage_cluster.remove_storageclass_from_storageconsumer(sc_name, consumer_name='internal')
Remove a StorageClass entry from StorageConsumer.spec.storageClasses[].
This prevents the ocs-client-operator from recreating the SC on its next reconcile cycle via the gRPC GetDesiredClientState() call. Must be called BEFORE deleting the StorageClass.
- Parameters:
sc_name (str) – Name of the StorageClass to deregister.
consumer_name (str) – Name of the StorageConsumer CR; default
ocs_ci.ocs.constants.INTERNAL_STORAGE_CONSUMER_NAME("internal").
- 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.set_non_resilient_pool(storage_cluster: StorageCluster, enable: bool = True) None
Enable non-resilient ceph settings by patching the storage cluster (Replica-1 feature)
- Parameters:
storage_cluster (StorageCluster) – StorageCluster object
enable (bool, optional) – cephNonResilientPools value * Setting False is not supported by ODF in 4.14 *.
- 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_non_resilient_pool(storage_cluster: StorageCluster) bool
Validate non-resilient pools (replica-1) are enabled in storage cluster
- Parameters:
storage_cluster (StorageCluster) – StorageCluster object
- Returns:
True if replica-1 enabled, False otherwise
- Return type:
bool
- 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(backingstore_name=None)
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, check_multiple_deviceclasses=False)
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
check_multiple_deviceclasses (bool) – If true, then check multiple deviceclasses. False, otherwise.
- 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(skip_mds=False)
Verify Multus network(s) created successfully and are present on relevant pods.
- Parameters:
skip_mds (bool) – If True, skip MDS pod and MDS map validation
- 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 (for ODF versions lesser than 4.19) 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_extended()
Verify storage cluster extended 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, check_multiple_deviceclasses=False)
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
check_multiple_deviceclasses (bool) – If true, then check multiple deviceclasses. False, otherwise.
- 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.storage_cluster.wait_for_storage_client_connected(timeout=180, sleep=10)
Wait for the Storage client to be in a connected phase
- Parameters:
timeout (int) – Time to wait for the Storage Client to be in a connected phase
sleep (int) – Time in seconds to sleep between attempts
- Raises:
ResourceWrongStatusException – In case the Storage Client didn’t reach the desired connected phase
ocs_ci.ocs.resources.storageclassclaim module
StorageClassClaim related functionalities
- class ocs_ci.ocs.resources.storageclassclaim.StorageClassClaim(**kwargs)
Bases:
OCSStorageClassClaim 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, namespace=None, consumer_context=None)
Bases:
objectBase StorageConsumer class
- create_storage_consumer(storage_classes=None, volume_snapshot_classes=None, volume_group_snapshot_classes=None, storage_quota_in_gib=None, resource_name_mapping_config_map_name=None)
Create a storage consumer
- Parameters:
storage_classes (list) – List of storage classes
volume_snapshot_classes (list) – List of volume snapshot classes
volume_group_snapshot_classes (list) – List of volume group snapshot classes
storage_quota_in_gib (int) – Storage quota in GiB
resource_name_mapping_config_map_name (str) – Resource name mapping config map
- Returns:
Dictionary with consumer data
- Return type:
dict
- get_client_status()
Get client status from storageconsumer resource and apply patch.
- Returns:
client status
- Return type:
dict
- get_heartbeat_cronjob()
- Returns:
status reporter cronjob OCS object
- Return type:
object
- get_last_heartbeat()
Get the last heartbeat cronjob.
- Returns:
last heartbeat timestamp
- Return type:
dict
- get_ocs_version()
Get ocs version from storageconsumer resource.
- Returns:
consumer ocs version
- Return type:
string
- get_onboarding_ticket_secret()
Get OnboardingTicketSecret from storageconsumer resource status. Optional field. Reference to name of an onboarding secret cr.
- Returns:
OnboardingTicketSecret
- Return type:
string
- get_owner_references()
Get owner references of the storage consumer.
- Returns:
List of owner references
- Return type:
list
- get_resource_name_mapping_config_map_from_spec()
Get ResourceNameMappingConfigMap from storageconsumer resource. It is optional, reflect the configMap we used, user provided or generated This is a name of the configmap, resource that stores ceph rns, svg names and more
- Returns:
ResourceNameMappingConfigMap
- Return type:
string
- get_resource_name_mapping_config_map_from_status()
Get ResourceNameMappingConfigMap from storageconsumer resource from Status. This is a name of the configmap, resource that stores ceph rns, svg names and more
- Returns:
ResourceNameMappingConfigMap
- Return type:
string
- get_state()
Get state from storageconsumer resource.
- Returns:
state of the storage consumer
- Return type:
string
- get_storage_classes()
Get storage classes from storageconsumer resource and apply patch.
- Returns:
storage classes
- Return type:
list
- get_storage_quota_in_gib()
Get storage quota in GiB from storageconsumer resource.
- Returns:
storage quota in GiB
- Return type:
int
- get_uid()
Get the UID of the StorageConsumer resource.
- Returns:
UID of the StorageConsumer resource
- Return type:
str
- get_volume_snapshot_classes()
Get volume snapshot classes from storageconsumer resource.
- Returns:
volume snapshot classes
- Return type:
list
- remove_custom_storage_class(storage_class)
Remove storage class from storageconsumer resource and apply patch.
- Parameters:
storage_class (string) – storage class
- remove_custom_volume_group_snapshot_class(group_snapshot_class)
Remove volume group snapshot class from storageconsumer resource and apply patch.
- Parameters:
group_snapshot_class (string) – volume group snapshot class
- remove_custom_volume_snapshot_class(snapshot_class)
Remove volume snapshot class from storageconsumer resource and apply patch.
- Parameters:
snapshot_class (string) – volume snapshot class
- resume_heartbeat()
Resume status reporter cron job.
- set_custom_volume_group_snapshot_class(group_snapshot_class)
Set volume group snapshot class to storageconsumer resource and apply patch.
- Parameters:
group_snapshot_class (string) – volume group snapshot class
- set_custom_volume_snapshot_class(snapshot_class)
Set volume snapshot class to storageconsumer resource and apply patch.
- Parameters:
snapshot_class (string) – volume snapshot class
- 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
- set_storage_classes(storage_classes)
Add one or multiple storage classes to the storageconsumer resource and apply patch.
- Parameters:
storage_classes (str or list) – A single storage class as a string or a list of storage classes.
- set_storage_quota_in_gib(quota)
Update storage quota in GiB in storageconsumer resource and apply patch.
- Parameters:
quota (int) – storage quota in GiB
- stop_heartbeat()
Suspend status reporter cron job.
- ocs_ci.ocs.resources.storageconsumer.add_storageclasses_to_storageconsumer(consumer_name, storageclasses)
Add storageclass(es) to a specific StorageConsumer on the provider cluster.
This function runs on the provider cluster and adds the specified storageclasses to the StorageConsumer’s spec.storageClasses list if they are not already present.
- Parameters:
consumer_name (str) – Name of the StorageConsumer CR
storageclasses (str or list) – Storageclass name(s) to add
- Returns:
- (success: bool, added_scs: list, current_scs: list)
success: True if operation completed without errors added_scs: List of storageclasses that were added current_scs: Final list of storageclasses in the StorageConsumer
- Return type:
tuple
Examples
Add single storageclass:
success, added, current = add_storageclasses_to_storageconsumer( "consumer-c21-c5", "openshift-storage.noobaa.io" )
Add multiple storageclasses:
success, added, current = add_storageclasses_to_storageconsumer( "consumer-c21-c5", ["openshift-storage.noobaa.io", "my-custom-noobaa-sc"] )
- ocs_ci.ocs.resources.storageconsumer.check_consumer_rns(consumer_name, pool_list, rns_list)
Verify that the Rados namespaces on the consumer match the expected ones. Each pool must have one RNS for each Storage Consumer.
- Parameters:
consumer_name (str) – Name of the storage consumer
pool_list (list) – List of pool names
rns_list (list) – List of Rados namespaces
- Returns:
True if RNS found for each consumer over all pools (excluding exception list), False otherwise.
- Return type:
bool
- ocs_ci.ocs.resources.storageconsumer.check_consumer_svg(consumer_name, volume_list, svg_list)
Verify that the subvolumegroup on the consumer matches the expected one.
- Parameters:
consumer_name (str) – Name of the storage consumer
volume_list (list) – List of volume names
svg_list (list) – List of subvolumegroup names
- Returns:
True if subvolumegroup found for each consumer, False otherwise.
- Return type:
bool
- ocs_ci.ocs.resources.storageconsumer.check_consumers_rns()
Verify that the Rados namespaces on the consumer match the expected ones. Function is for all clusters that host ceph and are post-convergence.
- Returns:
True if RNS found for each consumer over all pools, False otherwise.
- Return type:
bool
- ocs_ci.ocs.resources.storageconsumer.check_consumers_svg()
Verify that the subvolumegroup on the consumer matches the expected one. Function is for all clusters that host ceph and are post-convergence. Although only one volume/filesystem is currently supported, this function is designed to check all volumes have svg dedicated for consumer.
- Returns:
True if subvolumegroup found for each consumer, False otherwise.
- Return type:
bool
- ocs_ci.ocs.resources.storageconsumer.check_storage_classes_on_clients(ready_consumer_names: list[str])
Verify that the storage classes are distributed and available in the inventory of a hosted cluster.
- Returns:
True if the storage classes are distributed and available, False otherwise.
- Return type:
bool
- ocs_ci.ocs.resources.storageconsumer.create_storage_consumer_on_default_cluster(consumer_name, storage_classes=None, volume_snapshot_classes=None, volume_group_snapshot_classes=None, storage_quota_in_gib=None, resource_name_mapping_config_map_name=None)
Create a storage consumer on the storage provider cluster
- Parameters:
consumer_name (str) – Name of the storage consumer
storage_classes (list) – List of storage classes
volume_snapshot_classes (list) – List of volume snapshot classes
volume_group_snapshot_classes (list) – List of volume group snapshot classes
storage_quota_in_gib (int) – Storage quota in GiB
resource_name_mapping_config_map_name (str) – Resource name mapping config map
- Returns:
StorageConsumer object
- Return type:
- ocs_ci.ocs.resources.storageconsumer.find_consumer_for_storage_client(storage_client_name)
Find the StorageConsumer CR on the provider that owns
storage_client_name.Must be called within an active provider config context.
- Parameters:
storage_client_name (str) – StorageClient CR name on the client cluster.
- Returns:
(consumer_name, consumer_data)for the matchingStorageConsumer.
- Return type:
tuple[str, dict]
- Raises:
AssertionError – If no matching StorageConsumer is found.
- ocs_ci.ocs.resources.storageconsumer.get_cluster_name_from_storage_consumer(storage_consumer)
Get the storage consumer name used pre-convergence for a given consumer. Status.client.clusterName
- Parameters:
storage_consumer (str) – Name value from the storage consumer cr
- Returns:
storage consumer cluster name from Status.client.clusterName (prefix of full cluster console url)
- Return type:
str
- ocs_ci.ocs.resources.storageconsumer.get_consumer_svg_on_provider(storage_client_name)
Return the CephFS subvolume group name for a storage client on the provider cluster.
The SVG name equals the StorageConsumer CR name on the provider. Must be called within an active provider config context.
- Parameters:
storage_client_name (str) – StorageClient CR name on the client cluster.
- Returns:
Subvolume group name on the provider cluster.
- Return type:
str
- Raises:
AssertionError – If no matching StorageConsumer is found.
- ocs_ci.ocs.resources.storageconsumer.get_ready_consumers_names()
Get the names of all storage consumers that are in READY state.
- Returns:
List of names of storage consumers in READY state.
- Return type:
list
- ocs_ci.ocs.resources.storageconsumer.get_ready_storage_consumers()
Get a list of StorageConsumer objects that are in READY state.
- Returns:
List of StorageConsumer objects in READY state.
- Return type:
list[StorageConsumer]
- ocs_ci.ocs.resources.storageconsumer.verify_consumer_configmap(consumer_name, internal_consumer, config_map_name, storage_consumer_uid)
- ocs_ci.ocs.resources.storageconsumer.verify_last_heartbeat_timestamp(cluster_name)
Verify that the last heartbeat timestamp of the storage consumer for cluster_name is recent (not older than 4 minutes). Uses get_storage_consumer_name to map consumer resources to the given cluster name.
- Parameters:
cluster_name (str) – Name of the cluster to verify the storage consumer heartbeat.
- ocs_ci.ocs.resources.storageconsumer.verify_storage_consumer_resources(consumer_name, distributed_storage_classes=None, distributed_volume_snapshot_classes=None)
Function to Verify resources: ConfigMap of each client includes name of each cephclient of that client OwnerRef of each StorageConsumer is StorageCluster, matches the uid of StorageCluster metadata.uid of storageconsumer matches the cephclient names sufixes in postDeployment StorageCluster uid matches the internal StorageConsumer uid StorageConsumer has StorageClasses and VolumeSnapshotClasses that are available on the cluster
- Parameters:
consumer_name (str) – Name of the storage consumer
distributed_storage_classes (list) – List of distributed storage classes
distributed_volume_snapshot_classes (list) – List of distributed volume snapshot classes
- Raises:
AssertionError – If any of the checks fail
ocs_ci.ocs.resources.stretchcluster module
- class ocs_ci.ocs.resources.stretchcluster.StretchCluster(**kwargs)
Bases:
OCSA 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=60, grace=180)
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_mon_pods_in_a_zone(zone)
Fetches mon pods in a particular zone
- Parameters:
zone (str) – Zone
- Returns:
mon pods in a zone
- Return type:
List
- 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_osd_pods_in_a_zone(zone)
Fetches osd osd pods in particular zone
- Parameters:
zone (str) – Zone
- Returns:
OSD pods in a zone
- 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