blob: 719f62ecd3eae0125f2a544217c096e067a8d58b [file] [log] [blame]
girisha2f2cd02018-03-21 16:11:09 +05301#
2# Copyright 2017 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
17from twisted.internet.defer import inlineCallbacks
18
19"""
20Asfvolt16 Device specific information handler
21"""
22
23
24class Asfvolt16DeviceTopology(object):
25 def __init__(self, nnis=4, pons=16, mac_devs=8, mac_per_dev=2,
26 pon_sub_family="BAL_PON_SUB_FAMILY_XGPON"):
27 self.num_of_nni_ports = nnis
28 self.num_of_pon_ports = pons
29 self.num_of_mac_devs = mac_devs
30 self.num_of_pons_per_mac_dev = mac_per_dev
31 self.pon_sub_family = pon_sub_family
32
33
34class Asfvolt16DeviceSoftwareInfo(object):
35 def __init__(self, ver_type="BAL_VERSION_TYPE_RELEASE", maj_ver=2,
36 min_ver=4, om_ver=1):
37 self.version_type = ver_type
38 self.major_version = maj_ver
39 self.minor_version = min_ver
40 self.om_version = om_ver
41
42
43class Asfvolt16DeviceInfo(object):
44 def __init__(self, bal, log, device_id):
45 self.bal = bal
46 self.log = log
47 self.device_id = device_id
48 self.asfvolt16_device_topology = Asfvolt16DeviceTopology()
49 self.asfvolt16_device_sw_info = Asfvolt16DeviceSoftwareInfo()
50 self.sfp_device_presence_map = dict()
51
52 def update_device_topology(self, access_term_ind):
53 try:
54 self.asfvolt16_device_topology.num_of_nni_ports = \
55 access_term_ind.data.topology.num_of_nni_ports
56 self.asfvolt16_device_topology.num_of_pon_ports = \
57 access_term_ind.data.topology.num_of_pon_ports
58 self.asfvolt16_device_topology.num_of_mac_devs = \
59 access_term_ind.data.topology.num_of_mac_devs
60 self.asfvolt16_device_topology.num_of_pons_per_mac_dev = \
61 access_term_ind.data.topology.num_of_pons_per_mac_dev
62 self.asfvolt16_device_topology.pon_sub_family = \
63 access_term_ind.data.topology.pon_sub_family
64 except Exception as e:
65 self.log.error("error-reading-topology", e=e)
66
67 def update_device_software_info(self, access_term_ind):
68 try:
69 self.asfvolt16_device_sw_info.version_type = \
70 access_term_ind.data.sw_version.version_type
71 self.asfvolt16_device_sw_info.major_rev = \
72 access_term_ind.data.sw_version.major_rev
73 self.asfvolt16_device_sw_info.minor_rev = \
74 access_term_ind.data.sw_version.minor_rev
75 self.asfvolt16_device_sw_info.om_version = \
76 access_term_ind.data.sw_version.om_version
77 except Exception as e:
78 self.log.error("error-reading-software-info", e=e)
79
80 @inlineCallbacks
81 def read_and_build_device_sfp_presence_map(self):
82 try:
83 sfp_presence_bitmap = \
84 yield self.bal.get_asfvolt_sfp_presence_map(self.device_id)
85 for i in range(self.asfvolt16_device_topology.num_of_pon_ports + \
86 self.asfvolt16_device_topology.num_of_nni_ports):
87 if (1 << i) & int(sfp_presence_bitmap):
88 self.sfp_device_presence_map[i] = True
89 except Exception as e:
90 self.log.error("read_and_build_device_sfp_presence_map", e=e)