Skip to content

Commit 4cfbabb

Browse files
boonwareJosef Harte
andauthored
[minor] function to list AI Service instances (#106)
Co-authored-by: Josef Harte <josefharte@Josefs-MacBook-Pro.local>
1 parent b8c958c commit 4cfbabb

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

src/mas/devops/mas.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,16 +122,29 @@ def listMasInstances(dynClient: DynamicClient) -> list:
122122
"""
123123
Get a list of MAS instances on the cluster
124124
"""
125-
suitesAPI = dynClient.resources.get(api_version="core.mas.ibm.com/v1", kind="Suite")
125+
return listInstances(dynClient, "core.mas.ibm.com/v1", "Suite")
126126

127-
suites = suitesAPI.get().to_dict()['items']
128-
if len(suites) > 0:
129-
logger.info(f"There are {len(suites)} MAS instances installed on this cluster:")
130-
for suite in suites:
131-
logger.info(f" * {suite['metadata']['name']} v{suite['status']['versions']['reconciled']}")
127+
128+
def listAiServiceInstances(dynClient: DynamicClient) -> list:
129+
"""
130+
Get a list of AI Service instances on the cluster
131+
"""
132+
return listInstances(dynClient, "aiservice.ibm.com/v1", "AIServiceApp")
133+
134+
135+
def listInstances(dynClient: DynamicClient, apiVersion: str, kind: str) -> list:
136+
"""
137+
Get a list of instances of a particular CR on the cluster
138+
"""
139+
api = dynClient.resources.get(api_version=apiVersion, kind=kind)
140+
instances = api.get().to_dict()['items']
141+
if len(instances) > 0:
142+
logger.info(f"There are {len(instances)} {kind} instances installed on this cluster:")
143+
for instance in instances:
144+
logger.info(f" * {instance['metadata']['name']} v{instance['status']['versions']['reconciled']}")
132145
else:
133-
logger.info("There are no MAS instances installed on this cluster")
134-
return suites
146+
logger.info(f"There are no {kind} instances installed on this cluster")
147+
return instances
135148

136149

137150
def getWorkspaceId(dynClient: DynamicClient, instanceId: str) -> str:

0 commit comments

Comments
 (0)