blob: 06cbd421e216bb8144411ef2ef7df63f76d2bd7a [file] [log] [blame]
Yunpeng Zhang0048cf42017-08-15 23:01:28 -04001from xosresource import XOSResource
2from core.models import Tenant, Service
3from services.vpgwu.models import VPGWUTenant
4
5class XOSVPGWUTenant(XOSResource):
6 provides = "tosca.nodes.VPGWUTenant"
7 xos_model = VPGWUTenant
8 name_field = None
9 copyin_props = ["s5s8_pgw_tag", "display_message", "image_name"]
10
11 def get_xos_args(self, throw_exception=True):
12 args = super(XOSVPGWUTenant, self).get_xos_args()
13
14 provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=True)
15 if provider_name:
16 args["provider_service"] = self.get_xos_object(Service, throw_exception=True, name=provider_name)
17
18 return args
19
20 def get_existing_objs(self):
21 args = self.get_xos_args(throw_exception=False)
22 provider_service = args.get("provider", None)
23 if provider_service:
24 return [self.get_xos_object(provider_service=provider_service)]
25 return []
26
27 def postprocess(self, obj):
28 pass
29
30 def can_delete(self, obj):
31 return super(XOSVPGWUTenant, self).can_delete(obj)