summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-11-15 14:00:02 +0000
committerGerrit Code Review <review@openstack.org>2018-11-15 14:00:02 +0000
commit9f4d1cdf1528edf15ecfe1e39bbe21704c02a098 (patch)
treee2a81bd7cdb12e8dc3417e6e7b290a5b55bc0621
parentb750ef5013a81115c25213d9951b09af620af11c (diff)
parent7703aab662db2de8e8fd75d739a923637c3d111f (diff)
Merge "Handle validation failure if not all switch fields received"
-rw-r--r--ironic_inspector/plugins/local_link_connection.py8
-rw-r--r--ironic_inspector/test/unit/test_plugins_local_link_connection.py18
-rw-r--r--releasenotes/notes/handle-patch-port-failure-9a8b85749104506f.yaml6
3 files changed, 31 insertions, 1 deletions
diff --git a/ironic_inspector/plugins/local_link_connection.py b/ironic_inspector/plugins/local_link_connection.py
index bb86ba0..aea9faa 100644
--- a/ironic_inspector/plugins/local_link_connection.py
+++ b/ironic_inspector/plugins/local_link_connection.py
@@ -16,6 +16,7 @@
16import binascii 16import binascii
17 17
18from construct import core 18from construct import core
19from ironicclient import exceptions
19import netaddr 20import netaddr
20from oslo_config import cfg 21from oslo_config import cfg
21from oslo_utils import netutils 22from oslo_utils import netutils
@@ -157,4 +158,9 @@ class GenericLocalLinkConnectionHook(base.ProcessingHook):
157 if patch is not None: 158 if patch is not None:
158 patches.append(patch) 159 patches.append(patch)
159 160
160 node_info.patch_port(port, patches) 161 try:
162 node_info.patch_port(port, patches)
163 except exceptions.BadRequest as e:
164 LOG.warning("Failed to update port %(uuid)s: %(error)s",
165 {'uuid': port.uuid, 'error': e},
166 node_info=node_info)
diff --git a/ironic_inspector/test/unit/test_plugins_local_link_connection.py b/ironic_inspector/test/unit/test_plugins_local_link_connection.py
index a574816..b068720 100644
--- a/ironic_inspector/test/unit/test_plugins_local_link_connection.py
+++ b/ironic_inspector/test/unit/test_plugins_local_link_connection.py
@@ -11,6 +11,7 @@
11# See the License for the specific language governing permissions and 11# See the License for the specific language governing permissions and
12# limitations under the License. 12# limitations under the License.
13 13
14from ironicclient import exceptions
14import mock 15import mock
15from oslo_config import cfg 16from oslo_config import cfg
16 17
@@ -211,3 +212,20 @@ class TestGenericLocalLinkConnectionHook(test_base.NodeTest):
211 ] 212 ]
212 self.hook.before_update(self.data, self.node_info) 213 self.hook.before_update(self.data, self.node_info)
213 self.assertCalledWithPatch(patches, mock_patch) 214 self.assertCalledWithPatch(patches, mock_patch)
215
216 @mock.patch('ironic_inspector.plugins.local_link_connection.LOG')
217 @mock.patch.object(node_cache.NodeInfo, 'patch_port')
218 def test_patch_port_exception(self, mock_patch, mock_log):
219 self.data['all_interfaces'] = {
220 'em1': {"ip": self.ips[0], "mac": self.macs[0],
221 "lldp_processed": {
222 "switch_chassis_id": "192.0.2.1",
223 "switch_port_id": "Ethernet2/66"}
224 }
225 }
226
227 mock_patch.side_effect = exceptions.BadRequest('invalid data')
228 self.hook.before_update(self.data, self.node_info)
229 log_msg = ("Failed to update port %(uuid)s: %(error)s")
230 mock_log.warning.assert_called_with(log_msg, mock.ANY,
231 node_info=mock.ANY)
diff --git a/releasenotes/notes/handle-patch-port-failure-9a8b85749104506f.yaml b/releasenotes/notes/handle-patch-port-failure-9a8b85749104506f.yaml
new file mode 100644
index 0000000..41393fa
--- /dev/null
+++ b/releasenotes/notes/handle-patch-port-failure-9a8b85749104506f.yaml
@@ -0,0 +1,6 @@
1---
2fixes:
3 - Fixes issue that can result in introspection failure when a network switch
4 sends incomplete information for LLDP switch_id or port_id. The validation
5 expects these fields when a port is updated, this fix now handles the
6 validation exception.