diff --git a/sonic_sfp/bcmshell.py b/sonic_sfp/bcmshell.py index a86f37975d..63156c7538 100644 --- a/sonic_sfp/bcmshell.py +++ b/sonic_sfp/bcmshell.py @@ -30,7 +30,7 @@ class bcmshell (object): #--------------- # def __init__(self, keepopen=False, timeout=10, opennow=False, logfileobj=None, - socketname="/var/run/sswsyncd.socket", prompt='^drivshell>\s*$'): + socketname="/var/run/docker-syncd/sswsyncd.socket", prompt='^drivshell>\s*$'): """Constructor: keepopen - indicates that switchd socket should be kept open between @@ -54,7 +54,7 @@ def __init__(self, keepopen=False, timeout=10, opennow=False, logfileobj=None, raise SyntaxError("bcmshell constructor prompt expects an re string") else: self.re_prompt = re.compile(prompt, re.MULTILINE) - self.re_connectprompt = re.compile("bcmshell\r\n\r\r\n" + prompt, re.MULTILINE) + self.re_connectprompt = re.compile("bcmshell\r\n" + prompt, re.MULTILINE) if timeout <= 0: raise ValueError("bcmshell.timeout must be > 0") diff --git a/sonic_sfp/sfputilbase.py b/sonic_sfp/sfputilbase.py index e7c5bfb3a4..5412c9d083 100644 --- a/sonic_sfp/sfputilbase.py +++ b/sonic_sfp/sfputilbase.py @@ -204,7 +204,7 @@ def _read_eeprom_devid(self, port_num, devid, offset): i2c_adapter_id = self._get_port_i2c_adapter_id(port_num) if i2c_adapter_id == None: print 'Error getting i2c bus num' - return Non + return None # Get i2c virtual bus path for the sfp sysfs_sfp_i2c_adapter_path = sysfs_i2c_adapter_base_path + \ @@ -323,12 +323,16 @@ def read_porttab_mappings(cls, porttabfile): last_physical_port = 0 last_logical_port = '' first = 1 + port_pos_in_file = 0 + parse_fmt_port_config_ini = False try: f = open(porttabfile) except: raise + parse_fmt_port_config_ini = (os.path.basename(porttabfile) == 'port_config.ini') + # Read the porttab file and generate dicts # with mapping for future reference. # XXX: move the porttab @@ -338,11 +342,23 @@ def read_porttab_mappings(cls, porttabfile): line.strip() if re.search('^#', line) != None: continue - logical_port = line.split()[0] - bcm_port = line.split()[1].split(',')[0] - physical_port = logical_port.split('Ethernet').pop() - physical_port = int(physical_port.split('s').pop(0))/4 + # Parsing logic for 'port_config.ini' file + if (parse_fmt_port_config_ini): + # bcm_port is not explicitly listed in port_config.ini format + # Currently we assume ports are listed in numerical order according to bcm_port + # so we use the port's position in the file (zero-based) as bcm_port + logical_port = line.split()[0] + + bcm_port = str(port_pos_in_file); + + physical_port = logical_port.split('Ethernet').pop() + physical_port = int(physical_port.split('s').pop(0))/4 + else: # Parsing logic for older 'portmap.ini' file + (logical_port, bcm_port) = line.split('=')[1].split(',')[:2] + + physical_port = logical_port.split('Ethernet').pop() + physical_port = int(physical_port.split('s').pop(0))/4 if ((len(cls.sfp_ports) > 0) and (physical_port not in cls.sfp_ports)): @@ -379,6 +395,8 @@ def read_porttab_mappings(cls, porttabfile): last_physical_port = physical_port last_logical_port = logical_port + port_pos_in_file += 1 + sfputilbase.logical = logical sfputilbase.logical_to_bcm = logical_to_bcm sfputilbase.logical_to_physical = logical_to_physical