CORD-1250 Update to new Service/Tenancy models
Change-Id: I2e5fa0dd7d62a6451a6726eeaba2c3aaf1b83bc9
diff --git a/xos/tosca/resources/CORDSubscriber.py b/xos/tosca/resources/CORDSubscriber.py
index a7c75c5..d91e5bb 100644
--- a/xos/tosca/resources/CORDSubscriber.py
+++ b/xos/tosca/resources/CORDSubscriber.py
@@ -1,4 +1,4 @@
-from core.models import User, TenantRootPrivilege, TenantRootRole
+#from core.models import User, TenantRootPrivilege, TenantRootRole
from services.rcord.models import CordSubscriberRoot
from xosresource import XOSResource
@@ -7,9 +7,9 @@
xos_model = CordSubscriberRoot
copyin_props = ["service_specific_id", "firewall_enable", "url_filter_enable", "cdn_enable", "url_filter_level"]
- def postprocess(self, obj):
- rolemap = ( ("tosca.relationships.AdminPrivilege", "admin"), ("tosca.relationships.AccessPrivilege", "access"), )
- self.postprocess_privileges(TenantRootRole, 'TenantRoot', rolemap, obj)
+# def postprocess(self, obj):
+# rolemap = ( ("tosca.relationships.AdminPrivilege", "admin"), ("tosca.relationships.AccessPrivilege", "access"), )
+# self.postprocess_privileges(TenantRootRole, TenantRootPrivilege, rolemap, obj, "tenant_root")
def can_delete(self, obj):
return super(XOSCORDSubscriber, self).can_delete(obj)
diff --git a/xos/tosca/resources/VOLTTenant.py b/xos/tosca/resources/VOLTTenant.py
index 82158a1..326cb92 100644
--- a/xos/tosca/resources/VOLTTenant.py
+++ b/xos/tosca/resources/VOLTTenant.py
@@ -1,4 +1,4 @@
-from core.models import User
+from core.models import User, ServiceInstanceLink
from services.volt.models import VOLTTenant, VOLTService, VOLT_KIND
from services.rcord.models import CordSubscriberRoot
@@ -15,26 +15,30 @@
provider_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception)
if provider_name:
- args["provider_service"] = self.get_xos_object(VOLTService, 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(CordSubscriberRoot, throw_exception=throw_exception, name=subscriber_name)
+ args["owner"] = self.get_xos_object(VOLTService, throw_exception=throw_exception, name=provider_name)
return args
def get_existing_objs(self):
args = self.get_xos_args(throw_exception=False)
- provider_service = args.get("provider_service", None)
+ provider_service = args.get("owner", None)
service_specific_id = args.get("service_specific_id", None)
if (provider_service) and (service_specific_id):
- existing_obj = self.get_xos_object(VOLTTenant, kind=VOLT_KIND, provider_service=provider_service, service_specific_id=service_specific_id, throw_exception=False)
+ existing_obj = self.get_xos_object(VOLTTenant, owner=provider_service, service_specific_id=service_specific_id, throw_exception=False)
if existing_obj:
return [ existing_obj ]
return []
def postprocess(self, obj):
- pass
+ subscriber_name = self.get_requirement("tosca.relationships.BelongsToSubscriber")
+ if subscriber_name:
+ subscriber = self.get_xos_object(CordSubscriberRoot, throw_exception=True, name=subscriber_name)
+
+ links = ServiceInstanceLink.objects.filter(provider_service_instance = obj,
+ subscriber_service_instance = subscriber)
+ if not links:
+ link = ServiceInstanceLink(provider_service_instance = obj, subscriber_service_instance = subscriber)
+ link.save()
def can_delete(self, obj):
return super(XOSVOLTTenant, self).can_delete(obj)