Matteo Scandolo | 62dab88 | 2018-04-24 12:58:12 +0200 | [diff] [blame] | 1 | |
| 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 Scandolo | 62dab88 | 2018-04-24 12:58:12 +0200 | [diff] [blame] | 17 | from xosapi.orm import ORMWrapper, register_convenience_wrapper |
| 18 | |
Scott Baker | b167151 | 2019-04-01 19:16:54 -0700 | [diff] [blame] | 19 | |
Matteo Scandolo | d1707b3 | 2018-05-04 12:42:53 -0700 | [diff] [blame] | 20 | class ORMWrapperRCORDSubscriber(ORMWrapper): |
Matteo Scandolo | 62dab88 | 2018-04-24 12:58:12 +0200 | [diff] [blame] | 21 | @property |
| 22 | def volt(self): |
| 23 | links = self.subscribed_links.all() |
| 24 | for link in links: |
Matteo Scandolo | d1707b3 | 2018-05-04 12:42:53 -0700 | [diff] [blame] | 25 | # FIXME: hardcoded service dependency |
Matteo Scandolo | 62dab88 | 2018-04-24 12:58:12 +0200 | [diff] [blame] | 26 | # cast from ServiceInstance to VOLTServiceInstance |
Scott Baker | b167151 | 2019-04-01 19:16:54 -0700 | [diff] [blame] | 27 | volts = self.stub.VOLTServiceInstance.objects.filter(id=link.provider_service_instance.id) |
Matteo Scandolo | 62dab88 | 2018-04-24 12:58:12 +0200 | [diff] [blame] | 28 | 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 Scandolo | 62dab88 | 2018-04-24 12:58:12 +0200 | [diff] [blame] | 39 | "status") |
| 40 | |
Scott Baker | b167151 | 2019-04-01 19:16:54 -0700 | [diff] [blame] | 41 | |
Matteo Scandolo | d1707b3 | 2018-05-04 12:42:53 -0700 | [diff] [blame] | 42 | register_convenience_wrapper("RCORDSubscriber", ORMWrapperRCORDSubscriber) |