Skip to content

Commit

Permalink
addressed review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Amrita Mahapatra <[email protected]>
  • Loading branch information
amr1ta committed May 30, 2024
1 parent c5603c2 commit 532da3c
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 44 deletions.
2 changes: 1 addition & 1 deletion ocs_ci/deployment/baremetal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1292,7 +1292,7 @@ def clean_disk(worker, namespace=constants.BM_DEBUG_NODE_NS):

for lsblk_device in lsblk_devices:
if lsblk_device["name"] in selected_disks_to_ignore_cleanup:
print(f'the disk cleanup is ignored for, {lsblk_device["name"]}')
logger.info(f'the disk cleanup is ignored for, {lsblk_device["name"]}')
pass
else:
logger.info(f"Cleaning up {lsblk_device['name']}")
Expand Down
4 changes: 2 additions & 2 deletions ocs_ci/deployment/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,10 @@ def do_deploy_odf_provider_mode(self):
"""
# deploy provider-client deployment
from ocs_ci.deployment.provider_client.storage_client_deployment import (
StorageClientDeployment,
ODFAndNativeStorageClientDeploymentOnProvider,
)

storage_client_deployment_obj = StorageClientDeployment()
storage_client_deployment_obj = ODFAndNativeStorageClientDeploymentOnProvider()

# Provider-client deployment if odf_provider_mode_deployment: True
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""
This module provides installation of ODF in provider mode and storage-client creation
on the hosting cluster.
This module provides installation of ODF and native storage-client creation in provider mode
"""
import atexit
import logging
Expand All @@ -14,8 +13,6 @@
from ocs_ci.ocs.rados_utils import RadosHelper
from ocs_ci.deployment.helpers.lso_helpers import setup_local_storage
from ocs_ci.ocs.node import label_nodes, get_all_nodes, get_node_objs

# from ocs_ci.utility.retry import retry
from ocs_ci.ocs.ui.validation_ui import ValidationUI
from ocs_ci.ocs.ui.base_ui import login_ui, close_browser
from ocs_ci.ocs.utils import (
Expand Down Expand Up @@ -46,7 +43,7 @@
log = logging.getLogger(__name__)


class StorageClientDeployment(object):
class ODFAndNativeStorageClientDeploymentOnProvider(object):
def __init__(self):
log.info("Initializing webdriver and login to webconsole")
# Call a function during initialization
Expand Down
17 changes: 11 additions & 6 deletions ocs_ci/ocs/rados_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ def verify_cephblockpool_status(
Args:
pool_name (str): The name of the Ceph block pool
namespace(str): cluster namespace
required_phase(str): required phase of the cephblockpool
Returns:
status: True if the Ceph block pool is in Ready status, False otherwise
Expand All @@ -298,23 +300,22 @@ def verify_cephblockpool_status(
f"oc get {constants.CEPHBLOCKPOOL} {pool_name} -n {namespace} "
"-o=jsonpath='{.status.phase}'"
)
# phase = run_cmd(cmd=cmd)

phase = retry((CommandFailed), tries=20, delay=10,)(
run_cmd
)(cmd=cmd)

logger.info(f"{pool_name} is in {phase} phase")
logger.info(f"Required phase is {required_phase}")
if phase == required_phase:
return True
else:
return False
return phase == required_phase

def fetch_rados_namespaces(self, namespace=None):
"""
Verify if rados namespace exists
Args:
namespace(str): cluster namespace
Returns:
bool: True if the radosnamespace exists, False otherwise
"""
Expand All @@ -333,6 +334,10 @@ def check_phase_of_rados_namespace(
"""
Verify if rados namespace exists
Args:
namespace(str): cluster namespace
required_phase(str): required phase of the rados namespace
Returns:
bool: True if the radosnamespace exists, False otherwise
"""
Expand All @@ -345,7 +350,7 @@ def check_phase_of_rados_namespace(
"-o=jsonpath='{.status.phase}'"
)
phase = run_cmd(cmd=check_radosns_phase_cmd)
return True if phase == required_phase else False
return phase == required_phase


def corrupt_pg(osd_deployment, pool_name, pool_object):
Expand Down
23 changes: 19 additions & 4 deletions ocs_ci/ocs/resources/storage_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,30 @@
run_cmd,
)
from ocs_ci.utility import templating
from ocs_ci.ocs.resources.storage_cluster import (
check_storage_client_status,
)
from ocs_ci.helpers.managed_services import verify_storageclient_storageclass_claims


log = logging.getLogger(__name__)


def check_storage_client_status(namespace=constants.OPENSHIFT_STORAGE_CLIENT_NAMESPACE):
"""
Check storageclient status
Inputs:
namespace(str): Namespace where the storage client is created
Returns:
storageclient_status(str): storageclient phase
"""
cmd = (
f"oc get storageclient -n {namespace} " "-o=jsonpath='{.items[*].status.phase}'"
)
storageclient_status = run_cmd(cmd=cmd)
return storageclient_status


@retry(AssertionError, 12, 10, 1)
def create_storage_client(
storage_provider_endpoint=None,
Expand All @@ -43,7 +58,7 @@ def create_storage_client(
log.info("Pulling storageclient CR data from yaml")
storage_client_data = templating.load_yaml(constants.STORAGE_CLIENT_YAML)
resource_name = storage_client_data["metadata"]["name"]
print(f"the resource name: {resource_name}")
log.info(f"the resource name: {resource_name}")

# Check storageclient is available or not
storage_client_obj = ocp.OCP(kind="storageclient")
Expand Down
18 changes: 0 additions & 18 deletions ocs_ci/ocs/resources/storage_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2728,21 +2728,3 @@ def resize_osd(new_osd_size, check_size=True):
format_type="json",
)
return res


def check_storage_client_status(namespace=constants.OPENSHIFT_STORAGE_CLIENT_NAMESPACE):
"""
Check storageclient status
Inputs:
namespace(str): Namespace where the storage client is created
Returns:
storageclient_status(str): storageclient phase
"""
cmd = (
f"oc get storageclient -n {namespace} " "-o=jsonpath='{.items[*].status.phase}'"
)
storageclient_status = run_cmd(cmd=cmd)
return storageclient_status
8 changes: 0 additions & 8 deletions ocs_ci/ocs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1472,15 +1472,7 @@ def enable_console_plugin(value="[odf-console]"):
and ocsci_config.ENV_DATA["enable_console_plugin"]
):
log.info("Enabling console plugin")
# ocp_obj = OCP()
# patch = '\'[{"op": "add", "path": "/spec/plugins", "value": ["odf-console"]}]\''
# patch_cmd = (
# f"patch console.operator cluster -n {ocsci_config.ENV_DATA['cluster_namespace']}"
# f" --type json -p {patch}"
# )
# ocp_obj.exec_oc_cmd(command=patch_cmd)
path = "/spec/plugins"
# value = "[odf-console]"
params = f"""[{{"op": "add", "path": "{path}", "value": {value}}}]"""
ocp_obj = OCP(kind=constants.CONSOLE_CONFIG)
ocp_obj.patch(params=params, format_type="json"), (
Expand Down

0 comments on commit 532da3c

Please sign in to comment.