blob: 7c70b78f9a6905d9b37c0ab1529c5378cb2354ad [file] [log] [blame]
Shad Ansari3cd9bf22018-07-25 19:29:39 +00001#
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:
Nicolas Palpacuer324dcae2018-08-02 11:12:22 -040033 self.log.debug('bandwidth not configured',
Shad Ansari3cd9bf22018-07-25 19:29:39 +000034 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