Пример #1
0
class FansListField(Sensor):
    """The Fan device/s associated with Thermal."""

    indicator_led = base.MappedField('IndicatorLED',
                                     res_maps.INDICATOR_LED_VALUE_MAP)
    """The state of the indicator LED, used to identify the fan"""

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

    max_reading_range = base.Field('MaxReadingRange',
                                   adapter=utils.int_or_none)
    """Maximum value for Reading"""

    min_reading_range = base.Field('MinReadingRange',
                                   adapter=utils.int_or_none)
    """Minimum value for Reading"""

    model = base.Field('Model')
    """The model of this Fan"""

    part_number = base.Field('PartNumber')
    """Part number of this Fan"""

    reading = base.Field('Reading', adapter=utils.int_or_none)
    """Current Fan Speed"""

    reading_units = base.MappedField('ReadingUnits',
                                     the_maps.FAN_READING_UNITS_MAP)
    """Units in which the reading and thresholds are measured"""

    serial_number = base.Field('SerialNumber')
    """Serial number of this Fan"""
Пример #2
0
class Task(base.ResourceBase):

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

    name = base.Field('Name', required=True)
    """The Task name"""

    description = base.Field('Description')
    """The Task description"""

    task_monitor = base.Field('TaskMonitor')
    """An opaque URL that the client can use to monitor an asynchronous
       operation"""

    start_time = base.Field('StartTime')
    """Start time of the Task"""

    end_time = base.Field('EndTime')
    """End time of the Task"""

    percent_complete = base.Field('PercentComplete', adapter=utils.int_or_none)
    """Percentage complete of the Task"""

    task_state = base.MappedField('TaskState', task_maps.TASK_STATE_VALUE_MAP)
    """The Task state"""

    task_status = base.MappedField('TaskStatus', res_maps.HEALTH_VALUE_MAP)
    """The Task status"""

    messages = base.MessageListField("Messages")
    """List of :class:`.MessageListField` with messages from the Task"""

    def __init__(self, connector, identity, redfish_version=None,
                 registries=None, json_doc=None):
        """A class representing a Task

        :param connector: A Connector instance
        :param identity: The identity of the task
        :param redfish_version: The version of RedFish. Used to construct
            the object according to schema of the given version.
        :param registries: Dict of Redfish Message Registry objects to be
            used in any resource that needs registries to parse messages
        :param field_data: the data to use populating the fields
        """
        super(Task, self).__init__(
            connector, identity, redfish_version, registries,
            json_doc=json_doc)

    @property
    def is_processing(self):
        """Indicates if the Task is processing"""
        return self.status_code == http_client.ACCEPTED

    def parse_messages(self):
        """Parses the messages"""
        for m in self.messages:
            message_registry.parse_message(self._registries, m)
Пример #3
0
class PowerSupplyListField(base.ListField):
    """The power supplies associated with this Power resource"""

    firmware_version = base.Field('FirmwareVersion')
    """The firmware version for this Power Supply"""

    identity = base.Field('MemberId')
    """Identifier of the Power Supply"""

    indicator_led = base.MappedField('IndicatorLed',
                                     res_maps.INDICATOR_LED_VALUE_MAP)
    """The state of the indicator LED, used to identify the power supply"""

    input_ranges = InputRangeListField('InputRanges', default=[])
    """This is the input ranges that the power supply can use"""

    last_power_output_watts = base.Field('LastPowerOutputWatts',
                                         adapter=utils.int_or_none)
    """The average power output of this Power Supply"""

    line_input_voltage = base.Field('LineInputVoltage',
                                    adapter=utils.int_or_none)
    """The line input voltage at which the Power Supply is operating"""

    line_input_voltage_type = base.MappedField(
        'LineInputVoltageType',
        pow_maps.LINE_INPUT_VOLTAGE_TYPE_MAP)
    """The line voltage type supported as an input to this Power Supply"""

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

    model = base.Field('Model')
    """The model number for this Power Supply"""

    name = base.Field('Name')
    """Name of the Power Supply"""

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

    power_capacity_watts = base.Field('PowerCapacityWatts',
                                      adapter=utils.int_or_none)
    """The maximum capacity of this Power Supply"""

    power_supply_type = base.MappedField('PowerSupplyType',
                                         pow_maps.POWER_SUPPLY_TYPE_MAP)
    """The Power Supply type (AC or DC)"""

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

    spare_part_number = base.Field('SparePartNumber')
    """The spare part number for this Power Supply"""

    status = common.StatusField('Status')
    """Status of the sensor"""
