output
stringlengths
1
928k
instruction
stringlengths
7
928k
system
stringlengths
0
104k
def array_controller_by_model(self, model): """Returns array controller instance by model :returns Instance of array controller """ for member in self.get_members(): if member.model == model: return member
Write a Python 3 function that can return array controller instance by model
You are a Python code architect, reviewing and designing scalable and efficient code
Helper function to find the resource path by a list of path items.
Can you generate a brief explanation for the following Python 3 code def get_subresource_path_by(resource, subresource_path): if isinstance(subresource_path, six.string_types): subresource_path = [subresource_path] elif not subresource_path: raise ValueError('"subresource_path" cannot be empty')...
You are a Python code generator, capable of creating scripts from specifications.
Return a tuple of true / false based on bios and uefi support respectively.
Given the following Python 3 function, write the documentation def get_supported_boot_mode(supported_boot_mode): boot_mode_bios = 'false' boot_mode_uefi = 'false' if (supported_boot_mode == sys_cons.SUPPORTED_LEGACY_BIOS_ONLY): boot_mode_bios = 'true' elif (su...
As a python code expert, you are capable of creating scripts from specifications.
Helper function to get the HTTP allowed methods.
Explain what the following Python 3 code does def get_allowed_operations(resource, subresouce_path): uri = get_subresource_path_by(resource, subresouce_path) response = resource._conn.get(path=uri) return response.headers['Allow']
As a Python code translator, you convert algorithms and pseudocode into Python.
A function which sets the next host location on the request if applicable.
How would you explain what the following Python 3 function does def _set_next_host_location(self, context): ''' A function which sets the next host location on the request, if applicable. :param ~azure.storage.models.RetryContext context: The retry context containing the previous ...
You are a Python code architect, reviewing and designing scalable and efficient code
def _op(self, method, path='', data=None, headers=None): """Overrides the base method to support retrying the operation. :param method: The HTTP method to be used, e.g: GET, POST, PUT, PATCH, etc... :param path: The sub-URI path to the resource. :param data: Optional JSON da...
Write a Python 3 function for overriding the base method to support retrying the operation.
You are a Python code architect, reviewing and designing scalable and efficient code
def generate_file_shared_access_signature(self, share_name, directory_name=None, file_name=None, permission=None, expiry=None, ...
Create a Python 3 function to generate a shared access signature for the file. Use the returned signature with the sas_token parameter of FileService. :param str share_name: Name of share. :param str directory_name: Name of directory. SAS tokens cannot be created for directories, so this parameter should only be presen...
As a Python code translator, you convert algorithms and pseudocode into Python.
def set_file_service_properties(self, hour_metrics=None, minute_metrics=None, cors=None, timeout=None): ''' Sets the properties of a storage account's File service, including Azure Storage Analytics. If an element (ex HourMetrics) is left as None, the ...
Write a Python 3 script for setting the properties of a storage account s File service including the File service properties.
As a python code expert, you are capable of creating scripts from specifications.
Returns a generator to list the shares under the specified account.
Given the following Python 3 function, write the documentation def list_shares(self, prefix=None, marker=None, num_results=None, include_metadata=False, timeout=None): ''' Returns a generator to list the shares under the specified account. The generator will lazily follow th...
As a Python code analyst, you investigate and solve complex coding mysteries
Returns all user - defined metadata and system properties for the specified share.
Can you generate a brief explanation for the following Python 3 code def get_share_properties(self, share_name, timeout=None): ''' Returns all user-defined metadata and system properties for the specified share. The data returned does not include the shares's list of files or directories...
You are a Python code generator, capable of creating scripts from specifications.
def set_share_properties(self, share_name, quota, timeout=None): ''' Sets service-defined properties for the specified share. :param str share_name: Name of existing share. :param int quota: Specifies the maximum size of the share, in gigabytes. Must be ...
Can you write a function in Python 3 where it sets the properties of the specified share.
You are a Python code analyst, evaluating scripts for potential improvements.
def get_share_metadata(self, share_name, timeout=None): ''' Returns all user-defined metadata for the specified share. :param str share_name: Name of existing share. :param int timeout: The timeout parameter is expressed in seconds. :return: A...
Write a Python 3 script for returning all user - defined metadata for the specified share.
As a python code expert, you are capable of creating scripts from specifications.
Retrieves the approximate size of the data stored on the given share.
Explain what the following Python 3 code does def get_share_stats(self, share_name, timeout=None): ''' Gets the approximate size of the data stored on the share, rounded up to the nearest gigabyte. Note that this value may not include all recently created or recently res...
As a Python code composer, you craft elegant and concise scripts.
def list_directories_and_files(self, share_name, directory_name=None, num_results=None, marker=None, timeout=None): ''' Returns a generator to list the directories and files under the specified share. The generator will lazily follow the continuation tokens re...
Write a Python 3 function that can return a generator to list the directories and files under the specified share.
You are a Python code generator, capable of creating scripts from specifications.
def _list_directories_and_files(self, share_name, directory_name=None, marker=None, max_results=None, timeout=None): ''' Returns a list of the directories and files under the specified share. :param str share_name: Name of existing share. ...
Implement a function in Python 3 to return a list of directories and files under the specified share.
As a Python code translator, you convert algorithms and pseudocode into Python.
def set_file_properties(self, share_name, directory_name, file_name, content_settings, timeout=None): ''' Sets system properties on the file. If one property is set for the content_settings, all properties will be overriden. :param str share_name: ...
Implement a Python 3 function for setting system properties on the file.
You are a Python code generator, capable of creating scripts from specifications.
def copy_file(self, share_name, directory_name, file_name, copy_source, metadata=None, timeout=None): ''' Copies a blob or file to a destination file within the storage account. :param str share_name: Name of existing share. :param str directory_name: ...
Write a Python 3 script for copying a blob or file to a destination file within the storage account.
You are a Python code architect, reviewing and designing scalable and efficient code
def create_file(self, share_name, directory_name, file_name, content_length, content_settings=None, metadata=None, timeout=None): ''' Creates a new file. See create_file_from_* for high level functions that handle the creation and upload of large...
Write a Python 3 function for creating a new file in the specified share.
As a Python code analyst, you investigate and solve complex coding mysteries
Creates a new file from a string or updates the content of an existing file.
How would you explain what the following Python 3 function does def create_file_from_text(self, share_name, directory_name, file_name, text, encoding='utf-8', content_settings=None, metadata=None, timeout=None): ''' Creates a new file from str/unico...
As a python code expert, you are capable of creating scripts from specifications.
def create_file_from_bytes( self, share_name, directory_name, file_name, file, index=0, count=None, content_settings=None, metadata=None, progress_callback=None, max_connections=1, max_retries=5, retry_wait=1.0, timeout=None): ''' Creates a new file from an array of bytes...
Write a Python 3 script for creating a new file from an array of bytes.
You are a Python code architect, reviewing and designing scalable and efficient code
Creates a new file from a file or stream.
Here you have a function in Python 3, explain what it does def create_file_from_stream( self, share_name, directory_name, file_name, stream, count, content_settings=None, metadata=None, progress_callback=None, max_connections=1, max_retries=5, retry_wait=1.0, timeout=None): ''' C...
As a Python code translator, you convert algorithms and pseudocode into Python.
Download a file from the Cloud Storage service.
Can you tell what is the following Python 3 function doing def _get_file(self, share_name, directory_name, file_name, start_range=None, end_range=None, range_get_content_md5=None, timeout=None): ''' Downloads a file's content, metadata, and properties. You can specify a...
As a Python code analyst, you investigate and solve complex coding mysteries
Downloads a file to a file path.
Explain what the following Python 3 code does def get_file_to_path(self, share_name, directory_name, file_name, file_path, open_mode='wb', start_range=None, end_range=None, range_get_content_md5=None, progress_callback=None, max_connections=1, m...
You are a Python code generator, capable of creating scripts from specifications.
def get_file_to_stream( self, share_name, directory_name, file_name, stream, start_range=None, end_range=None, range_get_content_md5=None, progress_callback=None, max_connections=1, max_retries=5, retry_wait=1.0, timeout=None): ''' Downloads a file to a stream, with autom...
Write a Python 3 script for downloading a file from the given share to a stream.
As a Python code analyst, you investigate and solve complex coding mysteries
Downloads a file from the given share and returns an array of bytes.
Make a summary of the following Python 3 code def get_file_to_bytes(self, share_name, directory_name, file_name, start_range=None, end_range=None, range_get_content_md5=None, progress_callback=None, max_connections=1, max_retries=5, retry_wa...
You are a Python code analyst, evaluating scripts for potential improvements.
Downloads a file as unicode text and returns a File instance.
Make a summary of the following Python 3 code def get_file_to_text( self, share_name, directory_name, file_name, encoding='utf-8', start_range=None, end_range=None, range_get_content_md5=None, progress_callback=None, max_connections=1, max_retries=5, retry_wait=1.0, timeout=None): ...
You are a Python code analyst, evaluating scripts for potential improvements.
Update the range of the file in the specified share.
Can you tell what is the following Python 3 function doing def update_range(self, share_name, directory_name, file_name, data, start_range, end_range, content_md5=None, timeout=None): ''' Writes the bytes specified by the request body into the specified range. :pa...
You are a Python code generator, capable of creating scripts from specifications.
Clears the specified range and releases the space used in storage for that range is in the specified range.
Can you tell what is the following Python 3 function doing def clear_range(self, share_name, directory_name, file_name, start_range, end_range, timeout=None): ''' Clears the specified range and releases the space used in storage for that range. :param str s...
As a Python code analyst, you investigate and solve complex coding mysteries
Retrieves the valid ranges for a file in a given share.
Make a summary of the following Python 3 code def list_ranges(self, share_name, directory_name, file_name, start_range=None, end_range=None, timeout=None): ''' Retrieves the valid ranges for a file. :param str share_name: Name of existing share. :param st...
As a python code expert, you are capable of creating scripts from specifications.
def _get_sushy_system(self, system_id): """Get the sushy system for system_id :param system_id: The identity of the System resource :returns: the Sushy system instance :raises: IloError """ system_url = parse.urljoin(self._sushy.get_system_collection_path(), ...
Write a Python 3 function for getting the sushy system for the system_id.
As a Python code translator, you convert algorithms and pseudocode into Python.
Get the sushy Manager for the manager_id.
Make a summary of the following Python 3 code def _get_sushy_manager(self, manager_id): manager_url = parse.urljoin(self._sushy.get_manager_collection_path(), manager_id) try: return self._sushy.get_manager(manager_url) except sushy.exceptions.Sush...
As a python code expert, you are capable of creating scripts from specifications.
def get_host_power_status(self): """Request the power state of the server. :returns: Power State of the server, 'ON' or 'OFF' :raises: IloError, on an error from iLO. """ sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) return GET_POWER_STATE_MAP.get(sushy_syste...
Create a Python 3 function to request the power state of the server.
You are a Python code architect, reviewing and designing scalable and efficient code
def reset_server(self): """Resets the server. :raises: IloError, on an error from iLO. """ sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: sushy_system.reset_system(sushy.RESET_FORCE_RESTART) except sushy.exceptions.SushyError as e: ...
Can you write a function in Python 3 where it resets the server. :raises: IloError, on an error from iLO.
As a Python code translator, you convert algorithms and pseudocode into Python.
Sets the power state of the server.
Can you generate a brief explanation for the following Python 3 code def set_host_power(self, target_value): if target_value not in POWER_RESET_MAP: msg = ('The parameter "%(parameter)s" value "%(target_value)s" is ' 'invalid. Valid values are: %(valid_power_values)s' % ...
You are a Python code generator, capable of creating scripts from specifications.
Simulates a physical press of the server power button.
Can you generate a brief explanation for the following Python 3 code def press_pwr_btn(self): sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: sushy_system.push_power_button(sys_cons.PUSH_POWER_BUTTON_PRESS) except sushy.exceptions.SushyError as e: msg = (se...
You are a Python code analyst, evaluating scripts for potential improvements.
def activate_license(self, key): """Activates iLO license. :param key: iLO license key. :raises: IloError, on an error from iLO. """ sushy_manager = self._get_sushy_manager(PROLIANT_MANAGER_ID) try: sushy_manager.set_license(key) except sushy.exceptio...
Create a Python 3 function to activate the iLO license.
You are a Python code generator, capable of creating scripts from specifications.
def get_one_time_boot(self): """Retrieves the current setting for the one time boot. :returns: Returns boot device that would be used in next boot. Returns 'Normal' if no device is set. """ sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) if (sushy_sys...
Can you create a Python 3 function that retrieves the current setting for the one - time boot.
As a python code expert, you are capable of creating scripts from specifications.
Retrieves the pending boot mode of the server.
Can you generate the documentation for the following Python 3 function def get_pending_boot_mode(self): sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: return BOOT_MODE_MAP.get( sushy_system.bios_settings.pending_settings.boot_mode) except sushy.excepti...
As a Python code analyst, you investigate and solve complex coding mysteries
def _validate_virtual_media(self, device): """Check if the device is valid device. :param device: virtual media device :raises: IloInvalidInputError, if the device is not valid. """ if device not in VIRTUAL_MEDIA_MAP: msg = (self._("Invalid device '%s'. Valid devices...
Can you implement a function in Python 3 that checks if the device is valid virtual media.
As a Python code analyst, you investigate and solve complex coding mysteries
Ejects the Virtual Media image if one is inserted.
Explain what the following Python 3 code does def eject_virtual_media(self, device): self._validate_virtual_media(device) manager = self._get_sushy_manager(PROLIANT_MANAGER_ID) try: vmedia_device = ( manager.virtual_media.get_member_device( VIRTUAL...
You are a Python code analyst, evaluating scripts for potential improvements.
Set the virtual media drive status for the specified virtual media device.
Explain what the following Python 3 code does def set_vm_status(self, device='FLOPPY', boot_option='BOOT_ONCE', write_protect='YES'): """Sets the Virtual Media drive status It sets the boot option for virtual media device. Note: boot option can be set only for CD device. ...
As a python code expert, you are capable of creating scripts from specifications.
def update_firmware(self, file_url, component_type): """Updates the given firmware on the server for the given component. :param file_url: location of the raw firmware file. Extraction of the firmware file (if in compact format) is expected to happen pr...
Can you write a function in Python 3 where it updates the given firmware on the server for the given component type.
You are a Python code analyst, evaluating scripts for potential improvements.
def _is_boot_mode_uefi(self): """Checks if the system is in uefi boot mode. :return: 'True' if the boot mode is uefi else 'False' """ boot_mode = self.get_current_boot_mode() return (boot_mode == BOOT_MODE_MAP.get(sys_cons.BIOS_BOOT_MODE_UEFI))
Create a Python 3 function to check if the system is in uefi boot mode.
As a python code expert, you are capable of creating scripts from specifications.
def get_persistent_boot_device(self): """Get current persistent boot device set for the host :returns: persistent boot device for the system :raises: IloError, on an error from iLO. """ sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) # Return boot device if it ...
How would you implement a function in Python 3 that gets persistent boot device for the host.
As a Python code analyst, you investigate and solve complex coding mysteries
def set_pending_boot_mode(self, boot_mode): """Sets the boot mode of the system for next boot. :param boot_mode: either 'uefi' or 'legacy'. :raises: IloInvalidInputError, on an invalid input. :raises: IloError, on an error from iLO. """ sushy_system = self._get_sushy_sys...
Implement a Python 3 function for setting the pending boot mode of the system for next boot.
As a python code expert, you are capable of creating scripts from specifications.
Updates the persistent boot order for the host.
How would you explain what the following Python 3 function does def update_persistent_boot(self, devices=[]): sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) # Check if the input is valid for item in devices: if item.upper() not in DEVICE_COMMON_TO_REDFISH: ...
As a Python code composer, you craft elegant and concise scripts.
Configures a single boot from a specific device.
Explain what the following Python 3 code does def set_one_time_boot(self, device): sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) # Check if the input is valid if device.upper() not in DEVICE_COMMON_TO_REDFISH: msg = (self._('Invalid input "%(device)s". Valid devices: ' ...
You are a Python code generator, capable of creating scripts from specifications.
def reset_ilo_credential(self, password): """Resets the iLO password. :param password: The password to be set. :raises: IloError, if account not found or on an error from iLO. """ try: acc_service = self._sushy.get_account_service() member = acc_service.a...
Write a Python 3 function for resetting the iLO password.
You are a Python code analyst, evaluating scripts for potential improvements.
Get the system supported boot modes.
Can you tell what is the following Python 3 function doing def get_supported_boot_mode(self): sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: return SUPPORTED_BOOT_MODE_MAP.get( sushy_system.supported_boot_mode) except sushy.exceptions.SushyError as e: ...
As a python code expert, you are capable of creating scripts from specifications.
def get_server_capabilities(self): """Returns the server capabilities raises: IloError on an error from iLO. """ capabilities = {} sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) sushy_manager = self._get_sushy_manager(PROLIANT_MANAGER_ID) try: ...
Can you create a Python 3 function that returns the server capabilities from the iLO server.
You are a Python code generator, capable of creating scripts from specifications.
Resets the BIOS settings to default values.
Explain what the following Python 3 code does def reset_bios_to_default(self): sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: sushy_system.bios_settings.update_bios_to_default() except sushy.exceptions.SushyError as e: msg = (self._("The Redfish controller...
You are a Python code generator, capable of creating scripts from specifications.
Get the status of secure boot on the server.
Can you generate a brief explanation for the following Python 3 code def get_secure_boot_mode(self): sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: secure_boot_enabled = GET_SECUREBOOT_CURRENT_BOOT_MAP.get( sushy_system.secure_boot.current_boot) except...
As a Python code analyst, you investigate and solve complex coding mysteries
Enable or disable secure boot on the server.
Given the following Python 3 function, write the documentation def set_secure_boot_mode(self, secure_boot_enable): if self._is_boot_mode_uefi(): sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: sushy_system.secure_boot.enable_secure_boot(secure_boot_enable) ...
As a Python code analyst, you investigate and solve complex coding mysteries
def reset_secure_boot_keys(self): """Reset secure boot keys to manufacturing defaults. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server. """ if self._is_boot_mode_uefi(): sus...
Can you implement a function in Python 3 that resets secure boot keys to manufacturing defaults.
As a Python code composer, you craft elegant and concise scripts.
def get_essential_properties(self): """Constructs the dictionary of essential properties Constructs the dictionary of essential properties, named cpu, cpu_arch, local_gb, memory_mb. The MACs are also returned as part of this method. """ sushy_system = self._get_sushy_sys...
Can you create a Python 3 function that constructs the dictionary of essential properties named cpu cpu_arch local_gb memory_mb
As a python code expert, you are capable of creating scripts from specifications.
def _change_iscsi_target_settings(self, iscsi_info): """Change iSCSI target settings. :param iscsi_info: A dictionary that contains information of iSCSI target like target_name, lun, ip_address, port etc. :raises: IloError, on an error from iLO. """ su...
Write a Python 3 script for changing iSCSI target settings.
As a Python code analyst, you investigate and solve complex coding mysteries
def set_iscsi_info(self, target_name, lun, ip_address, port='3260', auth_method=None, username=None, password=None): """Set iSCSI details of the system in UEFI boot mode. The initiator system is set with the target details like IQN, LUN, IP, Port et...
Implement a function in Python 3 to set iSCSI details of the initiator system in UEFI boot mode.
As a Python code composer, you craft elegant and concise scripts.
Disable iSCSI boot option in UEFI boot mode.
How would you explain what the following Python 3 function does def unset_iscsi_info(self): if(self._is_boot_mode_uefi()): iscsi_info = {'iSCSIConnection': 'Disabled'} self._change_iscsi_target_settings(iscsi_info) else: msg = 'iSCSI boot is not supported in the BIOS ...
You are a Python code generator, capable of creating scripts from specifications.
def set_iscsi_initiator_info(self, initiator_iqn): """Set iSCSI initiator information in iLO. :param initiator_iqn: Initiator iqn for iLO. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedInBiosError, if the system is in the BIOS boot mode. ...
Implement a function in Python 3 to set iSCSI initiator information in iLO.
You are a Python code analyst, evaluating scripts for potential improvements.
Give iSCSI initiator information of iLO.
Explain what the following Python 3 code does def get_iscsi_initiator_info(self): sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) if(self._is_boot_mode_uefi()): try: iscsi_initiator = ( sushy_system.bios_settings.iscsi_resource.iscsi_initiator) ...
You are a Python code analyst, evaluating scripts for potential improvements.
def inject_nmi(self): """Inject NMI, Non Maskable Interrupt. Inject NMI (Non Maskable Interrupt) for a node immediately. :raises: IloError, on an error from iLO """ sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) if sushy_system.power_state != sushy.SYSTEM_POW...
Write a Python 3 function that can inject NMI and Non Maskable Interrupt for a node immediately.
You are a Python code analyst, evaluating scripts for potential improvements.
Get the current state of system POST.
Can you generate a brief explanation for the following Python 3 code def get_host_post_state(self): sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) return GET_POST_STATE_MAP.get(sushy_system.post_state)
As a python code expert, you are capable of creating scripts from specifications.
def read_raid_configuration(self, raid_config=None): """Read the logical drives from the system :param raid_config: None in case of post-delete read or in case of post-create a dictionary containing target raid configuration data. This data stuctu...
How would you implement a function in Python 3 that reads the logical drives from the system
As a python code expert, you are capable of creating scripts from specifications.
def get_current_bios_settings(self, only_allowed_settings=True): """Get current BIOS settings. :param: only_allowed_settings: True when only allowed BIOS settings are to be returned. If False, All the BIOS settings supported by iLO are returned. :return: a dictio...
Write a Python 3 script to get current BIOS settings.
You are a Python code generator, capable of creating scripts from specifications.
def set_bios_settings(self, data=None, only_allowed_settings=True): """Sets current BIOS settings to the provided data. :param: only_allowed_settings: True when only allowed BIOS settings are to be set. If False, all the BIOS settings supported by iLO and present in the ...
Create a Python 3 function for setting current BIOS settings to the provided data.
You are a Python code architect, reviewing and designing scalable and efficient code
Get default BIOS settings.
Can you generate the documentation for the following Python 3 function def get_default_bios_settings(self, only_allowed_settings=True): sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: settings = sushy_system.bios_settings.default_settings except sushy.exceptions.SushyE...
As a Python code translator, you convert algorithms and pseudocode into Python.
Create the raid configuration on the hardware.
Can you generate the documentation for the following Python 3 function def create_raid_configuration(self, raid_config): sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) sushy_system.create_raid(raid_config)
As a Python code translator, you convert algorithms and pseudocode into Python.
def get_bios_settings_result(self): """Gets the result of the bios settings applied :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server. """ sushy_system = self._get_sushy_system(PROLIANT_S...
Implement a Python 3 function for getting the result of the bios settings applied to the server.
You are a Python code architect, reviewing and designing scalable and efficient code
Generator function that returns collection members.
Here you have a function in Python 3, explain what it does def _get_collection(self, collection_uri, request_headers=None): # get the collection status, headers, thecollection = self._rest_get(collection_uri) if status != 200: msg = self._get_extended_error(thecollection) ...
As a python code expert, you are capable of creating scripts from specifications.
Return the type of an object.
Can you generate a brief explanation for the following Python 3 code def _get_type(self, obj): typever = obj['Type'] typesplit = typever.split('.') return typesplit[0] + '.' + typesplit[1]
As a Python code translator, you convert algorithms and pseudocode into Python.
def _render_extended_error_message_list(self, extended_error): """Parse the ExtendedError object and retruns the message. Build a list of decoded messages from the extended_error using the message registries. An ExtendedError JSON object is a response from the with its own schema. This...
Write a Python 3 function for parsing the ExtendedError JSON object and returns a list of plain language strings that represent the message.
As a python code expert, you are capable of creating scripts from specifications.
Get the system details.
Explain what the following Python 3 code does def _get_host_details(self): # Assuming only one system present as part of collection, # as we are dealing with iLO's here. status, headers, system = self._rest_get('/rest/v1/Systems/1') if status < 300: stype = self._get_type(sys...
You are a Python code architect, reviewing and designing scalable and efficient code
Check if the bios resource exists.
How would you explain what the following Python 3 function does def _check_bios_resource(self, properties=[]): system = self._get_host_details() if ('links' in system['Oem']['Hp'] and 'BIOS' in system['Oem']['Hp']['links']): # Get the BIOS URI and Settings bios_u...
You are a Python code generator, capable of creating scripts from specifications.
def _get_pci_devices(self): """Gets the PCI devices. :returns: PCI devices list if the pci resource exist. :raises: IloCommandNotSupportedError if the PCI resource doesn't exist. :raises: IloError, on an error from iLO. """ system = self._get_host_details() ...
Write a Python 3 function for getting the PCI devices list if the pci resource exist.
You are a Python code analyst, evaluating scripts for potential improvements.
def _get_gpu_pci_devices(self): """Returns the list of gpu devices.""" pci_device_list = self._get_pci_devices() gpu_list = [] items = pci_device_list['Items'] for item in items: if item['ClassCode'] in CLASSCODE_FOR_GPU_DEVICES: if item['SubclassCode...
Can you implement a function in Python 3 that returns the list of gpu devices.
You are a Python code generator, capable of creating scripts from specifications.
def _get_storage_resource(self): """Gets the SmartStorage resource if exists. :raises: IloCommandNotSupportedError if the resource SmartStorage doesn't exist. :returns the tuple of SmartStorage URI, Headers and settings. """ system = self._get_host_details() ...
Create a Python 3 function for getting the SmartStorage resource if exists.
As a Python code composer, you craft elegant and concise scripts.
def _get_array_controller_resource(self): """Gets the ArrayController resource if exists. :raises: IloCommandNotSupportedError if the resource ArrayController doesn't exist. :returns the tuple of SmartStorage URI, Headers and settings. """ headers, storage_uri, stora...
Write a Python 3 script for getting the ArrayController resource if exists.
As a Python code analyst, you investigate and solve complex coding mysteries
Creates the list of Array Controller URIs.
Explain what the following Python 3 code does def _create_list_of_array_controllers(self): headers, array_uri, array_settings = ( self._get_array_controller_resource()) array_uri_links = [] if ('links' in array_settings and 'Member' in array_settings['links']): ...
You are a Python code analyst, evaluating scripts for potential improvements.
def _get_drive_type_and_speed(self): """Gets the disk drive type. :returns: A dictionary with the following keys: - has_rotational: True/False. It is True if atleast one rotational disk is attached. - has_ssd: True/False. It is True if at least one SSD disk is ...
Write a Python 3 script to get the disk drive type and speed.
As a Python code analyst, you investigate and solve complex coding mysteries
Gets the DiskDrive resource if exists.
Can you tell what is the following Python 3 function doing def _get_drive_resource(self, drive_name): disk_details_list = [] array_uri_links = self._create_list_of_array_controllers() for array_link in array_uri_links: _, _, member_settings = ( self._rest_get(array_li...
You are a Python code generator, capable of creating scripts from specifications.
def _get_logical_raid_levels(self): """Gets the different raid levels configured on a server. :returns a dictionary of logical_raid_levels set to true. Example if raid level 1+0 and 6 are configured, it returns {'logical_raid_level_10': 'true', 'logical_raid_level_6...
Can you create a Python 3 function that gets the different raid levels configured on a server.
As a Python code composer, you craft elegant and concise scripts.
Get the RAID support on the physical server.
Can you generate the documentation for the following Python 3 function def _is_raid_supported(self): header, uri, array_resource = self._get_array_controller_resource() return True if array_resource['Total'] > 0 else False
You are a Python code generator, capable of creating scripts from specifications.
def _get_bios_settings_resource(self, data): """Get the BIOS settings resource.""" try: bios_settings_uri = data['links']['Settings']['href'] except KeyError: msg = ('BIOS Settings resource not found.') raise exception.IloError(msg) status, headers, b...
Write a Python 3 script to get the BIOS settings resource.
As a python code expert, you are capable of creating scripts from specifications.
def _validate_if_patch_supported(self, headers, uri): """Check if the PATCH Operation is allowed on the resource.""" if not self._operation_allowed(headers, 'PATCH'): msg = ('PATCH Operation not supported on the resource ' '"%s"' % uri) raise except...
How would you code a function in Python 3 to check if PATCH Operation is supported on the resource.
You are a Python code generator, capable of creating scripts from specifications.
def _get_bios_setting(self, bios_property): """Retrieves bios settings of the server.""" headers, bios_uri, bios_settings = self._check_bios_resource([ bios_property]) return bios_settings[bios_property]
Write a Python 3 script to retrieve the bios settings of the server.
As a python code expert, you are capable of creating scripts from specifications.
Get the hashed BIOS password.
How would you explain what the following Python 3 function does def _get_bios_hash_password(self, bios_password): request_headers = {} if bios_password: bios_password_hash = hashlib.sha256((bios_password.encode()). hexdigest().upper()) ...
As a python code expert, you are capable of creating scripts from specifications.
Change the bios settings to specified values.
Explain what the following Python 3 code does def _change_bios_setting(self, properties): keys = properties.keys() # Check if the BIOS resource/property exists. headers, bios_uri, settings = self._check_bios_resource(keys) if not self._operation_allowed(headers, 'PATCH'): hea...
As a Python code translator, you convert algorithms and pseudocode into Python.
Get the iscsi settings resource.
Can you generate a brief explanation for the following Python 3 code def _get_iscsi_settings_resource(self, data): try: iscsi_settings_uri = data['links']['Settings']['href'] except KeyError: msg = ('iscsi settings resource not found.') raise exception.IloCommandNotSu...
As a python code expert, you are capable of creating scripts from specifications.
def _get_bios_boot_resource(self, data): """Get the Boot resource like BootSources. :param data: Existing Bios settings of the server. :returns: boot settings. :raises: IloCommandNotSupportedError, if resource is not found. :raises: IloError, on an error from iLO. """ ...
Write a Python 3 script for getting the Boot resource like BootSources.
As a Python code analyst, you investigate and solve complex coding mysteries
def _get_bios_mappings_resource(self, data): """Get the Mappings resource. :param data: Existing Bios settings of the server. :returns: mappings settings. :raises: IloCommandNotSupportedError, if resource is not found. :raises: IloError, on an error from iLO. """ ...
How would you code a function in Python 3 to get the Mappings resource.
As a Python code translator, you convert algorithms and pseudocode into Python.
Checks if patch is supported on iscsi url.
How would you explain what the following Python 3 function does def _check_iscsi_rest_patch_allowed(self): headers, bios_uri, bios_settings = self._check_bios_resource() # Check if the bios resource exists. if('links' in bios_settings and 'iScsi' in bios_settings['links']): iscsi_u...
You are a Python code generator, capable of creating scripts from specifications.
def _change_iscsi_settings(self, iscsi_info): """Change iSCSI settings. :param iscsi_info: A dictionary that contains information of iSCSI target like target_name, lun, ip_address, port etc. :raises: IloError, on an error from iLO. """ headers, bios_ur...
Implement a Python 3 function for changing iSCSI settings. :param iscsi_info: A dictionary that contains information of iSCSI target like target_name, lun, ip_address, port etc. :raises: IloError, on an error from iLO.
You are a Python code architect, reviewing and designing scalable and efficient code
Change the secure boot settings on the server.
Here you have a function in Python 3, explain what it does def _change_secure_boot_settings(self, property, value): system = self._get_host_details() # find the BIOS URI if ('links' not in system['Oem']['Hp'] or 'SecureBoot' not in system['Oem']['Hp']['links']): msg = (' "...
You are a Python code generator, capable of creating scripts from specifications.
def get_secure_boot_mode(self): """Get the status of secure boot. :returns: True, if enabled, else False :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server. """ system = self._get_...
Write a Python 3 script for getting the status of secure boot.
You are a Python code generator, capable of creating scripts from specifications.
def set_secure_boot_mode(self, secure_boot_enable): """Enable/Disable secure boot on the server. :param secure_boot_enable: True, if secure boot needs to be enabled for next boot, else False. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, i...
Write a Python 3 function for enabling or disable secure boot on the server.
You are a Python code architect, reviewing and designing scalable and efficient code
Reset secure boot keys to manufacturing defaults.
Here you have a function in Python 3, explain what it does def reset_secure_boot_keys(self): if self._is_boot_mode_uefi(): self._change_secure_boot_settings('ResetToDefaultKeys', True) else: msg = ('System is not in UEFI boot mode. "SecureBoot" related ' 'resou...
You are a Python code architect, reviewing and designing scalable and efficient code
def clear_secure_boot_keys(self): """Reset all keys. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server. """ if self._is_boot_mode_uefi(): self._change_secure_boot_settings('Re...
Write a Python 3 function for resetting all keys. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
As a Python code translator, you convert algorithms and pseudocode into Python.
Perform requested power operation.
Given the following Python 3 function, write the documentation def _perform_power_op(self, oper): power_settings = {"Action": "Reset", "ResetType": oper} systems_uri = "/rest/v1/Systems/1" status, headers, response = self._rest_post(systems_uri, None, ...
You are a Python code analyst, evaluating scripts for potential improvements.
def _press_pwr_btn(self, pushType="Press"): """Simulates a physical press of the server power button. :param pushType: Type of power button press to simulate Supported values are: 'Press' and 'PressAndHold' :raises: IloError, on an error from iLO. """ po...
Implement a Python 3 function for simulating a physical press of the server power button.
As a Python code translator, you convert algorithms and pseudocode into Python.
This method retries power on operation.
Given the following Python 3 function, write the documentation def _retry_until_powered_on(self, power): # If the system is in the same power state as # requested by the user, it gives the error # InvalidOperationForSystemState. To avoid this error # the power state is checked before pow...
As a python code expert, you are capable of creating scripts from specifications.