blob: 090f381ab5c06859fac8e5a3607a888ea9581776 [file] [log] [blame]
Matteo Scandolo35113f72017-08-08 13:05:25 -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
Zack Williams1ce6c382016-10-05 18:02:09 -070015from xosresource import XOSResource
Scott Baker09820022017-07-18 11:29:59 -070016from core.models import Service
Scott Bakerffac7182017-07-27 15:21:30 -070017from services.exampleservice.models import ExampleServiceInstance
Scott Baker619de672016-06-20 12:49:38 -070018
Scott Bakerffac7182017-07-27 15:21:30 -070019class XOSExampleServiceInstance(XOSResource):
20 provides = ["tosca.nodes.ExampleServiceInstance",
21 "tosca.nodes.ExampleTenant" # deprecated
22 ]
23 xos_model = ExampleServiceInstance
Scott Baker619de672016-06-20 12:49:38 -070024 copyin_props = ("tenant_message",)
25
26 def get_xos_args(self, throw_exception=True):
Scott Bakerffac7182017-07-27 15:21:30 -070027 args = super(XOSExampleServiceInstance, self).get_xos_args()
Scott Baker619de672016-06-20 12:49:38 -070028
Scott Bakerffac7182017-07-27 15:21:30 -070029 # ExampleServiceInstance must always have a provider_service
Scott Baker619de672016-06-20 12:49:38 -070030 provider_name = self.get_requirement("tosca.relationships.TenantOfService", throw_exception=True)
31 if provider_name:
Scott Baker09820022017-07-18 11:29:59 -070032 args["owner"] = self.get_xos_object(Service, throw_exception=True, name=provider_name)
Scott Baker619de672016-06-20 12:49:38 -070033
34 return args
35
Scott Baker619de672016-06-20 12:49:38 -070036 def can_delete(self, obj):
Scott Bakerffac7182017-07-27 15:21:30 -070037 return super(XOSExampleServiceInstance, self).can_delete(obj)
Scott Baker619de672016-06-20 12:49:38 -070038