Пример #4
0
class BootField(base.CompositeField):
    allowed_values = base.Field(
        '*****@*****.**', adapter=list)

    enabled = base.MappedField('BootSourceOverrideEnabled',
                               sys_maps.BOOT_SOURCE_ENABLED_MAP)

    mode = base.MappedField('BootSourceOverrideMode',
                            sys_maps.BOOT_SOURCE_MODE_MAP)

    target = base.MappedField('BootSourceOverrideTarget',
                              sys_maps.BOOT_SOURCE_TARGET_MAP)
Пример #5
0
class StatusField(base.CompositeField):
    """This Field describes the status of a resource and its children.

    This field shall contain any state or health properties of a resource.
    """
    health = base.MappedField('Health', res_maps.HEALTH_VALUE_MAP)
    """Represents health of resource w/o considering its dependent resources"""

    health_rollup = base.MappedField('HealthRollup', res_maps.HEALTH_VALUE_MAP)
    """Represents health state of resource and its dependent resources"""

    state = base.MappedField('State', res_maps.STATE_VALUE_MAP)
    """Indicates the known state of the resource, such as if it is enabled."""
Пример #6
0
class PhysicalSecurity(base.CompositeField):
    intrusion_sensor = base.MappedField('IntrusionSensor',
                                        cha_maps.CHASSIS_INTRUSION_SENSOR_MAP)
    """IntrusionSensor
    This indicates the known state of the physical security sensor, such as if
    it is hardware intrusion detected.
    """

    intrusion_sensor_number = base.Field('IntrusionSensorNumber')
    """A numerical identifier to represent the physical security sensor"""

    intrusion_sensor_re_arm = (base.MappedField(
        'IntrusionSensorReArm', cha_maps.CHASSIS_INTRUSION_SENSOR_RE_ARM_MAP))
    """This indicates how the Normal state to be restored"""
Пример #7
0
class Drive(base.ResourceBase):
    """This class represents the Drive resource"""

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

    media_type = base.MappedField('MediaType', mappings.MEDIA_TYPE_MAP)
    """The type of media contained in this drive"""

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

    rotation_speed_rpm = base.Field('RotationSpeedRPM', adapter=int)
    """The rotation speed of this Drive in Revolutions per Minute (RPM)."""
Пример #8
0
class IPv6AddressField(base.CompositeField):

    address = base.Field('Address')
    """This is the IPv6 Address."""

    prefix_length = base.Field('PrefixLength', adapter=utils.int_or_none)
    """This is the IPv6 Address Prefix Length."""

    address_origin = base.MappedField('AddressOrigin',
                                      fab_maps.ADDRESS_ORIGIN_IPv6_VALUE_MAP)
    """This indicates how the address was determined."""

    address_state = base.MappedField('AddressState',
                                     fab_maps.ADDRESS_STATE_VALUE_MAP)
    """The current state of this address as defined in RFC 4862."""
