Ignore events for unnamed VM vNICs
VM vNIC names are mandatory. Still, we'll getting events for unnamed ports, breaking os-win consumers. We'll ignore those events, logging a warning. Change-Id: I58a408b33a590b9c1ca3d8f32fa3c4d027f43381 Closes-Bug: #1761748
This commit is contained in:
parent
1f8200ef79
commit
42cfab1081
@ -209,9 +209,12 @@ class NetworkUtilsTestCase(test_base.OsWinBaseTestCase):
|
||||
def test_get_vnic_event_listener(self, mock_get_event_query,
|
||||
mock_execute, mock_patcher):
|
||||
event = mock.MagicMock()
|
||||
# This event should be ignored.
|
||||
unnamed_port_event = mock.MagicMock(ElementName=None)
|
||||
port_class = self.netutils._conn.Msvm_SyntheticEthernetPortSettingData
|
||||
wmi_event_listener = port_class.watch_for.return_value
|
||||
mock_execute.side_effect = [exceptions.x_wmi_timed_out, event]
|
||||
mock_execute.side_effect = [exceptions.x_wmi_timed_out,
|
||||
unnamed_port_event, event]
|
||||
|
||||
# callback will raise an exception in order to stop iteration in the
|
||||
# listener.
|
||||
@ -229,7 +232,7 @@ class NetworkUtilsTestCase(test_base.OsWinBaseTestCase):
|
||||
mock_get_event_query.return_value)
|
||||
mock_execute.assert_has_calls(
|
||||
[mock.call(wmi_event_listener,
|
||||
self.netutils._VNIC_LISTENER_TIMEOUT_MS)] * 2)
|
||||
self.netutils._VNIC_LISTENER_TIMEOUT_MS)] * 3)
|
||||
callback.assert_called_once_with(event.ElementName)
|
||||
|
||||
def test_get_event_wql_query(self):
|
||||
|
@ -297,7 +297,11 @@ class NetworkUtils(baseutils.BaseUtilsVirt):
|
||||
# the checked interval.
|
||||
try:
|
||||
event = listen()
|
||||
callback(event.ElementName)
|
||||
if event.ElementName:
|
||||
callback(event.ElementName)
|
||||
else:
|
||||
LOG.warning("Ignoring port event. "
|
||||
"The port name is missing.")
|
||||
except exceptions.x_wmi_timed_out:
|
||||
# no new event published.
|
||||
pass
|
||||
|
Loading…
x
Reference in New Issue
Block a user