Matteo Scandolo | 86d6369 | 2017-08-08 13:05:26 -0700 | [diff] [blame] | 1 | |
| 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 Lin | c537fd9 | 2017-01-17 20:52:09 -0800 | [diff] [blame] | 17 | from services.vpgwc.models import VPGWCTenant, VPGWCService |
Pingping Lin | f3e24a9 | 2016-09-19 21:35:16 +0000 | [diff] [blame] | 18 | from xosresource import XOSResource |
| 19 | |
Pingping Lin | c537fd9 | 2017-01-17 20:52:09 -0800 | [diff] [blame] | 20 | class XOSVPGWCTenant(XOSResource): |
| 21 | provides = "tosca.nodes.VPGWCTenant" |
| 22 | xos_model = VPGWCTenant |
Saleil Bhat | 4f45a4f | 2017-02-01 17:04:22 -0800 | [diff] [blame] | 23 | copyin_props = ["s5s8_pgw_tag", "display_message", "image_name"] |
Pingping Lin | f3e24a9 | 2016-09-19 21:35:16 +0000 | [diff] [blame] | 24 | name_field = None |
| 25 | |
| 26 | def get_xos_args(self, throw_exception=True): |
Pingping Lin | c537fd9 | 2017-01-17 20:52:09 -0800 | [diff] [blame] | 27 | args = super(XOSVPGWCTenant, self).get_xos_args() |
Pingping Lin | f3e24a9 | 2016-09-19 21:35:16 +0000 | [diff] [blame] | 28 | |
| 29 | provider_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception) |
| 30 | if provider_name: |
Pingping Lin | d6c6987 | 2016-09-19 23:31:54 +0000 | [diff] [blame] | 31 | args["provider_service"] = self.get_xos_object(VPGWCService, throw_exception=throw_exception, name=provider_name) |
Pingping Lin | f3e24a9 | 2016-09-19 21:35:16 +0000 | [diff] [blame] | 32 | |
| 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 Lin | c537fd9 | 2017-01-17 20:52:09 -0800 | [diff] [blame] | 46 | return super(XOSVPGWCTenant, self).can_delete(obj) |
Pingping Lin | f3e24a9 | 2016-09-19 21:35:16 +0000 | [diff] [blame] | 47 | |