Gabe Black | 9062322 | 2017-01-18 19:52:28 +0000 | [diff] [blame^] | 1 | from core.models import Tenant, Service |
| 2 | from services.passivetest.models import PassiveTestTenant |
| 3 | |
| 4 | from xosresource import XOSResource |
| 5 | |
| 6 | class 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 | |