def update(self, mac_address, vlan_id=None):
        """Update attributes of static MAC

        :param mac_address: MAC address that should be forwarded to this port
        :param vlan_id: If specified, defines which packets tagged with
                        specific VLANId should be forwarded to this port
        """
        if not isinstance(mac_address, type("")):
            raise exceptions.InvalidParameterValueError(
                parameter="mac_address",
                value=mac_address,
                valid_values="string",
            )
        data = {"MACAddress": mac_address}

        if vlan_id is not None:
            if not isinstance(vlan_id, int):
                raise exceptions.InvalidParameterValueError(
                    parameter="vlan_id",
                    value=vlan_id,
                    valid_values="int",
                )
            data["VLANId"] = vlan_id

        self._conn.patch(self.path, data=data)
Exemple #2
0
    def update(self, bootable=None, erased=None):
        """Update volume properties

        :param bootable: Change bootable ability of the volume
        :param erased: Provide information if the drive was erased
        :raises: BadRequestError if at least one param isn't specified
        """
        if bootable is None and erased is None:
            raise ValueError('At least "bootable" or "erased" parameter has '
                             'to be specified')

        if bootable and not isinstance(bootable, bool):
            raise exceptions.InvalidParameterValueError(
                parameter='bootable',
                value=bootable,
                valid_values=[True, False])

        if erased and not isinstance(erased, bool):
            raise exceptions.InvalidParameterValueError(
                parameter='erased', value=erased, valid_values=[True, False])

        data = {'Oem': {'Intel_RackScale': {}}}
        if bootable is not None:
            data['Oem']['Intel_RackScale']['Bootable'] = bootable
        if erased is not None:
            data['Oem']['Intel_RackScale']['Erased'] = erased

        self._conn.patch(self.path, data=data)
Exemple #3
0
    def set_system_boot_options(self, target=None, enabled=None, mode=None):
        """Set boot source and/or boot frequency and/or boot mode.

        Set the boot source and/or boot frequency and/or boot mode to use
        on next reboot of the System.

        :param target: The target boot source, optional.
        :param enabled: The frequency, whether to set it for the next
            reboot only (BOOT_SOURCE_ENABLED_ONCE) or persistent to all
            future reboots (BOOT_SOURCE_ENABLED_CONTINUOUS) or disabled
            (BOOT_SOURCE_ENABLED_DISABLED), optional.
        :param mode: The boot mode (UEFI: BOOT_SOURCE_MODE_UEFI or
            BIOS: BOOT_SOURCE_MODE_BIOS), optional.
        :raises: InvalidParameterValueError, if any information passed is
            invalid.
        """
        data = collections.defaultdict(dict)

        if target is not None:
            valid_targets = self.get_allowed_system_boot_source_values()
            if target not in valid_targets:
                raise exceptions.InvalidParameterValueError(
                    parameter='target',
                    value=target,
                    valid_values=valid_targets)

            fishy_target = sys_maps.BOOT_SOURCE_TARGET_MAP_REV[target]

            data['Boot']['BootSourceOverrideTarget'] = fishy_target

        if enabled is not None:
            if enabled not in sys_maps.BOOT_SOURCE_ENABLED_MAP_REV:
                raise exceptions.InvalidParameterValueError(
                    parameter='enabled',
                    value=enabled,
                    valid_values=list(sys_maps.BOOT_SOURCE_ENABLED_MAP_REV))

            fishy_freq = sys_maps.BOOT_SOURCE_ENABLED_MAP_REV[enabled]

            data['Boot']['BootSourceOverrideEnabled'] = fishy_freq

        if mode is not None:
            if mode not in sys_maps.BOOT_SOURCE_MODE_MAP_REV:
                raise exceptions.InvalidParameterValueError(
                    parameter='mode',
                    value=mode,
                    valid_values=list(sys_maps.BOOT_SOURCE_MODE_MAP_REV))

            fishy_mode = sys_maps.BOOT_SOURCE_MODE_MAP_REV[mode]

            data['Boot']['BootSourceOverrideMode'] = fishy_mode

        # TODO(lucasagomes): Check the return code and response body ?
        #                    Probably we should call refresh() as well.
        self._conn.patch(self.path, data=data)
