blob: 8fad75b1de722fbff4945fb95435962800ee7b89 [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