blob: 2d572c051614d3c61e86d11bbab3e0db188ac161 [file] [log] [blame]
Woojoong Kime30f6062017-10-05 19:38:56 -05001# 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
15from xosresource import XOSResource
Woojoong Kim033b2ce2017-10-10 10:09:06 -070016from core.models import ServiceInstance, Service
Woojoong Kime30f6062017-10-05 19:38:56 -050017from services.vhss.models import VHSSTenant
18
19class XOSVHSSTenant(XOSResource):
20 provides = "tosca.nodes.VHSSTenant"
21 xos_model = VHSSTenant
Woojoong Kim033b2ce2017-10-10 10:09:06 -070022 name_field = None
Woojoong Kime30f6062017-10-05 19:38:56 -050023 copyin_props = ()
24
25 def get_xos_args(self, throw_exception=True):
26 args = super(XOSVHSSTenant, self).get_xos_args()
27
Woojoong Kim033b2ce2017-10-10 10:09:06 -070028 provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=throw_exception)
Woojoong Kime30f6062017-10-05 19:38:56 -050029 if provider_name:
Woojoong Kim033b2ce2017-10-10 10:09:06 -070030 args["owner"] = self.get_xos_object(Service, throw_exception=throw_exception, name=provider_name)
Woojoong Kime30f6062017-10-05 19:38:56 -050031
32 return args
33
34 def get_existing_objs(self):
35 args = self.get_xos_args(throw_exception=False)
Woojoong Kim033b2ce2017-10-10 10:09:06 -070036 owner = args.get("provider", None)
37 if owner:
38 return [ self.get_xos_object(owner=owner) ]
Woojoong Kime30f6062017-10-05 19:38:56 -050039 return []
40
Woojoong Kim033b2ce2017-10-10 10:09:06 -070041 def postprocess(self, obj):
42 pass
43
Woojoong Kime30f6062017-10-05 19:38:56 -050044 def can_delete(self, obj):
45 return super(XOSVHSSTenant, self).can_delete(obj)
46