Skip to content

Commit 7e6e64b

Browse files
author
Bhautik Vala
committed
[minor] Enable Manage AI Service Integration
1 parent 25b9131 commit 7e6e64b

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

src/mas/devops/aiservice.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,31 @@ def verifyAiServiceInstance(dynClient: DynamicClient, instanceId: str) -> bool:
4444
logger.error(f"Error: Unable to verify AI Service instance due to failed authorization: {e}")
4545
return False
4646

47+
def listAiServiceTenantInstances(dynClient: DynamicClient) -> list:
48+
"""
49+
Get a list of AI Service Tenant instances on the cluster
50+
"""
51+
return listInstances(dynClient, "aiservice.ibm.com/v1", "AIServiceTenant")
52+
53+
54+
def verifyAiServiceTenantInstance(dynClient: DynamicClient, instanceId: str, tenantId: str) -> bool:
55+
"""
56+
Validate that the chosen AI Service Tenant exists
57+
"""
58+
try:
59+
aiserviceTenantAPI = dynClient.resources.get(api_version="aiservice.ibm.com/v1", kind="AIServiceTenant")
60+
aiserviceTenantAPI.get(name=f"aiservice-{instanceId}-{tenantId}", namespace=f"aiservice-{instanceId}")
61+
return True
62+
except NotFoundError:
63+
print("NOT FOUND")
64+
return False
65+
except ResourceNotFoundError:
66+
# The AIServiceApp CRD has not even been installed in the cluster
67+
print("RESOURCE NOT FOUND")
68+
return False
69+
except UnauthorizedError as e:
70+
logger.error(f"Error: Unable to verify AI Service Tenant due to failed authorization: {e}")
71+
return False
4772

4873
def getAiserviceChannel(dynClient: DynamicClient, instanceId: str) -> str:
4974
"""

src/mas/devops/templates/pipelinerun-install.yml.j2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,14 @@ spec:
570570
value: "{{ mas_app_channel_manage }}"
571571
- name: mas_appws_components
572572
value: "{{ mas_appws_components }}"
573+
{%- if manage_bind_aiservice_instance_id is defined and manage_bind_aiservice_instance_id != "" %}
574+
- name: manage_bind_aiservice_instance_id
575+
value: "{{ manage_bind_aiservice_instance_id }}"
576+
{%- endif %}
577+
{%- if manage_bind_aiservice_tenant_id is defined and manage_bind_aiservice_tenant_id != "" %}
578+
- name: manage_bind_aiservice_tenant_id
579+
value: "{{ manage_bind_aiservice_tenant_id }}"
580+
{%- endif %}
573581
{%- if mas_appws_bindings_health_wsl_flag is defined and mas_appws_bindings_health_wsl_flag != "" %}
574582
- name: mas_appws_bindings_health_wsl_flag
575583
value: "{{ mas_appws_bindings_health_wsl_flag }}"

0 commit comments

Comments
 (0)