Matteo Scandolo | 5b7a5d4 | 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 | |
Saleil Bhat | 1c5593d | 2017-01-06 15:25:57 -0800 | [diff] [blame] | 17 | from services.vmme.models import VMMETenant, VMMEService |
| 18 | from xosresource import XOSResource |
| 19 | |
| 20 | class XOSVMMETenant(XOSResource): |
| 21 | provides = "tosca.nodes.VMMETenant" |
| 22 | xos_model = VMMETenant |
Saleil Bhat | 22afba8 | 2017-01-21 23:10:09 -0800 | [diff] [blame] | 23 | copyin_props = ["tenant_message", "image_name"] |
| 24 | name_field = None |
Saleil Bhat | 1c5593d | 2017-01-06 15:25:57 -0800 | [diff] [blame] | 25 | |
| 26 | def get_xos_args(self, throw_exception=True): |
| 27 | args = super(XOSVMMETenant, 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(VMMEService, 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(XOSVMMETenant, self).can_delete(obj) |