aboutsummaryrefslogtreecommitdiffstats
path: root/onap_data_provider
diff options
context:
space:
mode:
Diffstat (limited to 'onap_data_provider')
-rw-r--r--onap_data_provider/resources/service_instance_resource.py28
-rw-r--r--onap_data_provider/schemas/infra_1_1.schema4
2 files changed, 31 insertions, 1 deletions
diff --git a/onap_data_provider/resources/service_instance_resource.py b/onap_data_provider/resources/service_instance_resource.py
index b9af670..b23de40 100644
--- a/onap_data_provider/resources/service_instance_resource.py
+++ b/onap_data_provider/resources/service_instance_resource.py
@@ -69,7 +69,33 @@ class ServiceInstanceResource(Resource):
cloud_owner=self.data["cloud_owner"],
cloud_region_id=cloud_region_id,
)
- tenant: Tenant = cloud_region.get_tenant(self.data["tenant_id"])
+ tenant: Tenant = None
+ if tenant_name := self.data.get("tenant_name"):
+ # TODO: https://jira.onap.org/browse/INT-2056 refactor below when ONAP SDK 9.2.3 is released
+ cr_tenants = [
+ x for x in cloud_region.tenants if x.name == tenant_name
+ ]
+ if len(cr_tenants) > 1:
+ msg = "\n".join(
+ [
+ "===================",
+ f"There are more than one tenant with given name '{tenant_name}':",
+ "\n".join(
+ f"{t.name}: {t.tenant_id}" for t in cr_tenants
+ ),
+ "Use tenant-id instead of tenant-name to specify which tenant should be used during the instantiation.",
+ "===================",
+ ]
+ )
+ logging.error(msg)
+ raise ValueError(
+ "Value provided for 'tenant_name' is ambiguous."
+ )
+ if not cr_tenants:
+ raise ValueError(f"Tenant '{tenant_name}' not found.")
+ tenant = cr_tenants.pop()
+ else:
+ tenant = cloud_region.get_tenant(self.data["tenant_id"])
self.service_subscription.link_to_cloud_region_and_tenant(
cloud_region, tenant
)
diff --git a/onap_data_provider/schemas/infra_1_1.schema b/onap_data_provider/schemas/infra_1_1.schema
index 7175ec5..7514acc 100644
--- a/onap_data_provider/schemas/infra_1_1.schema
+++ b/onap_data_provider/schemas/infra_1_1.schema
@@ -402,6 +402,10 @@ properties:
maximum: 99999
aai_service:
type: string
+ tenant_id:
+ type: string
+ tenant_name:
+ type: string
service_subscription_type:
type: string
instantiation_parameters: