blob: f53048a73d87dab42d19220855ae4e3ee91e6a3e [file] [log] [blame]
JianHaoce45e042017-01-16 11:06:29 +00001from services.vsgw.models import *
Murat Parlakisik66fde4d2016-09-22 13:28:13 -07002from xosresource import XOSResource
3
4class XOSVSGWTenant(XOSResource):
JianHaoce45e042017-01-16 11:06:29 +00005 provides = "tosca.nodes.VSGWTenant"
Murat Parlakisik66fde4d2016-09-22 13:28:13 -07006 xos_model = VSGWTenant
7 name_field = "service_specific_id"
Saleil Bhat42e8c5e2017-02-01 15:59:54 -08008 copyin_props = ("tenant_message", "image_name")
Murat Parlakisik66fde4d2016-09-22 13:28:13 -07009
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
JianHaoce45e042017-01-16 11:06:29 +000014 provider_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception)
Murat Parlakisik66fde4d2016-09-22 13:28:13 -070015 if provider_name:
JianHaoce45e042017-01-16 11:06:29 +000016 args["provider_service"] = self.get_xos_object(VSGWService, throw_exception=throw_exception, name=provider_name)
Murat Parlakisik66fde4d2016-09-22 13:28:13 -070017
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