Skip to content

Commit

Permalink
Correcting the indentation and resolving merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
FuzailBrcm committed Nov 5, 2020
1 parent c14b93a commit 42a9c72
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 55 deletions.
31 changes: 21 additions & 10 deletions platform/pddf/i2c/utils/pddfparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,18 @@ def create_xcvr_i2c_device(self, dev, ops):
cmd="echo %s 0x%x > /sys/bus/i2c/devices/i2c-%d/new_device" % (dev['i2c']['topo_info']['dev_type'],
int(dev['i2c']['topo_info']['dev_addr'], 0), int(dev['i2c']['topo_info']['parent_bus'], 0))
create_ret = self.runcmd(cmd)
#print "\n"
if create_ret!=0:
return create_ret
# Add port name
port_name_sysfs = '/sys/bus/i2c/devices/{}-00{:02x}/port_name'.format(
int(dev['i2c']['topo_info']['parent_bus'], 0),int(dev['i2c']['topo_info']['dev_addr'], 0))

if os.path.exists(port_name_sysfs):
cmd="echo {} > /sys/bus/i2c/devices/{}-00{:02x}/port_name".format(
dev['dev_info']['virt_parent'].lower(), int(dev['i2c']['topo_info']['parent_bus'], 0),
int(dev['i2c']['topo_info']['dev_addr'], 0))
create_ret = self.runcmd(cmd)
if create_ret!=0:
return create_ret

Expand Down Expand Up @@ -973,12 +985,10 @@ def show_led_device(self, key, ops):
self.sysfs_obj[KEY] = []
path="pddf/devices/led"
for attr in self.data[key]['i2c']['attr_list']:
self.sysfs_attr('device_name', self.data[key]['dev_info']['device_name'], path,
self.sysfs_obj, KEY)
self.sysfs_attr('swpld_addr', self.data[key]['dev_info']['device_name'], path,
self.sysfs_obj, KEY)
self.sysfs_attr('swpld_addr_offset', self.data[key]['dev_info']['device_name'], path,
self.sysfs_obj, KEY)
self.sysfs_attr('device_name', self.data[key]['dev_info']['device_name'],path,self.sysfs_obj,KEY)
self.sysfs_attr('swpld_addr', self.data[key]['dev_info']['device_name'],path,self.sysfs_obj, KEY)
self.sysfs_attr('swpld_addr_offset',self.data[key]['dev_info']['device_name'],
path,self.sysfs_obj, KEY)
self.sysfs_device(self.data[key]['dev_attr'], path, self.sysfs_obj, KEY)
for attr_key in attr.keys():
attr_path="pddf/devices/led/" + attr['attr_name']
Expand Down Expand Up @@ -1159,8 +1169,8 @@ def verify_sysfs_data(self, verify_type):
path="pddf/devices/led/" + attr['attr_name']
for entry in attr.keys():
if (entry != 'attr_name' and entry != 'swpld_addr' and entry != 'swpld_addr_offset'):
self.verify_attr(entry, attr, path)
if ( entry == 'swpld_addr' or entry == 'swpld_addr_offset'):
self.verify_attr(entry, attr, path)
if ( entry == 'swpld_addr' or entry == 'swpld_addr_offset'):
self.verify_attr(entry, attr, 'pddf/devices/led')


Expand Down Expand Up @@ -1579,7 +1589,7 @@ def dev_parse(self, dev, ops):

if attr['device_type'] == 'SFP' or attr['device_type'] == 'SFP28' or \
attr['device_type'] == 'QSFP' or attr['device_type'] == 'QSFP28':
return self.optic_parse(dev, ops)
return self.optic_parse(dev, ops)

if attr['device_type'] == 'CPLD':
return self.cpld_parse(dev, ops)
Expand Down Expand Up @@ -1621,7 +1631,8 @@ def create_led_device(self, key, ops):
for attr_key in attr.keys():
if (attr_key == 'swpld_addr_offset' or attr_key == 'swpld_addr'):
self.create_attr(attr_key, attr[attr_key], path)
elif (attr_key != 'attr_name' and attr_key != 'descr'):
elif (attr_key != 'attr_name' and attr_key != 'descr' and
attr_key != 'attr_devtype' and attr_key != 'attr_devname'):
state_path=path+'/state_attr'
self.create_attr(attr_key, attr[attr_key],state_path)
cmd="echo '" + attr['attr_name']+"' > /sys/kernel/pddf/devices/led/dev_ops"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,19 @@ def __init__(self, index, pddf_data=None, pddf_plugin_data=None):
self.is_osfp_port = True if (self.sfp_type=='OSFP' or self.sfp_type=='QSFP-DD') else False
self.eeprom_path = self.pddf_obj.get_path(self.device, 'eeprom')

