diff --git a/CHANGELOG.md b/CHANGELOG.md index 8631545..9add54f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log +## [1.0.8] - 2020-07-10 +- Added option to inventory script to save information to a spreadsheet + ## [1.0.7] - 2020-05-22 - Removed 'PushPowerButton' from simple reset list diff --git a/README.md b/README.md index 5b58af3..408aa3f 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,9 @@ optional arguments: be shown --noabsent, -noabsent Indicates if absent devices should be skipped + --write [WRITE], -w [WRITE] + Indicates if the inventory should be written to a + spreadsheet and what the file name should be if given ``` Example: `rf_sys_inventory.py -u root -p root -r https://192.168.1.100 -details` diff --git a/redfish_utilities/inventory.py b/redfish_utilities/inventory.py index ea5b34c..4657f2b 100644 --- a/redfish_utilities/inventory.py +++ b/redfish_utilities/inventory.py @@ -288,34 +288,32 @@ def print_system_inventory( inventory_list, details = False, skip_absent = False print( "" ) -def write_system_inventory( inventory_list, file_name): +def write_system_inventory( inventory_list, file_name ): """ Write the system inventory list into a spreadsheet Args: inventory_list: The inventory list to write to an Excel spreadsheet + file_name: The name of the file for the spreadsheet """ # Excel workbook to save data extracted and parsed - workbook = xlsxwriter.Workbook(f"./{file_name}.xlsx") + workbook = xlsxwriter.Workbook( "./{}.xlsx".format( file_name ) ) - worksheet = workbook.add_worksheet("Device Inventory") - cell_header_format = workbook.add_format({'bold': True, 'bg_color': 'yellow'}) - cell_name_format = workbook.add_format({'bold': True}) + worksheet = workbook.add_worksheet( "Device Inventory" ) + cell_header_format = workbook.add_format( { 'bold': True, 'bg_color': 'yellow' } ) + cell_name_format = workbook.add_format( { 'bold': True } ) column = 0 row = 0 # Adds header to Excel file - header = ["NAME", "DESCRIPTION", "MANUFACTURER", "MODEL", "SKU", "PART NUMBER", "SERIAL NUMBER", "ASSET TAG" ] + header = [ "NAME", "DESCRIPTION", "MANUFACTURER", "MODEL", "SKU", "PART NUMBER", "SERIAL NUMBER", "ASSET TAG" ] for column_title in header: - worksheet.write(row, column, column_title, cell_header_format) + worksheet.write( row, column, column_title, cell_header_format ) column += 1 row = 1 - - - for chassis in inventory_list: # Go through each component type in the chassis type_list = [ "Chassis", "Processors", "Memory", "Drives", "PCIeDevices", "StorageControllers", "NetworkAdapters" ] @@ -323,12 +321,12 @@ def write_system_inventory( inventory_list, file_name): # Go through each component and prints its info for item in chassis[inv_type]: column = 0 - worksheet.write(row, column, inv_type, cell_name_format) + worksheet.write( row, column, inv_type, cell_name_format ) column += 1 detail_list = [ "Description", "Manufacturer", "Model", "SKU", "PartNumber", "SerialNumber", "AssetTag" ] for detail in detail_list: - worksheet.write(row, column, item[detail] ) + worksheet.write( row, column, item[detail] ) column += 1 row += 1 - - workbook.close() \ No newline at end of file + + workbook.close() diff --git a/scripts/rf_sys_inventory.py b/scripts/rf_sys_inventory.py index a182fe5..2c21e8a 100644 --- a/scripts/rf_sys_inventory.py +++ b/scripts/rf_sys_inventory.py @@ -37,7 +37,7 @@ inventory = redfish_utilities.get_system_inventory( redfish_obj ) redfish_utilities.print_system_inventory( inventory, details = args.details, skip_absent = args.noabsent ) - if(args.write): + if( args.write ): redfish_utilities.write_system_inventory( inventory, args.write ) finally: diff --git a/setup.py b/setup.py index dc465b2..0e52411 100644 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup( name = "redfish_utilities", - version = "1.0.7", + version = "1.0.8", description = "Redfish Utilities", long_description = long_description, long_description_content_type = "text/markdown",