Exemple #4
0
    def set_system_boot_source(self,
                               target,
                               enabled=sys_cons.BOOT_SOURCE_ENABLED_ONCE,
                               mode=None):
        """Set the boot source.

        Set the boot source to use on next reboot of the System.

        :param target: The target boot source.
        :param enabled: The frequency, whether to set it for the next
            reboot only (BOOT_SOURCE_ENABLED_ONCE) or persistent to all
            future reboots (BOOT_SOURCE_ENABLED_CONTINUOUS) or disabled
            (BOOT_SOURCE_ENABLED_DISABLED).
        :param mode: The boot mode, UEFI (BOOT_SOURCE_MODE_UEFI) or
            BIOS (BOOT_SOURCE_MODE_BIOS).
        :raises: InvalidParameterValueError, if any information passed is
            invalid.
        """
        valid_targets = self.get_allowed_system_boot_source_values()
        if target not in valid_targets:
            raise exceptions.InvalidParameterValueError(
                parameter='target', value=target, valid_values=valid_targets)

        if enabled not in sys_maps.BOOT_SOURCE_ENABLED_MAP_REV:
            raise exceptions.InvalidParameterValueError(
                parameter='enabled',
                value=enabled,
                valid_values=list(sys_maps.BOOT_SOURCE_ENABLED_MAP_REV))

        data = {
            'Boot': {
                'BootSourceOverrideTarget':
                sys_maps.BOOT_SOURCE_TARGET_MAP_REV[target],
                'BootSourceOverrideEnabled':
                sys_maps.BOOT_SOURCE_ENABLED_MAP_REV[enabled]
            }
        }

        if mode is not None:
            if mode not in sys_maps.BOOT_SOURCE_MODE_MAP_REV:
                raise exceptions.InvalidParameterValueError(
                    parameter='mode',
                    value=mode,
                    valid_values=list(sys_maps.BOOT_SOURCE_MODE_MAP_REV))

            data['Boot']['BootSourceOverrideMode'] = (
                sys_maps.BOOT_SOURCE_MODE_MAP_REV[mode])

        # TODO(lucasagomes): Check the return code and response body ?
        #                    Probably we should call refresh() as well.
        self._conn.patch(self.path, data=data)
Exemple #5
0
    def set_node_boot_source(self,
                             target,
                             enabled=node_cons.BOOT_SOURCE_ENABLED_ONCE,
                             mode=None):
        """Set the boot source.

        Set the boot source to use on next reboot of the Node.

        :param target: The target boot source.
        :param enabled: The frequency, whether to set it for the next
            reboot only (BOOT_SOURCE_ENABLED_ONCE) or persistent to all
            future reboots (BOOT_SOURCE_ENABLED_CONTINUOUS) or disabled
            (BOOT_SOURCE_ENABLED_DISABLED).
        :param mode: The boot mode, UEFI (BOOT_SOURCE_MODE_UEFI) or
            Legacy (BOOT_SOURCE_MODE_LEGACY).
        :raises: InvalidParameterValueError, if any information passed is
            invalid.
        """
        valid_targets = self.get_allowed_node_boot_source_values()
        if target not in valid_targets:
            raise exceptions.InvalidParameterValueError(
                parameter='target', value=target, valid_values=valid_targets)

        if enabled not in node_maps.BOOT_SOURCE_ENABLED_MAP_REV:
            raise exceptions.InvalidParameterValueError(
                parameter='enabled',
                value=enabled,
                valid_values=list(node_maps.BOOT_SOURCE_ENABLED_MAP_REV))

        data = {
            'Boot': {
                'BootSourceOverrideTarget':
                node_maps.BOOT_SOURCE_TARGET_MAP_REV[target],
                'BootSourceOverrideEnabled':
                node_maps.BOOT_SOURCE_ENABLED_MAP_REV[enabled]
            }
        }

        if mode is not None:
            if mode not in node_maps.BOOT_SOURCE_MODE_MAP_REV:
                raise exceptions.InvalidParameterValueError(
                    parameter='mode',
                    value=mode,
                    valid_values=list(node_maps.BOOT_SOURCE_MODE_MAP_REV))

            data['Boot']['BootSourceOverrideMode'] = (
                node_maps.BOOT_SOURCE_MODE_MAP_REV[mode])

        self._conn.patch(self.path, data=data)