Пример #9
0
class MessageListField(base.ListField):
    """List of messages with details of settings update status"""

    message_id = base.Field('MessageId', required=True)
    """The key for this message which can be used
    to look up the message in a message registry
    """

    message = base.Field('Message')
    """Human readable message, if provided"""

    severity = base.MappedField('Severity',
                                res_maps.SEVERITY_VALUE_MAP)
    """Severity of the error"""

    resolution = base.Field('Resolution')
    """Used to provide suggestions on how to resolve
    the situation that caused the error
    """

    _related_properties = base.Field('RelatedProperties')
    """List of properties described by the message"""

    message_args = base.Field('MessageArgs')
    """List of message substitution arguments for the message
Пример #10
0
class MessageDictionaryField(base.DictionaryField):

    description = base.Field('Description', required=True)
    """Indicates how and when the message is returned by the Redfish service"""

    message = base.Field('Message', required=True)
    """Template text of the message

    Template can include placeholders for message arguments in form
    %<integer> where <integer> denotes a position passed from MessageArgs.
    """

    number_of_args = base.Field('NumberOfArgs', required=True)
    """Number of arguments to be expected to be passed in as MessageArgs
    for this message
    """

    param_types = base.Field('ParamTypes',
                             adapter=lambda x:
                                 [res_maps.PARAMTYPE_VALUE_MAP[v]
                                  for v in x])
    """Mapped MessageArg types, in order, for the message"""

    resolution = base.Field('Resolution', required=True)
    """Suggestions on how to resolve the situation that caused the error"""

    severity = base.MappedField('Severity',
                                res_maps.SEVERITY_VALUE_MAP,
                                required=True)
    """Mapped severity of the message"""
Пример #11
0
class InputRangeListField(base.ListField):
    """This type describes an input range for a power supply"""

    input_type = base.MappedField('InputType',
                                  pow_maps.POWER_SUPPLY_INPUT_TYPE_MAP)
    """The Input type (AC or DC)"""

    maximum_frequency_hz = base.Field('MaximumFrequencyHz',
                                      adapter=utils.int_or_none)
    """The maximum line input frequency at which this power supply input range
    is effective"""

    maximum_voltage = base.Field('MaximumVoltage', adapter=utils.int_or_none)
    """The maximum line input voltage at which this power supply input range
    is effective"""

    minimum_frequency_hz = base.Field('MinimumFrequencyHz',
                                      adapter=utils.int_or_none)
    """The minimum line input frequency at which this power supply input range
    is effective"""

    minimum_voltage = base.Field('MinimumVoltage', adapter=utils.int_or_none)
    """The minimum line input voltage at which this power supply input range
    is effective"""

    output_wattage = base.Field('OutputWattage', adapter=utils.int_or_none)
    """The maximum capacity of this Power Supply when operating in this input
Пример #12
0
class ResourceBlock(base.ResourceBase):

    composition_status = CompositionStatusField('CompositionStatus',
                                                required=True)
    """The composition state of resource block"""

    description = base.Field('Description')
    """The resource block description"""

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

    name = base.Field('Name', required=True)
    """The resource block name"""

    resource_block_type = base.MappedField(
        'ResourceBlockType',
        res_maps.RESOURCE_BLOCK_TYPE_VALUE_MAP,
        required=True)
    """The type of resource block"""

    status = common.StatusField('Status')
    """The status of resource block"""
    def __init__(self, connector, identity, redfish_version=None):
        """A class representing a ResourceBlock

        :param connector: A Connector instance
        :param identity: The identity of the ResourceBlock resource
        :param redfish_version: The version of RedFish. Used to construct
            the object according to schema of given version.
        """
        super(ResourceBlock, self).__init__(connector, identity,
                                            redfish_version)
Пример #13
0
class ComplexResource(resource_base.ResourceBase):
    string = resource_base.Field('String', required=True)
    integer = resource_base.Field('Integer', adapter=int)
    nested = NestedTestField('Nested')
    non_existing_nested = NestedTestField('NonExistingNested')
    non_existing_mapped = resource_base.MappedField('NonExistingMapped',
                                                    MAPPING)
Пример #14
0
class IdentifiersListField(base.ListField):
    """This type describes any additional identifiers for a resource."""

    durable_name = base.Field('DurableName')
    """This indicates the world wide, persistent name of the resource."""

    durable_name_format = base.MappedField('DurableNameFormat',
                                           res_maps.DUR_NAME_FORMAT_VALUE_MAP)
    """This represents the format of the DurableName property."""
Пример #15
0
class ComplexResource(resource_base.ResourceBase):
    string = resource_base.Field('String', required=True)
    integer = resource_base.Field('Integer', adapter=int)
    nested = NestedTestField('Nested')
    mapped_list = resource_base.MappedListField('MappedList', MAPPING)
    field_list = TestListField('ListField')
    dictionary = TestDictionaryField('Dictionary')
    non_existing_nested = NestedTestField('NonExistingNested')
    non_existing_mapped = resource_base.MappedField('NonExistingMapped',
                                                    MAPPING)
Пример #16
0
class SimpleUpdateActionField(common.ActionField):

    image_uri = base.Field('ImageURI')
    """The URI of the software image to be installed"""

    targets = base.Field('Targets')
    """The array of URIs indicating where the update image is to be""" + \
        """applied"""

    transfer_protocol = base.MappedField(
        'TransferProtocol', up_maps.TRANSFER_PROTOCOL_TYPE_VALUE_MAP)
    """The network protocol used by the Update Service"""
