Skip to content

Commit

Permalink
Since sometimes the client storageclass names differ for different cl…
Browse files Browse the repository at this point in the history
…ient types, get the current storageclass names when creating resources using "scale_lib".

Signed-off-by: Itzhak Kave <[email protected]>
  • Loading branch information
Itzhak Kave committed Sep 29, 2024
1 parent 4cf888b commit bfc39cc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
38 changes: 38 additions & 0 deletions ocs_ci/helpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5209,3 +5209,41 @@ def configure_cephcluster_params_in_storagecluster_cr(params, default_values=Fal
f' "value": {parameter_value}}}]'
)
storagecluster_obj.patch(params=param, format_type="json")


def get_cephfs_sc_name():
"""
Get the cephfs storage class name.
Returns:
str: The cephfs storage class name.
Raises:
ValueError: If the cephfs storage class name hasn't been found.
"""
sc_names = get_all_storageclass_names()
cephfs_sc_names = [name for name in sc_names if constants.CEPHFS_INTERFACE in name]
if not cephfs_sc_names:
raise ValueError(
"Didn't find the cephfs storageclass in the storageclass names"
)
else:
return cephfs_sc_names[0]


def get_rbd_sc_name():
"""
Get the rbd storage class name.
Returns:
str: The rbd storage class name.
Raises:
ValueError: If the rbd storage class name hasn't been found.
"""
sc_names = get_all_storageclass_names()
rbd_sc_names = [name for name in sc_names if constants.RBD_INTERFACE in name]
if not rbd_sc_names:
raise ValueError("Didn't find the rbd storageclass in the storageclass names")
else:
return rbd_sc_names[0]
6 changes: 4 additions & 2 deletions ocs_ci/ocs/scale_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ def create_multi_pvc_pod(

logger.info(f"Start creating {pvc_count} PVC of 2 types RBD-RWO & FS-RWX")
if is_hci_cluster():
cephfs_sc_obj = constants.DEFAULT_STORAGECLASS_CLIENT_CEPHFS
rbd_sc_obj = constants.DEFAULT_STORAGECLASS_CLIENT_RBD
# Since sometimes the client storageclass names are different for different client types,
# get the current client storageclass names
cephfs_sc_obj = helpers.get_cephfs_sc_name()
rbd_sc_obj = helpers.get_rbd_sc_name()
else:
cephfs_sc_obj = constants.DEFAULT_STORAGECLASS_CEPHFS
rbd_sc_obj = constants.DEFAULT_STORAGECLASS_RBD
Expand Down

0 comments on commit bfc39cc

Please sign in to comment.