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