Пример #17
0
class HPELogicalDrive(base.ResourceBase):
    """This class represents the LogicalDrives resource"""

    identity = base.Field('Id')

    name = base.Field('Name')

    description = base.Field('Description')

    capacity_mib = base.Field('CapacityMiB', adapter=int)

    raid = base.MappedField('Raid', mappings.RAID_LEVEL_MAP)
Пример #18
0
class HPEPhysicalDrive(base.ResourceBase):
    """This class represents the HPEPhysicalDrives resource"""

    identity = base.Field('Id', required=True)

    name = base.Field('Name')

    description = base.Field('Description')

    capacity_mib = base.Field('CapacityMiB', adapter=int)

    media_type = base.MappedField('MediaType', mappings.MEDIA_TYPE_MAP)

    rotational_speed_rpm = base.Field('RotationalSpeedRpm', adapter=int)
Пример #19
0
class Processor(base.ResourceBase):

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

    socket = base.Field('Socket')
    """The socket or location of the processor"""

    # TODO(deray): Create mappings for the processor_type
    processor_type = base.Field('ProcessorType')
    """The type of processor"""

    processor_architecture = base.MappedField(
        'ProcessorArchitecture', sys_maps.PROCESSOR_ARCH_VALUE_MAP)
    """The architecture of the processor"""

    # TODO(deray): Create mappings for the instruction_set
    instruction_set = base.Field('InstructionSet')
    """The instruction set of the processor"""

    manufacturer = base.Field('Manufacturer')
    """The processor manufacturer"""

    model = base.Field('Model')
    """The product model number of this device"""

    max_speed_mhz = base.Field('MaxSpeedMHz', adapter=utils.int_or_none)
    """The maximum clock speed of the processor in MHz."""

    processor_id = ProcessorIdField('ProcessorId')
    """The processor id"""

    status = common.StatusField('Status')
    """The processor status"""

    total_cores = base.Field('TotalCores', adapter=utils.int_or_none)
    """The total number of cores contained in this processor"""

    total_threads = base.Field('TotalThreads', adapter=utils.int_or_none)
    """The total number of execution threads supported by this processor"""

    def __init__(self, connector, identity, redfish_version=None):
        """A class representing a Processor

        :param connector: A Connector instance
        :param identity: The identity of the processor
        :param redfish_version: The version of RedFish. Used to construct
            the object according to schema of the given version.
        """
        super(Processor, self).__init__(connector, identity, redfish_version)
Пример #20
0
class IPv4AddressField(base.CompositeField):

    address = base.Field('Address')
    """This is the IPv4 Address."""

    gateway = base.Field('Gateway')
    """This is the IPv4 gateway for this address."""

    subnet_mask = base.Field('SubnetMask')
    """This is the IPv4 Subnet mask."""

    address_origin = base.MappedField('AddressOrigin',
                                      fab_maps.ADDRESS_ORIGIN_IPv4_VALUE_MAP)
    """This indicates how the address was determined."""
Пример #21
0
class TaskService(base.ResourceBase):

    identity = base.Field('Id', required=True)
    """The task service identity"""

    name = base.Field('Name', required=True)
    """The task service name"""

    service_enabled = base.Field('ServiceEnabled')
    """The status of whether this service is enabled"""

    status = common.StatusField('Status')
    """The status of the task service"""

    overwrite_policy = base.MappedField(
        'CompletedTaskOverWritePolicy', ts_maps.OVERWRITE_POLICY_VALUE_MAP)
    """The overwrite policy for completed tasks"""

    event_on_task_state_change = base.Field(
        'LifeCycleEventOnTaskStateChange', adapter=bool)
    """Whether a task state change sends an event"""

    def __init__(self, connector, identity, redfish_version=None,
                 registries=None):
        """A class representing a TaskService

        :param connector: A Connector instance
        :param identity: The identity of the TaskService resource
        :param redfish_version: The version of RedFish. Used to construct
            the object according to schema of given version
        :param registries: Dict of Redfish Message Registry objects to be
            used in any resource that needs registries to parse messages
        """
        super(TaskService, self).__init__(
            connector, identity, redfish_version, registries)

    @property
    @utils.cache_it
    def tasks(self):
        """Property to reference `TaskCollection` instance

        It is set once when the first time it is queried. On refresh,
        this property is marked as stale (greedy-refresh not done).
        Here the actual refresh of the sub-resource happens, if stale.
        """
        return task.TaskCollection(
            self._conn, utils.get_sub_resource_path_by(self, 'Tasks'),
            redfish_version=self.redfish_version,
            registries=self.registries)
