Skip to content

Commit

Permalink
Requirements for new hypershift deployment (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
morenod authored Feb 26, 2025
1 parent 67757bd commit 50bd804
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 17 deletions.
7 changes: 4 additions & 3 deletions libs/platforms/azure/azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ def initialize(self):
self.logging.info(f"Azure Credentials File {self.environment['azure_credentials_file']} verified")
with open(self.environment["azure_credentials_file"], 'r') as azure_credentials_file:
for line in azure_credentials_file:
if line.startswith('subscriptionId:'):
self.environment['subscription_id'] = line.split(':', 1)[1].strip().strip('"')
if "subscriptionId" in line:
self.logging.debug(f"Found subscriptionId {line} on Azure credentials file {self.environment['azure_credentials_file']}")
self.environment['subscription_id'] = line.split(':', 1)[1].strip().strip('"\',')
# Verify Azure Login and subscription
self.logging.info("Getting azure subscriptions using `az account list`")
az_account_code, az_account_out, az_account_err = self.utils.subprocess_exec("az account list")
sys.exit("Exiting...") if az_account_code != 0 else self.logging.info("`az account list` execution OK")

self.logging.debug(f"SubscriptionID: {self.environment['subscription_id']}")
for subscription in json.loads(az_account_out):
if subscription["id"] == self.environment["subscription_id"]:
az_account_set_code, az_account_set_out, az_account_set_err = self.utils.subprocess_exec("az account set --subscription " + subscription["id"])
Expand Down
2 changes: 1 addition & 1 deletion libs/platforms/azure/hypershiftcli/hypershiftcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ def __init__(self, parser, config_file, environment):
super().__init__(parser, config_file, environment)
EnvDefault = self.EnvDefault

parser.add_argument("--mc-cluster-name", action=EnvDefault, env=environment, envvar="HCP_BURNER_AZURE_MC_CLUSTER_NAME", default='aro-hcp-mgmt-cluster', help="Azure cluster name of the MC Cluster")
parser.add_argument("--mc-cluster-name", action=EnvDefault, env=environment, envvar="HCP_BURNER_AZURE_MC_CLUSTER_NAME", default='aro-hcp-aks', help="Azure cluster name of the MC Cluster")
parser.add_argument("--mc-kubeconfig", action=EnvDefault, env=environment, envvar="HCP_BURNER_AZURE_MC_KUBECONFIG", help="Kubeconfig file for the MC Cluster")
parser.add_argument("--mc-az-resource-group", action=EnvDefault, env=environment, envvar="HCP_BURNER_AZURE_MC_RESOURCE_GROUP", help="Azure Resource group where MC is installed")

Expand Down
27 changes: 14 additions & 13 deletions libs/platforms/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,18 @@ def initialize(self):
self.logging.info(f"Initializing platform {self.environment['platform']}")

# OCM Login
self.logging.info("Attempting to log in OCM using `ocm login`")
ocm_login_command = (
"ocm login --url="
+ self.environment["ocm_url"]
+ " --token="
+ self.environment["ocm_token"]
)
ocm_code, ocm_out, ocm_err = self.utils.subprocess_exec(ocm_login_command)
sys.exit("Exiting...") if ocm_code != 0 else self.logging.info(
"`ocm login` execution OK"
)
if self.environment["ocm_token"]:
self.logging.info("Attempting to log in OCM using `ocm login`")
ocm_login_command = (
"ocm login --url="
+ self.environment["ocm_url"]
+ " --token="
+ self.environment["ocm_token"]
)
ocm_code, ocm_out, ocm_err = self.utils.subprocess_exec(ocm_login_command)
sys.exit("Exiting...") if ocm_code != 0 else self.logging.info(
"`ocm login` execution OK"
)

def download_kubeconfig(self, cluster_name, path):
self.logging.debug(
Expand Down Expand Up @@ -210,8 +211,8 @@ def __init__(self, parser, config_file, environment):
parser.set_defaults(**defaults)

temp_args, temp_unknown_args = parser.parse_known_args()
if not temp_args.ocm_token:
parser.error("hcp-burner.py: error: the following arguments (or equivalent definition) are required: --ocm-token")
# if not temp_args.ocm_token:
# parser.error("hcp-burner.py: error: the following arguments (or equivalent definition) are required: --ocm-token")

# def __getitem__(self, item):
# return self.parameters[item] if item in self.parameters else None
Expand Down

0 comments on commit 50bd804

Please sign in to comment.