Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create pylint.yml #334

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Pylint

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7","3.8", "3.9", "3.10"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
- name: Analysing the code with pylint
run: |
pip install Inspektor==0.5.3
inspekt checkall --disable-style E501,E265,W601,W605,E402,E722,E741,E115,E0606 --no-license-check
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

27 changes: 18 additions & 9 deletions analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def test_analysis(data):

# Loop through the 'tests' list in the JSON data and add rows
for i, test in enumerate(data['tests']):
dataframe.loc[i + 8] = [test['name'], test['status'], test['fail_reason']]
dataframe.loc[i + 8] = [test['name'],
test['status'], test['fail_reason']]

# Save the DataFrame to a Excel file
dataframe.to_excel('Analysis.xlsx', index=False)
Expand Down Expand Up @@ -111,15 +112,17 @@ def comparison_analysis(excel, data):
found = 0
for j in range(len(test_names)):
if test['name'] == test_names[j]:
new_dataframe.loc[j + 8] = [test['status'], test['fail_reason']]
new_dataframe.loc[j + 8] = [test['status'],
test['fail_reason']]
found = 1
break
if found == 0:
new = [test['name']]
for i in range(len(old_dataframe.columns)-1):
new.append("")
old_dataframe.loc[len(old_dataframe.index)] = new
new_dataframe.loc[len(old_dataframe.index)-1] = [test['status'], test['fail_reason']]
new_dataframe.loc[len(old_dataframe.index) -
1] = [test['status'], test['fail_reason']]

final_res = pd.concat([old_dataframe, new_dataframe], axis=1)
final_res.to_excel(excel, index=False)
Expand Down Expand Up @@ -179,26 +182,32 @@ def deco(excel):
for cell in row:
cell.font = Font(size=15)
cell.border = Border(left=Side(border_style='thin', color='000000'),
right=Side(border_style='thin', color='000000'),
right=Side(border_style='thin',
color='000000'),
top=Side(border_style='thin', color='000000'),
bottom=Side(border_style='thin', color='000000'))
cell.alignment = Alignment(wrap_text=True, vertical='center')

# Apply header formatting
for cell in worksheet[1]:
cell.font = Font(size=18, bold=True) # White text color
cell.fill = PatternFill(start_color='ADD8E6', end_color='ADD8E6', fill_type='solid') # Blue background color
# Blue background color
cell.fill = PatternFill(start_color='ADD8E6',
end_color='ADD8E6', fill_type='solid')

# Conditional formatting for the "Result" column if present
try:
for idx, value in enumerate(dataframe['Result'], start=2):
cell = worksheet.cell(row=idx, column=6)
if value == 'DIFF':
cell.fill = PatternFill(start_color='FF0000', end_color='FF0000', fill_type='solid') # Red
cell.fill = PatternFill(
start_color='FF0000', end_color='FF0000', fill_type='solid') # Red
elif value == 'SOLVED':
cell.fill = PatternFill(start_color='39E75F', end_color='39E75F', fill_type='solid') # Green
cell.fill = PatternFill(
start_color='39E75F', end_color='39E75F', fill_type='solid') # Green
elif value == 'REGRESSION':
cell.fill = PatternFill(start_color='FFA500', end_color='FFA500', fill_type='solid') # Orange
cell.fill = PatternFill(
start_color='FFA500', end_color='FFA500', fill_type='solid') # Orange
except Exception as e:
pass

Expand Down Expand Up @@ -248,4 +257,4 @@ def usage():


if __name__ == '__main__':
main()
main()
5 changes: 4 additions & 1 deletion avocado-setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
logger = logger_init(filepath=BASE_PATH).getlogger()
prescript_dir = CONFIGFILE.get('script-dir', 'prescriptdir')
postscript_dir = CONFIGFILE.get('script-dir', 'postscriptdir')
args = None
outputdir = ''
pipManager = None


class TestSuite():
Expand Down Expand Up @@ -673,7 +676,7 @@ def parse_test_config(test_config_file, avocado_bin, enable_kvm):
bootstraped = True

if args.run_tests:
with open("%s/host/dynamic_test_suite" % TEST_CONF_PATH+".cfg","w+") as fp:
with open("%s/host/dynamic_test_suite" % TEST_CONF_PATH+".cfg", "w+") as fp:
fp.write('\n'.join(args.run_tests.split(",")))
args.run_suite = str(args.run_suite)+","+"host_dynamic_test_suite"

Expand Down
45 changes: 36 additions & 9 deletions lib/pci.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def get_domains():
return list(set(domains))
return []

def is_nvmf():

def is_nvmf():
"""
Verify if nvmf is configured

Expand All @@ -55,6 +56,7 @@ def is_nvmf():
else:
return False


def list_fc_host_names(pci_domain):
"""
For a specific PCI domain find the nvmf disks behind FC PCI domain
Expand Down Expand Up @@ -88,6 +90,7 @@ def list_fc_host_names(pci_domain):
logger.debug("Error while traversing PCI domain %s", pci_domain)
return []


def list_nvmf_fc_node_names(host_names):
"""
For every FC hostnames find the node_name
Expand Down Expand Up @@ -116,6 +119,7 @@ def list_nvmf_fc_node_names(host_names):

return node_names


def list_nvmf_nvme_names(node_names):
"""
In the nvme list-subsystem output find the nvme host specific to FC node names
Expand All @@ -126,7 +130,6 @@ def list_nvmf_nvme_names(node_names):
"""
nvme_names = []
lines = runcmd('nvme list-subsys')[1].splitlines()

for line in lines:
for word in node_names:
if re.search(word, line):
Expand All @@ -135,6 +138,7 @@ def list_nvmf_nvme_names(node_names):

return nvme_names


def list_nvmf_disks(nvme_names):
"""
Traverse through nvme list command to find the corresponding nvmf disks
Expand All @@ -154,6 +158,7 @@ def list_nvmf_disks(nvme_names):
nvmf_disks.append(parts[0])
return nvmf_disks


def get_pci_addresses():
"""
Gets list of PCI addresses in the system.
Expand All @@ -167,6 +172,7 @@ def get_pci_addresses():
addresses.append(line.split()[0])
return addresses


def get_num_interfaces_in_pci(dom_pci_address):
"""
Gets number of interfaces of a given partial PCI address starting with
Expand All @@ -186,6 +192,7 @@ def get_num_interfaces_in_pci(dom_pci_address):
count += 1
return count


def get_disks_in_pci_address(pci_address):
"""
Gets disks in a PCI address.
Expand All @@ -202,6 +209,7 @@ def get_disks_in_pci_address(pci_address):
disk_list.append(os.path.abspath(os.path.join(disks_path, link)))
return disk_list


def get_disks_in_interface(interface):
"""
Gets disks in a PCI interface.
Expand All @@ -218,6 +226,7 @@ def get_disks_in_interface(interface):
disk_list.append('/dev/%s' % dev)
return disk_list


def get_multipath_wwids(disks_list):
"""
Get mpath wwid for given scsi disks
Expand All @@ -240,6 +249,7 @@ def get_multipath_wwids(disks_list):
existing_wwids.append(line.split('/')[1])
return [mpath for mpath in list(set(wwid_list)) if mpath in existing_wwids]


def get_multipath_disks(wwids_list):
"""
Get mpath disk names for given wwids
Expand All @@ -254,6 +264,7 @@ def get_multipath_disks(wwids_list):
mpath_list.append("/dev/mapper/%s" % disk)
return mpath_list


def get_root_disks():
"""
Gets the PCI address of the root disk.
Expand All @@ -267,6 +278,7 @@ def get_root_disks():
root_disk.append('/dev/%s' % line.split()[0])
return root_disk


def get_nics_in_pci_address(pci_address):
"""
Gets network interface(nic) in a PCI address.
Expand All @@ -277,6 +289,7 @@ def get_nics_in_pci_address(pci_address):
"""
return get_interfaces_in_pci_address(pci_address, "net")


def get_interfaces_in_pci_address(pci_address, pci_class):
"""
Gets interface in a PCI address.
Expand All @@ -297,6 +310,7 @@ def get_interfaces_in_pci_address(pci_address, pci_class):
if pci_address in os.readlink(os.path.join(pci_class_path,
interface))]


def get_pci_class_name(pci_address):
"""
Gets PCI class name for given PCI bus address
Expand All @@ -316,6 +330,7 @@ def get_pci_class_name(pci_address):
return ""
return pci_class_dic.get(pci_class_id)


def get_pci_type(pci_address):
"""
Gets PCI type for given PCI bus address
Expand All @@ -335,6 +350,7 @@ def get_pci_type(pci_address):
return ""
return pci_class_dic.get(pci_class_id)


def get_firmware(pci_address):
"""
Gets firmware of a pci_address
Expand Down Expand Up @@ -506,6 +522,7 @@ def get_pci_name(pci_address):
return " ".join(pci_name)
return ""


def get_driver(adapter_type, pci_address):
"""
Gets the kernel driver in use of given PCI address. (first match only)
Expand All @@ -532,6 +549,7 @@ def get_driver(adapter_type, pci_address):
return line.rsplit(None, 1)[-1]
return ""