Exemple #6
0
    def attach_endpoint(self, endpoint=None, capacity=None):
        """Attach endpoint from available pool to composed node

        :param endpoint: Link to endpoint to attach.
        :param capacity: Requested capacity of the drive in GiB.
        :raises: InvalidParameterValueError
        :raises: BadRequestError if at least one param isn't specified
        """
        attach_action = self._get_attach_endpoint_action_element()
        valid_endpoints = attach_action.allowed_values
        target_uri = attach_action.target_uri

        if endpoint and endpoint not in valid_endpoints:
            raise exceptions.InvalidParameterValueError(
                parameter="endpoint",
                value=endpoint,
                valid_values=valid_endpoints,
            )

        data = {}
        if endpoint is not None:
            data["Resource"] = {"@odata.id": endpoint}
        if capacity is not None:
            data["CapacityGiB"] = capacity

        self._conn.post(target_uri, data=data)
Exemple #7
0
    def simple_update(self,
                      image_uri,
                      targets=None,
                      transfer_protocol=up_cons.UPDATE_PROTOCOL_HTTP):
        """Simple Update is used to update software components"""
        valid_transfer_protocols = self.get_allowed_transfer_protocols()

        if transfer_protocol in valid_transfer_protocols:
            transfer_protocol = up_maps.TRANSFER_PROTOCOL_TYPE_VALUE_MAP_REV[
                transfer_protocol]

        else:
            legacy_transfer_protocols = self._get_legacy_transfer_protocols()

            if transfer_protocol not in legacy_transfer_protocols:
                raise exceptions.InvalidParameterValueError(
                    parameter='transfer_protocol',
                    value=transfer_protocol,
                    valid_values=valid_transfer_protocols)

            LOG.warning(
                'Legacy transfer protocol constant %s is being used. '
                'Consider migrating to any of: %s', transfer_protocol,
                ', '.join(up_maps.TRANSFER_PROTOCOL_TYPE_VALUE_MAP_REV))

        target_uri = self._get_simple_update_element().target_uri

        LOG.debug('Updating software component %s via '
                  '%s ...', image_uri, target_uri)

        data = {'ImageURI': image_uri, 'TransferProtocol': transfer_protocol}
        if targets:
            data['Targets'] = targets
        self._conn.post(target_uri, data=data)
Exemple #8
0
    def resize(self, num_bytes):
        """Update volume properties

        :param num_bytes: size in bytes of new resized volume
        """
        if not isinstance(num_bytes, int):
            raise exceptions.InvalidParameterValueError(parameter='num_bytes',
                                                        value=num_bytes,
                                                        valid_values='integer')

        if self.capacity_bytes and num_bytes <= self.capacity_bytes:
            raise exceptions.InvalidParameterValueError(
                parameter='num_bytes',
                value=num_bytes,
                valid_values='> {0}'.format(self.capacity_bytes))

        data = {"Capacity": {"Data": {'AllocatedBytes': num_bytes}}}
        self._conn.patch(self.path, data=data)
Exemple #9
0
    def set_enabled(self, enabled):
        """Enable/disable secure boot.

        :param enabled: True, if secure boot is enabled for next boot.
        """
        if not isinstance(enabled, bool):
            raise exceptions.InvalidParameterValueError(
                "Expected a boolean for 'enabled', got %r" % enabled)

        self._conn.patch(self.path, data={'SecureBootEnable': enabled})
