Merge "Migrate System Network to enums"
This commit is contained in:
@@ -26,6 +26,7 @@ from sushy.resources.ipaddresses import * # noqa
|
||||
from sushy.resources.manager.constants import * # noqa
|
||||
from sushy.resources.registry.constants import * # noqa
|
||||
from sushy.resources.system.constants import * # noqa
|
||||
from sushy.resources.system.network.constants import * # noqa
|
||||
from sushy.resources.system.storage.constants import * # noqa
|
||||
from sushy.resources.updateservice.constants import * # noqa
|
||||
from sushy.resources.taskservice.constants import * # noqa
|
||||
|
||||
@@ -11,79 +11,110 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
# AuthenticationMethod Types
|
||||
# Values comes from the Redfish System json-schema:
|
||||
# https://redfish.dmtf.org/schemas/v1/NetworkDeviceFunction.v1_7_0.json
|
||||
# https://redfish.dmtf.org/schemas/v1/NetworkPort.v1_4_1.json
|
||||
# Using Network prefix since some names are too generic.
|
||||
|
||||
AUTHENTICATION_METHOD_CHAP = 'iSCSI Challenge Handshake'\
|
||||
'Authentication Protocol'
|
||||
"""
|
||||
iSCSI Challenge Handshake Authentication Protocol (CHAP)
|
||||
authentication is used.
|
||||
"""
|
||||
import enum
|
||||
|
||||
AUTHENTICATION_METHOD_MUTUAL_CHAP = 'iSCSI Mutual Challenge Handshake'\
|
||||
'Authentication Protocol'
|
||||
"""
|
||||
iSCSI Mutual Challenge Handshake Authentication Protocol (CHAP)
|
||||
authentication is used.
|
||||
"""
|
||||
|
||||
AUTHENTICATION_METHOD_NONE = 'none'
|
||||
"""No iSCSI authentication is used."""
|
||||
class NetworkAuthenticationMethod(enum.Enum):
|
||||
|
||||
# BootMode Types
|
||||
NONE = 'None'
|
||||
"""No iSCSI authentication is used."""
|
||||
|
||||
BOOT_MODE_DISABLED = 'disabled'
|
||||
"""Do not indicate to UEFI/BIOS that this device is bootable."""
|
||||
CHAP = 'CHAP'
|
||||
"""iSCSI Challenge Handshake Authentication Protocol (CHAP)
|
||||
authentication is used."""
|
||||
|
||||
BOOT_MODE_PXE = 'pxe'
|
||||
"""Boot this device by PXE"""
|
||||
MUTUAL_CHAP = 'MutualCHAP'
|
||||
"""iSCSI Mutual Challenge Handshake Authentication Protocol (CHAP)
|
||||
authentication is used."""
|
||||
|
||||
# IP Address Types
|
||||
|
||||
IP_ADDRESS_TYPE_IPV4 = 'IPv4'
|
||||
"""IPv4 addressing is used for all IP-fields in this object."""
|
||||
class NetworkBootMode(enum.Enum):
|
||||
|
||||
IP_ADDRESS_TYPE_IPV6 = 'IPv6'
|
||||
"""IPv6 addressing is used for all IP-fields in this object."""
|
||||
DISABLED = 'Disabled'
|
||||
"""Do not indicate to UEFI/BIOS that this device is bootable."""
|
||||
|
||||
# FlowControl Types
|
||||
PXE = 'PXE'
|
||||
"""Boot this device by using the embedded PXE support. Only applicable
|
||||
if the NetDevFuncType is `Ethernet` or `InfiniBand`."""
|
||||
|
||||
FLOW_CONTROL_NONE = 'none'
|
||||
"""No IEEE 802.3x flow control is enabled on this port."""
|
||||
SCSI = 'iSCSI'
|
||||
"""Boot this device by using the embedded iSCSI boot support and
|
||||
configuration. Only applicable if the NetDevFuncType is `iSCSI` or
|
||||
`Ethernet`."""
|
||||
|
||||
FLOW_CONTROL_RX = 'rx'
|
||||
"""IEEE 802.3x flow control may be initiated by the link partner."""
|
||||
FIBRE_CHANNEL = 'FibreChannel'
|
||||
"""Boot this device by using the embedded Fibre Channel support and
|
||||
configuration. Only applicable if the NetDevFuncType is
|
||||
`FibreChannel`."""
|
||||
|
||||
FLOW_CONTROL_TX = 'tx'
|
||||
"""IEEE 802.3x flow control may be initiated by this station."""
|
||||
FIBRE_CHANNEL_OVER_ETHERNET = 'FibreChannelOverEthernet'
|
||||
"""Boot this device by using the embedded Fibre Channel over Ethernet
|
||||
(FCoE) boot support and configuration. Only applicable if the
|
||||
NetDevFuncType is `FibreChannelOverEthernet`."""
|
||||
|
||||
FLOW_CONTROL_TX_RX = 'tx/rx'
|
||||
"""
|
||||
IEEE 802.3x flow control may be initiated
|
||||
by this station or the link partner.
|
||||
"""
|
||||
|
||||
# NetworkDeviceTechnology Types
|
||||
class IPAddressType(enum.Enum):
|
||||
|
||||
NETWORK_DEVICE_TECHNOLOGY_DISABLED = 'disabled'
|
||||
"""Neither enumerated nor visible to the operating system."""
|
||||
IPV4 = 'IPv4'
|
||||
"""IPv4 addressing is used for all IP-fields in this object."""
|
||||
|
||||
NETWORK_DEVICE_TECHNOLOGY_ETHERNET = 'ethernet'
|
||||
"""Appears to the operating system as an Ethernet device."""
|
||||
IPV6 = 'IPv6'
|
||||
"""IPv6 addressing is used for all IP-fields in this object."""
|
||||
|
||||
NETWORK_DEVICE_TECHNOLOGY_FIBRE_CHANNEL = 'fibre channel'
|
||||
"""Appears to the operating system as a Fibre Channel device."""
|
||||
|
||||
NETWORK_DEVICE_TECHNOLOGY_FCOE = 'fibre channel over ethernet'
|
||||
"""Appears to the operating system as an FCoE device."""
|
||||
class FlowControl(enum.Enum):
|
||||
|
||||
NETWORK_DEVICE_TECHNOLOGY_ISCSI = 'Internet SCSI'
|
||||
"""Appears to the operating system as an iSCSI device."""
|
||||
NONE = 'None'
|
||||
"""No IEEE 802.3x flow control is enabled on this port."""
|
||||
|
||||
# LinkStatus Types
|
||||
TX = 'TX'
|
||||
"""This station can initiate IEEE 802.3x flow control."""
|
||||
|
||||
LINK_STATUS_DOWN = 'down'
|
||||
"""The port is enabled but link is down."""
|
||||
RX = 'RX'
|
||||
"""The link partner can initiate IEEE 802.3x flow control."""
|
||||
|
||||
LINK_STATUS_UP = 'up'
|
||||
"""The port is enabled and link is good (up)."""
|
||||
TX_RX = 'TX_RX'
|
||||
"""This station or the link partner can initiate IEEE 802.3x flow
|
||||
control."""
|
||||
|
||||
|
||||
class NetworkDeviceTechnology(enum.Enum):
|
||||
|
||||
DISABLED = 'Disabled'
|
||||
"""Neither enumerated nor visible to the operating system."""
|
||||
|
||||
ETHERNET = 'Ethernet'
|
||||
"""Appears to the operating system as an Ethernet device."""
|
||||
|
||||
FIBRE_CHANNEL = 'FibreChannel'
|
||||
"""Appears to the operating system as a Fibre Channel device."""
|
||||
|
||||
iSCSI = 'iSCSI'
|
||||
"""Appears to the operating system as an iSCSI device."""
|
||||
|
||||
FIBRE_CHANNEL_OVER_ETHERNET = 'FibreChannelOverEthernet'
|
||||
"""Appears to the operating system as an FCoE device."""
|
||||
|
||||
INFINI_BAND = 'InfiniBand'
|
||||
"""Appears to the operating system as an InfiniBand device."""
|
||||
|
||||
|
||||
class LinkStatus(enum.Enum):
|
||||
|
||||
DOWN = 'Down'
|
||||
"""The port is enabled but link is down."""
|
||||
|
||||
UP = 'Up'
|
||||
"""The port is enabled and link is good (up)."""
|
||||
|
||||
STARTING = 'Starting'
|
||||
"""This link on this interface is starting. A physical link has been
|
||||
established, but the port is not able to transfer data."""
|
||||
|
||||
TRAINING = 'Training'
|
||||
"""This physical link on this interface is training."""
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
from sushy.resources import base
|
||||
from sushy.resources import common
|
||||
from sushy.resources.system.network import mappings as net_maps
|
||||
from sushy.resources.system.network import constants
|
||||
from sushy.resources.system.network import port
|
||||
from sushy import utils
|
||||
|
||||
@@ -39,7 +39,7 @@ class VLANField(base.CompositeField):
|
||||
|
||||
class ISCSIBootField(base.CompositeField):
|
||||
authentication_method = base.MappedField(
|
||||
'AuthenticationMethod', net_maps.AUTHENTICATION_METHOD_TYPE_MAP)
|
||||
'AuthenticationMethod', constants.NetworkAuthenticationMethod)
|
||||
"""The configured capability of this network device function."""
|
||||
|
||||
initiator_default_gateway = base.Field('InitiatorDefaultGateway')
|
||||
@@ -52,7 +52,7 @@ class ISCSIBootField(base.CompositeField):
|
||||
"""The IPv6 or IPv4 netmask of the iSCSI boot initiator."""
|
||||
|
||||
ip_address_type = base.MappedField(
|
||||
'IPAddressType', net_maps.IP_ADDRESS_TYPE_MAP)
|
||||
'IPAddressType', constants.IPAddressType)
|
||||
"""The type of IP address being populated IP address fields."""
|
||||
|
||||
primary_dns = base.Field('PrimaryDNS')
|
||||
@@ -120,11 +120,11 @@ class FibreChannelField(base.CompositeField):
|
||||
|
||||
class NetworkDeviceFunction(base.ResourceBase):
|
||||
capabilities = base.MappedListField(
|
||||
'NetDevFuncCapabilities', net_maps.NETWORK_TECHNOLOGY_TYPE_MAP)
|
||||
'NetDevFuncCapabilities', constants.NetworkDeviceTechnology)
|
||||
"""An array of capabilities for this network device function."""
|
||||
|
||||
type = base.MappedField(
|
||||
'NetDevFuncType', net_maps.NETWORK_TECHNOLOGY_TYPE_MAP)
|
||||
'NetDevFuncType', constants.NetworkDeviceTechnology)
|
||||
"""The configured capability of this network device function."""
|
||||
|
||||
description = base.Field('Description')
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
# Copyright (c) 2021 Anexia Internetdienstleistungs GmbH
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from sushy.resources.system.network import constants as net_cons
|
||||
|
||||
AUTHENTICATION_METHOD_TYPE_MAP = {
|
||||
'CHAP': net_cons.AUTHENTICATION_METHOD_CHAP,
|
||||
'MutualCHAP': net_cons.AUTHENTICATION_METHOD_MUTUAL_CHAP,
|
||||
'None': net_cons.AUTHENTICATION_METHOD_NONE
|
||||
}
|
||||
|
||||
BOOT_MODE_TYPE_MAP = {
|
||||
'Disabled': net_cons.BOOT_MODE_DISABLED,
|
||||
'FibreChannel': net_cons.NETWORK_DEVICE_TECHNOLOGY_FIBRE_CHANNEL,
|
||||
'FibreChannelOverEthernet': net_cons.NETWORK_DEVICE_TECHNOLOGY_FCOE,
|
||||
'PXE': net_cons.BOOT_MODE_PXE,
|
||||
'iSCSI': net_cons.NETWORK_DEVICE_TECHNOLOGY_ISCSI
|
||||
}
|
||||
|
||||
IP_ADDRESS_TYPE_MAP = {
|
||||
'IPv4': net_cons.IP_ADDRESS_TYPE_IPV4,
|
||||
'IPv6': net_cons.IP_ADDRESS_TYPE_IPV6,
|
||||
}
|
||||
|
||||
LINK_STATUS_TYPE_MAP = {
|
||||
'Up': net_cons.LINK_STATUS_UP,
|
||||
'Down': net_cons.LINK_STATUS_DOWN,
|
||||
}
|
||||
|
||||
FLOW_CONTROL_TYPE_MAP = {
|
||||
'None': net_cons.FLOW_CONTROL_NONE,
|
||||
'TX': net_cons.FLOW_CONTROL_TX,
|
||||
'RX': net_cons.FLOW_CONTROL_RX,
|
||||
'TX_RX': net_cons.FLOW_CONTROL_TX_RX,
|
||||
}
|
||||
|
||||
NETWORK_TECHNOLOGY_TYPE_MAP = {
|
||||
'Disabled': net_cons.NETWORK_DEVICE_TECHNOLOGY_DISABLED,
|
||||
'Ethernet': net_cons.NETWORK_DEVICE_TECHNOLOGY_ETHERNET,
|
||||
'FibreChannel': net_cons.NETWORK_DEVICE_TECHNOLOGY_FIBRE_CHANNEL,
|
||||
'iSCSI': net_cons.NETWORK_DEVICE_TECHNOLOGY_ISCSI,
|
||||
'FibreChannelOverEthernet': net_cons.NETWORK_DEVICE_TECHNOLOGY_FCOE
|
||||
}
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
from sushy.resources import base
|
||||
from sushy.resources import common
|
||||
from sushy.resources.system.network import mappings as net_maps
|
||||
from sushy.resources.system.network import constants
|
||||
|
||||
|
||||
class NetworkPortCollection(base.ResourceCollectionBase):
|
||||
@@ -40,23 +40,18 @@ class NetworkPort(base.ResourceBase):
|
||||
description = base.Field('Description')
|
||||
"""The network port description"""
|
||||
|
||||
flow_control_configuration = base.MappedField(
|
||||
'FlowControlConfiguration',
|
||||
net_maps.FLOW_CONTROL_TYPE_MAP
|
||||
)
|
||||
flow_control_configuration = base.MappedField('FlowControlConfiguration',
|
||||
constants.FlowControl)
|
||||
"""The locally configured 802.3x flow control setting."""
|
||||
|
||||
flow_control_status = base.MappedField('FlowControlStatus',
|
||||
net_maps.FLOW_CONTROL_TYPE_MAP)
|
||||
constants.FlowControl)
|
||||
"""The 802.3x flow control behavior negotiated with the link partner"""
|
||||
|
||||
identity = base.Field('Id', required=True)
|
||||
"""The network port identity"""
|
||||
|
||||
link_status = base.MappedField(
|
||||
'LinkStatus',
|
||||
net_maps.LINK_STATUS_TYPE_MAP
|
||||
)
|
||||
link_status = base.MappedField('LinkStatus', constants.LinkStatus)
|
||||
"""The link status of the network port."""
|
||||
|
||||
name = base.Field(
|
||||
|
||||
@@ -42,17 +42,16 @@ class NetworkDeviceFunctionTestCase(base.TestCase):
|
||||
self.assertEqual('NIC.Integrated.1-2-1', self.function.identity)
|
||||
self.assertEqual('NetworkDeviceFunction', self.function.name)
|
||||
self.assertEqual('NetworkDeviceFunction', self.function.description)
|
||||
self.assertEqual(res_cons.STATE_ENABLED, self.function.status.state)
|
||||
self.assertEqual(res_cons.HEALTH_OK,
|
||||
self.function.status.health)
|
||||
self.assertEqual(res_cons.HEALTH_OK,
|
||||
self.assertEqual(res_cons.State.ENABLED, self.function.status.state)
|
||||
self.assertEqual(res_cons.Health.OK, self.function.status.health)
|
||||
self.assertEqual(res_cons.Health.OK,
|
||||
self.function.status.health_rollup)
|
||||
self.assertEqual(self.function.type,
|
||||
net_cons.NETWORK_DEVICE_TECHNOLOGY_ETHERNET)
|
||||
net_cons.NetworkDeviceTechnology.ETHERNET)
|
||||
self.assertEqual([
|
||||
net_cons.NETWORK_DEVICE_TECHNOLOGY_DISABLED,
|
||||
net_cons.NETWORK_DEVICE_TECHNOLOGY_ETHERNET,
|
||||
net_cons.NETWORK_DEVICE_TECHNOLOGY_ISCSI,
|
||||
net_cons.NetworkDeviceTechnology.DISABLED,
|
||||
net_cons.NetworkDeviceTechnology.ETHERNET,
|
||||
net_cons.NetworkDeviceTechnology.iSCSI,
|
||||
], self.function.capabilities)
|
||||
self.assertEqual(1,
|
||||
len(self.function.fibre_channel.boot_targets))
|
||||
@@ -73,9 +72,9 @@ class NetworkDeviceFunctionTestCase(base.TestCase):
|
||||
self.assertEqual(1,
|
||||
self.function.ethernet.vlan.vlan_id)
|
||||
self.assertTrue(self.function.ethernet.vlan.vlan_enabled)
|
||||
self.assertEqual(net_cons.AUTHENTICATION_METHOD_NONE,
|
||||
self.assertEqual(net_cons.NetworkAuthenticationMethod.NONE,
|
||||
self.function.iscsi_boot.authentication_method)
|
||||
self.assertEqual(net_cons.IP_ADDRESS_TYPE_IPV4,
|
||||
self.assertEqual(net_cons.IPAddressType.IPV4,
|
||||
self.function.iscsi_boot.ip_address_type)
|
||||
self.assertEqual('0.0.0.0',
|
||||
self.function.iscsi_boot.initiator_ip_address)
|
||||
|
||||
@@ -40,17 +40,17 @@ class NetworkPortTestCase(base.TestCase):
|
||||
self.assertEqual('NIC.Integrated.1-1', self.port.identity)
|
||||
self.assertEqual('Network Port View', self.port.name)
|
||||
self.assertEqual('Network Port View', self.port.description)
|
||||
self.assertEqual(res_cons.STATE_ENABLED, self.port.status.state)
|
||||
self.assertEqual(res_cons.HEALTH_OK, self.port.status.health)
|
||||
self.assertEqual(res_cons.HEALTH_OK, self.port.status.health_rollup)
|
||||
self.assertEqual(res_cons.State.ENABLED, self.port.status.state)
|
||||
self.assertEqual(res_cons.Health.OK, self.port.status.health)
|
||||
self.assertEqual(res_cons.Health.OK, self.port.status.health_rollup)
|
||||
self.assertEqual(['01:02:03:04:05:06'],
|
||||
self.port.associated_network_addresses)
|
||||
self.assertEqual(10000, self.port.current_link_speed_mbps)
|
||||
self.assertEqual(net_cons.FLOW_CONTROL_NONE,
|
||||
self.assertEqual(net_cons.FlowControl.NONE,
|
||||
self.port.flow_control_configuration)
|
||||
self.assertEqual(net_cons.FLOW_CONTROL_NONE,
|
||||
self.assertEqual(net_cons.FlowControl.NONE,
|
||||
self.port.flow_control_status)
|
||||
self.assertEqual(net_cons.LINK_STATUS_UP, self.port.link_status)
|
||||
self.assertEqual(net_cons.LinkStatus.UP, self.port.link_status)
|
||||
|
||||
|
||||
class NetworkPortCollectionTestCase(base.TestCase):
|
||||
|
||||
Reference in New Issue
Block a user