JianHao | ce45e04 | 2017-01-16 11:06:29 +0000 | [diff] [blame] | 1 | from services.vsgw.models import * |
Murat Parlakisik | 66fde4d | 2016-09-22 13:28:13 -0700 | [diff] [blame] | 2 | from xosresource import XOSResource |
| 3 | |
| 4 | class XOSVSGWTenant(XOSResource): |
JianHao | ce45e04 | 2017-01-16 11:06:29 +0000 | [diff] [blame] | 5 | provides = "tosca.nodes.VSGWTenant" |
Murat Parlakisik | 66fde4d | 2016-09-22 13:28:13 -0700 | [diff] [blame] | 6 | xos_model = VSGWTenant |
| 7 | name_field = "service_specific_id" |
Saleil Bhat | 42e8c5e | 2017-02-01 15:59:54 -0800 | [diff] [blame] | 8 | copyin_props = ("tenant_message", "image_name") |
Murat Parlakisik | 66fde4d | 2016-09-22 13:28:13 -0700 | [diff] [blame] | 9 | |
| 10 | def get_xos_args(self, throw_exception=True): |
| 11 | args = super(XOSVSGWTenant, self).get_xos_args() |
| 12 | |
| 13 | # ExampleTenant must always have a provider_service |
JianHao | ce45e04 | 2017-01-16 11:06:29 +0000 | [diff] [blame] | 14 | provider_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception) |
Murat Parlakisik | 66fde4d | 2016-09-22 13:28:13 -0700 | [diff] [blame] | 15 | if provider_name: |
JianHao | ce45e04 | 2017-01-16 11:06:29 +0000 | [diff] [blame] | 16 | args["provider_service"] = self.get_xos_object(VSGWService, throw_exception=throw_exception, name=provider_name) |
Murat Parlakisik | 66fde4d | 2016-09-22 13:28:13 -0700 | [diff] [blame] | 17 | |
| 18 | return args |
| 19 | |
| 20 | def get_existing_objs(self): |
| 21 | args = self.get_xos_args(throw_exception=False) |
| 22 | return VSGWTenant.get_tenant_objects().filter(provider_service=args["provider_service"], service_specific_id=args["service_specific_id"]) |
| 23 | return [] |
| 24 | |
| 25 | def can_delete(self, obj): |
| 26 | return super(XOSVSGWTenant, self).can_delete(obj) |
| 27 | |