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