blob: 7fb6d4694af7580992e8a225560d249aa55dff52 [file] [log] [blame]
Matteo Scandolo5b7a5d42017-08-08 13:05:26 -07001# 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
Saleil Bhat1c5593d2017-01-06 15:25:57 -080015from xosresource import XOSResource
Pingping Lina83e3772017-10-04 11:29:50 -070016from core.models import ServiceInstance, Service
Pingping Linece8a742017-10-03 16:39:23 -070017from services.vmme.models import VMMETenant
Saleil Bhat1c5593d2017-01-06 15:25:57 -080018
19class XOSVMMETenant(XOSResource):
20 provides = "tosca.nodes.VMMETenant"
21 xos_model = VMMETenant
Pingping Linece8a742017-10-03 16:39:23 -070022 name_field = None
23 copyin_props = ()
Saleil Bhat1c5593d2017-01-06 15:25:57 -080024
25 def get_xos_args(self, throw_exception=True):
26 args = super(XOSVMMETenant, self).get_xos_args()
27
Pingping Linece8a742017-10-03 16:39:23 -070028 provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=throw_exception)
Saleil Bhat1c5593d2017-01-06 15:25:57 -080029 if provider_name:
Sapan Bhatia81c88092017-10-09 18:05:35 -040030 args["owner"] = self.get_xos_object(Service, throw_exception=throw_exception, name=provider_name)
Saleil Bhat1c5593d2017-01-06 15:25:57 -080031
32 return args
33
34 def get_existing_objs(self):
35 args = self.get_xos_args(throw_exception=False)
Sapan Bhatia81c88092017-10-09 18:05:35 -040036 owner = args.get("provider", None)
37 if owner:
38 return [ self.get_xos_object(owner=owner) ]
Saleil Bhat1c5593d2017-01-06 15:25:57 -080039 return []
40
41 def postprocess(self, obj):
42 pass
43
44 def can_delete(self, obj):
45 return super(XOSVMMETenant, self).can_delete(obj)
Pingping Linece8a742017-10-03 16:39:23 -070046