blob: 24c5410e4bfa1c735fc38cc09818c65de638a552 [file] [log] [blame]
Chetan Gaonker7997bb42016-03-28 09:46:15 -07001import os
2import json
3##load the olt config
4
5class OltConfig:
6 def __init__(self, olt_conf_file = ''):
7 if not olt_conf_file:
8 self.olt_conf_file = os.getenv('OLT_CONFIG')
9 else:
10 self.olt_conf_file = olt_conf_file
11 try:
12 self.olt_handle = open(self.olt_conf_file, 'r')
13 self.olt_conf = json.load(self.olt_handle)
14 except:
15 self.olt_handle = None
16 self.olt_conf = {}
17 self.olt_conf['olt'] = False
18
19 def on_olt(self):
20 return self.olt_conf['olt'] is True
21
22 def olt_port_map(self):
23 if self.on_olt() and self.olt_conf.has_key('ports'):
24 port_map = {}
25 ##Build a rx/tx port number to interface map
26 port_map[1] = self.olt_conf['ports']['rx']
27 port_map[2] = self.olt_conf['ports']['tx']
28 port_map[port_map[1]] = 1
29 port_map[port_map[2]] = 2
30 return port_map
31 else:
32 return None
Chetan Gaonkera2b87df2016-03-31 15:41:31 -070033
34 def olt_device_data(self):
35 if self.on_olt():
36 accessDeviceDict = {}
37 accessDeviceDict['uplink'] = str(self.olt_conf['uplink'])
38 accessDeviceDict['vlan'] = str(self.olt_conf['vlan'])
39 return accessDeviceDict
40 return None