Exemple #1
0
class StorageControllersListField(base.ListField):
    """The set of storage controllers represented by this resource."""

    member_id = base.Field('MemberId', required=True)
    """Uniquely identifies the member within the collection."""

    name = base.Field('Name', required=True)
    """The name of the storage controller"""

    status = common.StatusField('Status')
    """Describes the status and health of the resource and its children."""

    identifiers = common.IdentifiersListField('Identifiers', default=[])
    """The Durable names for the storage controller."""

    speed_gbps = base.Field('SpeedGbps')
    """The maximum speed of the storage controller's device interface."""

    controller_protocols = base.MappedListField(
        'SupportedControllerProtocols', res_maps.PROTOCOL_TYPE_VALUE_MAP)
    """The protocols by which this storage controller can be communicated to"""

    device_protocols = base.MappedListField('SupportedDeviceProtocols',
                                            res_maps.PROTOCOL_TYPE_VALUE_MAP)
    """The protocols which the controller can use tocommunicate with devices"""
Exemple #2
0
class ConnectedEntitiesListField(base.ListField):
    """All the entities connected to this endpoint."""

    pci_class_code = base.Field('PciClassCode')
    """The Class Code, Subclass code, and Programming Interface code of
    this PCIe function."""

    pci_function_number = base.Field('PciFunctionNumber',
                                     adapter=utils.int_or_none)
    """The PCI ID of the connected entity."""

    entity_pci_id = PciIdField('EntityPciId')
    """The PCI ID of the connected entity."""

    identifiers = common.IdentifiersListField('Identifiers', default=[])
    """Identifiers for the remote entity."""

    entity_role = base.MappedField('EntityRole',
                                   fab_maps.ENTITY_ROLE_VALUE_MAP)
    """The role of the connected entity."""

    entity_type = base.MappedField('EntityType',
                                   fab_maps.ENTITY_TYPE_VALUE_MAP)
    """The type of the connected entity."""