Exemple #10
0
    def set_system_boot_source(self, target, enabled="Once", mode=None):
        """Set the boot source.

        Set the boot source to use on next reboot of the System.

        :param target: The target boot source.
        :param enabled: The frequency, whether to set it for the next
            reboot only ("Once") or persistent to all future reboots
            ("Continuous") or disabled ("Disabled").
        :param mode: The boot mode, UEFI ("UEFI") or BIOS ("Legacy").
        :raises: InvalidParameterValueError, if any information passed is
            invalid.
        """
        valid_targets = self.get_allowed_system_boot_source_values()
        if target not in valid_targets:
            raise exceptions.InvalidParameterValueError(
                parameter="target", value=target, valid_values=valid_targets
            )

        if enabled not in constants.BOOT_SOURCE_ENABLED_VALUE:
            raise exceptions.InvalidParameterValueError(
                parameter="enabled",
                value=enabled,
                valid_values=constants.BOOT_SOURCE_ENABLED_VALUE,
            )

        data = {
            "Boot": {
                "BootSourceOverrideTarget": target,
                "BootSourceOverrideEnabled": enabled,
            }
        }

        if mode is not None:
            valid_modes = self.get_allowed_system_boot_mode_values()
            if mode not in valid_modes:
                raise exceptions.InvalidParameterValueError(
                    parameter="mode", value=mode, valid_values=valid_modes
                )

            data["Boot"]["BootSourceOverrideMode"] = mode

        self._conn.patch(self.path, data=data)
Exemple #11
0
    def update(self, asset_tag=None, erase_on_detach=None, erased=None):
        """Update drive properties

        :param asset_tag: The user assigned asset tag for this drive
        :param erase_on_detach: Indicates if drive should be erased when
                                detached from Composed Node.
        :param erased: Indicate whether drive was cleared after assignment to
                       composed node
        :raises: InvalidParameterValueError if one param is incorrect
        """

        data = {}

        if asset_tag is not None:
            data["AssetTag"] = asset_tag

        if erase_on_detach is not None or erased is not None:
            data["Oem"] = {"Intel_RackScale": {}}

            if erase_on_detach is not None:
                if not isinstance(erase_on_detach, bool):
                    raise exceptions.InvalidParameterValueError(
                        parameter="erase_on_detach",
                        value=erase_on_detach,
                        valid_values=[True, False],
                    )
                else:
                    data["Oem"]["Intel_RackScale"][
                        "EraseOnDetach"] = erase_on_detach

            if erased is not None:
                if not isinstance(erased, bool):
                    raise exceptions.InvalidParameterValueError(
                        parameter="erased",
                        value=erased,
                        valid_values=[True, False],
                    )
                else:
                    data["Oem"]["Intel_RackScale"]["DriveErased"] = erased

        self._conn.patch(self.path, data=data)
Exemple #12
0
    def simple_update(self,
                      image_uri,
                      targets=None,
                      transfer_protocol=up_cons.UPDATE_PROTOCOL_HTTP):
        """Simple Update is used to update software components.

        :returns: A task monitor.
        """
        valid_transfer_protocols = self.get_allowed_transfer_protocols()

        if transfer_protocol in valid_transfer_protocols:
            transfer_protocol = up_maps.TRANSFER_PROTOCOL_TYPE_VALUE_MAP_REV[
                transfer_protocol]

        else:
            legacy_transfer_protocols = self._get_legacy_transfer_protocols()

            if transfer_protocol not in legacy_transfer_protocols:
                raise exceptions.InvalidParameterValueError(
                    parameter='transfer_protocol',
                    value=transfer_protocol,
                    valid_values=valid_transfer_protocols)

            LOG.warning(
                'Legacy transfer protocol constant %s is being used. '
                'Consider migrating to any of: %s', transfer_protocol,
                ', '.join(up_maps.TRANSFER_PROTOCOL_TYPE_VALUE_MAP_REV))

        target_uri = self._get_simple_update_element().target_uri

        LOG.debug('Updating software component %s via '
                  '%s ...', image_uri, target_uri)

        data = {'ImageURI': image_uri, 'TransferProtocol': transfer_protocol}
        if targets:
            data['Targets'] = targets
        rsp = self._conn.post(target_uri, data=data)

        json_data = rsp.json() if rsp.content else {}
        field_data = base.FieldData(rsp.status_code, rsp.headers, json_data)

        header = 'Location'
        task_monitor = rsp.headers.get(header)
        if not task_monitor:
            raise exceptions.MissingHeaderError(target_uri=target_uri,
                                                header=header)

        return taskmonitor.TaskMonitor(self._conn,
                                       task_monitor,
                                       redfish_version=self.redfish_version,
                                       registries=self.registries,
                                       field_data=field_data)