def ioa_details():
"""
Gets the IPR IOA details and returns
Expand All @@ -555,7 +573,8 @@ def ioa_details():
r_serial = line.split()[-1]
if line.startswith('Current Dual Adapter State'):
status = line.split()[-1]
ioas.append({'ioa': ioa, 'pci': pci, 'serial': serial, 'r_serial': r_serial, 'status': status})
ioas.append({'ioa': ioa, 'pci': pci, 'serial': serial,
'r_serial': r_serial, 'status': status})
return ioas


Expand All @@ -572,6 +591,7 @@ def get_primary_ioa(pci_address):
return ioa_detail['ioa']
return ''


def get_multipath_nvmf_wwids():
"""
Gets the wwids of the nvmf multipath disks
Expand All @@ -592,6 +612,7 @@ def get_multipath_nvmf_wwids():

return wwid_list


def get_secondary_ioa(primary_ioa):
"""
Gets the Secondary IPR IOA in the given Primary IPR IOA
Expand Down Expand Up @@ -648,15 +669,17 @@ def pci_info(pci_addrs, pci_type='', pci_blocklist='', type_blocklist=''):
pci_dic['class'] = get_pci_class_name(pci_dic['functions'][0])
pci_dic['interfaces'] = []
for fun in pci_dic['functions']:
pci_dic['interfaces'].extend(get_interfaces_in_pci_address(fun, pci_dic['class']))
pci_dic['interfaces'].extend(
get_interfaces_in_pci_address(fun, pci_dic['class']))
pci_dic['disks'] = []
pci_dic['mpath_wwids'] = []
pci_dic['mpath_disks'] = []
if pci_dic['adapter_type'] == 'fc' and is_nvmf():
pci_dic['adapter_type'] = 'nvmf'
if is_rhel8():
pci_dic['mpath_wwids'] = get_multipath_nvmf_wwids()
pci_dic['mpath_disks'] = get_multipath_disks(pci_dic['mpath_wwids'])
pci_dic['mpath_disks'] = get_multipath_disks(
pci_dic['mpath_wwids'])
pci_dic['disks'] = pci_dic['mpath_disks']
else:
pci_val = ':'.join(pci_addr.split(':')[:2])
Expand All @@ -667,12 +690,14 @@ def pci_info(pci_addrs, pci_type='', pci_blocklist='', type_blocklist=''):
pci_dic['disks'] = list(set(pci_dic['disks']))
if pci_dic['class'] == 'scsi_host' and not pci_dic['adapter_type'] == 'nvmf':
pci_dic['mpath_wwids'] = get_multipath_wwids(pci_dic['disks'])
pci_dic['mpath_disks'] = get_multipath_disks(pci_dic['mpath_wwids'])
pci_dic['mpath_disks'] = get_multipath_disks(
pci_dic['mpath_wwids'])
pci_dic['disks'] = pci_dic['mpath_disks']
pci_dic['pci_root'] = pci_addr
pci_dic['adapter_description'] = get_pci_name(pci_dic['functions'][0])
pci_dic['adapter_id'] = get_pci_id(pci_dic['functions'][0])
pci_dic['driver'] = get_driver(pci_dic['adapter_type'], pci_dic['functions'][0])
pci_dic['driver'] = get_driver(
pci_dic['adapter_type'], pci_dic['functions'][0])
pci_dic['slot'] = get_slot_from_sysfs(pci_dic['functions'][0])
if pci_dic['adapter_type'] in type_blocklist:
continue
Expand All @@ -682,11 +707,13 @@ def pci_info(pci_addrs, pci_type='', pci_blocklist='', type_blocklist=''):
pci_dic['infiniband_interfaces'] = []
if pci_dic['adapter_type'] == 'infiniband':
for fun in pci_dic['functions']:
pci_dic['infiniband_interfaces'].extend(get_interfaces_in_pci_address(fun, 'infiniband'))
pci_dic['infiniband_interfaces'].extend(
get_interfaces_in_pci_address(fun, 'infiniband'))
if pci_dic['adapter_type'] == 'raid':
for fun in pci_dic['functions']:
pci_dic['primary_ioa'] = get_primary_ioa(fun)
pci_dic['secondary_ioa'] = get_secondary_ioa(pci_dic['primary_ioa'])
pci_dic['secondary_ioa'] = get_secondary_ioa(
pci_dic['primary_ioa'])
pci_dic['is_root_disk'] = False
for disk in pci_dic['disks']:
for root_disk in root_disks:
Expand Down
Loading
Loading