Пример #22
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."""
Пример #23
0
class Fabric(base.ResourceBase):
    """Fabric resource

    The Fabric represents a simple fabric consisting of one or more
    switches, zero or more endpoints, and zero or more zones.
    """

    identity = base.Field('Id', required=True)
    """Identifier for the fabric"""

    name = base.Field('Name', required=True)
    """The fabric name"""

    description = base.Field('Description')
    """The fabric description"""

    max_zones = base.Field('MaxZones', adapter=utils.int_or_none)
    """The maximum number of zones the switch can currently configure"""

    status = common.StatusField('Status')
    """The fabric status"""

    fabric_type = base.MappedField('FabricType',
                                   res_maps.PROTOCOL_TYPE_VALUE_MAP)
    """The protocol being sent over this fabric"""
    def __init__(self,
                 connector,
                 identity,
                 redfish_version=None,
                 registries=None):
        """A class representing a Fabric

        :param connector: A Connector instance
        :param identity: The identity of the Fabric resource
        :param redfish_version: The version of RedFish. Used to construct
            the object according to schema of the given version.
        :param registries: Dict of Redfish Message Registry objects to be
            used in any resource that needs registries to parse messages
        """
        super(Fabric, self).__init__(connector, identity, redfish_version,
                                     registries)

    @property
    @utils.cache_it
    def endpoints(self):
        return fab_endpoint.EndpointCollection(
            self._conn, utils.get_sub_resource_path_by(self, 'Endpoints'),
            self.redfish_version, self.registries)
Пример #24
0
class IPTransportDetailsListField(base.ListField):
    """IP transport details

    This array contains details for each IP transport supported by this
    endpoint. The array structure can be used to model multiple IP addresses
    for this endpoint.
    """

    port = base.Field('Port', adapter=utils.int_or_none)
    """The UDP or TCP port number used by the Endpoint."""

    transport_protocol = base.MappedField('TransportProtocol',
                                          res_maps.PROTOCOL_TYPE_VALUE_MAP)
    """The protocol used by the connection entity."""

    ipv4_address = IPv4AddressField('IPv4Address')
    """The IPv4 address object."""

    ipv6_address = IPv6AddressField('IPv6Address')
    """The IPv6 address object."""
Пример #25
0
class CompositionStatusField(base.CompositeField):

    composition_state = base.MappedField('CompositionState',
                                         res_maps.COMPOSITION_STATE_VALUE_MAP,
                                         required=True)
    """Inform the client, state of the resource block"""

    max_compositions = base.Field('MaxCompositions')
    """The maximum number of compositions"""

    number_of_compositions = base.Field('NumberOfCompositions')
    """The number of compositions"""

    reserved_state = base.Field('Reserved')
    """Inform the resource block has been identified by a client"""

    sharing_capable = base.Field('SharingCapable')
    """Indicates if this Resource Block is capable of participating in
    multiple compositions simultaneously"""

    sharing_enabled = base.Field('SharingEnabled')
    """Indicates if this Resource Block is allowed to participate in
Пример #26
0
class Endpoint(base.ResourceBase):
    """This class represents a fabric endpoint.

    It represents the properties of an entity that sends or receives protocol
    defined messages over a transport.
    """

    identity = base.Field('Id', required=True)
    """Identifier for the endpoint"""

    name = base.Field('Name', required=True)
    """The endpoint name"""

    description = base.Field('Description')
    """The endpoint description"""

    status = common.StatusField('Status')
    """The endpoint status"""

    host_reservation_memory_bytes = base.Field('HostReservationMemoryBytes',
                                               adapter=utils.int_or_none)
    """The amount of memory in Bytes that the Host should allocate to connect
    to this endpoint.
    """

    endpoint_protocol = base.MappedField('EndpointProtocol',
                                         res_maps.PROTOCOL_TYPE_VALUE_MAP)
    """The protocol supported by this endpoint."""

    pci_id = PciIdField('PciId')
    """The PCI ID of the endpoint."""

    IP_transport_details = IPTransportDetailsListField('IPTransportDetails')
    """This array contains details for each IP transport supported by this
    endpoint. The array structure can be used to model multiple IP addresses
    for this endpoint."""

    connected_entities = ConnectedEntitiesListField('ConnectedEntities')
    """All entities connected to this endpoint."""
