Handle validation failure if not all switch fields received
The Ironic API has a validation on the LocalLinkConnectionType to ensure all mandatory values are included. Handle failures which could occur if the switch does not send all mandatory fields. Change-Id: I8716a69586265a58520cc2c6bc0bbc00a7c159da Story: 2004238 Task: 27761
This commit is contained in:
parent
054f300290
commit
7703aab662
@ -16,6 +16,7 @@
|
|||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
from construct import core
|
from construct import core
|
||||||
|
from ironicclient import exceptions
|
||||||
import netaddr
|
import netaddr
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_utils import netutils
|
from oslo_utils import netutils
|
||||||
@ -157,4 +158,9 @@ class GenericLocalLinkConnectionHook(base.ProcessingHook):
|
|||||||
if patch is not None:
|
if patch is not None:
|
||||||
patches.append(patch)
|
patches.append(patch)
|
||||||
|
|
||||||
node_info.patch_port(port, patches)
|
try:
|
||||||
|
node_info.patch_port(port, patches)
|
||||||
|
except exceptions.BadRequest as e:
|
||||||
|
LOG.warning("Failed to update port %(uuid)s: %(error)s",
|
||||||
|
{'uuid': port.uuid, 'error': e},
|
||||||
|
node_info=node_info)
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
from ironicclient import exceptions
|
||||||
import mock
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
@ -211,3 +212,20 @@ class TestGenericLocalLinkConnectionHook(test_base.NodeTest):
|
|||||||
]
|
]
|
||||||
self.hook.before_update(self.data, self.node_info)
|
self.hook.before_update(self.data, self.node_info)
|
||||||
self.assertCalledWithPatch(patches, mock_patch)
|
self.assertCalledWithPatch(patches, mock_patch)
|
||||||
|
|
||||||
|
@mock.patch('ironic_inspector.plugins.local_link_connection.LOG')
|
||||||
|
@mock.patch.object(node_cache.NodeInfo, 'patch_port')
|
||||||
|
def test_patch_port_exception(self, mock_patch, mock_log):
|
||||||
|
self.data['all_interfaces'] = {
|
||||||
|
'em1': {"ip": self.ips[0], "mac": self.macs[0],
|
||||||
|
"lldp_processed": {
|
||||||
|
"switch_chassis_id": "192.0.2.1",
|
||||||
|
"switch_port_id": "Ethernet2/66"}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mock_patch.side_effect = exceptions.BadRequest('invalid data')
|
||||||
|
self.hook.before_update(self.data, self.node_info)
|
||||||
|
log_msg = ("Failed to update port %(uuid)s: %(error)s")
|
||||||
|
mock_log.warning.assert_called_with(log_msg, mock.ANY,
|
||||||
|
node_info=mock.ANY)
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- Fixes issue that can result in introspection failure when a network switch
|
||||||
|
sends incomplete information for LLDP switch_id or port_id. The validation
|
||||||
|
expects these fields when a port is updated, this fix now handles the
|
||||||
|
validation exception.
|
Loading…
Reference in New Issue
Block a user