Fix VIF list for noop network interface
Creating a node with the noop network interface, then listing the node's VIFs, e.g. via openstack baremetal node vif list <node>, ironic previously returned a 500 internal server error. This change fixes the issue by returning an empty list instead of None from the vif_list method. This change also adds unit tests to cover the noop network interface as it previously had none. Change-Id: I327c961f094528d46a78c26610d198ebc2a4f370 Closes-Bug: #1700497
This commit is contained in:
parent
f0e6a07ade
commit
181005106b
@ -61,7 +61,7 @@ class NoopNetwork(base.NetworkInterface):
|
||||
:returns: List of VIF dictionaries, each dictionary will have an 'id'
|
||||
entry with the ID of the VIF.
|
||||
"""
|
||||
pass
|
||||
return []
|
||||
|
||||
def get_current_vif(self, task, p_obj):
|
||||
"""Returns the currently used VIF associated with port or portgroup
|
||||
|
91
ironic/tests/unit/drivers/modules/network/test_noop.py
Normal file
91
ironic/tests/unit/drivers/modules/network/test_noop.py
Normal file
@ -0,0 +1,91 @@
|
||||
# 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 ironic.conductor import task_manager
|
||||
from ironic.drivers.modules.network import noop
|
||||
from ironic.tests.unit.conductor import mgr_utils
|
||||
from ironic.tests.unit.db import base as db_base
|
||||
from ironic.tests.unit.objects import utils
|
||||
|
||||
|
||||
class NoopInterfaceTestCase(db_base.DbTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(NoopInterfaceTestCase, self).setUp()
|
||||
self.config(enabled_drivers=['fake'])
|
||||
mgr_utils.mock_the_extension_manager()
|
||||
self.interface = noop.NoopNetwork()
|
||||
self.node = utils.create_test_node(self.context,
|
||||
network_interface='noop')
|
||||
self.port = utils.create_test_port(
|
||||
self.context, node_id=self.node.id, address='52:54:00:cf:2d:32')
|
||||
|
||||
def test_get_properties(self):
|
||||
result = self.interface.get_properties()
|
||||
self.assertEqual({}, result)
|
||||
|
||||
def test_validate(self):
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
self.interface.validate(task)
|
||||
|
||||
def test_port_changed(self):
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
self.interface.port_changed(task, self.port)
|
||||
|
||||
def test_portgroup_changed(self):
|
||||
portgroup = utils.create_test_portgroup(self.context)
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
self.interface.portgroup_changed(task, portgroup)
|
||||
|
||||
def test_vif_attach(self):
|
||||
vif = {'id': 'vif-id'}
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
self.interface.vif_attach(task, vif)
|
||||
|
||||
def test_vif_detach(self):
|
||||
vif_id = 'vif-id'
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
self.interface.vif_detach(task, vif_id)
|
||||
|
||||
def test_vif_list(self):
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
result = self.interface.vif_list(task)
|
||||
self.assertEqual([], result)
|
||||
|
||||
def test_get_current_vif(self):
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
result = self.interface.get_current_vif(task, self.port)
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_add_provisioning_network(self):
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
self.interface.add_provisioning_network(task)
|
||||
|
||||
def test_remove_provisioning_network(self):
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
self.interface.remove_provisioning_network(task)
|
||||
|
||||
def test_configure_tenant_networks(self):
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
self.interface.configure_tenant_networks(task)
|
||||
|
||||
def test_unconfigure_tenant_networks(self):
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
self.interface.unconfigure_tenant_networks(task)
|
||||
|
||||
def test_add_cleaning_network(self):
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
self.interface.add_cleaning_network(task)
|
||||
|
||||
def test_remove_cleaning_network(self):
|
||||
with task_manager.acquire(self.context, self.node.id) as task:
|
||||
self.interface.remove_cleaning_network(task)
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes an issue with the 'noop' network interface where listing the VIFs for
|
||||
a node fails with a HTTP 500 Internal Server Error.
|
Loading…
Reference in New Issue
Block a user