William Kurkian | 6f436d0 | 2019-02-06 16:25:01 -0500 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2018 the original author or authors. |
| 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 | |
| 17 | DEFAULT_ONU_BW_PROFILE = "default" |
| 18 | DEFAULT_ONU_PIR = 1000000 # 1Gbps |
| 19 | |
| 20 | |
| 21 | class OpenOltBW(object): |
| 22 | |
| 23 | def __init__(self, log, proxy): |
| 24 | self.log = log |
| 25 | self.proxy = proxy |
| 26 | |
| 27 | def pir(self, serial_number): |
| 28 | bw = 0 |
| 29 | try: |
| 30 | bw = self.proxy.get( |
| 31 | '/traffic_descriptor_profiles/{}'.format(serial_number)) |
| 32 | except KeyError: |
| 33 | self.log.debug('bandwidth not configured', |
| 34 | serial_number=serial_number) |
| 35 | try: |
| 36 | bw = self.proxy.get('/traffic_descriptor_profiles/{}' \ |
| 37 | .format(DEFAULT_ONU_BW_PROFILE)) |
| 38 | except KeyError: |
| 39 | return DEFAULT_ONU_PIR |
| 40 | |
| 41 | return bw.maximum_bandwidth |