Skip to content

Commit

Permalink
simplify create creds
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Jan 31, 2025
1 parent 798db33 commit c8ead3a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
8 changes: 3 additions & 5 deletions ailib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,9 +808,8 @@ def create_onprem(args):


def create_creds(args):
cluster = args.cluster
info(f"Creating creds for cluster {cluster}")
ai_create_creds(cluster)
info("Gathering ABI creds")
ai_create_creds()


def delete_onprem(args):
Expand Down Expand Up @@ -885,8 +884,7 @@ def cli():

credscreate_desc = 'Create Creds for ABI'
credscreate_parser = create_subparsers.add_parser('creds', description=credscreate_desc, help=credscreate_desc,
formatter_class=rawhelp)
credscreate_parser.add_argument('cluster', metavar='CLUSTER')
formatter_class=rawhelp, aliases=['credentials', 'abi-creds'])
credscreate_parser.set_defaults(func=create_creds)

deploymentcreate_desc = 'Create Deployment e2e'
Expand Down
20 changes: 10 additions & 10 deletions ailib/common/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
from ast import literal_eval
from base64 import b64decode
from urllib.request import urlopen
from urllib.parse import urlencode
from glob import glob
import json
import os
import socket
from shutil import copy2, which
import socket
from subprocess import call
import sys
from tempfile import TemporaryDirectory
from time import time
import urllib.request
from urllib.request import urlopen
from urllib.parse import urlencode
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
import urllib.request
import yaml

# colors = {'blue': '36', 'red': '31', 'green': '32', 'yellow': '33', 'pink': '35', 'white': '37'}


def error(text):
color = "31"
Expand Down Expand Up @@ -265,11 +264,12 @@ def delete_onprem(overrides={}, debug=False):
call("podman pod rm -fi assisted-installer", shell=True)


def create_creds(cluster):
jsonfile = f"{cluster}/.openshift_install_state.json"
if not os.path.exists(jsonfile):
error(f"{jsonfile} Not found")
def create_creds():
jsonfiles = glob('.openshift_install_state.json') + glob('*/.openshift_install_state.json')
if not jsonfiles:
error("No .openshift_install_state.json file Not found")
return
jsonfile = jsonfiles[0]
with open(jsonfile, "r", encoding="utf-8") as f:
data = json.load(f)
result = next((file["contents"]["source"] for file in data["*image.Ignition"]["Config"]["storage"]["files"]
Expand Down

0 comments on commit c8ead3a

Please sign in to comment.