Skip to content

Commit

Permalink
Add support to create ROSA HCP in managed env and fetch the cluster a…
Browse files Browse the repository at this point in the history
…p… (red-hat-data-services#1708)

Add suport to create ROSA HCP in managed env and fetch the cluster api url from cluster

Signed-off-by: Arthy Loganathan <[email protected]>
  • Loading branch information
aloganat authored and bdattoma committed Sep 2, 2024
1 parent 6a93f29 commit b101cd8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ods_ci/tasks/Tasks/rhods_olm.robot
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Library String
${cluster_type} selfmanaged
${image_url} ${EMPTY}
${RHODS_OSD_INSTALL_REPO} None
@{SUPPORTED_TEST_ENV} AWS AWS_DIS GCP PSI PSI_DIS ROSA IBM_CLOUD CRC
@{SUPPORTED_TEST_ENV} AWS AWS_DIS GCP PSI PSI_DIS ROSA IBM_CLOUD CRC AZURE ROSA_HCP
${TEST_ENV} AWS
${INSTALL_TYPE} OperatorHub
${UPDATE_CHANNEL} odh-nightlies
Expand Down
12 changes: 12 additions & 0 deletions ods_ci/utils/scripts/ocm/ocm.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,16 @@ def get_osd_cluster_console_url(self):
sys.exit(1)
return cluster_console_url.strip("\n")

def get_osd_cluster_api_url(self):
"""Gets osd cluster api url"""

filter_str = "--json | jq -r '.api.url'"
cluster_api_url = self.ocm_describe(jq_filter=filter_str)
if cluster_api_url in [None, ""]:
log.error(f"Unable to retrieve cluster api url for cluster name {self.cluster_name}. EXITING")
sys.exit(1)
return cluster_api_url.strip("\n")

def get_osd_cluster_info(self, config_file="cluster_config.yaml"):
"""Gets osd cluster information and stores in config file"""

Expand All @@ -271,6 +281,8 @@ def get_osd_cluster_info(self, config_file="cluster_config.yaml"):
cluster_info["OCP_CONSOLE_URL"] = console_url
cluster_version = self.get_osd_cluster_version()
cluster_info["CLUSTER_VERSION"] = cluster_version
api_url = self.get_osd_cluster_api_url()
cluster_info["OCP_API_URL"] = api_url
odh_dashboard_url = console_url.replace(
"console-openshift-console",
"rhods-dashboard-redhat-ods-applications",
Expand Down
3 changes: 2 additions & 1 deletion ods_ci/utils/scripts/testconfig/generateTestConfigFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ def generate_test_config_file(
data["S3"]["BUCKET_5"]["ENDPOINT"] = config_data["S3"]["BUCKET_5"]["ENDPOINT"]
data["ANACONDA_CE"]["ACTIVATION_KEY"] = config_data["ANACONDA_CE"]["ACTIVATION_KEY"]
data["OCP_CONSOLE_URL"] = config_data["TEST_CLUSTERS"][test_cluster]["OCP_CONSOLE_URL"]
data["OCP_API_URL"] = config_data["TEST_CLUSTERS"][test_cluster]["OCP_API_URL"]
data["ODH_DASHBOARD_URL"] = config_data["TEST_CLUSTERS"][test_cluster]["ODH_DASHBOARD_URL"]
data["TEST_USER"]["AUTH_TYPE"] = config_data["TEST_CLUSTERS"][test_cluster]["TEST_USER"]["AUTH_TYPE"]
data["TEST_USER"]["USERNAME"] = config_data["TEST_CLUSTERS"][test_cluster]["TEST_USER"]["USERNAME"]
Expand Down Expand Up @@ -287,7 +288,7 @@ def generate_test_config_file(

# Login to test cluster using oc command
oc_login(
data["OCP_CONSOLE_URL"],
data["OCP_API_URL"],
data["OCP_ADMIN_USER"]["USERNAME"],
data["OCP_ADMIN_USER"]["PASSWORD"],
)
Expand Down
6 changes: 2 additions & 4 deletions ods_ci/utils/scripts/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,11 @@ def execute_command(cmd: str, print_stdout: bool = True) -> str | None:
return None


def oc_login(ocp_console_url, username, password, timeout=600):
def oc_login(ocp_api_url, username, password, timeout=600):
"""
Login to test cluster using oc cli command
"""
cluster_api_url = ocp_console_url.replace("console-openshift-console.apps", "api")
cluster_api_url = re.sub(r"/$", "", cluster_api_url) + ":6443"
cmd = "oc login -u {} -p {} {} --insecure-skip-tls-verify=true".format(username, password, cluster_api_url)
cmd = f"oc login -u {username} -p {password} {ocp_api_url} --insecure-skip-tls-verify=true"
count = 0
chk_flag = 0
while count <= timeout:
Expand Down

0 comments on commit b101cd8

Please sign in to comment.