blob: 3e45e2659d88b393ed7c29b72156ed9a63fe1d6b [file] [log] [blame]
Gabe Black4c040b72016-11-17 22:35:04 +00001from core.models import Tenant, Service
2from services.activetest.models import VpmaTenant
3
4from xosresource import XOSResource
5
6class XOSVpmaTenant(XOSResource):
7 name_field = "service_specific_id"
8 provides = "tosca.nodes.VpmaTenant"
9 copyin_props = ("is_reflector","is_initiator","reflector",)
10 xos_model = VpmaTenant
11
12 def get_xos_args(self, throw_exception=True):
13 args = super(XOSVpmaTenant, self).get_xos_args()
14
15 # VpmaTenant 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 can_delete(self, obj):
23 return super(XOSVpmaTenant, self).can_delete(obj)
24
25 def get_existing_objs(self):
26 args = self.get_xos_args(throw_exception=False)
27 return VpmaTenant.get_tenant_objects().filter(provider_service=args["provider_service"], service_specific_id=args["service_specific_id"])
28 return []