Exemple #3
0
class Volume(base.ResourceBase):
    """This class adds the Storage Volume resource"""

    identity = base.Field('Id', required=True)
    """The Volume identity string"""

    name = base.Field('Name')
    """The name of the resource"""

    capacity_bytes = base.Field('CapacityBytes', adapter=utils.int_or_none)
    """The size in bytes of this Volume."""

    volume_type = base.MappedField('VolumeType',
                                   store_maps.VOLUME_TYPE_TYPE_MAP)
    """The type of this volume."""

    raid_type = base.MappedField('RAIDType', store_maps.RAID_TYPE_TYPE_MAP)
    """The RAID type of this volume."""

    encrypted = base.Field('Encrypted', adapter=bool)
    """Is this Volume encrypted."""

    identifiers = common.IdentifiersListField('Identifiers', default=[])
    """The Durable names for the volume."""

    block_size_bytes = base.Field('BlockSizeBytes', adapter=int)
    """The size of the smallest addressable unit of this volume in bytes."""

    operation_apply_time_support = common.OperationApplyTimeSupportField()
    """Indicates if a client is allowed to request for a specific apply
    time of a create, delete, or action operation of a given resource"""

    _actions = ActionsField('Actions')

    def _get_initialize_action_element(self):
        initialize_action = self._actions.initialize
        if not initialize_action:
            raise exceptions.MissingActionError(action='#Volume.Initialize',
                                                resource=self._path)
        return initialize_action

    def get_allowed_initialize_volume_values(self):
        """Get the allowed values for initializing the volume.

        :returns: A set with the allowed values.
        """
        action = self._get_initialize_action_element()

        if not action.allowed_values:
            LOG.warning(
                'Could not figure out the allowed values for the '
                'initialize volume action for Volume %s', self.identity)
            return set(store_maps.VOLUME_INIT_TYPE_MAP_REV)

        return set([
            store_maps.VOLUME_INIT_TYPE_MAP[v]
            for v in set(store_maps.VOLUME_INIT_TYPE_MAP).intersection(
                action.allowed_values)
        ])

    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

    def initialize(self,
                   value=store_cons.VOLUME_INIT_TYPE_FAST,
                   apply_time=None,
                   timeout=500):
        """Initialize the volume.

        :param value: The InitializeType value.
        :param apply_time: When to update the attributes. Optional.
            APPLY_TIME_IMMEDIATE - Immediate,
            APPLY_TIME_ON_RESET - On reset,
            APPLY_TIME_MAINT_START - During specified maintenance time
            APPLY_TIME_MAINT_RESET - On reset during specified maintenance time
        :param timeout: Max time in seconds to wait for blocking async call.
        :raises: InvalidParameterValueError, if the target value is not
            allowed.
        :raises: ConnectionError
        :raises: HTTPError
        :returns: TaskMonitor if async task or None if successful init
        """
        r, target_uri = self._initialize(value, apply_time, timeout)
        if r.status_code == 202:
            return TaskMonitor.from_response(self._conn, r, target_uri,
                                             self.redfish_version,
                                             self.registries)

    def initialize_volume(self,
                          value=store_cons.VOLUME_INIT_TYPE_FAST,
                          apply_time=None,
                          timeout=500):
        """Initialize the volume.

        Deprecated: Use initialize

        :param value: The InitializeType value.
        :param apply_time: When to update the attributes. Optional.
            APPLY_TIME_IMMEDIATE - Immediate,
            APPLY_TIME_ON_RESET - On reset,
            APPLY_TIME_MAINT_START - During specified maintenance time
            APPLY_TIME_MAINT_RESET - On reset during specified maintenance time
        :param timeout: Max time in seconds to wait for blocking async call.
        :raises: InvalidParameterValueError, if the target value is not
            allowed.
        :raises: ConnectionError
        :raises: HTTPError
        :returns: TaskMonitor if async task or None if successful init
        """
        r, _ = self._initialize(value, apply_time, timeout)
        if r.status_code == 202:
            return (TaskMonitorDepr(self,
                                    r.headers.get('location')).set_retry_after(
                                        r.headers.get('retry-after')))

    def _delete(self, payload=None, apply_time=None, timeout=500):
        blocking = False
        oat_prop = '@Redfish.OperationApplyTime'
        if apply_time:
            if payload is None:
                payload = {}
            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
        r = self._conn.delete(self._path,
                              data=payload,
                              blocking=blocking,
                              timeout=timeout)
        return r

    def delete(self, payload=None, apply_time=None, timeout=500):
        """Delete the volume.

        :param payload: May contain @Redfish.OperationApplyTime property
        :param apply_time: When to update the attributes. Optional.
            APPLY_TIME_IMMEDIATE - Immediate,
            APPLY_TIME_ON_RESET - On reset,
            APPLY_TIME_MAINT_START - During specified maintenance time
            APPLY_TIME_MAINT_RESET - On reset during specified maintenance time
        :param timeout: Max time in seconds to wait for blocking async call.
        :raises: ConnectionError
        :raises: HTTPError
        :returns: TaskMonitor if async task or None if successful deletion
        """
        r = self._delete(payload, apply_time, timeout)
        if r.status_code == 202:
            return TaskMonitor.from_response(self._conn, r, self._path,
                                             self.redfish_version,
                                             self.registries)

    def delete_volume(self, payload=None, apply_time=None, timeout=500):
        """Delete the volume.

        Deprecated: Use delete

        :param payload: May contain @Redfish.OperationApplyTime property
        :param apply_time: When to update the attributes. Optional.
            APPLY_TIME_IMMEDIATE - Immediate,
            APPLY_TIME_ON_RESET - On reset,
            APPLY_TIME_MAINT_START - During specified maintenance time
            APPLY_TIME_MAINT_RESET - On reset during specified maintenance time
        :param timeout: Max time in seconds to wait for blocking async call.
        :raises: ConnectionError
        :raises: HTTPError
        :returns: TaskMonitor if async task or None if successful deletion
        """
        r = self._delete(payload, apply_time, timeout)
        if r.status_code == 202:
            return (TaskMonitorDepr(self._conn,
                                    r.headers.get('location')).set_retry_after(
                                        r.headers.get('retry-after')))
