From 4c3b5c15df5b42c2d330573e6e3e0cf3dc147392 Mon Sep 17 00:00:00 2001 From: Ramakrishnan G Date: Fri, 26 Jun 2015 03:53:42 +0000 Subject: [PATCH] Change dict() to {} This commit changes dict() invocations to {} as it has been found to be better in performance. Change-Id: Id44ea76036a00d1901456c48f65711b3bf84c603 --- proliantutils/hpssa/manager.py | 2 +- proliantutils/hpssa/objects.py | 6 +++--- proliantutils/ilo/ribcl.py | 2 +- proliantutils/ilo/ris.py | 24 ++++++++++++------------ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/proliantutils/hpssa/manager.py b/proliantutils/hpssa/manager.py index b261a32..59cf0cf 100644 --- a/proliantutils/hpssa/manager.py +++ b/proliantutils/hpssa/manager.py @@ -193,7 +193,7 @@ def get_configuration(): """ server = objects.Server() logical_drives = server.get_logical_drives() - raid_config = dict() + raid_config = {} raid_config['logical_disks'] = [] for logical_drive in logical_drives: diff --git a/proliantutils/hpssa/objects.py b/proliantutils/hpssa/objects.py index 99ad977..2852f2a 100644 --- a/proliantutils/hpssa/objects.py +++ b/proliantutils/hpssa/objects.py @@ -58,7 +58,7 @@ def _get_key_value(string): def _get_dict(lines, start_index, indentation): """Recursive function for parsing hpssacli output.""" - info = dict() + info = {} current_item = None i = start_index @@ -69,7 +69,7 @@ def _get_dict(lines, start_index, indentation): if current_line_indentation == indentation: current_item = current_line.lstrip(' ') - info[current_item] = dict() + info[current_item] = {} i = i + 1 continue @@ -312,7 +312,7 @@ class Controller(object): self.unassigned_physical_drives = [] self.raid_arrays = [] - unassigned_drives = properties.get('unassigned', dict()) + unassigned_drives = properties.get('unassigned', {}) for key, value in unassigned_drives.items(): self.unassigned_physical_drives.append(PhysicalDrive(key, value, diff --git a/proliantutils/ilo/ribcl.py b/proliantutils/ilo/ribcl.py index 85aae93..55797fc 100644 --- a/proliantutils/ilo/ribcl.py +++ b/proliantutils/ilo/ribcl.py @@ -199,7 +199,7 @@ class RIBCLOperations(operations.IloOperations): Converts the actual response from the ILO for an API to the dictionary. """ - node = dict() + node = {} text = getattr(element, 'text') if text is not None: text = text.strip() diff --git a/proliantutils/ilo/ris.py b/proliantutils/ilo/ris.py index 4226e9c..e4c2935 100755 --- a/proliantutils/ilo/ris.py +++ b/proliantutils/ilo/ris.py @@ -62,7 +62,7 @@ class RISOperations(operations.IloOperations): start_url = url.geturl() if request_headers is None: - request_headers = dict() + request_headers = {} # Use self.login/self.password and Basic Auth if self.login is not None and self.password is not None: @@ -141,7 +141,7 @@ class RISOperations(operations.IloOperations): HTTP response codes could be 500, 404, 202 etc. """ if not isinstance(request_headers, dict): - request_headers = dict() + request_headers = {} request_headers['Content-Type'] = 'application/json' return self._rest_op('PATCH', suburi, request_headers, request_body) @@ -151,7 +151,7 @@ class RISOperations(operations.IloOperations): HTTP response codes could be 500, 404, 202 etc. """ if not isinstance(request_headers, dict): - request_headers = dict() + request_headers = {} request_headers['Content-Type'] = 'application/json' return self._rest_op('PUT', suburi, request_headers, request_body) @@ -162,7 +162,7 @@ class RISOperations(operations.IloOperations): ExtendedError, or it could be empty. """ if not isinstance(request_headers, dict): - request_headers = dict() + request_headers = {} request_headers['Content-Type'] = 'application/json' return self._rest_op('POST', suburi, request_headers, request_body) @@ -370,7 +370,7 @@ class RISOperations(operations.IloOperations): def _get_bios_hash_password(self, bios_password): """Get the hashed BIOS password.""" - request_headers = dict() + request_headers = {} if bios_password: bios_password_hash = hashlib.sha256((bios_password.encode()). hexdigest().upper()) @@ -557,7 +557,7 @@ class RISOperations(operations.IloOperations): secure_boot_uri = system['Oem']['Hp']['links']['SecureBoot']['href'] # Change the property required - new_secure_boot_settings = dict() + new_secure_boot_settings = {} new_secure_boot_settings[property] = value # perform the patch @@ -713,7 +713,7 @@ class RISOperations(operations.IloOperations): in the bios boot mode. """ if(self._validate_uefi_boot_mode() is True): - iscsi_info = dict() + iscsi_info = {} iscsi_info['iSCSITargetName'] = target_name iscsi_info['iSCSIBootLUN'] = lun iscsi_info['iSCSITargetIpAddress'] = ip_address @@ -940,7 +940,7 @@ class RISOperations(operations.IloOperations): msg = ('"LicenseService" section in Manager/Oem/Hp does not exist') raise exception.IloCommandNotSupportedError(msg) - lic_key = dict() + lic_key = {} lic_key['LicenseKey'] = key # Perform POST to activate license @@ -1008,7 +1008,7 @@ class RISOperations(operations.IloOperations): # BOOT_OPTION = BOOT_ALWAYS | BOOT_ONCE | NO_BOOT # WRITE_PROTECT = YES | NO # IMAGE_INSERTED = YES | NO - response_data = dict() + response_data = {} if response.get('WriteProtected', False): response_data['WRITE_PROTECT'] = 'YES' @@ -1074,7 +1074,7 @@ class RISOperations(operations.IloOperations): response, vm_device_uri = self._get_vm_device_status(device) # Update required property - vm_settings = dict() + vm_settings = {} vm_settings['Oem'] = ( {'Hp': {'BootOnNextServerReset': boot_option_map[boot_option]}}) @@ -1104,7 +1104,7 @@ class RISOperations(operations.IloOperations): self.eject_virtual_media(device) # Update required property - vm_settings = dict() + vm_settings = {} vm_settings['Image'] = url # Perform the patch operation @@ -1126,7 +1126,7 @@ class RISOperations(operations.IloOperations): response, vm_device_uri = self._get_vm_device_status(device) # Update required property - vm_settings = dict() + vm_settings = {} vm_settings['Image'] = None # perform the patch operation