Woojoong Kim | e30f606 | 2017-10-05 19:38:56 -0500 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | from xosresource import XOSResource |
Woojoong Kim | 033b2ce | 2017-10-10 10:09:06 -0700 | [diff] [blame] | 16 | from core.models import ServiceInstance |
Woojoong Kim | e30f606 | 2017-10-05 19:38:56 -0500 | [diff] [blame] | 17 | from services.vhss.models import VHSSVendor |
| 18 | |
| 19 | class XOSVHSSVendor(XOSResource): |
| 20 | provides = "tosca.nodes.VHSSVendor" |
| 21 | xos_model = VHSSVendor |
| 22 | name_field = None |
| 23 | copyin_props = ( "name",) |
| 24 | |
| 25 | def get_xos_args(self, throw_exception=True): |
| 26 | args = super(XOSVHSSVendor, self).get_xos_args() |
| 27 | |
| 28 | tenant_name = self.get_requirement("tosca.relationships.VendorOfTenant", throw_exception=throw_exception) |
| 29 | if tenant_name: |
Woojoong Kim | 033b2ce | 2017-10-10 10:09:06 -0700 | [diff] [blame] | 30 | args["provider_tenant"] = self.get_xos_object(ServiceInstance, throw_exception=throw_exception, name=tenant_name) |
Woojoong Kim | e30f606 | 2017-10-05 19:38:56 -0500 | [diff] [blame] | 31 | |
| 32 | return args |
| 33 | |
| 34 | def get_existing_objs(self): |
| 35 | args = self.get_xos_args(throw_exception=False) |
| 36 | provider_tenant = args.get("provider", None) |
| 37 | if provider_tenant: |
| 38 | return [ self.get_xos_object(provider_tenant=provider_tenant) ] |
| 39 | return [] |
| 40 | |
| 41 | def postprocess(self, obj): |
| 42 | pass |
| 43 | |
| 44 | def can_delete(self, obj): |
| 45 | return super(XOSVHSSVendor, self).can_delete(obj) |
| 46 | |