Exemple #13
0
    def initialize_volume(self, value):
        """Initialize the volume.

        :param value: The InitializeType value.
        :raises: InvalidParameterValueError, if the target value is not
            allowed.
        """
        valid_values = self.get_allowed_initialize_volume_values()
        if value not in valid_values:
            raise exceptions.InvalidParameterValueError(
                parameter='value', value=value, valid_values=valid_values)
        value = store_maps.VOLUME_INIT_TYPE_MAP_REV[value]
        target_uri = self._get_initialize_action_element().target_uri
        self._conn.post(target_uri, data={'InitializeType': value})
Exemple #14
0
    def update(self, clear_tpm_on_delete=None, pm_on_delete=None):
        """Update properties of this composed node

        :param clear_tpm_on_delete: This is used to specify if TPM module
            should be cleared on composed node DELETE request.
        :param pm_on_delete: This is used to specify what operation should be
            performed on Intel OptaneTM DC Persistent Memory on ComposedNode
            DELETE Request:
            - PreserveConfiguration
            - SecureErase
            - OverwritePCD
        :raises: InvalidParameterValueError, if any information passed is
            invalid.
        """
        if clear_tpm_on_delete is None and pm_on_delete is None:
            raise ValueError('At least "clear_tpm_on_delete" or "pm_on_delete"'
                             ' parameter has to be specified')

        data = {}
        if clear_tpm_on_delete is not None:
            if not isinstance(clear_tpm_on_delete, bool):
                raise exceptions.InvalidParameterValueError(
                    parameter='clear_tpm_on_delete',
                    value=clear_tpm_on_delete,
                    valid_values=[True, False])
            data['ClearTPMOnDelete'] = clear_tpm_on_delete

        if pm_on_delete is not None:
            if pm_on_delete not in PM_OPENATION_ON_DELETE_VALUES:
                raise exceptions.InvalidParameterValueError(
                    parameter='pm_on_delete',
                    value=pm_on_delete,
                    valid_values=PM_OPENATION_ON_DELETE_VALUES)
            data['PersistentMemoryOperationOnDelete'] = pm_on_delete

        self._conn.patch(self.path, data=data)
Exemple #15
0
    def reset_keys(self, reset_type):
        """Reset secure boot keys.

        :param reset_type: Reset type, one of `SECORE_BOOT_RESET_KEYS_*`
            constants.
        """
        valid_resets = self.get_allowed_reset_keys_values()
        if reset_type not in valid_resets:
            raise exceptions.InvalidParameterValueError(
                parameter='reset_type',
                value=reset_type,
                valid_values=valid_resets)

        target_uri = self._get_reset_action_element().target_uri
        self._conn.post(target_uri, data={'ResetKeysType': reset_type})
Exemple #16
0
    def reset_port(self, value):
        """Reset the port.

        :param value: The target value.
        :raises: InvalidParameterValueError, if the target value is not
            allowed.
        """
        valid_resets = self.get_allowed_reset_port_values()
        if value not in valid_resets:
            raise exceptions.InvalidParameterValueError(
                parameter="value", value=value, valid_values=valid_resets)

        target_uri = self._get_reset_action_element().target_uri

        self._conn.post(target_uri, data={"ResetType": value})
Exemple #17
0
    def initialize(self, init_type):
        """Change initialize type of this volume

        :param type: volume initialize type
        :raises: InvalidParameterValueError if invalid "type" parameter
        """
        allowed_init_type_values = ['Fast', 'Slow']
        if init_type not in allowed_init_type_values:
            raise exceptions.InvalidParameterValueError(
                parameter='init_type', value=init_type,
                valid_values=allowed_init_type_values)

        data = {"InitializeType": init_type}

        target_uri = self._get_initialize_action_element().target_uri
        self._conn.post(target_uri, data=data)