self.info_dict_keys = ['type', 'hardwarerev', 'serialnum', 'manufacturename', 'modelname', 'Connector', 'encoding', 'ext_identifier',
'ext_rateselect_compliance', 'cable_type', 'cable_length', 'nominal_bit_rate', 'specification_compliance', 'vendor_date', 'vendor_oui']
self.info_dict_keys = ['type', 'hardware_rev', 'serial', 'manufacturer', 'model', 'connector', 'encoding',
'ext_identifier', 'ext_rateselect_compliance', 'cable_type', 'cable_length', 'nominal_bit_rate',
'specification_compliance', 'vendor_date', 'vendor_oui', 'application_advertisement']

self.dom_dict_keys = ['rx_los', 'tx_fault', 'reset_status', 'power_lpmode', 'tx_disable', 'tx_disable_channel', 'temperature', 'voltage',
'rx1power', 'rx2power', 'rx3power', 'rx4power', 'tx1bias', 'tx2bias', 'tx3bias', 'tx4bias', 'tx1power', 'tx2power', 'tx3power', 'tx4power']
self.dom_dict_keys = ['rx_los', 'tx_fault', 'reset_status', 'power_lpmode', 'tx_disable', 'tx_disable_channel',
'temperature', 'voltage', 'rx1power', 'rx2power', 'rx3power', 'rx4power', 'tx1bias', 'tx2bias',
'tx3bias', 'tx4bias', 'tx1power', 'tx2power', 'tx3power', 'tx4power']

self.threshold_dict_keys = ['temphighalarm', 'temphighwarning', 'templowalarm', 'templowwarning', 'vcchighalarm', 'vcchighwarning', 'vcclowalarm', 'vcclowwarning', 'rxpowerhighalarm', 'rxpowerhighwarning',
'rxpowerlowalarm', 'rxpowerlowwarning', 'txpowerhighalarm', 'txpowerhighwarning', 'txpowerlowalarm', 'txpowerlowwarning', 'txbiashighalarm', 'txbiashighwarning', 'txbiaslowalarm', 'txbiaslowwarning']
self.threshold_dict_keys = ['temphighalarm', 'temphighwarning', 'templowalarm', 'templowwarning',
'vcchighalarm', 'vcchighwarning', 'vcclowalarm', 'vcclowwarning', 'rxpowerhighalarm',
'rxpowerhighwarning', 'rxpowerlowalarm', 'rxpowerlowwarning', 'txpowerhighalarm', 'txpowerhighwarning',
'txpowerlowalarm', 'txpowerlowwarning', 'txbiashighalarm', 'txbiashighwarning', 'txbiaslowalarm',
'txbiaslowwarning']

SfpBase.__init__(self)

