Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport "Add option in ocm.py script to just check if the cluster exists #2196" in releases/2.8.0 #2209

Open
wants to merge 1 commit into
base: releases/2.8.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions ods_ci/utils/scripts/ocm/ocm.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ def is_osd_cluster_exists(self):
log.info(f"ocm cluster with name {self.cluster_name} exists!")
return True

def fail_if_cluster_does_not_exist(self):
"""Exit if cluster does not exist"""
# get_osd_cluster_id exits with code 1 if the cluster does not exist
cluster_id = self.get_osd_cluster_id()
if "error" in cluster_id.lower():
log.info(f"ocm command failed. Cannot tell if {self.cluster_name} cluster exists or not!")
sys.exit(2)

def osd_cluster_create(self):
"""Creates OSD cluster"""

Expand Down Expand Up @@ -1700,6 +1708,23 @@ def update_ocm_policy(self):
)
hibernate_cluster_parser.set_defaults(func=ocm_obj.hibernate_cluster)

# Argument parsers for fail_if_cluster_exists
cluster_exists_parser = subparsers.add_parser(
"check_cluster_existence",
help="Check if the given managed OpenShift Dedicated v4 clusters exists via OCM.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
cluster_exists_parser.add_argument(
"--cluster-name",
help="osd cluster name",
action="store",
dest="cluster_name",
metavar="",
default="",
required=True
)
cluster_exists_parser.set_defaults(func=ocm_obj.fail_if_cluster_does_not_exist)

# Argument parsers for resume_cluster
resume_cluster_parser = subparsers.add_parser(
"resume_cluster",
Expand Down
Loading