blob: 7c70b78f9a6905d9b37c0ab1529c5378cb2354ad [file] [log] [blame]
William Kurkian6f436d02019-02-06 16:25:01 -05001#
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
17DEFAULT_ONU_BW_PROFILE = "default"
18DEFAULT_ONU_PIR = 1000000 # 1Gbps
19
20
21class 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