blob: 84ac28fc0229fc286922a7a68c2501d051503fbb [file] [log] [blame]
Gabe Black90623222017-01-18 19:52:28 +00001from core.models import Tenant, Service
2from services.passivetest.models import PassiveTestTenant
3
4from xosresource import XOSResource
5
6class XOSPassiveTestTenant(XOSResource):
7 provides = "tosca.nodes.PassiveTestTenant"
8 xos_model = PassiveTestTenant
9 name_field = "service_specific_id"
10 copyin_props = ("tenant_message",)
11
12 def get_xos_args(self, throw_exception=True):
13 args = super(XOSPassiveTestTenant, self).get_xos_args()
14
15 # PassiveTestTenant 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 PassiveTestTenant.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(XOSPassiveTestTenant, self).can_delete(obj)
29