Exemple #18
0
    def reset_node(self, value):
        """Reset the node.

        :param value: The target value.
        :raises: InvalidParameterValueError, if the target value is not
            allowed.
        """
        valid_resets = self.get_allowed_reset_node_values()
        if value not in valid_resets:
            raise exceptions.InvalidParameterValueError(
                parameter='value', value=value, valid_values=valid_resets)

        value = node_maps.RESET_NODE_VALUE_MAP_REV[value]
        target_uri = self._get_reset_action_element().target_uri

        self._conn.post(target_uri, data={'ResetType': value})
Exemple #19
0
    def simple_update(self, image_uri, targets, transfer_protocol='HTTP'):
        """Simple Update is used to update software components"""
        transfer_protocol = transfer_protocol

        valid_transfer_protocols = self.get_allowed_transfer_protocol_values()
        if transfer_protocol not in valid_transfer_protocols:
            raise exceptions.InvalidParameterValueError(
                parameter='transfer_protocol',
                value=transfer_protocol,
                valid_values=valid_transfer_protocols)

        self._conn.post(
            data={
                'ImageURI': image_uri,
                'Targets': targets,
                'TransferProtocol': transfer_protocol
            })
Exemple #20
0
    def update(self, clear_tpm_on_delete):
        """Update properties of this composed node

        :param clear_tpm_on_delete: This is used to specify if TPM module
            should be cleared on composed node DELETE request.
        :raises: InvalidParameterValueError, if any information passed is
            invalid.
        """
        if not isinstance(clear_tpm_on_delete, bool):
            raise exceptions.InvalidParameterValueError(
                parameter='clear_tpm_on_delete',
                value=clear_tpm_on_delete,
                valid_values=[True, False])

        data = {'ClearTPMOnDelete': clear_tpm_on_delete}

        self._conn.patch(self.path, data=data)
Exemple #21
0
    def bind_port(self, port):
        """Bind port from this switch ACL

        :param port: Link to port to bind.
        :raises: InvalidParameterValueError
        """
        bind_action = self._get_bind_action_element()
        valid_ports = bind_action.allowed_values
        target_uri = bind_action.target_uri

        if port and port not in valid_ports:
            raise exceptions.InvalidParameterValueError(
                parameter="port", value=port, valid_values=valid_ports)

        data = {"Port": {"@odata.id": port}}

        self._conn.post(target_uri, data=data)
Exemple #22
0
    def reset_manager(self, value):
        """Reset the manager.

        :param value: The target value.
        :raises: InvalidParameterValueError, if the target value is not
            allowed.
        """
        valid_resets = self.get_allowed_reset_manager_values()
        if value not in valid_resets:
            raise exceptions.InvalidParameterValueError(
                parameter='value', value=value, valid_values=valid_resets)

        value = mgr_maps.RESET_MANAGER_VALUE_MAP_REV[value]
        target_uri = self._get_reset_action_element().target_uri

        LOG.debug('Resetting the Manager %s ...', self.identity)
        self._conn.post(target_uri, data={'ResetType': value})
        LOG.info('The Manager %s is being reset', self.identity)
Exemple #23
0
    def set_indicator_led(self, state):
        """Set IndicatorLED to the given state.

        :param state: Desired LED state, lit (INDICATOR_LED_LIT), blinking
            (INDICATOR_LED_BLINKING), off (INDICATOR_LED_OFF)
        :raises: InvalidParameterValueError, if any information passed is
            invalid.
        """
        if state not in res_maps.INDICATOR_LED_VALUE_MAP_REV:
            raise exceptions.InvalidParameterValueError(
                parameter='state',
                value=state,
                valid_values=list(res_maps.INDICATOR_LED_VALUE_MAP_REV))

        data = {'IndicatorLED': res_maps.INDICATOR_LED_VALUE_MAP_REV[state]}

        self._conn.patch(self.path, data=data)
        self.invalidate()