Пример #27
0
class BIOSPendingSettings(base.ResourceBase):
    """Class that defines the functionality for BIOS pending settings."""

    boot_mode = base.MappedField(["Attributes", "BootMode"],
                                 mappings.GET_BIOS_BOOT_MODE_MAP)

    def set_pending_boot_mode(self, boot_mode):
        """Sets the boot mode of the system for next boot.

        :param boot_mode: either sys_cons.BIOS_BOOT_MODE_LEGACY_BIOS,
         sys_cons.BIOS_BOOT_MODE_UEFI.
        """
        bios_properties = {
            'BootMode': mappings.GET_BIOS_BOOT_MODE_MAP_REV.get(boot_mode)
        }

        if boot_mode == sys_cons.BIOS_BOOT_MODE_UEFI:
            bios_properties['UefiOptimizedBoot'] = 'Enabled'

        self.update_bios_data_by_patch(bios_properties)

    def update_bios_data_by_post(self, data):
        """Update bios data by post

        :param data: default bios config data
        """
        bios_settings_data = {'Attributes': data}
        self._conn.post(self.path, data=bios_settings_data)

    def update_bios_data_by_patch(self, data):
        """Update bios data by patch

        :param data: default bios config data
        """
        bios_settings_data = {'Attributes': data}
        self._conn.patch(self.path, data=bios_settings_data)
Пример #28
0
class Manager(base.ResourceBase):

    firmware_version = base.Field('FirmwareVersion')
    """The manager firmware version"""

    graphical_console = RemoteAccessField('GraphicalConsole')
    """A dictionary containing the remote access support service via
       graphical console (e.g. KVMIP) and max concurrent sessions
    """

    serial_console = RemoteAccessField('SerialConsole')
    """A dictionary containing the remote access support service via
       serial console (e.g. Telnet, SSH, IPMI) and max concurrent sessions
    """

    command_shell = RemoteAccessField('CommandShell')
    """A dictionary containing the remote access support service via
       command shell (e.g. Telnet, SSH) and max concurrent sessions
    """

    description = base.Field('Description')
    """The manager description"""

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

    name = base.Field('Name')
    """The manager name"""

    model = base.Field('Model')
    """The manager model"""

    manager_type = base.MappedField('ManagerType',
                                    mgr_maps.MANAGER_TYPE_VALUE_MAP)
    """The manager type"""

    uuid = base.Field('UUID')
    """The manager UUID"""

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

    def __init__(self, connector, identity, redfish_version=None):
        """A class representing a Manager

        :param connector: A Connector instance
        :param identity: The identity of the Manager resource
        :param redfish_version: The version of RedFish. Used to construct
            the object according to schema of the given version.
        """
        super(Manager, self).__init__(connector, identity, redfish_version)

    def get_supported_graphical_console_types(self):
        """Get the supported values for Graphical Console connection types.

        :returns: A set of supported values.
        """
        if (not self.graphical_console
                or not self.graphical_console.connect_types_supported):
            LOG.warning(
                'Could not figure out the supported values for '
                'remote access via graphical console for Manager %s',
                self.identity)
            return set(mgr_maps.GRAPHICAL_CONSOLE_VALUE_MAP_REV)

        return set([
            mgr_maps.GRAPHICAL_CONSOLE_VALUE_MAP[v]
            for v in set(mgr_maps.GRAPHICAL_CONSOLE_VALUE_MAP).intersection(
                self.graphical_console.connect_types_supported)
        ])

    def get_supported_serial_console_types(self):
        """Get the supported values for Serial Console connection types.

        :returns: A set of supported values.
        """
        if (not self.serial_console
                or not self.serial_console.connect_types_supported):
            LOG.warning(
                'Could not figure out the supported values for '
                'remote access via serial console for Manager %s',
                self.identity)
            return set(mgr_maps.SERIAL_CONSOLE_VALUE_MAP_REV)

        return set([
            mgr_maps.SERIAL_CONSOLE_VALUE_MAP[v]
            for v in set(mgr_maps.SERIAL_CONSOLE_VALUE_MAP).intersection(
                self.serial_console.connect_types_supported)
        ])

    def get_supported_command_shell_types(self):
        """Get the supported values for Command Shell connection types.

        :returns: A set of supported values.
        """
        if (not self.command_shell
                or not self.command_shell.connect_types_supported):
            LOG.warning(
                'Could not figure out the supported values for '
                'remote access via command shell for Manager %s',
                self.identity)
            return set(mgr_maps.COMMAND_SHELL_VALUE_MAP_REV)

        return set([
            mgr_maps.COMMAND_SHELL_VALUE_MAP[v]
            for v in set(mgr_maps.COMMAND_SHELL_VALUE_MAP).intersection(
                self.command_shell.connect_types_supported)
        ])

    def _get_reset_action_element(self):
        reset_action = self._actions.reset

        if not reset_action:
            raise exceptions.MissingActionError(action='#Manager.Reset',
                                                resource=self._path)
        return reset_action

    def get_allowed_reset_manager_values(self):
        """Get the allowed values for resetting the manager.

        :returns: A set of allowed values.
        :raises: MissingAttributeError, if Actions/#Manager.Reset attribute
            not present.
        """
        reset_action = self._get_reset_action_element()

        if not reset_action.allowed_values:
            LOG.warning(
                'Could not figure out the allowed values for the '
                'reset manager action for Manager %s', self.identity)
            return set(mgr_maps.RESET_MANAGER_VALUE_MAP_REV)

        return set([
            mgr_maps.RESET_MANAGER_VALUE_MAP[v]
            for v in set(mgr_maps.RESET_MANAGER_VALUE_MAP).intersection(
                reset_action.allowed_values)
        ])

    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)
