code
string
signature
string
docstring
string
loss_without_docstring
float64
loss_with_docstring
float64
factor
float64
''' Creates a new file from str/unicode, or updates the content of an existing file, with automatic chunking and progress notifications. :param str share_name: Name of existing share. :param str directory_name: The path to the directory. :param str file_name: Name of file to create or update. :param str text: Text to upload to the file. :param str encoding: Python encoding to use to convert the text to bytes. :param ~azure.storage.file.models.ContentSettings content_settings: ContentSettings object used to set file properties. :param metadata: Name-value pairs associated with the file as metadata. :type metadata: a dict mapping str to str :param int timeout: The timeout parameter is expressed in seconds. This method may make multiple calls to the Azure service and the timeout will apply to each call individually. ''' _validate_not_none('share_name', share_name) _validate_not_none('file_name', file_name) _validate_not_none('text', text) if not isinstance(text, bytes): _validate_not_none('encoding', encoding) text = text.encode(encoding) self.create_file_from_bytes( share_name, directory_name, file_name, text, 0, len(text), content_settings, metadata, timeout)
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/unicode, or updates the content of an existing file, with automatic chunking and progress notifications. :param str share_name: Name of existing share. :param str directory_name: The path to the directory. :param str file_name: Name of file to create or update. :param str text: Text to upload to the file. :param str encoding: Python encoding to use to convert the text to bytes. :param ~azure.storage.file.models.ContentSettings content_settings: ContentSettings object used to set file properties. :param metadata: Name-value pairs associated with the file as metadata. :type metadata: a dict mapping str to str :param int timeout: The timeout parameter is expressed in seconds. This method may make multiple calls to the Azure service and the timeout will apply to each call individually.
1.797062
1.283494
1.400133
''' Downloads a file's content, metadata, and properties. You can specify a range if you don't need to download the file in its entirety. If no range is specified, the full file will be downloaded. See get_file_to_* for high level functions that handle the download of large files with automatic chunking and progress notifications. :param str share_name: Name of existing share. :param str directory_name: The path to the directory. :param str file_name: Name of existing file. :param int start_range: Start of byte range to use for downloading a section of the file. If no end_range is given, all bytes after the start_range will be downloaded. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param int end_range: End of byte range to use for downloading a section of the file. If end_range is given, start_range must be provided. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param bool range_get_content_md5: When this header is set to True and specified together with the Range header, the service returns the MD5 hash for the range, as long as the range is less than or equal to 4 MB in size. :param int timeout: The timeout parameter is expressed in seconds. :return: A File with content, properties, and metadata. :rtype: :class:`~azure.storage.file.models.File` ''' _validate_not_none('share_name', share_name) _validate_not_none('file_name', file_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = _get_path(share_name, directory_name, file_name) request.query = [('timeout', _int_to_str(timeout))] _validate_and_format_range_headers( request, start_range, end_range, start_range_required=False, end_range_required=False, check_content_md5=range_get_content_md5) response = self._perform_request(request, None) return _parse_file(file_name, response)
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 range if you don't need to download the file in its entirety. If no range is specified, the full file will be downloaded. See get_file_to_* for high level functions that handle the download of large files with automatic chunking and progress notifications. :param str share_name: Name of existing share. :param str directory_name: The path to the directory. :param str file_name: Name of existing file. :param int start_range: Start of byte range to use for downloading a section of the file. If no end_range is given, all bytes after the start_range will be downloaded. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param int end_range: End of byte range to use for downloading a section of the file. If end_range is given, start_range must be provided. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param bool range_get_content_md5: When this header is set to True and specified together with the Range header, the service returns the MD5 hash for the range, as long as the range is less than or equal to 4 MB in size. :param int timeout: The timeout parameter is expressed in seconds. :return: A File with content, properties, and metadata. :rtype: :class:`~azure.storage.file.models.File`
2.042279
1.257048
1.624663
''' Writes the bytes specified by the request body into the specified range. :param str share_name: Name of existing share. :param str directory_name: The path to the directory. :param str file_name: Name of existing file. :param bytes data: Content of the range. :param int start_range: Start of byte range to use for updating a section of the file. The range can be up to 4 MB in size. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param int end_range: End of byte range to use for updating a section of the file. The range can be up to 4 MB in size. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param str content_md5: An MD5 hash of the range content. This hash is used to verify the integrity of the range during transport. When this header is specified, the storage service compares the hash of the content that has arrived with the header value that was sent. If the two hashes do not match, the operation will fail with error code 400 (Bad Request). :param int timeout: The timeout parameter is expressed in seconds. ''' _validate_not_none('share_name', share_name) _validate_not_none('file_name', file_name) _validate_not_none('data', data) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = _get_path(share_name, directory_name, file_name) request.query = [ ('comp', 'range'), ('timeout', _int_to_str(timeout)), ] request.headers = [ ('Content-MD5', _to_str(content_md5)), ('x-ms-write', 'update'), ] _validate_and_format_range_headers( request, start_range, end_range) request.body = _get_request_body_bytes_only('data', data) self._perform_request(request)
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. :param str share_name: Name of existing share. :param str directory_name: The path to the directory. :param str file_name: Name of existing file. :param bytes data: Content of the range. :param int start_range: Start of byte range to use for updating a section of the file. The range can be up to 4 MB in size. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param int end_range: End of byte range to use for updating a section of the file. The range can be up to 4 MB in size. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param str content_md5: An MD5 hash of the range content. This hash is used to verify the integrity of the range during transport. When this header is specified, the storage service compares the hash of the content that has arrived with the header value that was sent. If the two hashes do not match, the operation will fail with error code 400 (Bad Request). :param int timeout: The timeout parameter is expressed in seconds.
1.766053
1.258483
1.403319
''' Clears the specified range and releases the space used in storage for that range. :param str share_name: Name of existing share. :param str directory_name: The path to the directory. :param str file_name: Name of existing file. :param int start_range: Start of byte range to use for clearing a section of the file. The range can be up to 4 MB in size. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param int end_range: End of byte range to use for clearing a section of the file. The range can be up to 4 MB in size. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param int timeout: The timeout parameter is expressed in seconds. ''' _validate_not_none('share_name', share_name) _validate_not_none('file_name', file_name) request = HTTPRequest() request.method = 'PUT' request.host = self._get_host() request.path = _get_path(share_name, directory_name, file_name) request.query = [ ('comp', 'range'), ('timeout', _int_to_str(timeout)), ] request.headers = [ ('Content-Length', '0'), ('x-ms-write', 'clear'), ] _validate_and_format_range_headers( request, start_range, end_range) self._perform_request(request)
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 share_name: Name of existing share. :param str directory_name: The path to the directory. :param str file_name: Name of existing file. :param int start_range: Start of byte range to use for clearing a section of the file. The range can be up to 4 MB in size. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param int end_range: End of byte range to use for clearing a section of the file. The range can be up to 4 MB in size. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param int timeout: The timeout parameter is expressed in seconds.
1.886963
1.323138
1.426127
''' Retrieves the valid ranges for a file. :param str share_name: Name of existing share. :param str directory_name: The path to the directory. :param str file_name: Name of existing file. :param int start_range: Specifies the start offset of bytes over which to list ranges. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param int end_range: Specifies the end offset of bytes over which to list ranges. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param int timeout: The timeout parameter is expressed in seconds. :returns: a list of valid ranges :rtype: a list of :class:`.FileRange` ''' _validate_not_none('share_name', share_name) _validate_not_none('file_name', file_name) request = HTTPRequest() request.method = 'GET' request.host = self._get_host() request.path = _get_path(share_name, directory_name, file_name) request.query = [ ('comp', 'rangelist'), ('timeout', _int_to_str(timeout)), ] if start_range is not None: _validate_and_format_range_headers( request, start_range, end_range, start_range_required=False, end_range_required=False) response = self._perform_request(request) return _convert_xml_to_ranges(response)
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 str directory_name: The path to the directory. :param str file_name: Name of existing file. :param int start_range: Specifies the start offset of bytes over which to list ranges. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param int end_range: Specifies the end offset of bytes over which to list ranges. The start_range and end_range params are inclusive. Ex: start_range=0, end_range=511 will download first 512 bytes of file. :param int timeout: The timeout parameter is expressed in seconds. :returns: a list of valid ranges :rtype: a list of :class:`.FileRange`
1.869016
1.355079
1.379268
system_url = parse.urljoin(self._sushy.get_system_collection_path(), system_id) try: return self._sushy.get_system(system_url) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish System "%(system)s" was not found. ' 'Error %(error)s') % {'system': system_id, 'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
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
2.834641
2.86172
0.990537
manager_url = parse.urljoin(self._sushy.get_manager_collection_path(), manager_id) try: return self._sushy.get_manager(manager_url) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish Manager "%(manager)s" was not found. ' 'Error %(error)s') % {'manager': manager_id, 'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
def _get_sushy_manager(self, manager_id)
Get the sushy Manager for manager_id :param manager_id: The identity of the Manager resource :returns: the Sushy Manager instance :raises: IloError
2.854153
3.02163
0.944574
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) return GET_POWER_STATE_MAP.get(sushy_system.power_state)
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.
6.212845
8.044019
0.772356
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: sushy_system.reset_system(sushy.RESET_FORCE_RESTART) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller failed to reset server. ' 'Error %(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
def reset_server(self)
Resets the server. :raises: IloError, on an error from iLO.
3.850578
3.955367
0.973507
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' % {'parameter': 'target_value', 'target_value': target_value, 'valid_power_values': POWER_RESET_MAP.keys()}) raise exception.InvalidInputError(msg) # Check current power status, do not act if it's in requested state. current_power_status = self.get_host_power_status() if current_power_status == target_value: LOG.debug(self._("Node is already in '%(target_value)s' power " "state."), {'target_value': target_value}) return sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: sushy_system.reset_system(POWER_RESET_MAP[target_value]) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller failed to set power state ' 'of server to %(target_value)s. Error %(error)s') % {'target_value': target_value, 'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
def set_host_power(self, target_value)
Sets the power state of the system. :param target_value: The target value to be set. Value can be: 'ON' or 'OFF'. :raises: IloError, on an error from iLO. :raises: InvalidInputError, if the target value is not allowed.
2.830373
2.738547
1.033531
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 = (self._('The Redfish controller failed to press power button' ' of server. Error %(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
def press_pwr_btn(self)
Simulates a physical press of the server power button. :raises: IloError, on an error from iLO.
4.401209
4.274069
1.029747
sushy_manager = self._get_sushy_manager(PROLIANT_MANAGER_ID) try: sushy_manager.set_license(key) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller failed to update ' 'the license. Error %(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
def activate_license(self, key)
Activates iLO license. :param key: iLO license key. :raises: IloError, on an error from iLO.
3.984719
4.159711
0.957932
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) if (sushy_system.boot.enabled == sushy.BOOT_SOURCE_ENABLED_ONCE): return DEVICE_REDFISH_TO_COMMON.get(sushy_system.boot.target) else: # value returned by RIBCL if one-time boot setting are absent return 'Normal'
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.
9.035016
8.005394
1.128616
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.exceptions.SushyError as e: msg = (self._('The pending BIOS Settings was not found. Error ' '%(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
def get_pending_boot_mode(self)
Retrieves the pending boot mode of the server. Gets the boot mode to be set on next reset. :returns: either LEGACY or UEFI. :raises: IloError, on an error from iLO.
3.632217
4.049939
0.896857
if device not in VIRTUAL_MEDIA_MAP: msg = (self._("Invalid device '%s'. Valid devices: FLOPPY or " "CDROM.") % device) LOG.debug(msg) raise exception.IloInvalidInputError(msg)
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.
5.031949
4.583974
1.097726
self._validate_virtual_media(device) manager = self._get_sushy_manager(PROLIANT_MANAGER_ID) try: vmedia_device = ( manager.virtual_media.get_member_device( VIRTUAL_MEDIA_MAP[device])) if not vmedia_device.inserted: LOG.debug(self._("No media available in the device '%s' to " "perform eject operation.") % device) return LOG.debug(self._("Ejecting the media image '%(url)s' from the " "device %(device)s.") % {'url': vmedia_device.image, 'device': device}) vmedia_device.eject_media() except sushy.exceptions.SushyError as e: msg = (self._("The Redfish controller failed to eject the virtual" " media device '%(device)s'. Error %(error)s.") % {'device': device, 'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
def eject_virtual_media(self, device)
Ejects the Virtual Media image if one is inserted. :param device: virual media device :raises: IloError, on an error from iLO. :raises: IloInvalidInputError, if the device is not valid.
3.59698
3.467607
1.037309
# CONNECT is a RIBCL call. There is no such property to set in Redfish. if boot_option == 'CONNECT': return self._validate_virtual_media(device) if boot_option not in BOOT_OPTION_MAP: msg = (self._("Virtual media boot option '%s' is invalid.") % boot_option) LOG.debug(msg) raise exception.IloInvalidInputError(msg) manager = self._get_sushy_manager(PROLIANT_MANAGER_ID) try: vmedia_device = ( manager.virtual_media.get_member_device( VIRTUAL_MEDIA_MAP[device])) vmedia_device.set_vm_status(BOOT_OPTION_MAP[boot_option]) except sushy.exceptions.SushyError as e: msg = (self._("The Redfish controller failed to set the virtual " "media status for '%(device)s'. Error %(error)s") % {'device': device, 'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
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. :param device: virual media device :param boot_option: boot option to set on the virtual media device :param write_protect: set the write protect flag on the vmedia device Note: It's ignored. In Redfish it is read-only. :raises: IloError, on an error from iLO. :raises: IloInvalidInputError, if the device is not valid.
3.728522
3.615821
1.031169
try: update_service_inst = self._sushy.get_update_service() update_service_inst.flash_firmware(self, file_url) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller failed to update firmware ' 'with firmware %(file)s Error %(error)s') % {'file': file_url, 'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
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 prior to this invocation. :param component_type: Type of component to be applied to. :raises: IloError, on an error from iLO.
4.026348
4.105222
0.980787
boot_mode = self.get_current_boot_mode() return (boot_mode == BOOT_MODE_MAP.get(sys_cons.BIOS_BOOT_MODE_UEFI))
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'
5.281909
5.928096
0.890996
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) # Return boot device if it is persistent. if ((sushy_system. boot.enabled) == sushy.BOOT_SOURCE_ENABLED_CONTINUOUS): return PERSISTENT_BOOT_MAP.get(sushy_system.boot.target) # Check if we are in BIOS boot mode. # There is no resource to fetch boot device order for BIOS boot mode if not self._is_boot_mode_uefi(): return None try: boot_device = (sushy_system.bios_settings.boot_settings. get_persistent_boot_device()) return PERSISTENT_BOOT_MAP.get(boot_device) except sushy.exceptions.SushyError as e: msg = (self._("The Redfish controller is unable to get " "persistent boot device. Error %(error)s") % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
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.
4.005468
4.222178
0.948674
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) if boot_mode.upper() not in BOOT_MODE_MAP_REV.keys(): msg = (('Invalid Boot mode: "%(boot_mode)s" specified, valid boot ' 'modes are either "uefi" or "legacy"') % {'boot_mode': boot_mode}) raise exception.IloInvalidInputError(msg) try: sushy_system.bios_settings.pending_settings.set_pending_boot_mode( BOOT_MODE_MAP_REV.get(boot_mode.upper())) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller failed to set ' 'pending boot mode to %(boot_mode)s. ' 'Error: %(error)s') % {'boot_mode': boot_mode, 'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
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.
2.805667
2.828449
0.991946
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: msg = (self._('Invalid input "%(device)s". Valid devices: ' 'NETWORK, HDD, ISCSI or CDROM.') % {'device': item}) raise exception.IloInvalidInputError(msg) try: sushy_system.update_persistent_boot( devices, persistent=True) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller failed to update ' 'persistent boot device %(devices)s.' 'Error: %(error)s') % {'devices': devices, 'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
def update_persistent_boot(self, devices=[])
Changes the persistent boot device order for the host :param devices: ordered list of boot devices :raises: IloError, on an error from iLO. :raises: IloInvalidInputError, if the given input is not valid.
3.805349
3.635852
1.046618
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: ' 'NETWORK, HDD, ISCSI or CDROM.') % {'device': device}) raise exception.IloInvalidInputError(msg) try: sushy_system.update_persistent_boot( [device], persistent=False) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller failed to set ' 'one time boot device %(device)s. ' 'Error: %(error)s') % {'device': device, 'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
def set_one_time_boot(self, device)
Configures a single boot from a specific device. :param device: Device to be set as a one time boot device :raises: IloError, on an error from iLO. :raises: IloInvalidInputError, if the given input is not valid.
3.903456
3.853003
1.013095
try: acc_service = self._sushy.get_account_service() member = acc_service.accounts.get_member_details(self._username) if member is None: msg = (self._("No account found with username: %s") % self._username) LOG.debug(msg) raise exception.IloError(msg) member.update_credentials(password) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller failed to update ' 'credentials for %(username)s. Error %(error)s') % {'username': self._username, 'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
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.
3.047457
3.1222
0.97606
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: msg = (self._('The Redfish controller failed to get the ' 'supported boot modes. Error: %s') % e) LOG.debug(msg) raise exception.IloError(msg)
def get_supported_boot_mode(self)
Get the system supported boot modes. :return: any one of the following proliantutils.ilo.constants: SUPPORTED_BOOT_MODE_LEGACY_BIOS_ONLY, SUPPORTED_BOOT_MODE_UEFI_ONLY, SUPPORTED_BOOT_MODE_LEGACY_BIOS_AND_UEFI :raises: IloError, if account not found or on an error from iLO.
3.432856
3.297512
1.041044
capabilities = {} sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) sushy_manager = self._get_sushy_manager(PROLIANT_MANAGER_ID) try: count = len(sushy_system.pci_devices.gpu_devices) boot_mode = rf_utils.get_supported_boot_mode( sushy_system.supported_boot_mode) capabilities.update( {'pci_gpu_devices': count, 'ilo_firmware_version': sushy_manager.firmware_version, 'rom_firmware_version': sushy_system.rom_version, 'server_model': sushy_system.model, 'nic_capacity': sushy_system.pci_devices.max_nic_capacity, 'boot_mode_bios': boot_mode.boot_mode_bios, 'boot_mode_uefi': boot_mode.boot_mode_uefi}) tpm_state = sushy_system.bios_settings.tpm_state all_key_to_value_expression_tuples = [ ('sriov_enabled', sushy_system.bios_settings.sriov == sys_cons.SRIOV_ENABLED), ('cpu_vt', sushy_system.bios_settings.cpu_vt == ( sys_cons.CPUVT_ENABLED)), ('trusted_boot', (tpm_state == sys_cons.TPM_PRESENT_ENABLED or tpm_state == sys_cons.TPM_PRESENT_DISABLED)), ('secure_boot', self._has_secure_boot()), ('iscsi_boot', (sushy_system.bios_settings.iscsi_resource. is_iscsi_boot_supported())), ('hardware_supports_raid', len(sushy_system.smart_storage.array_controllers. members_identities) > 0), ('has_ssd', common_storage.has_ssd(sushy_system)), ('has_rotational', common_storage.has_rotational(sushy_system)), ('has_nvme_ssd', common_storage.has_nvme_ssd(sushy_system)) ] all_key_to_value_expression_tuples += ( [('logical_raid_level_' + x, True) for x in sushy_system.smart_storage.logical_raid_levels]) all_key_to_value_expression_tuples += ( [('drive_rotational_' + str(x) + '_rpm', True) for x in common_storage.get_drive_rotational_speed_rpm(sushy_system)]) capabilities.update( {key: 'true' for (key, value) in all_key_to_value_expression_tuples if value}) memory_data = sushy_system.memory.details() if memory_data.has_nvdimm_n: capabilities.update( {'persistent_memory': ( json.dumps(memory_data.has_persistent_memory)), 'nvdimm_n': ( json.dumps(memory_data.has_nvdimm_n)), 'logical_nvdimm_n': ( json.dumps(memory_data.has_logical_nvdimm_n))}) except sushy.exceptions.SushyError as e: msg = (self._("The Redfish controller is unable to get " "resource or its members. Error " "%(error)s)") % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg) return capabilities
def get_server_capabilities(self)
Returns the server capabilities raises: IloError on an error from iLO.
3.25763
3.257789
0.999951
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 is unable to update bios " "settings to default Error %(error)s") % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
def reset_bios_to_default(self)
Resets the BIOS settings to default values. :raises: IloError, on an error from iLO.
3.675246
4.12507
0.890954
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 sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller failed to provide ' 'information about secure boot on the server. ' 'Error: %(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloCommandNotSupportedError(msg) if secure_boot_enabled: LOG.debug(self._("Secure boot is Enabled")) else: LOG.debug(self._("Secure boot is Disabled")) return secure_boot_enabled
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.
3.56591
3.515641
1.014299
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) except exception.InvalidInputError as e: msg = (self._('Invalid input. Error %(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller failed to set secure ' 'boot settings on the server. Error: %(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg) else: msg = (self._('System is not in UEFI boot mode. "SecureBoot" ' 'related resources cannot be changed.')) raise exception.IloCommandNotSupportedInBiosError(msg)
def set_secure_boot_mode(self, secure_boot_enable)
Enable/Disable secure boot on the server. Resetting the server post updating this settings is needed from the caller side to make this into effect. :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, if the command is not supported on the server.
2.931931
2.953728
0.99262
if self._is_boot_mode_uefi(): sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: sushy_system.secure_boot.reset_keys( sys_cons.SECUREBOOT_RESET_KEYS_DEFAULT) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller failed to reset secure ' 'boot keys on the server. Error %(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg) else: msg = (self._('System is not in UEFI boot mode. "SecureBoot" ' 'related resources cannot be changed.')) raise exception.IloCommandNotSupportedInBiosError(msg)
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.
3.968206
3.866159
1.026395
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: # TODO(nisha): Add local_gb here and return after # local_gb changes are merged. # local_gb = sushy_system.storage_summary prop = {'memory_mb': (sushy_system.memory_summary.size_gib * 1024), 'cpus': sushy_system.processors.summary.count, 'cpu_arch': sushy_map.PROCESSOR_ARCH_VALUE_MAP_REV.get( sushy_system.processors.summary.architecture), 'local_gb': common_storage.get_local_gb(sushy_system)} return {'properties': prop, 'macs': sushy_system.ethernet_interfaces.summary} except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller failed to get the ' 'resource data. Error %(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
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.
4.433552
4.074937
1.088005
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: pci_settings_map = ( sushy_system.bios_settings.bios_mappings.pci_settings_mappings) nics = [] for mapping in pci_settings_map: for subinstance in mapping['Subinstances']: for association in subinstance['Associations']: if 'NicBoot' in association: nics.append(association) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller failed to get the ' 'bios mappings. Error %(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg) if not nics: msg = ('No nics were found on the system') raise exception.IloError(msg) # Set iSCSI info to all nics iscsi_infos = [] for nic in nics: data = iscsi_info.copy() data['iSCSIAttemptName'] = nic data['iSCSINicSource'] = nic data['iSCSIAttemptInstance'] = nics.index(nic) + 1 iscsi_infos.append(data) iscsi_data = {'iSCSISources': iscsi_infos} try: (sushy_system.bios_settings.iscsi_resource. iscsi_settings.update_iscsi_settings(iscsi_data)) except sushy.exceptions.SushyError as e: msg = (self._("The Redfish controller is failed to update iSCSI " "settings. Error %(error)s") % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
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.
3.202009
3.282303
0.975538
if(self._is_boot_mode_uefi()): iscsi_info = {} iscsi_info['iSCSITargetName'] = target_name iscsi_info['iSCSILUN'] = lun iscsi_info['iSCSITargetIpAddress'] = ip_address iscsi_info['iSCSITargetTcpPort'] = int(port) iscsi_info['iSCSITargetInfoViaDHCP'] = False iscsi_info['iSCSIConnection'] = 'Enabled' if (auth_method == 'CHAP'): iscsi_info['iSCSIAuthenticationMethod'] = 'Chap' iscsi_info['iSCSIChapUsername'] = username iscsi_info['iSCSIChapSecret'] = password self._change_iscsi_target_settings(iscsi_info) else: msg = 'iSCSI boot is not supported in the BIOS boot mode' raise exception.IloCommandNotSupportedInBiosError(msg)
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 etc. :param target_name: Target Name for iSCSI. :param lun: logical unit number. :param ip_address: IP address of the target. :param port: port of the target. :param auth_method : either None or CHAP. :param username: CHAP Username for authentication. :param password: CHAP secret. :raises: IloCommandNotSupportedInBiosError, if the system is in the bios boot mode.
2.699387
2.298829
1.174244
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 boot mode' raise exception.IloCommandNotSupportedInBiosError(msg)
def unset_iscsi_info(self)
Disable iSCSI boot option in UEFI boot mode. :raises: IloCommandNotSupportedInBiosError, if the system is in the BIOS boot mode.
6.68436
3.8332
1.743807
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) if(self._is_boot_mode_uefi()): iscsi_data = {'iSCSIInitiatorName': initiator_iqn} try: (sushy_system.bios_settings.iscsi_resource. iscsi_settings.update_iscsi_settings(iscsi_data)) except sushy.exceptions.SushyError as e: msg = (self._("The Redfish controller has failed to update " "iSCSI settings. Error %(error)s") % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg) else: msg = 'iSCSI initiator cannot be updated in BIOS boot mode' raise exception.IloCommandNotSupportedInBiosError(msg)
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.
3.879762
3.552923
1.091992
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) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller has failed to get the ' 'iSCSI initiator. Error %(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg) return iscsi_initiator else: msg = 'iSCSI initiator cannot be retrieved in BIOS boot mode' raise exception.IloCommandNotSupportedInBiosError(msg)
def get_iscsi_initiator_info(self)
Give iSCSI initiator information of iLO. :returns: iSCSI initiator information. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedInBiosError, if the system is in the BIOS boot mode.
3.817157
3.48157
1.096389
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) if sushy_system.power_state != sushy.SYSTEM_POWER_STATE_ON: raise exception.IloError("Server is not in powered on state.") try: sushy_system.reset_system(sushy.RESET_NMI) except sushy.exceptions.SushyError as e: msg = (self._('The Redfish controller failed to inject nmi to ' 'server. Error %(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
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
3.385181
3.655831
0.925968
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) return GET_POST_STATE_MAP.get(sushy_system.post_state)
def get_host_post_state(self)
Get the current state of system POST. Retrieves current state of system POST. :returns: POST state of the server. The valida states are:- null, Unknown, Reset, PowerOff, InPost, InPostDiscoveryComplete and FinishedPost. :raises: IloError, on an error from iLO
6.793413
8.476152
0.801474
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) return sushy_system.read_raid(raid_config=raid_config)
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 stucture should be as follows: raid_config = {'logical_disks': [{'raid_level': 1, 'size_gb': 100, 'physical_disks': ['6I:1:5'], 'controller': 'HPE Smart Array P408i-a SR Gen10'}, <info-for-logical-disk-2>]} :raises: IloError, on an error from iLO. :returns: A dictionary containing list of logical disks
5.98567
8.130632
0.736187
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: current_settings = sushy_system.bios_settings.json except sushy.exceptions.SushyError as e: msg = (self._('The current BIOS Settings were not found. Error ' '%(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg) attributes = current_settings.get("Attributes") if only_allowed_settings and attributes: return common_utils.apply_bios_properties_filter( attributes, ilo_cons.SUPPORTED_REDFISH_BIOS_PROPERTIES) return attributes
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 dictionary of current BIOS settings is returned. Depending on the 'only_allowed_settings', either only the allowed settings are returned or all the supported settings are returned. :raises: IloError, on an error from iLO
3.936831
4.341506
0.906789
if not data: raise exception.IloError("Could not apply settings with" " empty data") sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) if only_allowed_settings: unsupported_settings = [key for key in data if key not in ( ilo_cons.SUPPORTED_REDFISH_BIOS_PROPERTIES)] if unsupported_settings: msg = ("Could not apply settings as one or more settings are" " not supported. Unsupported settings are %s." " Supported settings are %s." % ( unsupported_settings, ilo_cons.SUPPORTED_REDFISH_BIOS_PROPERTIES)) raise exception.IloError(msg) try: settings_required = sushy_system.bios_settings.pending_settings settings_required.update_bios_data_by_patch(data) except sushy.exceptions.SushyError as e: msg = (self._('The pending BIOS Settings resource not found.' ' Error %(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg)
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 'data' are set. :param: data: a dictionary of BIOS settings to be applied. Depending on the 'only_allowed_settings', either only the allowed settings are set or all the supported settings that are in the 'data' are set. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
3.76507
3.847443
0.97859
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: settings = sushy_system.bios_settings.default_settings except sushy.exceptions.SushyError as e: msg = (self._('The default BIOS Settings were not found. Error ' '%(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg) if only_allowed_settings: return common_utils.apply_bios_properties_filter( settings, ilo_cons.SUPPORTED_REDFISH_BIOS_PROPERTIES) return settings
def get_default_bios_settings(self, only_allowed_settings=True)
Get default 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 dictionary of default BIOS settings(factory settings). Depending on the 'only_allowed_settings', either only the allowed settings are returned or all the supported settings are returned. :raises: IloError, on an error from iLO.
3.665521
3.91347
0.936642
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) sushy_system.create_raid(raid_config)
def create_raid_configuration(self, raid_config)
Create the raid configuration on the hardware. Based on user raid_config input, it will create raid :param raid_config: A dictionary containing target raid configuration data. This data stucture should be as follows: raid_config = {'logical_disks': [{'raid_level': 1, 'size_gb': 100, 'physical_disks': ['6I:1:5'], 'controller': 'HPE Smart Array P408i-a SR Gen10'}, <info-for-logical-disk-2>]} :raises: IloError, on an error from iLO.
6.205037
7.681047
0.807837
sushy_system = self._get_sushy_system(PROLIANT_SYSTEM_ID) try: settings_result = sushy_system.bios_settings.messages except sushy.exceptions.SushyError as e: msg = (self._('The BIOS Settings results were not found. Error ' '%(error)s') % {'error': str(e)}) LOG.debug(msg) raise exception.IloError(msg) status = "failed" if len(settings_result) > 1 else "success" return {"status": status, "results": settings_result}
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.
3.716605
3.942254
0.942762
# get the collection status, headers, thecollection = self._rest_get(collection_uri) if status != 200: msg = self._get_extended_error(thecollection) raise exception.IloError(msg) while status < 300: # verify expected type # Don't limit to version 0 here as we will rev to 1.0 at some # point hopefully with minimal changes ctype = self._get_type(thecollection) if (ctype not in ['Collection.0', 'Collection.1']): raise exception.IloError("collection not found") # if this collection has inline items, return those # NOTE: Collections are very flexible in how the represent # members. They can be inline in the collection as members # of the 'Items' array, or they may be href links in the # links/Members array. The could actually be both. Typically, # iLO implements the inline (Items) for only when the collection # is read only. We have to render it with the href links when an # array contains PATCHable items because its complex to PATCH # inline collection members. if 'Items' in thecollection: # iterate items for item in thecollection['Items']: # if the item has a self uri pointer, # supply that for convenience. memberuri = None if 'links' in item and 'self' in item['links']: memberuri = item['links']['self']['href'] yield 200, None, item, memberuri # else walk the member links elif ('links' in thecollection and 'Member' in thecollection['links']): # iterate members for memberuri in thecollection['links']['Member']: # for each member return the resource indicated by the # member link status, headers, member = self._rest_get(memberuri['href']) yield status, headers, member, memberuri['href'] # page forward if there are more pages in the collection if ('links' in thecollection and 'NextPage' in thecollection['links']): next_link_uri = (collection_uri + '?page=' + str( thecollection['links']['NextPage']['page'])) status, headers, thecollection = self._rest_get(next_link_uri) # else we are finished iterating the collection else: break
def _get_collection(self, collection_uri, request_headers=None)
Generator function that returns collection members.
6.075492
5.983068
1.015448
typever = obj['Type'] typesplit = typever.split('.') return typesplit[0] + '.' + typesplit[1]
def _get_type(self, obj)
Return the type of an object.
7.475933
6.380002
1.171776
messages = [] if isinstance(extended_error, dict): if ('Type' in extended_error and extended_error['Type'].startswith('ExtendedError.')): for msg in extended_error['Messages']: message_id = msg['MessageID'] x = message_id.split('.') registry = x[0] msgkey = x[len(x) - 1] # if the correct message registry is loaded, # do string resolution if (registry in self.message_registries and msgkey in self.message_registries[registry]['Messages']): rmsgs = self.message_registries[registry]['Messages'] msg_dict = rmsgs[msgkey] msg_str = message_id + ': ' + msg_dict['Message'] for argn in range(0, msg_dict['NumberOfArgs']): subst = '%' + str(argn+1) m = str(msg['MessageArgs'][argn]) msg_str = msg_str.replace(subst, m) if ('Resolution' in msg_dict and msg_dict['Resolution'] != 'None'): msg_str += ' ' + msg_dict['Resolution'] messages.append(msg_str) else: # no message registry, simply return the msg object # in string form messages.append(str(message_id)) return messages
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 function knows how to parse the ExtendedError object and, using any loaded message registries, render an array of plain language strings that represent the response.
3.55651
3.204364
1.109896
# 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(system) if stype not in ['ComputerSystem.0', 'ComputerSystem.1']: msg = "%s is not a valid system type " % stype raise exception.IloError(msg) else: msg = self._get_extended_error(system) raise exception.IloError(msg) return system
def _get_host_details(self)
Get the system details.
5.103335
4.532891
1.125846
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_uri = system['Oem']['Hp']['links']['BIOS']['href'] status, headers, bios_settings = self._rest_get(bios_uri) if status >= 300: msg = self._get_extended_error(bios_settings) raise exception.IloError(msg) # If property is not None, check if the bios_property is supported for property in properties: if property not in bios_settings: # not supported on this platform msg = ('BIOS Property "' + property + '" is not' ' supported on this system.') raise exception.IloCommandNotSupportedError(msg) return headers, bios_uri, bios_settings else: msg = ('"links/BIOS" section in ComputerSystem/Oem/Hp' ' does not exist') raise exception.IloCommandNotSupportedError(msg)
def _check_bios_resource(self, properties=[])
Check if the bios resource exists.
3.669769
3.531047
1.039286
system = self._get_host_details() if ('links' in system['Oem']['Hp'] and 'PCIDevices' in system['Oem']['Hp']['links']): # Get the PCI URI and Settings pci_uri = system['Oem']['Hp']['links']['PCIDevices']['href'] status, headers, pci_device_list = self._rest_get(pci_uri) if status >= 300: msg = self._get_extended_error(pci_device_list) raise exception.IloError(msg) return pci_device_list else: msg = ('links/PCIDevices section in ComputerSystem/Oem/Hp' ' does not exist') raise exception.IloCommandNotSupportedError(msg)
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.
4.148505
3.619004
1.146311
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'] in SUBCLASSCODE_FOR_GPU_DEVICES: gpu_list.append(item) return gpu_list
def _get_gpu_pci_devices(self)
Returns the list of gpu devices.
3.395248
3.108588
1.092216
system = self._get_host_details() if ('links' in system['Oem']['Hp'] and 'SmartStorage' in system['Oem']['Hp']['links']): # Get the SmartStorage URI and Settings storage_uri = system['Oem']['Hp']['links']['SmartStorage']['href'] status, headers, storage_settings = self._rest_get(storage_uri) if status >= 300: msg = self._get_extended_error(storage_settings) raise exception.IloError(msg) return headers, storage_uri, storage_settings else: msg = ('"links/SmartStorage" section in ComputerSystem/Oem/Hp' ' does not exist') raise exception.IloCommandNotSupportedError(msg)
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.
4.169231
3.316579
1.257088
headers, storage_uri, storage_settings = self._get_storage_resource() if ('links' in storage_settings and 'ArrayControllers' in storage_settings['links']): # Get the ArrayCOntrollers URI and Settings array_uri = storage_settings['links']['ArrayControllers']['href'] status, headers, array_settings = self._rest_get(array_uri) if status >= 300: msg = self._get_extended_error(array_settings) raise exception.IloError(msg) return headers, array_uri, array_settings else: msg = ('"links/ArrayControllers" section in SmartStorage' ' does not exist') raise exception.IloCommandNotSupportedError(msg)
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.
4.502372
3.522721
1.278095
headers, array_uri, array_settings = ( self._get_array_controller_resource()) array_uri_links = [] if ('links' in array_settings and 'Member' in array_settings['links']): array_uri_links = array_settings['links']['Member'] else: msg = ('"links/Member" section in ArrayControllers' ' does not exist') raise exception.IloCommandNotSupportedError(msg) return array_uri_links
def _create_list_of_array_controllers(self)
Creates the list of Array Controller URIs. :raises: IloCommandNotSupportedError if the ArrayControllers doesnt have member "Member". :returns list of ArrayControllers.
5.493752
4.134702
1.328694
disk_details = self._get_physical_drive_resource() drive_hdd = False drive_ssd = False drive_details = {} speed_const_list = [4800, 5400, 7200, 10000, 15000] if disk_details: for item in disk_details: value = item['MediaType'] if value == "HDD": drive_hdd = True speed = item['RotationalSpeedRpm'] if speed in speed_const_list: var = 'rotational_drive_' + str(speed) + '_rpm' drive_details.update({var: 'true'}) # Note: RIS returns value as 'SDD' for SSD drives. else: drive_ssd = True if drive_hdd: drive_details.update({'has_rotational': 'true'}) if drive_ssd: drive_details.update({'has_ssd': 'true'}) return drive_details if len(drive_details.keys()) > 0 else None
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 attached. - drive_rotational_<speed>_rpm: These are set to true as per the speed of the rotational disks. :raises: IloCommandNotSupportedError if the PhysicalDrives resource doesn't exist. :raises: IloError, on an error from iLO.
3.668811
3.284995
1.116839
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_link['href'])) if ('links' in member_settings and drive_name in member_settings['links']): disk_uri = member_settings['links'][drive_name]['href'] headers, disk_member_uri, disk_mem = ( self._rest_get(disk_uri)) if ('links' in disk_mem and 'Member' in disk_mem['links']): for disk_link in disk_mem['links']['Member']: diskdrive_uri = disk_link['href'] _, _, disk_details = ( self._rest_get(diskdrive_uri)) disk_details_list.append(disk_details) else: msg = ('"links/Member" section in %s' ' does not exist', drive_name) raise exception.IloCommandNotSupportedError(msg) else: msg = ('"links/%s" section in ' ' ArrayController/links/Member does not exist', drive_name) raise exception.IloCommandNotSupportedError(msg) if disk_details_list: return disk_details_list
def _get_drive_resource(self, drive_name)
Gets the DiskDrive resource if exists. :param drive_name: can be either "PhysicalDrives" or "LogicalDrives". :returns the list of drives. :raises: IloCommandNotSupportedError if the given drive resource doesn't exist. :raises: IloError, on an error from iLO.
3.342025
3.219577
1.038032
logical_drive_details = self._get_logical_drive_resource() raid_level = {} if logical_drive_details: for item in logical_drive_details: if 'Raid' in item: raid_level_var = "logical_raid_level_" + item['Raid'] raid_level.update({raid_level_var: 'true'}) return raid_level if len(raid_level.keys()) > 0 else None
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': 'true'}
3.494774
3.116079
1.121529
header, uri, array_resource = self._get_array_controller_resource() return True if array_resource['Total'] > 0 else False
def _is_raid_supported(self)
Get the RAID support on the server. This method returns the raid support on the physical server. It checks for the list of array controllers configured to the Smart Storage. If one or more array controllers available then raid is supported by the server. If none, raid is not supported. :return: Raid support as a dictionary with true/false as its value.
22.383488
15.84683
1.41249
try: bios_settings_uri = data['links']['Settings']['href'] except KeyError: msg = ('BIOS Settings resource not found.') raise exception.IloError(msg) status, headers, bios_settings = self._rest_get(bios_settings_uri) if status != 200: msg = self._get_extended_error(bios_settings) raise exception.IloError(msg) return headers, bios_settings_uri, bios_settings
def _get_bios_settings_resource(self, data)
Get the BIOS settings resource.
2.647283
2.550709
1.037862
if not self._operation_allowed(headers, 'PATCH'): msg = ('PATCH Operation not supported on the resource ' '"%s"' % uri) raise exception.IloError(msg)
def _validate_if_patch_supported(self, headers, uri)
Check if the PATCH Operation is allowed on the resource.
6.95356
4.912628
1.415446
headers, bios_uri, bios_settings = self._check_bios_resource([ bios_property]) return bios_settings[bios_property]
def _get_bios_setting(self, bios_property)
Retrieves bios settings of the server.
7.63704
6.643324
1.149581
request_headers = {} if bios_password: bios_password_hash = hashlib.sha256((bios_password.encode()). hexdigest().upper()) request_headers['X-HPRESTFULAPI-AuthToken'] = bios_password_hash return request_headers
def _get_bios_hash_password(self, bios_password)
Get the hashed BIOS password.
5.315094
5.103038
1.041555
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'): headers, bios_uri, _ = self._get_bios_settings_resource(settings) self._validate_if_patch_supported(headers, bios_uri) request_headers = self._get_bios_hash_password(self.bios_password) status, headers, response = self._rest_patch(bios_uri, request_headers, properties) if status >= 300: msg = self._get_extended_error(response) raise exception.IloError(msg)
def _change_bios_setting(self, properties)
Change the bios settings to specified values.
4.585641
4.581859
1.000826
try: iscsi_settings_uri = data['links']['Settings']['href'] except KeyError: msg = ('iscsi settings resource not found.') raise exception.IloCommandNotSupportedError(msg) status, headers, iscsi_settings = self._rest_get(iscsi_settings_uri) if status != 200: msg = self._get_extended_error(iscsi_settings) raise exception.IloError(msg) return headers, iscsi_settings_uri, iscsi_settings
def _get_iscsi_settings_resource(self, data)
Get the iscsi settings resoure. :param data: Existing iscsi settings of the server. :returns: headers, iscsi_settings url and iscsi settings as a dictionary. :raises: IloCommandNotSupportedError, if resource is not found. :raises: IloError, on an error from iLO.
3.038905
2.552942
1.190354
try: boot_uri = data['links']['Boot']['href'] except KeyError: msg = ('Boot resource not found.') raise exception.IloCommandNotSupportedError(msg) status, headers, boot_settings = self._rest_get(boot_uri) if status != 200: msg = self._get_extended_error(boot_settings) raise exception.IloError(msg) return boot_settings
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.
3.302301
2.932382
1.12615
try: map_uri = data['links']['Mappings']['href'] except KeyError: msg = ('Mappings resource not found.') raise exception.IloCommandNotSupportedError(msg) status, headers, map_settings = self._rest_get(map_uri) if status != 200: msg = self._get_extended_error(map_settings) raise exception.IloError(msg) return map_settings
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.
3.498312
3.191633
1.096088
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_uri = bios_settings['links']['iScsi']['href'] status, headers, settings = self._rest_get(iscsi_uri) if status != 200: msg = self._get_extended_error(settings) raise exception.IloError(msg) if not self._operation_allowed(headers, 'PATCH'): headers, iscsi_uri, settings = ( self._get_iscsi_settings_resource(settings)) self._validate_if_patch_supported(headers, iscsi_uri) return iscsi_uri else: msg = ('"links/iScsi" section in bios' ' does not exist') raise exception.IloCommandNotSupportedError(msg)
def _check_iscsi_rest_patch_allowed(self)
Checks if patch is supported on iscsi. :returns: iscsi url. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
4.088969
3.776306
1.082796
headers, bios_uri, bios_settings = self._check_bios_resource() # Get the Mappings resource. map_settings = self._get_bios_mappings_resource(bios_settings) nics = [] for mapping in map_settings['BiosPciSettingsMappings']: for subinstance in mapping['Subinstances']: for association in subinstance['Associations']: if 'NicBoot' in association: nics.append(association) if not nics: msg = ('No nics found') raise exception.IloError(msg) iscsi_uri = self._check_iscsi_rest_patch_allowed() # Set iSCSI info to all nics iscsi_infos = [] for nic in nics: data = iscsi_info.copy() data['iSCSIBootAttemptName'] = nic data['iSCSINicSource'] = nic data['iSCSIBootAttemptInstance'] = nics.index(nic) + 1 iscsi_infos.append(data) patch_data = {'iSCSIBootSources': iscsi_infos} status, headers, response = self._rest_patch(iscsi_uri, None, patch_data) if status >= 300: msg = self._get_extended_error(response) raise exception.IloError(msg)
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.
4.462662
4.467367
0.998947
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 = (' "SecureBoot" resource or feature is not ' 'supported on this system') raise exception.IloCommandNotSupportedError(msg) secure_boot_uri = system['Oem']['Hp']['links']['SecureBoot']['href'] # Change the property required new_secure_boot_settings = {} new_secure_boot_settings[property] = value # perform the patch status, headers, response = self._rest_patch( secure_boot_uri, None, new_secure_boot_settings) if status >= 300: msg = self._get_extended_error(response) raise exception.IloError(msg) # Change the bios setting as a workaround to enable secure boot # Can be removed when fixed for Gen9 snap2 val = self._get_bios_setting('CustomPostMessage') val = val.rstrip() if val.endswith(" ") else val+" " self._change_bios_setting({'CustomPostMessage': val})
def _change_secure_boot_settings(self, property, value)
Change secure boot settings on the server.
4.806203
4.823313
0.996453
system = self._get_host_details() if ('links' not in system['Oem']['Hp'] or 'SecureBoot' not in system['Oem']['Hp']['links']): msg = ('"SecureBoot" resource or feature is not supported' ' on this system') raise exception.IloCommandNotSupportedError(msg) secure_boot_uri = system['Oem']['Hp']['links']['SecureBoot']['href'] # get the Secure Boot object status, headers, secure_boot_settings = self._rest_get(secure_boot_uri) if status >= 300: msg = self._get_extended_error(secure_boot_settings) raise exception.IloError(msg) return secure_boot_settings['SecureBootCurrentState']
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.
3.589053
3.543061
1.012981
if self._is_boot_mode_uefi(): self._change_secure_boot_settings('SecureBootEnable', secure_boot_enable) else: msg = ('System is not in UEFI boot mode. "SecureBoot" related ' 'resources cannot be changed.') raise exception.IloCommandNotSupportedInBiosError(msg)
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, if the command is not supported on the server.
5.497412
5.445305
1.009569
if self._is_boot_mode_uefi(): self._change_secure_boot_settings('ResetToDefaultKeys', True) else: msg = ('System is not in UEFI boot mode. "SecureBoot" related ' 'resources cannot be changed.') raise exception.IloCommandNotSupportedInBiosError(msg)
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.
7.016954
6.808877
1.03056
if self._is_boot_mode_uefi(): self._change_secure_boot_settings('ResetAllKeys', True) else: msg = ('System is not in UEFI boot mode. "SecureBoot" related ' 'resources cannot be changed.') raise exception.IloCommandNotSupportedInBiosError(msg)
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.
7.154692
6.08202
1.176368
power_settings = {"Action": "Reset", "ResetType": oper} systems_uri = "/rest/v1/Systems/1" status, headers, response = self._rest_post(systems_uri, None, power_settings) if status >= 300: msg = self._get_extended_error(response) raise exception.IloError(msg)
def _perform_power_op(self, oper)
Perform requested power operation. :param oper: Type of power button press to simulate. Supported values: 'ON', 'ForceOff', 'ForceRestart' and 'Nmi' :raises: IloError, on an error from iLO.
6.212956
4.898502
1.268338
power_settings = {"Action": "PowerButton", "Target": "/Oem/Hp", "PushType": pushType} systems_uri = "/rest/v1/Systems/1" status, headers, response = self._rest_post(systems_uri, None, power_settings) if status >= 300: msg = self._get_extended_error(response) raise exception.IloError(msg)
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.
5.370684
5.362178
1.001586
# 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 power on # operation is performed. status = self.get_host_power_status() if (status != power): self._perform_power_op(POWER_STATE[power]) return self.get_host_power_status() else: return status
def _retry_until_powered_on(self, power)
This method retries power on operation. :param: power : target power state
7.118352
7.111929
1.000903
power = power.upper() if (power is not None) and (power not in POWER_STATE): msg = ("Invalid input '%(pow)s'. " "The expected input is ON or OFF." % {'pow': power}) raise exception.IloInvalidInputError(msg) # Check current power status, do not act if it's in requested state. cur_status = self.get_host_power_status() if cur_status == power: LOG.debug(self._("Node is already in '%(power)s' power state."), {'power': power}) return if power == 'ON' and 'PROLIANT BL' in self.get_product_name().upper(): self._retry_until_powered_on(power) else: self._perform_power_op(POWER_STATE[power])
def set_host_power(self, power)
Toggle the power button of server. :param power: 'ON' or 'OFF' :raises: IloError, on an error from iLO.
5.114871
5.040884
1.014677
if(self._is_boot_mode_uefi() is True): return self._get_bios_setting('UefiShellStartupUrl') else: msg = 'get_http_boot_url is not supported in the BIOS boot mode' raise exception.IloCommandNotSupportedInBiosError(msg)
def get_http_boot_url(self)
Request the http boot url from system in uefi boot mode. :returns: URL for http boot :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedInBiosError, if the system is in the bios boot mode.
5.529378
3.893018
1.420332
if(self._is_boot_mode_uefi() is True): self._change_bios_setting({'UefiShellStartupUrl': url}) else: msg = 'set_http_boot_url is not supported in the BIOS boot mode' raise exception.IloCommandNotSupportedInBiosError(msg)
def set_http_boot_url(self, url)
Set url to the UefiShellStartupUrl to the system in uefi boot mode. :param url: URL for http boot :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedInBiosError, if the system is in the bios boot mode.
5.229317
3.235404
1.616279
if(self._is_boot_mode_uefi() is True): iscsi_info = {'iSCSIBootEnable': 'Disabled'} self._change_iscsi_settings(iscsi_info) else: msg = 'iSCSI boot is not supported in the BIOS boot mode' raise exception.IloCommandNotSupportedInBiosError(msg)
def unset_iscsi_info(self)
Disable iSCSI boot option in UEFI boot mode. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedInBiosError, if the system is in the BIOS boot mode.
6.034769
3.557401
1.696398
headers, bios_uri, bios_settings = self._check_bios_resource() if('links' in bios_settings and 'iScsi' in bios_settings['links']): iscsi_uri = bios_settings['links']['iScsi']['href'] status, headers, iscsi_settings = self._rest_get(iscsi_uri) if status != 200: msg = self._get_extended_error(iscsi_settings) raise exception.IloError(msg) return iscsi_settings['iSCSIInitiatorName'] else: msg = ('"links/iScsi" section in bios ' 'does not exist') raise exception.IloCommandNotSupportedError(msg)
def get_iscsi_initiator_info(self)
Give iSCSI initiator information of iLO. :returns: iSCSI initiator information. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the system is in the bios boot mode.
3.68455
3.443916
1.069872
if(self._is_boot_mode_uefi() is True): iscsi_uri = self._check_iscsi_rest_patch_allowed() initiator_info = {'iSCSIInitiatorName': initiator_iqn} status, headers, response = self._rest_patch(iscsi_uri, None, initiator_info) if status >= 300: msg = self._get_extended_error(response) raise exception.IloError(msg) else: msg = 'iSCSI initiator cannot be set in the BIOS boot mode' raise exception.IloCommandNotSupportedError(msg)
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: IloCommandNotSupportedError, if the system is in the bios boot mode.
4.243389
3.682103
1.152436
headers, uri, bios_settings = self._check_bios_resource(['BootMode']) _, _, settings = self._get_bios_settings_resource(bios_settings) boot_mode = settings.get('BootMode') if boot_mode == 'LegacyBios': boot_mode = 'legacy' return boot_mode.upper()
def get_pending_boot_mode(self)
Retrieves the pending boot mode of the server. Gets the boot mode to be set on next reset. :returns: either LEGACY or UEFI. :raises: IloError, on an error from iLO.
5.293147
5.911926
0.895334
boot_mode = boot_mode.lower() if boot_mode not in ['uefi', 'legacy']: msg = 'Invalid Boot mode specified' raise exception.IloInvalidInputError(msg) boot_properties = {'BootMode': boot_mode} if boot_mode == 'legacy': boot_properties['BootMode'] = 'LegacyBios' else: # If Boot Mode is 'Uefi' set the UEFIOptimizedBoot first. boot_properties['UefiOptimizedBoot'] = "Enabled" # Change the Boot Mode self._change_bios_setting(boot_properties)
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. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
3.736605
3.750071
0.996409
system = self._get_host_details() bios_uefi_class_val = 0 # value for bios_only boot mode if ('Bios' in system['Oem']['Hp'] and 'UefiClass' in system['Oem']['Hp']['Bios']): bios_uefi_class_val = (system['Oem']['Hp'] ['Bios']['UefiClass']) return mappings.GET_SUPPORTED_BOOT_MODE_RIS_MAP.get( bios_uefi_class_val)
def get_supported_boot_mode(self)
Retrieves the supported boot mode. :returns: any one of the following proliantutils.ilo.constants: SUPPORTED_BOOT_MODE_LEGACY_BIOS_ONLY, SUPPORTED_BOOT_MODE_UEFI_ONLY, SUPPORTED_BOOT_MODE_LEGACY_BIOS_AND_UEFI
4.742369
4.693346
1.010445
acc_uri = '/rest/v1/AccountService/Accounts' for status, hds, account, memberuri in self._get_collection(acc_uri): if account['UserName'] == self.login: mod_user = {} mod_user['Password'] = password status, headers, response = self._rest_patch(memberuri, None, mod_user) if status != 200: msg = self._get_extended_error(response) raise exception.IloError(msg) return msg = "iLO Account with specified username is not found." raise exception.IloError(msg)
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. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
4.98686
4.651363
1.072129
manager_uri = '/rest/v1/Managers/1' status, headers, manager = self._rest_get(manager_uri) if status != 200: msg = self._get_extended_error(manager) raise exception.IloError(msg) # verify expected type mtype = self._get_type(manager) if (mtype not in ['Manager.0', 'Manager.1']): msg = "%s is not a valid Manager type " % mtype raise exception.IloError(msg) return manager, manager_uri
def _get_ilo_details(self)
Gets iLO details :raises: IloError, on an error from iLO. :raises: IloConnectionError, if iLO is not up after reset. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
4.069668
4.010699
1.014703
manager, reset_uri = self._get_ilo_details() action = {'Action': 'Reset'} # perform the POST status, headers, response = self._rest_post(reset_uri, None, action) if(status != 200): msg = self._get_extended_error(response) raise exception.IloError(msg) # Check if the iLO is up again. common.wait_for_ilo_after_reset(self)
def reset_ilo(self)
Resets the iLO. :raises: IloError, on an error from iLO. :raises: IloConnectionError, if iLO is not up after reset. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
5.742744
5.706632
1.006328
# Check if the BIOS resource if exists. headers_bios, bios_uri, bios_settings = self._check_bios_resource() # Get the BaseConfig resource. try: base_config_uri = bios_settings['links']['BaseConfigs']['href'] except KeyError: msg = ("BaseConfigs resource not found. Couldn't apply the BIOS " "Settings.") raise exception.IloCommandNotSupportedError(msg) # Check if BIOS resource supports patch, else get the settings if not self._operation_allowed(headers_bios, 'PATCH'): headers, bios_uri, _ = self._get_bios_settings_resource( bios_settings) self._validate_if_patch_supported(headers, bios_uri) status, headers, config = self._rest_get(base_config_uri) if status != 200: msg = self._get_extended_error(config) raise exception.IloError(msg) new_bios_settings = {} for cfg in config['BaseConfigs']: default_settings = cfg.get('default', None) if default_settings is not None: new_bios_settings = default_settings break else: msg = ("Default Settings not found in 'BaseConfigs' resource.") raise exception.IloCommandNotSupportedError(msg) request_headers = self._get_bios_hash_password(self.bios_password) status, headers, response = self._rest_patch(bios_uri, request_headers, new_bios_settings) if status >= 300: msg = self._get_extended_error(response) raise exception.IloError(msg)
def reset_bios_to_default(self)
Resets the BIOS settings to default values. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
3.289829
3.2543
1.010918
try: manager, reset_uri = self._get_ilo_details() ilo_fw_ver_str = ( manager['Oem']['Hp']['Firmware']['Current']['VersionString'] ) return common.get_major_minor(ilo_fw_ver_str) except Exception: return None
def get_ilo_firmware_version_as_major_minor(self)
Gets the ilo firmware version for server capabilities :returns: String with the format "<major>.<minor>" or None.
6.116819
6.215812
0.984074
capabilities = {} system = self._get_host_details() capabilities['server_model'] = system['Model'] rom_firmware_version = ( system['Oem']['Hp']['Bios']['Current']['VersionString']) capabilities['rom_firmware_version'] = rom_firmware_version capabilities.update(self._get_ilo_firmware_version()) capabilities.update(self._get_number_of_gpu_devices_connected()) drive_details = self._get_drive_type_and_speed() if drive_details is not None: capabilities.update(drive_details) raid_details = self._get_logical_raid_levels() if raid_details is not None: capabilities.update(raid_details) if self._is_raid_supported(): capabilities['hardware_supports_raid'] = 'true' boot_modes = common.get_supported_boot_modes( self.get_supported_boot_mode()) capabilities.update({ 'boot_mode_bios': boot_modes.boot_mode_bios, 'boot_mode_uefi': boot_modes.boot_mode_uefi}) if self._get_tpm_capability(): capabilities['trusted_boot'] = 'true' if self._get_cpu_virtualization(): capabilities['cpu_vt'] = 'true' if self._get_nvdimm_n_status(): capabilities['nvdimm_n'] = 'true' try: self._check_iscsi_rest_patch_allowed() capabilities['iscsi_boot'] = 'true' except exception.IloError: # If an error is raised dont populate the capability # iscsi_boot pass try: self.get_secure_boot_mode() capabilities['secure_boot'] = 'true' except exception.IloCommandNotSupportedError: # If an error is raised dont populate the capability # secure_boot pass if self._is_sriov_enabled(): capabilities['sriov_enabled'] = 'true' return capabilities
def get_server_capabilities(self)
Gets server properties which can be used for scheduling :returns: a dictionary of hardware properties like firmware versions, server model. :raises: IloError, if iLO returns an error in command execution.
3.276876
3.189936
1.027254
manager, uri = self._get_ilo_details() try: lic_uri = manager['Oem']['Hp']['links']['LicenseService']['href'] except KeyError: msg = ('"LicenseService" section in Manager/Oem/Hp does not exist') raise exception.IloCommandNotSupportedError(msg) lic_key = {} lic_key['LicenseKey'] = key # Perform POST to activate license status, headers, response = self._rest_post(lic_uri, None, lic_key) if status >= 300: msg = self._get_extended_error(response) raise exception.IloError(msg)
def activate_license(self, key)
Activates iLO license. :param key: iLO license key. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
4.673323
4.264904
1.095763
valid_devices = {'FLOPPY': 'floppy', 'CDROM': 'cd'} # Check if the input is valid if device not in valid_devices: raise exception.IloInvalidInputError( "Invalid device. Valid devices: FLOPPY or CDROM.") manager, uri = self._get_ilo_details() try: vmedia_uri = manager['links']['VirtualMedia']['href'] except KeyError: msg = ('"VirtualMedia" section in Manager/links does not exist') raise exception.IloCommandNotSupportedError(msg) for status, hds, vmed, memberuri in self._get_collection(vmedia_uri): status, headers, response = self._rest_get(memberuri) if status != 200: msg = self._get_extended_error(response) raise exception.IloError(msg) if (valid_devices[device] in [item.lower() for item in response['MediaTypes']]): vm_device_uri = response['links']['self']['href'] return response, vm_device_uri # Requested device not found msg = ('Virtualmedia device "' + device + '" is not' ' found on this system.') raise exception.IloError(msg)
def _get_vm_device_status(self, device='FLOPPY')
Returns the given virtual media device status and device URI :param device: virtual media device to be queried :returns json format virtual media device status and its URI :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
4.610724
4.428655
1.041112
response, vm_device_uri = self._get_vm_device_status(device) # Create RIBCL equivalent response # RIBCL provides this data in VM status # VM_APPLET = CONNECTED | DISCONNECTED # DEVICE = FLOPPY | CDROM # BOOT_OPTION = BOOT_ALWAYS | BOOT_ONCE | NO_BOOT # WRITE_PROTECT = YES | NO # IMAGE_INSERTED = YES | NO response_data = {} if response.get('WriteProtected', False): response_data['WRITE_PROTECT'] = 'YES' else: response_data['WRITE_PROTECT'] = 'NO' if response.get('BootOnNextServerReset', False): response_data['BOOT_OPTION'] = 'BOOT_ONCE' else: response_data['BOOT_OPTION'] = 'BOOT_ALWAYS' if response.get('Inserted', False): response_data['IMAGE_INSERTED'] = 'YES' else: response_data['IMAGE_INSERTED'] = 'NO' if response.get('ConnectedVia') == 'NotConnected': response_data['VM_APPLET'] = 'DISCONNECTED' # When media is not connected, it's NO_BOOT response_data['BOOT_OPTION'] = 'NO_BOOT' else: response_data['VM_APPLET'] = 'CONNECTED' response_data['IMAGE_URL'] = response['Image'] response_data['DEVICE'] = device # FLOPPY cannot be a boot device if ((response_data['BOOT_OPTION'] == 'BOOT_ONCE') and (response_data['DEVICE'] == 'FLOPPY')): response_data['BOOT_OPTION'] = 'NO_BOOT' return response_data
def get_vm_status(self, device='FLOPPY')
Returns the virtual media drive status. :param device: virtual media device to be queried :returns device status in dictionary form :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
3.075481
3.117102
0.986647
# CONNECT is a RIBCL call. There is no such property to set in RIS. if boot_option == 'CONNECT': return boot_option_map = {'BOOT_ONCE': True, 'BOOT_ALWAYS': False, 'NO_BOOT': False } if boot_option not in boot_option_map: msg = ('Virtualmedia boot option "' + boot_option + '" is ' 'invalid.') raise exception.IloInvalidInputError(msg) response, vm_device_uri = self._get_vm_device_status(device) # Update required property vm_settings = {} vm_settings['Oem'] = ( {'Hp': {'BootOnNextServerReset': boot_option_map[boot_option]}}) # perform the patch operation status, headers, response = self._rest_patch( vm_device_uri, None, vm_settings) if status >= 300: msg = self._get_extended_error(response) raise exception.IloError(msg)
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. :param device: virual media device :param boot_option: boot option to set on the virtual media device :param write_protect: set the write protect flag on the vmedia device Note: It's ignored. In RIS it is read-only. :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
4.694855
4.516778
1.039426
response, vm_device_uri = self._get_vm_device_status(device) # Eject media if there is one. RIBCL was tolerant enough to overwrite # existing media, RIS is not. This check is to take care of that # assumption. if response.get('Inserted', False): self.eject_virtual_media(device) # Update required property vm_settings = {} vm_settings['Image'] = url # Perform the patch operation status, headers, response = self._rest_patch( vm_device_uri, None, vm_settings) if status >= 300: msg = self._get_extended_error(response) raise exception.IloError(msg)
def insert_virtual_media(self, url, device='FLOPPY')
Notifies iLO of the location of a virtual media diskette image. :param url: URL to image :param device: virual media device :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
7.274921
6.99976
1.03931
# Check if the BIOS resource if exists. headers_bios, bios_uri, bios_settings = self._check_bios_resource() # Get the Boot resource. boot_settings = self._get_bios_boot_resource(bios_settings) # Get the BootSources resource try: boot_sources = boot_settings['BootSources'] except KeyError: msg = ("BootSources resource not found.") raise exception.IloError(msg) try: boot_order = boot_settings['PersistentBootConfigOrder'] except KeyError: msg = ("PersistentBootConfigOrder resource not found.") raise exception.IloCommandNotSupportedError(msg) return boot_sources, boot_order
def _get_persistent_boot_devices(self)
Get details of persistent boot devices, its order :returns: List of dictionary of boot sources and list of boot device order :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
4.08491
3.56351
1.146317
system = self._get_host_details() try: # Return boot device if it is persistent. if system['Boot']['BootSourceOverrideEnabled'] == 'Continuous': device = system['Boot']['BootSourceOverrideTarget'] if device in DEVICE_RIS_TO_COMMON: return DEVICE_RIS_TO_COMMON[device] return device except KeyError as e: msg = "get_persistent_boot_device failed with the KeyError:%s" raise exception.IloError((msg) % e) # Check if we are in BIOS boot mode. # There is no resource to fetch boot device order for BIOS boot mode if not self._is_boot_mode_uefi(): return None # Get persistent boot device order for UEFI boot_sources, boot_devices = self._get_persistent_boot_devices() boot_string = "" try: for source in boot_sources: if (source["StructuredBootString"] == boot_devices[0]): boot_string = source["BootString"] break except KeyError as e: msg = "get_persistent_boot_device failed with the KeyError:%s" raise exception.IloError((msg) % e) if 'HP iLO Virtual USB CD' in boot_string: return 'CDROM' elif ('NIC' in boot_string or 'PXE' in boot_string or "iSCSI" in boot_string): return 'NETWORK' elif common.isDisk(boot_string): return 'HDD' else: return None
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. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
4.298713
4.287093
1.00271
tenure = 'Once' new_device = device_type[0] # If it is a standard device, we need to convert in RIS convention if device_type[0].upper() in DEVICE_COMMON_TO_RIS: new_device = DEVICE_COMMON_TO_RIS[device_type[0].upper()] if persistent: tenure = 'Continuous' systems_uri = "/rest/v1/Systems/1" # Need to set this option first if device is 'UefiTarget' if new_device is 'UefiTarget': system = self._get_host_details() uefi_devices = ( system['Boot']['UefiTargetBootSourceOverrideSupported']) iscsi_device = None for device in uefi_devices: if device is not None and 'iSCSI' in device: iscsi_device = device break if iscsi_device is None: msg = 'No UEFI iSCSI bootable device found' raise exception.IloError(msg) new_boot_settings = {} new_boot_settings['Boot'] = {'UefiTargetBootSourceOverride': iscsi_device} status, headers, response = self._rest_patch(systems_uri, None, new_boot_settings) if status >= 300: msg = self._get_extended_error(response) raise exception.IloError(msg) new_boot_settings = {} new_boot_settings['Boot'] = {'BootSourceOverrideEnabled': tenure, 'BootSourceOverrideTarget': new_device} status, headers, response = self._rest_patch(systems_uri, None, new_boot_settings) if status >= 300: msg = self._get_extended_error(response) raise exception.IloError(msg)
def _update_persistent_boot(self, device_type=[], persistent=False)
Changes the persistent boot device order in BIOS boot mode for host Note: It uses first boot device from the device_type and ignores rest. :param device_type: ordered list of boot devices :param persistent: Boolean flag to indicate if the device to be set as a persistent boot device :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
3.142452
3.105781
1.011807
# Check if the input is valid for item in device_type: if item.upper() not in DEVICE_COMMON_TO_RIS: raise exception.IloInvalidInputError("Invalid input. Valid " "devices: NETWORK, HDD," " ISCSI or CDROM.") self._update_persistent_boot(device_type, persistent=True)
def update_persistent_boot(self, device_type=[])
Changes the persistent boot device order for the host :param device_type: ordered list of boot devices :raises: IloError, on an error from iLO. :raises: IloCommandNotSupportedError, if the command is not supported on the server.
6.796584
7.520594
0.90373