Exemple #4
0
class Volume(base.ResourceBase):
    """This class adds the Storage Volume resource"""

    identity = base.Field('Id', required=True)
    """The Volume identity string"""

    name = base.Field('Name')
    """The name of the resource"""

    capacity_bytes = base.Field('CapacityBytes', adapter=utils.int_or_none)
    """The size in bytes of this Volume."""

    volume_type = base.MappedField('VolumeType',
                                   store_maps.VOLUME_TYPE_TYPE_MAP)
    """The type of this volume."""

    raid_type = base.MappedField('RAIDType', store_maps.RAID_TYPE_TYPE_MAP)
    """The RAID type of this volume."""

    encrypted = base.Field('Encrypted', adapter=bool)
    """Is this Volume encrypted."""

    identifiers = common.IdentifiersListField('Identifiers', default=[])
    """The Durable names for the volume."""

    block_size_bytes = base.Field('BlockSizeBytes', adapter=int)
    """The size of the smallest addressable unit of this volume in bytes."""

    operation_apply_time_support = common.OperationApplyTimeSupportField()
    """Indicates if a client is allowed to request for a specific apply
    time of a create, delete, or action operation of a given resource"""

    _actions = ActionsField('Actions', required=True)

    def _get_initialize_action_element(self):
        initialize_action = self._actions.initialize
        if not initialize_action:
            raise exceptions.MissingActionError(action='#Volume.Initialize',
                                                resource=self._path)
        return initialize_action

    def get_allowed_initialize_volume_values(self):
        """Get the allowed values for initializing the volume.

        :returns: A set with the allowed values.
        """
        action = self._get_initialize_action_element()

        if not action.allowed_values:
            LOG.warning(
                'Could not figure out the allowed values for the '
                'initialize volume action for Volume %s', self.identity)
            return set(store_maps.VOLUME_INIT_TYPE_MAP_REV)

        return set([
            store_maps.VOLUME_INIT_TYPE_MAP[v]
            for v in set(store_maps.VOLUME_INIT_TYPE_MAP).intersection(
                action.allowed_values)
        ])

    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},
                        blocking=True)

    def delete_volume(self, payload=None):
        """Delete the volume.

        :param payload: May contain @Redfish.OperationApplyTime property
        :raises: ConnectionError
        :raises: HTTPError
        """
        self._conn.delete(self._path, data=payload, blocking=True)
Exemple #5
0
class Drive(base.ResourceBase):
    """This class represents a disk drive or other physical storage medium."""

    block_size_bytes = base.Field('BlockSizeBytes', adapter=utils.int_or_none)
    """The size of the smallest addressable unit of this drive in bytes"""

    capacity_bytes = base.Field('CapacityBytes', adapter=utils.int_or_none)
    """The size in bytes of this Drive"""

    identifiers = common.IdentifiersListField('Identifiers', default=[])
    """The Durable names for the drive"""

    identity = base.Field('Id', required=True)
    """The Drive identity string"""

    indicator_led = base.MappedField('IndicatorLED',
                                     res_maps.INDICATOR_LED_VALUE_MAP)
    """Whether the indicator LED is lit or off"""

    manufacturer = base.Field('Manufacturer')
    """This is the manufacturer of this drive"""

    media_type = base.Field('MediaType')
    """The type of media contained in this drive"""

    model = base.Field('Model')
    """This is the model number for the drive"""

    name = base.Field('Name')
    """The name of the resource"""

    part_number = base.Field('PartNumber')
    """The part number for this drive"""

    protocol = base.MappedField('Protocol', res_maps.PROTOCOL_TYPE_VALUE_MAP)
    """Protocol this drive is using to communicate to the storage controller"""

    serial_number = base.Field('SerialNumber')
    """The serial number for this drive"""

    status = common.StatusField('Status')
    """This type describes the status and health of the drive"""

    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()