blob: b103678e04f97c6c06b7f4c21111a1f3fe4af3a1 [file] [log] [blame]
Matteo Scandolo86d63692017-08-08 13:05:26 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
Pingping Linc537fd92017-01-17 20:52:09 -080017from services.vpgwc.models import VPGWCTenant, VPGWCService
Pingping Linf3e24a92016-09-19 21:35:16 +000018from xosresource import XOSResource
19
Pingping Linc537fd92017-01-17 20:52:09 -080020class XOSVPGWCTenant(XOSResource):
21 provides = "tosca.nodes.VPGWCTenant"
22 xos_model = VPGWCTenant
Saleil Bhat4f45a4f2017-02-01 17:04:22 -080023 copyin_props = ["s5s8_pgw_tag", "display_message", "image_name"]
Pingping Linf3e24a92016-09-19 21:35:16 +000024 name_field = None
25
26 def get_xos_args(self, throw_exception=True):
Pingping Linc537fd92017-01-17 20:52:09 -080027 args = super(XOSVPGWCTenant, self).get_xos_args()
Pingping Linf3e24a92016-09-19 21:35:16 +000028
29 provider_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception)
30 if provider_name:
Pingping Lind6c69872016-09-19 23:31:54 +000031 args["provider_service"] = self.get_xos_object(VPGWCService, throw_exception=throw_exception, name=provider_name)
Pingping Linf3e24a92016-09-19 21:35:16 +000032
33 return args
34
35 def get_existing_objs(self):
36 args = self.get_xos_args(throw_exception=False)
37 provider_service = args.get("provider", None)
38 if provider_service:
39 return [ self.get_xos_object(provider_service=provider_service) ]
40 return []
41
42 def postprocess(self, obj):
43 pass
44
45 def can_delete(self, obj):
Pingping Linc537fd92017-01-17 20:52:09 -080046 return super(XOSVPGWCTenant, self).can_delete(obj)
Pingping Linf3e24a92016-09-19 21:35:16 +000047