blob: e6e7bf07f7c6403557ca77c602b857a972b9a65a [file] [log] [blame]
Matteo Scandolo62dab882018-04-24 12:58:12 +02001
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
Matteo Scandolo62dab882018-04-24 12:58:12 +020017from xosapi.orm import ORMWrapper, register_convenience_wrapper
18
Scott Bakerb1671512019-04-01 19:16:54 -070019
Matteo Scandolod1707b32018-05-04 12:42:53 -070020class ORMWrapperRCORDSubscriber(ORMWrapper):
Matteo Scandolo62dab882018-04-24 12:58:12 +020021 @property
22 def volt(self):
23 links = self.subscribed_links.all()
24 for link in links:
Matteo Scandolod1707b32018-05-04 12:42:53 -070025 # FIXME: hardcoded service dependency
Matteo Scandolo62dab882018-04-24 12:58:12 +020026 # cast from ServiceInstance to VOLTServiceInstance
Scott Bakerb1671512019-04-01 19:16:54 -070027 volts = self.stub.VOLTServiceInstance.objects.filter(id=link.provider_service_instance.id)
Matteo Scandolo62dab882018-04-24 12:58:12 +020028 if volts:
29 return volts[0]
30 return None
31
32 sync_attributes = ("firewall_enable",
33 "firewall_rules",
34 "url_filter_enable",
35 "url_filter_rules",
36 "cdn_enable",
37 "uplink_speed",
38 "downlink_speed",
Matteo Scandolo62dab882018-04-24 12:58:12 +020039 "status")
40
Scott Bakerb1671512019-04-01 19:16:54 -070041
Matteo Scandolod1707b32018-05-04 12:42:53 -070042register_convenience_wrapper("RCORDSubscriber", ORMWrapperRCORDSubscriber)