Add network interface in RSD 2.1 System instance
Change-Id: I6f88d6cc275d360c6ce1a1ef9d982863f6964712
This commit is contained in:
parent
b742b61230
commit
e662db24ae
@ -121,8 +121,8 @@ class Manager(base.ResourceBase):
|
||||
"""Helper function to find the network protocol path"""
|
||||
return utils.get_sub_resource_path_by(self, 'NetworkProtocol')
|
||||
|
||||
def _get_ethernet_interface_path(self):
|
||||
"""Helper function to find the Ethernet Interface path"""
|
||||
def _get_ethernet_interfaces_path(self):
|
||||
"""Helper function to find the Ethernet Interfaces path"""
|
||||
return utils.get_sub_resource_path_by(self, 'EthernetInterfaces')
|
||||
|
||||
@property
|
||||
@ -146,7 +146,7 @@ class Manager(base.ResourceBase):
|
||||
refresh, this property is reset.
|
||||
"""
|
||||
return ethernet_interface.EthernetInterfaceCollection(
|
||||
self._conn, self._get_ethernet_interface_path(),
|
||||
self._conn, self._get_ethernet_interfaces_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
|
@ -18,6 +18,7 @@ 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 +56,36 @@ class System(system.System):
|
||||
self._conn, self._get_storage_subsystem_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_ethernet_interface_collection_path(self):
|
||||
"""Helper function to find the network interface path"""
|
||||
def _get_ethernet_interfaces_collection_path(self):
|
||||
"""Helper function to find the ethernet interfaces 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
|
||||
def ethernet_interfaces(self):
|
||||
"""Property to provide reference to `EthernetInterfaceCollection`
|
||||
|
||||
It is calculated once the first time it is queried. On refresh,
|
||||
this property is reset.
|
||||
"""
|
||||
return ethernet_interface.EthernetInterfaceCollection(
|
||||
self._conn, self._get_ethernet_interface_collection_path(),
|
||||
self._conn, self._get_ethernet_interfaces_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
def _get_network_interfaces_collection_path(self):
|
||||
"""Helper function to find the network interfaces path"""
|
||||
return utils.get_sub_resource_path_by(self, 'NetworkInterfaces')
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def network_interfaces(self):
|
||||
"""Property to provide reference to `NetworkInterfaceCollection`
|
||||
|
||||
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_interfaces_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
|
@ -24,13 +24,13 @@ class Manager(manager.Manager):
|
||||
@property
|
||||
@utils.cache_it
|
||||
def ethernet_interfaces(self):
|
||||
"""Property to provide reference to `EthernetInterface` instance
|
||||
"""Property to provide reference to `EthernetInterfaceColection`
|
||||
|
||||
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(),
|
||||
self._conn, self._get_ethernet_interfaces_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
|
@ -23,14 +23,14 @@ class System(system.System):
|
||||
|
||||
@property
|
||||
@utils.cache_it
|
||||
def ethernet_interface(self):
|
||||
"""Property to provide reference to `EthernetInterface` instance
|
||||
def ethernet_interfaces(self):
|
||||
"""Property to provide reference to `EthernetInterfaceCollection`
|
||||
|
||||
It is calculated once the first time it is queried. On refresh,
|
||||
this property is reset.
|
||||
"""
|
||||
return ethernet_interface.EthernetInterfaceCollection(
|
||||
self._conn, self._get_ethernet_interface_collection_path(),
|
||||
self._conn, self._get_ethernet_interfaces_collection_path(),
|
||||
redfish_version=self.redfish_version)
|
||||
|
||||
|
||||
|
@ -94,11 +94,14 @@
|
||||
"@odata.id": "/redfish/v1/Systems/437XR1138R2/SimpleStorage"
|
||||
},
|
||||
"Storage": {
|
||||
"@odata.id": "/redfish/v1/Systems/1/Storage"
|
||||
"@odata.id": "/redfish/v1/Systems/437XR1138R2/Storage"
|
||||
},
|
||||
"LogServices": {
|
||||
"@odata.id": "/redfish/v1/Systems/437XR1138R2/LogServices"
|
||||
},
|
||||
"NetworkInterfaces": {
|
||||
"@odata.id": "/redfish/v1/Systems/437XR1138R2/NetworkInterfaces"
|
||||
},
|
||||
"Links": {
|
||||
"Chassis": [
|
||||
{
|
||||
|
@ -52,6 +52,9 @@
|
||||
"EthernetInterfaces": {
|
||||
"@odata.id": "/redfish/v1/Systems/System2/EthernetInterfaces"
|
||||
},
|
||||
"NetworkInterfaces": {
|
||||
"@odata.id": "/redfish/v1/Systems/System2/NetworkInterfaces"
|
||||
},
|
||||
"SimpleStorage": {},
|
||||
"Storage": {
|
||||
"@odata.id": "/redfish/v1/Systems/System2/Storage"
|
||||
|
@ -94,11 +94,14 @@
|
||||
"@odata.id": "/redfish/v1/Systems/437XR1138R2/SimpleStorage"
|
||||
},
|
||||
"Storage": {
|
||||
"@odata.id": "/redfish/v1/Systems/1/Storage"
|
||||
"@odata.id": "/redfish/v1/Systems/437XR1138R2/Storage"
|
||||
},
|
||||
"LogServices": {
|
||||
"@odata.id": "/redfish/v1/Systems/437XR1138R2/LogServices"
|
||||
},
|
||||
"NetworkInterfaces": {
|
||||
"@odata.id": "/redfish/v1/Systems/437XR1138R2/NetworkInterfaces"
|
||||
},
|
||||
"Links": {
|
||||
"Chassis": [
|
||||
{
|
||||
|
@ -132,12 +132,12 @@ class TestManager(base.TestCase):
|
||||
self.assertIsInstance(self.manager_inst.network_protocol,
|
||||
network_protocol.NetworkProtocol)
|
||||
|
||||
def test__get_ethernet_interface_path(self):
|
||||
def test__get_ethernet_interfaces_path(self):
|
||||
expected = '/redfish/v1/Managers/PSME/EthernetInterfaces'
|
||||
result = self.manager_inst._get_ethernet_interface_path()
|
||||
result = self.manager_inst._get_ethernet_interfaces_path()
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
def test_ethernet_interface(self):
|
||||
def test_ethernet_interfaces(self):
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
@ -158,7 +158,7 @@ class TestManager(base.TestCase):
|
||||
self.manager_inst.ethernet_interfaces)
|
||||
self.conn.get.return_value.json.assert_not_called()
|
||||
|
||||
def test_ethernet_interface_on_refresh(self):
|
||||
def test_ethernet_interfaces_on_refresh(self):
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'manager_ethernet_interface_collection.json', 'r') as f:
|
||||
|
@ -22,6 +22,7 @@ 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
|
||||
|
||||
@ -101,7 +102,7 @@ class SystemTestCase(testtools.TestCase):
|
||||
|
||||
def test__get_storage_collection_path(self):
|
||||
self.assertEqual(
|
||||
'/redfish/v1/Systems/1/Storage',
|
||||
'/redfish/v1/Systems/437XR1138R2/Storage',
|
||||
self.system_inst._get_storage_subsystem_collection_path())
|
||||
|
||||
def test__get_storage_collection_path_missing_systems_attr(self):
|
||||
@ -156,25 +157,25 @@ class SystemTestCase(testtools.TestCase):
|
||||
self.assertIsInstance(self.system_inst.storage_subsystem,
|
||||
storage_subsystem.StorageSubsystemCollection)
|
||||
|
||||
def test__get_ethernet_interface_collection_path(self):
|
||||
def test__get_ethernet_interfaces_collection_path(self):
|
||||
self.assertEqual(
|
||||
'/redfish/v1/Systems/437XR1138R2/EthernetInterfaces',
|
||||
self.system_inst._get_ethernet_interface_collection_path())
|
||||
self.system_inst._get_ethernet_interfaces_collection_path())
|
||||
|
||||
def test__get_ethernet_interface_collection_path_missing_attr(self):
|
||||
def test__get_ethernet_interfaces_collection_path_missing_attr(self):
|
||||
self.system_inst._json.pop('EthernetInterfaces')
|
||||
with self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute EthernetInterfaces'):
|
||||
self.system_inst._get_ethernet_interface_collection_path()
|
||||
self.system_inst._get_ethernet_interfaces_collection_path()
|
||||
|
||||
def test_ethernet_interface(self):
|
||||
def test_ethernet_interfaces(self):
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_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())
|
||||
# | WHEN |
|
||||
actual_ethernet_interface_col = self.system_inst.ethernet_interface
|
||||
actual_ethernet_interface_col = self.system_inst.ethernet_interfaces
|
||||
# | THEN |
|
||||
self.assertIsInstance(actual_ethernet_interface_col,
|
||||
ethernet_interface.EthernetInterfaceCollection)
|
||||
@ -185,16 +186,16 @@ class SystemTestCase(testtools.TestCase):
|
||||
# | WHEN & THEN |
|
||||
# tests for same object on invoking subsequently
|
||||
self.assertIs(actual_ethernet_interface_col,
|
||||
self.system_inst.ethernet_interface)
|
||||
self.system_inst.ethernet_interfaces)
|
||||
self.conn.get.return_value.json.assert_not_called()
|
||||
|
||||
def test_ethernet_interface_on_refresh(self):
|
||||
def test_ethernet_interfaces_on_refresh(self):
|
||||
# | GIVEN |
|
||||
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())
|
||||
# | WHEN & THEN |
|
||||
self.assertIsInstance(self.system_inst.ethernet_interface,
|
||||
self.assertIsInstance(self.system_inst.ethernet_interfaces,
|
||||
ethernet_interface.EthernetInterfaceCollection)
|
||||
|
||||
# on refreshing the system instance...
|
||||
@ -210,9 +211,66 @@ class SystemTestCase(testtools.TestCase):
|
||||
'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.ethernet_interface,
|
||||
self.assertIsInstance(self.system_inst.ethernet_interfaces,
|
||||
ethernet_interface.EthernetInterfaceCollection)
|
||||
|
||||
def test__get_network_interfaces_collection_path(self):
|
||||
self.assertEqual(
|
||||
'/redfish/v1/Systems/437XR1138R2/NetworkInterfaces',
|
||||
self.system_inst._get_network_interfaces_collection_path())
|
||||
|
||||
def test__get_network_interfaces_collection_path_missing_attr(self):
|
||||
self.system_inst._json.pop('NetworkInterfaces')
|
||||
with self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute NetworkInterfaces'):
|
||||
self.system_inst._get_network_interfaces_collection_path()
|
||||
|
||||
def test_network_interfaces(self):
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'network_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_interfaces
|
||||
# | THEN |
|
||||
self.assertIsInstance(actual_network_interface_col,
|
||||
network_interface.NetworkInterfaceCollection)
|
||||
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_interfaces)
|
||||
self.conn.get.return_value.json.assert_not_called()
|
||||
|
||||
def test_network_interfaces_on_refresh(self):
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'network_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_interfaces,
|
||||
network_interface.NetworkInterfaceCollection)
|
||||
|
||||
# on refreshing the system instance...
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/system.json',
|
||||
'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
|
||||
self.system_inst.invalidate()
|
||||
self.system_inst.refresh(force=False)
|
||||
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_1/'
|
||||
'network_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_interfaces,
|
||||
network_interface.NetworkInterfaceCollection)
|
||||
|
||||
|
||||
class SystemCollectionTestCase(testtools.TestCase):
|
||||
|
||||
|
@ -33,12 +33,12 @@ class TestManager(base.TestCase):
|
||||
'/redfish/v1/Manager/PSME',
|
||||
redfish_version='1.0.2')
|
||||
|
||||
def test__get_ethernet_interface_path(self):
|
||||
def test__get_ethernet_interfaces_path(self):
|
||||
expected = '/redfish/v1/Managers/PSME/EthernetInterfaces'
|
||||
result = self.manager_inst._get_ethernet_interface_path()
|
||||
result = self.manager_inst._get_ethernet_interfaces_path()
|
||||
self.assertEqual(expected, result)
|
||||
|
||||
def test_ethernet_interface(self):
|
||||
def test_ethernet_interfaces(self):
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
@ -59,7 +59,7 @@ class TestManager(base.TestCase):
|
||||
self.manager_inst.ethernet_interfaces)
|
||||
self.conn.get.return_value.json.assert_not_called()
|
||||
|
||||
def test_ethernet_interface_on_refresh(self):
|
||||
def test_ethernet_interfaces_on_refresh(self):
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
'manager_ethernet_interface_collection.json', 'r') as f:
|
||||
|
@ -43,25 +43,25 @@ class SystemTestCase(testtools.TestCase):
|
||||
self.assertIsInstance(self.system_inst, v2_2_system.System)
|
||||
self.assertIsInstance(self.system_inst, sushy_system.System)
|
||||
|
||||
def test__get_ethernet_interface_collection_path(self):
|
||||
def test__get_ethernet_interfaces_collection_path(self):
|
||||
self.assertEqual(
|
||||
'/redfish/v1/Systems/437XR1138R2/EthernetInterfaces',
|
||||
self.system_inst._get_ethernet_interface_collection_path())
|
||||
self.system_inst._get_ethernet_interfaces_collection_path())
|
||||
|
||||
def test__get_ethernet_interface_collection_path_missing_attr(self):
|
||||
def test__get_ethernet_interfaces_collection_path_missing_attr(self):
|
||||
self.system_inst._json.pop('EthernetInterfaces')
|
||||
with self.assertRaisesRegex(
|
||||
exceptions.MissingAttributeError, 'attribute EthernetInterfaces'):
|
||||
self.system_inst._get_ethernet_interface_collection_path()
|
||||
self.system_inst._get_ethernet_interfaces_collection_path()
|
||||
|
||||
def test_ethernet_interface(self):
|
||||
def test_ethernet_interfaces(self):
|
||||
# | GIVEN |
|
||||
self.conn.get.return_value.json.reset_mock()
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
'system_ethernet_interface_collection.json', 'r') as f:
|
||||
self.conn.get.return_value.json.return_value = json.loads(f.read())
|
||||
# | WHEN |
|
||||
actual_ethernet_interface_col = self.system_inst.ethernet_interface
|
||||
actual_ethernet_interface_col = self.system_inst.ethernet_interfaces
|
||||
# | THEN |
|
||||
self.assertIsInstance(actual_ethernet_interface_col,
|
||||
ethernet_interface.EthernetInterfaceCollection)
|
||||
@ -72,16 +72,16 @@ class SystemTestCase(testtools.TestCase):
|
||||
# | WHEN & THEN |
|
||||
# tests for same object on invoking subsequently
|
||||
self.assertIs(actual_ethernet_interface_col,
|
||||
self.system_inst.ethernet_interface)
|
||||
self.system_inst.ethernet_interfaces)
|
||||
self.conn.get.return_value.json.assert_not_called()
|
||||
|
||||
def test_ethernet_interface_on_refresh(self):
|
||||
def test_ethernet_interfaces_on_refresh(self):
|
||||
# | GIVEN |
|
||||
with open('rsd_lib/tests/unit/json_samples/v2_3/'
|
||||
'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.ethernet_interface,
|
||||
self.assertIsInstance(self.system_inst.ethernet_interfaces,
|
||||
ethernet_interface.EthernetInterfaceCollection)
|
||||
|
||||
# on refreshing the system instance...
|
||||
@ -97,7 +97,7 @@ class SystemTestCase(testtools.TestCase):
|
||||
'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.ethernet_interface,
|
||||
self.assertIsInstance(self.system_inst.ethernet_interfaces,
|
||||
ethernet_interface.EthernetInterfaceCollection)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user