blob: b5a5b4b7f4d73911af2a4696478d48489e071f88 [file] [log] [blame]
Matteo Scandolo41ed0992017-08-08 13:05:27 -07001
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
JianHaoce45e042017-01-16 11:06:29 +000017from services.vsgw.models import *
Murat Parlakisik66fde4d2016-09-22 13:28:13 -070018from xosresource import XOSResource
19
20class XOSVSGWTenant(XOSResource):
JianHaoce45e042017-01-16 11:06:29 +000021 provides = "tosca.nodes.VSGWTenant"
Murat Parlakisik66fde4d2016-09-22 13:28:13 -070022 xos_model = VSGWTenant
23 name_field = "service_specific_id"
Saleil Bhat42e8c5e2017-02-01 15:59:54 -080024 copyin_props = ("tenant_message", "image_name")
Murat Parlakisik66fde4d2016-09-22 13:28:13 -070025
26 def get_xos_args(self, throw_exception=True):
27 args = super(XOSVSGWTenant, self).get_xos_args()
28
29 # ExampleTenant must always have a provider_service
JianHaoce45e042017-01-16 11:06:29 +000030 provider_name = self.get_requirement("tosca.relationships.MemberOfService", throw_exception=throw_exception)
Murat Parlakisik66fde4d2016-09-22 13:28:13 -070031 if provider_name:
JianHaoce45e042017-01-16 11:06:29 +000032 args["provider_service"] = self.get_xos_object(VSGWService, throw_exception=throw_exception, name=provider_name)
Murat Parlakisik66fde4d2016-09-22 13:28:13 -070033
34 return args
35
36 def get_existing_objs(self):
37 args = self.get_xos_args(throw_exception=False)
38 return VSGWTenant.get_tenant_objects().filter(provider_service=args["provider_service"], service_specific_id=args["service_specific_id"])
39 return []
40
41 def can_delete(self, obj):
42 return super(XOSVSGWTenant, self).can_delete(obj)
43