Provide proper error message if interface name is invalid
Currently if an invalid interface name is used for the "openstack baremetal introspection interface show" command the unhelpful message "need more than 0 values to unpack" is returned. This fix returns a better message. Story: 2002749 Task: 22603 Change-Id: I0556b64e39c5b3e9be0cfecfb6d741a4e5cd16e7
This commit is contained in:
parent
519475f94a
commit
5d2a4d1650
|
@ -427,8 +427,7 @@ class TestInterfaceApi(BaseTest):
|
|||
self.uuid, "em1", fields)
|
||||
self.assertEqual(expected_values, iface_dict)
|
||||
|
||||
# Test interface name not in 'all_interfaces'
|
||||
expected_values = collections.OrderedDict()
|
||||
iface_dict = self.get_client().get_interface_data(
|
||||
self.uuid, "em55", fields)
|
||||
self.assertEqual(expected_values, iface_dict)
|
||||
def test_invalid_interface(self, mock_req):
|
||||
mock_req.return_value.json.return_value = self.inspector_db
|
||||
self.assertRaises(ValueError, self.get_client().get_interface_data,
|
||||
self.uuid, "em55", ["node_ident", "interface"])
|
||||
|
|
|
@ -287,6 +287,7 @@ class ClientV1(http.BaseClient):
|
|||
:param interface: interface name
|
||||
:param field_sel: list of all fields for which to get data
|
||||
:returns: interface data in OrderedDict
|
||||
:raises: ValueError if interface is not found.
|
||||
"""
|
||||
# Use OrderedDict to maintain order of user-entered fields
|
||||
iface_data = collections.OrderedDict()
|
||||
|
@ -296,7 +297,9 @@ class ClientV1(http.BaseClient):
|
|||
|
||||
# Make sure interface name is valid
|
||||
if interface not in all_interfaces:
|
||||
return iface_data
|
||||
raise ValueError(
|
||||
_("Interface %s was not found on this node")
|
||||
% interface)
|
||||
|
||||
# If lldp data not available this will still return interface,
|
||||
# mac, node_ident etc.
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
fixes:
|
||||
- The error message returned when running the
|
||||
`openstack baremetal introspection interface show`
|
||||
command with an interface not associated with the node has been fixed.
|
||||
It now indicates that the interface was invalid.
|
Loading…
Reference in New Issue