blob: 7b1a09d266753e112849d635e9706c948274e716 [file] [log] [blame]
Gabe Black4c040b72016-11-17 22:35:04 +00001from core.models import Tenant, Service
2from services.activetest.models import ActiveTestTenant, ACTIVETEST_KIND as ACTIVETESTTENANT_KIND
3
4from xosresource import XOSResource
5
6class XOSActiveTestTenant(XOSResource):
7 provides = "tosca.nodes.ActiveTestTenant"
8 xos_model = ActiveTestTenant
9 name_field = "service_specific_id"
10 copyin_props = ("tenant_message",)
11
12 def get_xos_args(self, throw_exception=True):
13 args = super(XOSActiveTestTenant, self).get_xos_args()
14
15 # ActiveTestTenant must always have a provider_service
16 provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=True)
17 if provider_name:
18 args["provider_service"] = self.get_xos_object(Service, throw_exception=True, name=provider_name)
19
20 return args
21
22 def get_existing_objs(self):
23 args = self.get_xos_args(throw_exception=False)
24 return ActiveTestTenant.get_tenant_objects().filter(provider_service=args["provider_service"], service_specific_id=args["service_specific_id"])
25 return []
26
27 def can_delete(self, obj):
28 return super(XOSActiveTestTenant, self).can_delete(obj)
29