Exemple #24
0
    def reset_system(self, value):
        """Reset the system.

        :param value: The target value.
        :raises: InvalidParameterValueError, if the target value is not
            allowed.
        """
        valid_resets = self.get_allowed_reset_system_values()
        if value not in valid_resets:
            raise exceptions.InvalidParameterValueError(
                parameter='value', value=value, valid_values=valid_resets)

        value = sys_maps.RESET_SYSTEM_VALUE_MAP_REV[value]
        target_uri = self._get_reset_action_element().target_uri

        # TODO(lucasagomes): Check the return code and response body ?
        #                    Probably we should call refresh() as well.
        self._conn.post(target_uri, data={'ResetType': value})
Exemple #25
0
    def detach_endpoint(self, endpoint):
        """Detach already attached endpoint from composed node

        :param endpoint: Link to endpoint to detach
        :raises: InvalidParameterValueError
        :raises: BadRequestError
        """
        detach_action = self._get_detach_endpoint_action_element()
        valid_endpoints = detach_action.allowed_values
        target_uri = detach_action.target_uri

        if endpoint not in valid_endpoints:
            raise exceptions.InvalidParameterValueError(
                parameter='endpoint',
                value=endpoint,
                valid_values=valid_endpoints)

        data = {'Resource': endpoint}

        self._conn.post(target_uri, data=data)
Exemple #26
0
    def detach_endpoint(self, resource):
        """Detach endpoint from available pool to composed node

        :param resource: Link to endpoint to detach.
        :raises: InvalidParameterValueError
        """
        detach_action = self._get_detach_endpoint_action_element()
        valid_endpoints = self.get_allowed_detach_endpoints()
        target_uri = detach_action.target_uri

        if resource not in valid_endpoints:
            raise exceptions.InvalidParameterValueError(
                parameter='resource',
                value=resource,
                valid_values=valid_endpoints)

        data = {}
        if resource is not None:
            data['Resource'] = {'@odata.id': resource}

        self._conn.post(target_uri, data=data)
Exemple #27
0
 def _initialize(self,
                 value=store_cons.VOLUME_INIT_TYPE_FAST,
                 apply_time=None,
                 timeout=500):
     valid_values = self.get_allowed_initialize_volume_values()
     if value not in valid_values:
         raise exceptions.InvalidParameterValueError(
             parameter='value', value=value, valid_values=valid_values)
     value = store_maps.VOLUME_INIT_TYPE_MAP_REV[value]
     payload = {'InitializeType': value}
     blocking = False
     oat_prop = '@Redfish.OperationApplyTime'
     if apply_time:
         payload[oat_prop] = res_maps.APPLY_TIME_VALUE_MAP_REV[apply_time]
     if (payload
             and payload.get(oat_prop) == res_maps.APPLY_TIME_VALUE_MAP_REV[
                 res_cons.APPLY_TIME_IMMEDIATE]):
         blocking = True
     target_uri = self._get_initialize_action_element().target_uri
     r = self._conn.post(target_uri,
                         data=payload,
                         blocking=blocking,
                         timeout=timeout)
     return r, target_uri
Exemple #28
0
    def attach_endpoint(self, endpoint, protocol=None):
        """Attach endpoint from available pool to composed node

        :param endpoint: Link to endpoint to attach.
        :param protocol: Protocol of the remote drive.
        :raises: InvalidParameterValueError
        """
        attach_action = self._get_attach_endpoint_action_element()
        valid_endpoints = attach_action.allowed_values
        target_uri = attach_action.target_uri

        if endpoint and endpoint not in valid_endpoints:
            raise exceptions.InvalidParameterValueError(
                parameter='endpoint',
                value=endpoint,
                valid_values=valid_endpoints)

        data = {}
        if endpoint is not None:
            data['Resource'] = {'@odata.id': endpoint}
        if protocol is not None:
            data['Protocol'] = protocol

        self._conn.post(target_uri, data=data)