blob: c82a0c8720f56367f7996f1c44bb7a6faba1b7c6 [file] [log] [blame]
Scott Baker3b8ceca2017-10-12 11:38:50 -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
17from xosapi.orm import ORMWrapper, register_convenience_wrapper
18
19class ORMWrapperVEEServiceInstance(ORMWrapper):
20 @property
21 def veg(self):
22 links = self.stub.ServiceInstanceLink.objects.filter(subscriber_service_instance_id = self.id)
23 for link in links:
24 # cast from ServiceInstance to VSGTenant
25 vegs = self.stub.VEGTenant.objects.filter(id = link.provider_service_instance.id)
26 if vegs:
27 return vegs[0]
28 return None
29
30 # DEPRECATED
31 @property
32 def vcpe(self):
33 return self.veg
34
35 # DEPRECATED
36 @property
37 def vsg(Self):
38 return self.veg
39
40 @property
41 def subscriber(self):
42 links = self.stub.ServiceInstanceLink.objects.filter(provider_service_instance_id = self.id)
43 for link in links:
44 # assume the only thing that links to a VEE must be a subscriber
45 if link.subscriber_service_instance:
46 return link.subscriber_service_instance.leaf_model
47 return None
48
49register_convenience_wrapper("VEEServiceInstance", ORMWrapperVEEServiceInstance)