Matteo Scandolo | eb3487c | 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 | 99ed559 | 2016-09-01 01:41:34 +0000 | [diff] [blame] | 17 | from services.vbbu.models import VBBUComponent, MCORDService |
Pingping Lin | d28ab98 | 2016-08-29 18:42:52 +0000 | [diff] [blame] | 18 | from xosresource import XOSResource |
| 19 | |
| 20 | class XOSVBBUComponent(XOSResource): |
| 21 | provides = "tosca.nodes.VBBUComponent" |
| 22 | xos_model = VBBUComponent |
| 23 | copyin_props = ["s1u_tag", "s1mme_tag", "rru_tag", "display_message"] |
| 24 | name_field = None |
| 25 | |
| 26 | def get_xos_args(self, throw_exception=True): |
| 27 | args = super(XOSVBBUComponent, self).get_xos_args() |
| 28 | |
| 29 | provider_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception) |
| 30 | if provider_name: |
| 31 | args["provider_service"] = self.get_xos_object(MCORDService, throw_exception=throw_exception, name=provider_name) |
| 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): |
| 46 | return super(XOSVBBUComponent, self).can_delete(obj) |
| 47 | |