Adding elements to base Tenant in order to support general chain
Change-Id: Ia8fcf94b271f0ab40456630bed920a952709d250
diff --git a/xos/core/models/service.py b/xos/core/models/service.py
index 365b1b2..45f6e6d 100644
--- a/xos/core/models/service.py
+++ b/xos/core/models/service.py
@@ -634,6 +634,7 @@
# when subclassing a service, redefine KIND to describe the new service
KIND = "generic"
+ name = StrippedCharField(max_length=200, blank=True, null=True)
kind = StrippedCharField(max_length=30, default=KIND)
provider_service = models.ForeignKey(
Service, related_name='provided_tenants')
diff --git a/xos/tosca/custom_types/xos.m4 b/xos/tosca/custom_types/xos.m4
index dc09b1d..924dfa8 100644
--- a/xos/tosca/custom_types/xos.m4
+++ b/xos/tosca/custom_types/xos.m4
@@ -1373,6 +1373,10 @@
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Subscriber ]
+ tosca.relationships.BelongsToTenant:
+ derived_from: tosca.relationships.Root
+ valid_target_types: [ tosca.capabilities.xos.Tenant ]
+
tosca.relationships.UsesDashboard:
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.DashboardView ]
@@ -1482,6 +1486,10 @@
derived_from: tosca.capabilities.Root
description: An XOS TenantRole
+ tosca.capabilities.xos.Tenant:
+ derived_from: tosca.capabilities.Root
+ description: An XOS Tenant
+
tosca.capabilities.xos.Image:
derived_from: tosca.capabilities.Root
description: An XOS Image
diff --git a/xos/tosca/custom_types/xos.yaml b/xos/tosca/custom_types/xos.yaml
index a089d9d..7c96180 100644
--- a/xos/tosca/custom_types/xos.yaml
+++ b/xos/tosca/custom_types/xos.yaml
@@ -2350,6 +2350,10 @@
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.Subscriber ]
+ tosca.relationships.BelongsToTenant:
+ derived_from: tosca.relationships.Root
+ valid_target_types: [ tosca.capabilities.xos.Tenant ]
+
tosca.relationships.UsesDashboard:
derived_from: tosca.relationships.Root
valid_target_types: [ tosca.capabilities.xos.DashboardView ]
@@ -2459,6 +2463,10 @@
derived_from: tosca.capabilities.Root
description: An XOS TenantRole
+ tosca.capabilities.xos.Tenant:
+ derived_from: tosca.capabilities.Root
+ description: An XOS Tenant
+
tosca.capabilities.xos.Image:
derived_from: tosca.capabilities.Root
description: An XOS Image
diff --git a/xos/tosca/resources/tenant.py b/xos/tosca/resources/tenant.py
index c22eecf..221c288 100644
--- a/xos/tosca/resources/tenant.py
+++ b/xos/tosca/resources/tenant.py
@@ -2,12 +2,11 @@
from xosresource import XOSResource
from toscaparser.tosca_template import ToscaTemplate
-from core.models import Tenant, Service
+from core.models import Tenant, Service, Subscriber
class XOSTenant(XOSResource):
provides = "tosca.nodes.Tenant"
xos_model = Tenant
- name_field = None
copyin_props = ("kind", "service_specific_attribute")
def get_xos_args(self, throw_exception=True):
@@ -17,11 +16,21 @@
if provider_name:
args["provider_service"] = self.get_xos_object(Service, throw_exception=throw_exception, name=provider_name)
+ subscriber_name = self.get_requirement("tosca.relationships.BelongsToSubscriber")
+ if subscriber_name:
+ args["subscriber_root"] = self.get_xos_object(Subscriber, throw_exception=throw_exception,
+ name=subscriber_name)
+
+ tenant_name = self.get_requirement("tosca.relationships.BelongsToTenant")
+ if tenant_name:
+ args["subscriber_tenant"] = self.get_xos_object(Tenant, throw_exception=throw_exception,
+ name=tenant_name)
+
return args
def get_existing_objs(self):
args = self.get_xos_args(throw_exception=False)
- provider_service = args.get("provider", None)
+ provider_service = args.get("provider_service", None)
if provider_service:
return [ self.get_xos_object(provider_service=provider_service) ]
return []