Пример #29
0
class NestedTestField(resource_base.CompositeField):
    string = resource_base.Field('String', required=True)
    integer = resource_base.Field('Integer', adapter=int)
    nested_field = resource_base.Field(['Object', 'Field'], required=True)
    mapped = resource_base.MappedField('Mapped', MAPPING)
    non_existing = resource_base.Field('NonExisting', default=3.14)
Пример #30
0
class Chassis(base.ResourceBase):
    """Chassis resource

    The Chassis represents the physical components of a system. This
    resource represents the sheet-metal confined spaces and logical zones
    such as racks, enclosures, chassis and all other containers.
    """

    chassis_type = base.MappedField('ChassisType',
                                    cha_maps.CHASSIS_TYPE_VALUE_MAP,
                                    required=True)
    """The type of physical form factor of the chassis"""

    identity = base.Field('Id', required=True)
    """Identifier for the chassis"""

    name = base.Field('Name', required=True)
    """The chassis name"""

    asset_tag = base.Field('AssetTag')
    """The user assigned asset tag of this chassis"""

    depth_mm = base.Field('DepthMm')
    """Depth in millimeters
    The depth of the chassis. The value of this property shall represent
    the depth (length) of the chassis (in millimeters) as specified by the
    manufacturer.
    """

    description = base.Field('Description')
    """The chassis description"""

    height_mm = base.Field('HeightMm')
    """Height in millimeters
    The height of the chassis. The value of this property shall represent
    the height of the chassis (in millimeters) as specified by the
    manufacturer.
    """

    indicator_led = base.MappedField('IndicatorLED',
                                     res_maps.INDICATOR_LED_VALUE_MAP)
    """The state of the indicator LED, used to identify the chassis"""

    manufacturer = base.Field('Manufacturer')
    """The manufacturer of this chassis"""

    model = base.Field('Model')
    """The model number of the chassis"""

    part_number = base.Field('PartNumber')
    """The part number of the chassis"""

    physical_security = PhysicalSecurity('PhysicalSecurity')
    """PhysicalSecurity
    This value of this property shall contain the sensor state of the physical
    security.
    """

    power_state = base.MappedField('PowerState',
                                   res_maps.POWER_STATE_VALUE_MAP)
    """The current power state of the chassis"""

    serial_number = base.Field('SerialNumber')
    """The serial number of the chassis"""

    sku = base.Field('SKU')
    """Stock-keeping unit number (SKU)
    The value of this property shall be the stock-keeping unit number for
    this chassis.
    """

    status = common.StatusField('Status')
    """Status and Health
    This property describes the status and health of the chassis and its
    children.
    """

    uuid = base.Field('UUID')
    """The Universal Unique Identifier (UUID) for this Chassis."""

    weight_kg = base.Field('WeightKg')
    """Weight in kilograms
    The value of this property shall represent the published mass (commonly
    referred to as weight) of the chassis (in kilograms).
    """

    width_mm = base.Field('WidthMm')
    """Width in millimeters
    The value of this property shall represent the width of the chassis
    (in millimeters) as specified by the manufacturer.
    """

    _actions = ActionsField('Actions')

    def __init__(self,
                 connector,
                 identity,
                 redfish_version=None,
                 registries=None):
        """A class representing a Chassis

        :param connector: A Connector instance
        :param identity: The identity of the Chassis resource
        :param redfish_version: The version of RedFish. Used to construct
            the object according to schema of the given version.
        :param registries: Dict of Redfish Message Registry objects to be
            used in any resource that needs registries to parse messages
        """
        super(Chassis, self).__init__(connector, identity, redfish_version,
                                      registries)

    def _get_reset_action_element(self):
        reset_action = self._actions.reset

        if not reset_action:
            raise exceptions.MissingActionError(action='#Chassis.Reset',
                                                resource=self._path)
        return reset_action

    def get_allowed_reset_chassis_values(self):
        """Get the allowed values for resetting the chassis.

        :returns: A set of allowed values.
        :raises: MissingAttributeError, if Actions/#Chassis.Reset attribute
            not present.
        """
        reset_action = self._get_reset_action_element()

        if not reset_action.allowed_values:
            LOG.warning(
                'Could not figure out the allowed values for the '
                'reset chassis action for Chassis %s', self.identity)
            return set(res_maps.RESET_TYPE_VALUE_MAP_REV)

        return set([
            res_maps.RESET_TYPE_VALUE_MAP[v]
            for v in set(res_maps.RESET_TYPE_VALUE_MAP).intersection(
                reset_action.allowed_values)
        ])

    def reset_chassis(self, value):
        """Reset the chassis.

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

        value = res_maps.RESET_TYPE_VALUE_MAP_REV[value]
        target_uri = self._get_reset_action_element().target_uri

        LOG.debug('Resetting the Chassis %s ...', self.identity)
        self._conn.post(target_uri, data={'ResetType': value})
        LOG.info('The Chassis %s is being reset', self.identity)

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

    @property
    @utils.cache_it
    def managers(self):
        """A list of managers for this chassis.

        Returns a list of `Manager` objects representing the managers
        that manage this chassis.

        :raises: MissingAttributeError if '@odata.id' field is missing.
        :returns: A list of `Manager` instances
        """
        paths = utils.get_sub_resource_path_by(self, ["Links", "ManagedBy"],
                                               is_collection=True)

        return [
            manager.Manager(self._conn, path, self.redfish_version,
                            self.registries) for path in paths
        ]

    @property
    @utils.cache_it
    def systems(self):
        """A list of systems residing in this chassis.

        Returns a list of `System` objects representing systems being
        mounted in this chassis/cabinet.

        :raises: MissingAttributeError if '@odata.id' field is missing.
        :returns: A list of `System` instances
        """
        paths = utils.get_sub_resource_path_by(self,
                                               ["Links", "ComputerSystems"],
                                               is_collection=True)

        from sushy.resources.system import system
        return [
            system.System(self._conn, path, self.redfish_version,
                          self.registries) for path in paths
        ]

    @property
    @utils.cache_it
    def power(self):
        """Property to reference `Power` instance

        It is set once when the first time it is queried. On refresh,
        this property is marked as stale (greedy-refresh not done).
        Here the actual refresh of the sub-resource happens, if stale.
        """
        return power.Power(self._conn,
                           utils.get_sub_resource_path_by(self, 'Power'),
                           self.redfish_version, self.registries)

    @property
    @utils.cache_it
    def thermal(self):
        """Property to reference `Thermal` instance

        It is set once when the first time it is queried. On refresh,
        this property is marked as stale (greedy-refresh not done).
        Here the actual refresh of the sub-resource happens, if stale.
        """
        return thermal.Thermal(self._conn,
                               utils.get_sub_resource_path_by(self, 'Thermal'),
                               self.redfish_version, self.registries)