Remove duplicate ethernet interface class in manager
The ethernet interface in manager is identical with system network interface, so remove one duplicate copy. Change-Id: I27aee43f50d1d97bf83c728a37484a7bd947e4ad
This commit is contained in:
parent
c487703cf1
commit
bf81ec72f8
@ -16,9 +16,8 @@
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
|
||||
from rsd_lib.resources.v2_1.manager import ethernet_interface
|
||||
from rsd_lib.resources.v2_1.manager import network_protocol
|
||||
from rsd_lib.resources.v2_1.system import ethernet_interface
|
||||
from rsd_lib import utils as rsd_lib_utils
|
||||
|
||||
|
||||
|
@ -13,13 +13,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rsd_lib.resources.v2_1.ethernet_switch import vlan
|
||||
from rsd_lib import utils as rsd_lib_utils
|
||||
|
||||
from sushy import exceptions
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib.resources.v2_1.ethernet_switch import vlan
|
||||
from rsd_lib import utils as rsd_lib_utils
|
||||
|
||||
|
||||
class StatusField(base.CompositeField):
|
||||
state = base.Field('State')
|
||||
@ -37,7 +36,7 @@ class IPv4AddressesField(base.ListField):
|
||||
address_origin = base.Field("AddressOrigin")
|
||||
"""The IPv4Addresses addressorigin"""
|
||||
|
||||
gate_way = base.Field("Gateway")
|
||||
gateway = base.Field("Gateway")
|
||||
"""The IPv4Addresses gateway"""
|
||||
|
||||
|
||||
@ -170,10 +169,7 @@ class EthernetInterface(base.ResourceBase):
|
||||
|
||||
def _get_vlan_collection_path(self):
|
||||
"""Helper function to find the VLANCollection path"""
|
||||
try:
|
||||
return utils.get_sub_resource_path_by(self, 'VLANs')
|
||||
except exceptions.MissingAttributeError:
|
||||
return None
|
||||
return utils.get_sub_resource_path_by(self, 'VLANs')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
@ -183,13 +179,9 @@ class EthernetInterface(base.ResourceBase):
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
path = self._get_vlan_collection_path()
|
||||
if path:
|
||||
return vlan.VLANCollection(
|
||||
self._conn, path,
|
||||
redfish_version=self.redfish_version)
|
||||
else:
|
||||
return None
|
||||
return vlan.VLANCollection(
|
||||
self._conn, self._get_vlan_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class EthernetInterfaceCollection(base.ResourceCollectionBase):
|
@ -1,156 +0,0 @@
|
||||
# Copyright 2018 99cloud, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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 import base
|
||||
|
||||
from rsd_lib import utils as rsd_lib_utils
|
||||
|
||||
|
||||
class StatusField(base.CompositeField):
|
||||
state = base.Field('State')
|
||||
health = base.Field('Health')
|
||||
health_rollup = base.Field('HealthRollup')
|
||||
|
||||
|
||||
class IPv4AddressesField(base.ListField):
|
||||
address = base.Field('Address')
|
||||
subnet_mask = base.Field('SubnetMask')
|
||||
address_origin = base.Field('AddressOrigin')
|
||||
gateway = base.Field('Gateway')
|
||||
|
||||
|
||||
class IPv6AddressesField(base.ListField):
|
||||
address = base.Field('Address')
|
||||
prefix_length = base.Field('PrefixLength')
|
||||
address_origin = base.Field('AddressOrigin')
|
||||
address_state = base.Field('AddressState')
|
||||
|
||||
|
||||
class IPv6StaticAddressesField(base.ListField):
|
||||
address = base.Field('Address')
|
||||
prefix_length = base.Field('PrefixLength')
|
||||
|
||||
|
||||
class VLANField(base.CompositeField):
|
||||
vlan_enable = base.Field('VLANEnable', adapter=bool)
|
||||
vlan_id = base.Field('VLANId',
|
||||
adapter=rsd_lib_utils.num_or_none)
|
||||
|
||||
|
||||
class NetworkInterface(base.ResourceBase):
|
||||
|
||||
name = base.Field('Name')
|
||||
"""The network interface name"""
|
||||
|
||||
identity = base.Field('Id')
|
||||
"""The network interface identity"""
|
||||
|
||||
description = base.Field('Description')
|
||||
"""The network interface description"""
|
||||
|
||||
status = StatusField('Status')
|
||||
"""The network interface status"""
|
||||
|
||||
interface_enabled = base.Field('InterfaceEnabled', adapter=bool)
|
||||
"""The boolean indicate this network interface is enabled or not"""
|
||||
|
||||
permanent_mac_address = base.Field('PermanentMACAddress')
|
||||
"""The network interface permanent mac address"""
|
||||
|
||||
mac_address = base.Field('MACAddress')
|
||||
"""The network interface mac address"""
|
||||
|
||||
speed_mbps = base.Field('SpeedMbps')
|
||||
"""The network interface speed"""
|
||||
|
||||
auto_neg = base.Field('AutoNeg', adapter=bool)
|
||||
"""Indicates if the speed and duplex is automatically configured
|
||||
by the NIC
|
||||
"""
|
||||
|
||||
full_duplex = base.Field('FullDuplex', adapter=bool)
|
||||
"""Indicates if the NIC is in Full Duplex mode or not"""
|
||||
|
||||
mtu_size = base.Field('MTUSize',
|
||||
adapter=rsd_lib_utils.num_or_none)
|
||||
"""The network interface mtu size"""
|
||||
|
||||
host_name = base.Field('HostName')
|
||||
"""The network interface host name"""
|
||||
|
||||
fqdn = base.Field('FQDN')
|
||||
"""Fully qualified domain name obtained by DNS for this interface"""
|
||||
|
||||
ipv6_default_gateway = base.Field('IPv6DefaultGateway')
|
||||
"""Default gateway address that is currently in use on this interface"""
|
||||
|
||||
max_ipv6_static_addresses = base.Field('MaxIPv6StaticAddresses',
|
||||
adapter=rsd_lib_utils.num_or_none)
|
||||
"""Indicates the maximum number of Static IPv6 addresses that can be
|
||||
configured on this interface
|
||||
"""
|
||||
|
||||
name_servers = base.Field('NameServers')
|
||||
"""The network interface nameserver"""
|
||||
|
||||
ipv4_addresses = IPv4AddressesField('IPv4Addresses')
|
||||
"""The network interface ipv4 address"""
|
||||
|
||||
ipv6_addresses = IPv6AddressesField('IPv6Addresses')
|
||||
"""The network interface ipv6 address"""
|
||||
|
||||
ipv6_static_addresses = IPv6StaticAddressesField('IPv6StaticAddresses')
|
||||
"""The network interface ipv6 static address"""
|
||||
|
||||
vlan = VLANField('VLAN')
|
||||
"""The network interface vlan collection"""
|
||||
|
||||
oem = base.Field('oem')
|
||||
"""The network interface oem field"""
|
||||
|
||||
links = base.Field('links')
|
||||
"""The network interface links field"""
|
||||
|
||||
def __init__(self, connector, identity, redfish_version=None):
|
||||
"""A class representing a Network Interface
|
||||
|
||||
:param connector: A Connector instance
|
||||
:param identity: The identity of the Network Interface
|
||||
:param redfish_version: The version of RedFish. Used to construct
|
||||
the object according to schema of the given version.
|
||||
"""
|
||||
super(NetworkInterface, self).__init__(connector,
|
||||
identity,
|
||||
redfish_version)
|
||||
|
||||
|
||||
class NetworkInterfaceCollection(base.ResourceCollectionBase):
|
||||
|
||||
@property
|
||||
def _resource_type(self):
|
||||
return NetworkInterface
|
||||
|
||||
def __init__(self, connector, path, redfish_version=None):
|
||||
"""A class representing a NetworkInterfaceCollection
|
||||
|
||||
:param connector: A Connector instance
|
||||
:param path: The canonical path to the network interface collection
|
||||
resource
|
||||
:param redfish_version: The version of RedFish. Used to construct
|
||||
the object according to schema of the given version.
|
||||
"""
|
||||
super(NetworkInterfaceCollection, self).__init__(connector,
|
||||
path,
|
||||
redfish_version)
|
@ -16,8 +16,8 @@
|
||||
from sushy.resources.system import system
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib.resources.v2_1.system import ethernet_interface
|
||||
from rsd_lib.resources.v2_1.system import memory
|
||||
from rsd_lib.resources.v2_1.system import network_interface
|
||||
from rsd_lib.resources.v2_1.system import storage_subsystem
|
||||
|
||||
|
||||
@ -55,20 +55,20 @@ class System(system.System):
|
||||
self._conn, self._get_storage_subsystem_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_network_interface_collection_path(self):
|
||||
def _get_ethernet_interface_collection_path(self):
|
||||
"""Helper function to find the network interface path"""
|
||||
return utils.get_sub_resource_path_by(self, 'EthernetInterfaces')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def network_interface(self):
|
||||
"""Property to provide reference to `NetworkInterface` instance
|
||||
def ethernet_interface(self):
|
||||
"""Property to provide reference to `EthernetInterface` instance
|
||||
|
||||
It is calculated once the first time it is queried. On refresh,
|
||||
this property is reset.
|
||||
"""
|
||||
return network_interface.NetworkInterfaceCollection(
|
||||
self._conn, self._get_network_interface_collection_path(),
|
||||
return ethernet_interface.EthernetInterfaceCollection(
|
||||
self._conn, self._get_ethernet_interface_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
|
@ -1,42 +0,0 @@
|
||||
# Copyright 2019 Intel, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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 import base
|
||||
|
||||
|
||||
from rsd_lib.resources.v2_1.manager import ethernet_interface as \
|
||||
v2_1_ethernet_interface
|
||||
|
||||
|
||||
class EthernetInterfaceCollection(v2_1_ethernet_interface.
|
||||
EthernetInterfaceCollection):
|
||||
|
||||
description = base.Field("Description")
|
||||
"""The ethernet interface description"""
|
||||
|
||||
def __init__(self, connector, path, redfish_version=None):
|
||||
"""A class representing a EthernetInterface Collection
|
||||
|
||||
:param connector: A Connector instance
|
||||
:param path: The canonical path to the EthernetInterface collection
|
||||
resource
|
||||
:param redfish_version: The version of RedFish. Used to construct
|
||||
the object according to schema of the given version.
|
||||
"""
|
||||
|
||||
super(EthernetInterfaceCollection, self).__init__(connector,
|
||||
path,
|
||||
redfish_version)
|
@ -13,12 +13,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from rsd_lib.resources.v2_1.manager import manager as v2_1_manager
|
||||
|
||||
from rsd_lib.resources.v2_2.manager import ethernet_interface
|
||||
|
||||
from sushy.resources import base
|
||||
from sushy import utils
|
||||
|
||||
from rsd_lib.resources.v2_1.manager import manager as v2_1_manager
|
||||
|
||||
|
||||
class ManagerResetFiled(base.CompositeField):
|
||||
@ -28,31 +25,17 @@ class ManagerResetFiled(base.CompositeField):
|
||||
|
||||
class ActionsField(base.CompositeField):
|
||||
manager_reset = ManagerResetFiled("#Manager.Reset")
|
||||
"""The acyions manager reset """
|
||||
"""The actions manager reset """
|
||||
|
||||
|
||||
class Manager(v2_1_manager.Manager):
|
||||
|
||||
actions = ActionsField("Actions")
|
||||
"""The manager actions"""
|
||||
|
||||
def _get_ethernet_interface_path(self):
|
||||
"""Helper function to find the Ethernet Interface path"""
|
||||
return utils.get_sub_resource_path_by(self, 'EthernetInterfaces')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def ethernet_interface(self):
|
||||
"""Property to provide reference to `EthernetInterface` instance
|
||||
|
||||
It is calculated once when it is queried for the first time. On
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
return ethernet_interface.EthernetInterfaceCollection(
|
||||
self._conn, self._get_ethernet_interface_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
class ManagerCollection(base.ResourceCollectionBase):
|
||||
|
||||
description = base.Field("Description")
|
||||
"""The manager collection description"""
|
||||
|
||||
|
@ -1,61 +0,0 @@
|
||||
{
|
||||
"@odata.context":"/redfish/v1/$metadata#EthernetInterface.EthernetInterface",
|
||||
"@odata.id":"/redfish/v1/Systems/System1/EthernetInterfaces/LAN1",
|
||||
"@odata.type":"#EthernetInterface.v1_1_0.EthernetInterface",
|
||||
"Id":"LAN1",
|
||||
"Name":"Ethernet Interface",
|
||||
"Description":"System NIC 1",
|
||||
"Status":{
|
||||
"State":"Enabled",
|
||||
"Health":"OK",
|
||||
"HealthRollup":null
|
||||
},
|
||||
"InterfaceEnabled":true,
|
||||
"PermanentMACAddress":"AA:BB:CC:DD:EE:FF",
|
||||
"MACAddress":"AA:BB:CC:DD:EE:FF",
|
||||
"SpeedMbps":100,
|
||||
"AutoNeg":true,
|
||||
"FullDuplex":true,
|
||||
"MTUSize":1500,
|
||||
"HostName":"web483",
|
||||
"FQDN":"web483.redfishspecification.org",
|
||||
"IPv6DefaultGateway":"fe80::3ed9:2bff:fe34:600",
|
||||
"MaxIPv6StaticAddresses":null,
|
||||
"NameServers":[
|
||||
"names.redfishspecification.org"
|
||||
],
|
||||
"IPv4Addresses":[
|
||||
{
|
||||
"Address":"192.168.0.10",
|
||||
"SubnetMask":"255.255.252.0",
|
||||
"AddressOrigin":"Static",
|
||||
"Gateway":"192.168.0.1"
|
||||
}
|
||||
],
|
||||
"IPv6Addresses":[
|
||||
{
|
||||
"Address":"fe80::1ec1:deff:fe6f:1e24",
|
||||
"PrefixLength":64,
|
||||
"AddressOrigin":"Static",
|
||||
"AddressState":"Preferred"
|
||||
}
|
||||
],
|
||||
"IPv6StaticAddresses":[
|
||||
|
||||
],
|
||||
"VLAN":null,
|
||||
"VLANs":null,
|
||||
"Oem":{
|
||||
|
||||
},
|
||||
"Links":{
|
||||
"Oem":{
|
||||
"Intel_RackScale":{
|
||||
"@odata.type":"#Intel.Oem.EthernetInterface",
|
||||
"NeighborPort":{
|
||||
"@odata.id":"/redfish/v1/EthernetSwitches/1/Ports/1"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,8 +17,10 @@ import json
|
||||
import mock
|
||||
import testtools
|
||||
|
||||
from sushy import exceptions
|
||||
|
||||
from rsd_lib.resources.v2_1.ethernet_switch import vlan
|
||||
from rsd_lib.resources.v2_1.manager import ethernet_interface
|
||||
from rsd_lib.resources.v2_1.system import ethernet_interface
|
||||
|
||||
|
||||
class EthernetInterface(testtools.TestCase):
|
||||
@ -26,7 +28,7 @@ class EthernetInterface(testtools.TestCase):
|
||||
super(EthernetInterface, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'ethernet_interface.json', 'r') as f:
|
||||
'manager_ethernet_interface.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.ethernet_interface_inst = ethernet_interface.EthernetInterface(
|
||||
@ -77,7 +79,7 @@ class EthernetInterface(testtools.TestCase):
|
||||
ethernet_interface_inst.ipv4_addresses[0].
|
||||
address_origin)
|
||||
self.assertEqual("192.168.0.1", self.ethernet_interface_inst.
|
||||
ipv4_addresses[0].gate_way)
|
||||
ipv4_addresses[0].gateway)
|
||||
self.assertEqual("fe80::1ec1:deff:fe6f:1e24", self.
|
||||
ethernet_interface_inst.ipv6_addresses[0].address)
|
||||
self.assertEqual(64, self.ethernet_interface_inst.ipv6_addresses[0].
|
||||
@ -104,12 +106,10 @@ class EthernetInterface(testtools.TestCase):
|
||||
actual_path)
|
||||
|
||||
def test__get_vlan_collection_path_without_vlans(self):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'ethernet_interface_without_vlans.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.ethernet_interface_inst.refresh(force=True)
|
||||
actual_path = self.ethernet_interface_inst._get_vlan_collection_path()
|
||||
self.assertEqual(None, actual_path)
|
||||
self.ethernet_interface_inst._json.pop('VLANs')
|
||||
with self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute VLANs'):
|
||||
self.ethernet_interface_inst._get_vlan_collection_path()
|
||||
|
||||
def test_vlans(self):
|
||||
# | GIVEN |
|
||||
@ -143,7 +143,7 @@ class EthernetInterface(testtools.TestCase):
|
||||
|
||||
# On refreshing...
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'ethernet_interface.json', 'r') as f:
|
||||
'manager_ethernet_interface.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(
|
||||
f.read())
|
||||
|
||||
@ -159,21 +159,13 @@ class EthernetInterface(testtools.TestCase):
|
||||
self.assertIsInstance(actual_vlans,
|
||||
vlan.VLANCollection)
|
||||
|
||||
def test_without_vlans(self):
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'ethernet_interface_without_vlans.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.ethernet_interface_inst.refresh(force=True)
|
||||
actual_vlans = self.ethernet_interface_inst.vlans
|
||||
self.assertEqual(None, actual_vlans)
|
||||
|
||||
|
||||
class EthernetInterfaceCollectionTestCase(testtools.TestCase):
|
||||
def setUp(self):
|
||||
super(EthernetInterfaceCollectionTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'ethernrt_interface_collection.json', 'r') as f:
|
||||
'manager_ethernet_interface_collection.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.ethernet_interface_col = ethernet_interface. \
|
||||
EthernetInterfaceCollection(self.conn,
|
||||
|
@ -11,14 +11,13 @@
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
|
||||
import mock
|
||||
|
||||
from sushy.tests.unit import base
|
||||
|
||||
from rsd_lib.resources.v2_1.manager import ethernet_interface
|
||||
from rsd_lib.resources.v2_1.manager import manager
|
||||
from rsd_lib.resources.v2_1.manager import network_protocol
|
||||
from rsd_lib.resources.v2_1.system import ethernet_interface
|
||||
|
||||
|
||||
class TestManager(base.TestCase):
|
||||
@ -142,7 +141,7 @@ class TestManager(base.TestCase):
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'ethernet_interface.json', 'r') as f:
|
||||
'manager_ethernet_interface.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN |
|
||||
actual_ethernet_interface = self.manager_inst.ethernet_interface
|
||||
@ -162,7 +161,7 @@ class TestManager(base.TestCase):
|
||||
def test_ethernet_interface_on_refresh(self):
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'ethernet_interface.json', 'r') as f:
|
||||
'manager_ethernet_interface.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.manager_inst.ethernet_interface,
|
||||
@ -178,7 +177,7 @@ class TestManager(base.TestCase):
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'ethernet_interface.json', 'r') as f:
|
||||
'manager_ethernet_interface.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.manager_inst.ethernet_interface,
|
||||
|
@ -0,0 +1,132 @@
|
||||
# Copyright 2018 99cloud, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import json
|
||||
import mock
|
||||
import testtools
|
||||
|
||||
from rsd_lib.resources.v2_1.system import ethernet_interface
|
||||
|
||||
|
||||
class EthernetInterfaceTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(EthernetInterfaceTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'system_ethernet_interface.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.ethernet_interface_inst = ethernet_interface.EthernetInterface(
|
||||
self.conn, '/redfish/v1/Systems/System1/EthernetInterfaces/LAN1',
|
||||
redfish_version='1.1.0')
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.ethernet_interface_inst._parse_attributes()
|
||||
self.assertEqual('Ethernet Interface',
|
||||
self.ethernet_interface_inst.name)
|
||||
self.assertEqual('LAN1', self.ethernet_interface_inst.identity)
|
||||
self.assertEqual('System NIC 1',
|
||||
self.ethernet_interface_inst.description)
|
||||
self.assertEqual('Enabled', self.ethernet_interface_inst.status.state)
|
||||
self.assertEqual('OK', self.ethernet_interface_inst.status.health)
|
||||
self.assertEqual('OK',
|
||||
self.ethernet_interface_inst.status.health_rollup)
|
||||
self.assertEqual(True, self.ethernet_interface_inst.interface_enabled)
|
||||
self.assertEqual('AA:BB:CC:DD:EE:FF',
|
||||
self.ethernet_interface_inst.permanent_mac_address)
|
||||
self.assertEqual('AA:BB:CC:DD:EE:FF',
|
||||
self.ethernet_interface_inst.mac_address)
|
||||
self.assertEqual(100, self.ethernet_interface_inst.speed_mbps)
|
||||
self.assertEqual(True, self.ethernet_interface_inst.auto_neg)
|
||||
self.assertEqual(True, self.ethernet_interface_inst.full_duplex)
|
||||
self.assertEqual(1500, self.ethernet_interface_inst.mtu_size)
|
||||
self.assertEqual('web483', self.ethernet_interface_inst.host_name)
|
||||
self.assertEqual('web483.redfishspecification.org',
|
||||
self.ethernet_interface_inst.fqdn)
|
||||
self.assertEqual('fe80::3ed9:2bff:fe34:600',
|
||||
self.ethernet_interface_inst.ipv6_default_gateway)
|
||||
self.assertEqual(
|
||||
None, self.ethernet_interface_inst.max_ipv6_static_addresses)
|
||||
self.assertEqual(['names.redfishspecification.org'],
|
||||
self.ethernet_interface_inst.name_servers)
|
||||
self.assertEqual(
|
||||
'192.168.0.10',
|
||||
self.ethernet_interface_inst.ipv4_addresses[0].address)
|
||||
self.assertEqual('255.255.252.0',
|
||||
self.ethernet_interface_inst.ipv4_addresses[0].
|
||||
subnet_mask)
|
||||
self.assertEqual(
|
||||
'192.168.0.1',
|
||||
self.ethernet_interface_inst.ipv4_addresses[0].gateway)
|
||||
self.assertEqual(
|
||||
'fe80::1ec1:deff:fe6f:1e24',
|
||||
self.ethernet_interface_inst.ipv6_addresses[0].address)
|
||||
self.assertEqual(64,
|
||||
self.ethernet_interface_inst.ipv6_addresses[0].
|
||||
prefix_length)
|
||||
self.assertEqual('Static',
|
||||
self.ethernet_interface_inst.ipv6_addresses[0].
|
||||
address_origin)
|
||||
self.assertEqual('Preferred',
|
||||
self.ethernet_interface_inst.ipv6_addresses[0].
|
||||
address_state)
|
||||
self.assertEqual(
|
||||
[], self.ethernet_interface_inst.ipv6_static_addresses)
|
||||
self.assertEqual(None, self.ethernet_interface_inst.vlan)
|
||||
|
||||
|
||||
class EthernetInterfaceCollectionTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(EthernetInterfaceCollectionTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'system_ethernet_interface_collection.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.ethernet_interface_col = ethernet_interface.\
|
||||
EthernetInterfaceCollection(
|
||||
self.conn,
|
||||
'/redfish/v1/Systems/System1/EthernetInterfaces',
|
||||
redfish_version='1.1.0')
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.ethernet_interface_col._parse_attributes()
|
||||
self.assertEqual('1.1.0', self.ethernet_interface_col.redfish_version)
|
||||
self.assertEqual(
|
||||
('/redfish/v1/Systems/System1/EthernetInterfaces/LAN1',),
|
||||
self.ethernet_interface_col.members_identities)
|
||||
|
||||
@mock.patch.object(ethernet_interface, 'EthernetInterface', autospec=True)
|
||||
def test_get_member(self, mock_network_interface):
|
||||
self.ethernet_interface_col.get_member(
|
||||
'/redfish/v1/Systems/System1/EthernetInterfaces/LAN1')
|
||||
mock_network_interface.assert_called_once_with(
|
||||
self.ethernet_interface_col._conn,
|
||||
'/redfish/v1/Systems/System1/EthernetInterfaces/LAN1',
|
||||
redfish_version=self.ethernet_interface_col.redfish_version)
|
||||
|
||||
@mock.patch.object(ethernet_interface, 'EthernetInterface', autospec=True)
|
||||
def test_get_members(self, mock_network_interface):
|
||||
members = self.ethernet_interface_col.get_members()
|
||||
calls = [
|
||||
mock.call(self.ethernet_interface_col._conn,
|
||||
'/redfish/v1/Systems/System1/EthernetInterfaces/LAN1',
|
||||
redfish_version=self.ethernet_interface_col.
|
||||
redfish_version)
|
||||
]
|
||||
mock_network_interface.assert_has_calls(calls)
|
||||
self.assertIsInstance(members, list)
|
||||
self.assertEqual(1, len(members))
|
@ -1,128 +0,0 @@
|
||||
# Copyright 2018 99cloud, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import json
|
||||
import mock
|
||||
import testtools
|
||||
|
||||
from rsd_lib.resources.v2_1.system import network_interface
|
||||
|
||||
|
||||
class NetworkInterfaceTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(NetworkInterfaceTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'system_network_interface.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.network_interface_inst = network_interface.NetworkInterface(
|
||||
self.conn, '/redfish/v1/Systems/System1/EthernetInterfaces/LAN1',
|
||||
redfish_version='1.1.0')
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.network_interface_inst._parse_attributes()
|
||||
self.assertEqual('Ethernet Interface',
|
||||
self.network_interface_inst.name)
|
||||
self.assertEqual('LAN1', self.network_interface_inst.identity)
|
||||
self.assertEqual('System NIC 1',
|
||||
self.network_interface_inst.description)
|
||||
self.assertEqual('Enabled', self.network_interface_inst.status.state)
|
||||
self.assertEqual('OK', self.network_interface_inst.status.health)
|
||||
self.assertEqual('OK',
|
||||
self.network_interface_inst.status.health_rollup)
|
||||
self.assertEqual(True, self.network_interface_inst.interface_enabled)
|
||||
self.assertEqual('AA:BB:CC:DD:EE:FF',
|
||||
self.network_interface_inst.permanent_mac_address)
|
||||
self.assertEqual('AA:BB:CC:DD:EE:FF',
|
||||
self.network_interface_inst.mac_address)
|
||||
self.assertEqual(100, self.network_interface_inst.speed_mbps)
|
||||
self.assertEqual(True, self.network_interface_inst.auto_neg)
|
||||
self.assertEqual(True, self.network_interface_inst.full_duplex)
|
||||
self.assertEqual(1500, self.network_interface_inst.mtu_size)
|
||||
self.assertEqual('web483', self.network_interface_inst.host_name)
|
||||
self.assertEqual('web483.redfishspecification.org',
|
||||
self.network_interface_inst.fqdn)
|
||||
self.assertEqual('fe80::3ed9:2bff:fe34:600',
|
||||
self.network_interface_inst.ipv6_default_gateway)
|
||||
self.assertEqual(None,
|
||||
self.network_interface_inst.max_ipv6_static_addresses)
|
||||
self.assertEqual(['names.redfishspecification.org'],
|
||||
self.network_interface_inst.name_servers)
|
||||
self.assertEqual('192.168.0.10',
|
||||
self.network_interface_inst.ipv4_addresses[0].address)
|
||||
self.assertEqual('255.255.252.0',
|
||||
self.network_interface_inst.ipv4_addresses[0].
|
||||
subnet_mask)
|
||||
self.assertEqual('192.168.0.1',
|
||||
self.network_interface_inst.ipv4_addresses[0].gateway)
|
||||
self.assertEqual('fe80::1ec1:deff:fe6f:1e24',
|
||||
self.network_interface_inst.ipv6_addresses[0].address)
|
||||
self.assertEqual(64,
|
||||
self.network_interface_inst.ipv6_addresses[0].
|
||||
prefix_length)
|
||||
self.assertEqual('Static',
|
||||
self.network_interface_inst.ipv6_addresses[0].
|
||||
address_origin)
|
||||
self.assertEqual('Preferred',
|
||||
self.network_interface_inst.ipv6_addresses[0].
|
||||
address_state)
|
||||
self.assertEqual([], self.network_interface_inst.ipv6_static_addresses)
|
||||
self.assertEqual(None, self.network_interface_inst.vlan)
|
||||
|
||||
|
||||
class NetworkInterfaceCollectionTestCase(testtools.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(NetworkInterfaceCollectionTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'system_network_interface_collection.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.network_interface_col = network_interface.\
|
||||
NetworkInterfaceCollection(
|
||||
self.conn,
|
||||
'/redfish/v1/Systems/System1/EthernetInterfaces',
|
||||
redfish_version='1.1.0')
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.network_interface_col._parse_attributes()
|
||||
self.assertEqual('1.1.0', self.network_interface_col.redfish_version)
|
||||
self.assertEqual(
|
||||
('/redfish/v1/Systems/System1/EthernetInterfaces/LAN1',),
|
||||
self.network_interface_col.members_identities)
|
||||
|
||||
@mock.patch.object(network_interface, 'NetworkInterface', autospec=True)
|
||||
def test_get_member(self, mock_network_interface):
|
||||
self.network_interface_col.get_member(
|
||||
'/redfish/v1/Systems/System1/EthernetInterfaces/LAN1')
|
||||
mock_network_interface.assert_called_once_with(
|
||||
self.network_interface_col._conn,
|
||||
'/redfish/v1/Systems/System1/EthernetInterfaces/LAN1',
|
||||
redfish_version=self.network_interface_col.redfish_version)
|
||||
|
||||
@mock.patch.object(network_interface, 'NetworkInterface', autospec=True)
|
||||
def test_get_members(self, mock_network_interface):
|
||||
members = self.network_interface_col.get_members()
|
||||
calls = [
|
||||
mock.call(self.network_interface_col._conn,
|
||||
'/redfish/v1/Systems/System1/EthernetInterfaces/LAN1',
|
||||
redfish_version=self.network_interface_col.
|
||||
redfish_version)
|
||||
]
|
||||
mock_network_interface.assert_has_calls(calls)
|
||||
self.assertIsInstance(members, list)
|
||||
self.assertEqual(1, len(members))
|
@ -20,8 +20,8 @@ import testtools
|
||||
from sushy import exceptions
|
||||
from sushy.resources.system import system as sushy_system
|
||||
|
||||
from rsd_lib.resources.v2_1.system import ethernet_interface
|
||||
from rsd_lib.resources.v2_1.system import memory
|
||||
from rsd_lib.resources.v2_1.system import network_interface
|
||||
from rsd_lib.resources.v2_1.system import storage_subsystem
|
||||
from rsd_lib.resources.v2_1.system import system
|
||||
|
||||
@ -156,46 +156,46 @@ class SystemTestCase(testtools.TestCase):
|
||||
self.assertIsInstance(self.system_inst.storage_subsystem,
|
||||
storage_subsystem.StorageSubsystemCollection)
|
||||
|
||||
def test__get_network_interface_collection_path(self):
|
||||
def test__get_ethernet_interface_collection_path(self):
|
||||
self.assertEqual(
|
||||
'/redfish/v1/Systems/437XR1138R2/EthernetInterfaces',
|
||||
self.system_inst._get_network_interface_collection_path())
|
||||
self.system_inst._get_ethernet_interface_collection_path())
|
||||
|
||||
def test__get_network_interface_collection_path_missing_systems_attr(self):
|
||||
def test__get_ethernet_interface_collection_path_missing_attr(self):
|
||||
self.system_inst._json.pop('EthernetInterfaces')
|
||||
with self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute EthernetInterfaces'):
|
||||
self.system_inst._get_network_interface_collection_path()
|
||||
self.system_inst._get_ethernet_interface_collection_path()
|
||||
|
||||
def test_network_interface(self):
|
||||
def test_ethernet_interface(self):
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'system_network_interface_collection.json', 'r') as f:
|
||||
'system_ethernet_interface_collection.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN |
|
||||
actual_network_interface_col = self.system_inst.network_interface
|
||||
actual_ethernet_interface_col = self.system_inst.ethernet_interface
|
||||
# | THEN |
|
||||
self.assertIsInstance(actual_network_interface_col,
|
||||
network_interface.NetworkInterfaceCollection)
|
||||
self.assertIsInstance(actual_ethernet_interface_col,
|
||||
ethernet_interface.EthernetInterfaceCollection)
|
||||
self.conn.get.return_value.json.assert_called_once_with()
|
||||
|
||||
# reset mock
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
# | WHEN & THEN |
|
||||
# tests for same object on invoking subsequently
|
||||
self.assertIs(actual_network_interface_col,
|
||||
self.system_inst.network_interface)
|
||||
self.assertIs(actual_ethernet_interface_col,
|
||||
self.system_inst.ethernet_interface)
|
||||
self.conn.get.return_value.json.assert_not_called()
|
||||
|
||||
def test_network_interface_on_refresh(self):
|
||||
def test_ethernet_interface_on_refresh(self):
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'system_network_interface_collection.json', 'r') as f:
|
||||
'system_ethernet_interface_collection.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.system_inst.network_interface,
|
||||
network_interface.NetworkInterfaceCollection)
|
||||
self.assertIsInstance(self.system_inst.ethernet_interface,
|
||||
ethernet_interface.EthernetInterfaceCollection)
|
||||
|
||||
# on refreshing the system instance...
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/system.json',
|
||||
@ -207,11 +207,11 @@ class SystemTestCase(testtools.TestCase):
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'system_network_interface_collection.json', 'r') as f:
|
||||
'system_ethernet_interface_collection.json', 'r') as f:
|
||||
self.conn.get.return_value.son.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.system_inst.network_interface,
|
||||
network_interface.NetworkInterfaceCollection)
|
||||
self.assertIsInstance(self.system_inst.ethernet_interface,
|
||||
ethernet_interface.EthernetInterfaceCollection)
|
||||
|
||||
|
||||
class SystemCollectionTestCase(testtools.TestCase):
|
||||
|
@ -1,52 +0,0 @@
|
||||
# Copyright 2019 Intel, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# 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.
|
||||
|
||||
import json
|
||||
import mock
|
||||
import testtools
|
||||
|
||||
from rsd_lib.resources.v2_2.manager import ethernet_interface
|
||||
|
||||
|
||||
class EthernetInterface(testtools.TestCase):
|
||||
def setUp(self):
|
||||
super(EthernetInterface, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
'ethernet_interface.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.ethernet_interface_inst = ethernet_interface.EthernetInterface(
|
||||
self.conn,
|
||||
'/redfish/v1/Managers/1/EthernetInterfaces/1',
|
||||
redfish_version='1.0.2')
|
||||
|
||||
|
||||
class EthernetInterfaceCollectionTestCase(testtools.TestCase):
|
||||
def setUp(self):
|
||||
super(EthernetInterfaceCollectionTestCase, self).setUp()
|
||||
self.conn = mock.Mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
'ethernet_interface_collection.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
self.ethernet_interface_col = ethernet_interface.\
|
||||
EthernetInterfaceCollection(self.conn,
|
||||
'/redfish/v1/Managers/1/Ethernet'
|
||||
'Interfaces/1',
|
||||
redfish_version='1.0.2')
|
||||
|
||||
def test__parse_attributes(self):
|
||||
self.assertEqual("description-as-string", self.ethernet_interface_col.
|
||||
description)
|
@ -17,7 +17,7 @@ import json
|
||||
|
||||
import mock
|
||||
|
||||
from rsd_lib.resources.v2_2.manager import ethernet_interface
|
||||
from rsd_lib.resources.v2_1.system import ethernet_interface
|
||||
from rsd_lib.resources.v2_2.manager import manager
|
||||
|
||||
from sushy.tests.unit import base
|
||||
@ -46,7 +46,7 @@ class TestManager(base.TestCase):
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
'ethernet_interface.json', 'r') as f:
|
||||
'manager_ethernet_interface.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN |
|
||||
actual_ethernet_interface = self.manager_inst.ethernet_interface
|
||||
@ -66,7 +66,7 @@ class TestManager(base.TestCase):
|
||||
def test_ethernet_interface_on_refresh(self):
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
'ethernet_interface.json', 'r') as f:
|
||||
'manager_ethernet_interface.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.manager_inst.ethernet_interface,
|
||||
@ -82,7 +82,7 @@ class TestManager(base.TestCase):
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_2/'
|
||||
'ethernet_interface.json', 'r') as f:
|
||||
'manager_ethernet_interface.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.manager_inst.ethernet_interface,
|
||||
|
Loading…
x
Reference in New Issue
Block a user