Expand All @@ -204,11 +209,11 @@ def get_transceiver_info(self):
keys |Value Format |Information
---------------------------|---------------|----------------------------
type |1*255VCHAR |type of SFP
hardwarerev |1*255VCHAR |hardware version of SFP
serialnum |1*255VCHAR |serial number of the SFP
manufacturename |1*255VCHAR |SFP vendor name
modelname |1*255VCHAR |SFP model name
Connector |1*255VCHAR |connector information
hardware_rev |1*255VCHAR |hardware version of SFP
serial |1*255VCHAR |serial number of the SFP
manufacturer |1*255VCHAR |SFP vendor name
model |1*255VCHAR |SFP model name
connector |1*255VCHAR |connector information
encoding |1*255VCHAR |encoding information
ext_identifier |1*255VCHAR |extend identifier
ext_rateselect_compliance |1*255VCHAR |extended rateSelect compliance
Expand All @@ -217,6 +222,7 @@ def get_transceiver_info(self):
specification_compliance |1*255VCHAR |specification compliance
vendor_date |1*255VCHAR |vendor date
vendor_oui |1*255VCHAR |vendor OUI
application_advertisement |1*255VCHAR |supported applications advertisement
========================================================================
"""
# check present status
Expand Down Expand Up @@ -307,7 +313,7 @@ def get_transceiver_info(self):

if sfp_interface_bulk_data:
xcvr_info_dict['type'] = sfp_interface_bulk_data['data']['type']['value']
xcvr_info_dict['Connector'] = sfp_interface_bulk_data['data']['Connector']['value']
xcvr_info_dict['connector'] = sfp_interface_bulk_data['data']['Connector']['value']
xcvr_info_dict['encoding'] = sfp_interface_bulk_data['data']['EncodingCodes']['value']
xcvr_info_dict['ext_identifier'] = sfp_interface_bulk_data['data']['Extended Identifier']['value']
xcvr_info_dict['ext_rateselect_compliance'] = sfp_interface_bulk_data['data']['RateIdentifier']['value']
Expand All @@ -316,10 +322,10 @@ def get_transceiver_info(self):
xcvr_info_dict['type'] = sfp_type_data['data']['type']['value'] if sfp_type_data else 'N/A'
xcvr_info_dict['type_abbrv_name'] = sfp_type_abbrv_name['data']['type_abbrv_name']['value'] if sfp_type_abbrv_name else 'N/A'

xcvr_info_dict['manufacturename'] = sfp_vendor_name_data['data']['Vendor Name']['value'] if sfp_vendor_name_data else 'N/A'
xcvr_info_dict['modelname'] = sfp_vendor_pn_data['data']['Vendor PN']['value'] if sfp_vendor_pn_data else 'N/A'
xcvr_info_dict['hardwarerev'] = sfp_vendor_rev_data['data']['Vendor Rev']['value'] if sfp_vendor_rev_data else 'N/A'
xcvr_info_dict['serialnum'] = sfp_vendor_sn_data['data']['Vendor SN']['value'] if sfp_vendor_sn_data else 'N/A'
xcvr_info_dict['manufacturer'] = sfp_vendor_name_data['data']['Vendor Name']['value'] if sfp_vendor_name_data else 'N/A'
xcvr_info_dict['model'] = sfp_vendor_pn_data['data']['Vendor PN']['value'] if sfp_vendor_pn_data else 'N/A'
xcvr_info_dict['hardware_rev'] = sfp_vendor_rev_data['data']['Vendor Rev']['value'] if sfp_vendor_rev_data else 'N/A'
xcvr_info_dict['serial'] = sfp_vendor_sn_data['data']['Vendor SN']['value'] if sfp_vendor_sn_data else 'N/A'
xcvr_info_dict['vendor_oui'] = sfp_vendor_oui_data['data']['Vendor OUI']['value'] if sfp_vendor_oui_data else 'N/A'
xcvr_info_dict['vendor_date'] = sfp_vendor_date_data['data']['VendorDataCode(YYYY-MM-DD Lot)']['value'] if sfp_vendor_date_data else 'N/A'
xcvr_info_dict['cable_type'] = "Unknown"
Expand All @@ -341,6 +347,8 @@ def get_transceiver_info(self):
xcvr_info_dict['nominal_bit_rate'] = str(sfp_interface_bulk_data['data']['Nominal Bit Rate(100Mbs)']['value'])
else:
xcvr_info_dict['nominal_bit_rate'] = 'N/A'
elif sfp_type == 'OSFP':
pass
else:
for key in sfp_cable_length_tup:
if key in sfp_interface_bulk_data['data']:
Expand Down Expand Up @@ -1334,7 +1342,7 @@ def get_model(self):
"""
transceiver_dom_info_dict = self.get_transceiver_info()
if transceiver_dom_info_dict is not None:
return transceiver_dom_info_dict.get("modelname", "N/A")
return transceiver_dom_info_dict.get("model", "N/A")
else:
return None

Expand All @@ -1346,7 +1354,7 @@ def get_serial(self):
"""
transceiver_dom_info_dict = self.get_transceiver_info()
if transceiver_dom_info_dict is not None:
return transceiver_dom_info_dict.get("serialnum", "N/A")
return transceiver_dom_info_dict.get("serial", "N/A")
else:
return None

Expand All @@ -1366,7 +1374,7 @@ def get_connector_type(self):
"""
transceiver_dom_info_dict = self.get_transceiver_info()
if transceiver_dom_info_dict is not None:
return transceiver_dom_info_dict.get("Connector", "N/A")
return transceiver_dom_info_dict.get("connector", "N/A")
else:
return None

Expand Down
Loading

0 comments on commit 42a9c72

Please sign in to comment.