Merge "Fixes port security settings caching issue"
This commit is contained in:
commit
b5f08e21eb
@ -606,14 +606,16 @@ class NetworkUtilsTestCase(test_base.OsWinBaseTestCase):
|
||||
self.netutils._set_switch_port_security_settings(
|
||||
mock.sentinel.switch_port_name,
|
||||
VirtualSubnetId=mock.sentinel.vsid)
|
||||
mock_remove_feature = self.netutils._jobutils.remove_virt_feature
|
||||
mock_remove_feature.assert_called_once_with(mock_sec_settings)
|
||||
|
||||
self.assertEqual(mock.sentinel.vsid,
|
||||
mock_sec_settings.VirtualSubnetId)
|
||||
mock_add_feature = self.netutils._jobutils.add_virt_feature
|
||||
mock_add_feature.assert_called_once_with(mock_sec_settings,
|
||||
mock_port_alloc)
|
||||
if missing_sec:
|
||||
mock_add_feature = self.netutils._jobutils.add_virt_feature
|
||||
mock_add_feature.assert_called_once_with(mock_sec_settings,
|
||||
mock_port_alloc)
|
||||
else:
|
||||
mock_modify_feature = self.netutils._jobutils.modify_virt_feature
|
||||
mock_modify_feature.assert_called_once_with(mock_sec_settings)
|
||||
|
||||
def test_set_switch_port_security_settings(self):
|
||||
self._check_set_switch_port_security_settings()
|
||||
|
@ -547,14 +547,12 @@ class NetworkUtils(baseutils.BaseUtilsVirt):
|
||||
sec_settings = self._get_security_setting_data_from_port_alloc(
|
||||
port_alloc)
|
||||
|
||||
if sec_settings:
|
||||
exists = sec_settings is not None
|
||||
|
||||
if exists:
|
||||
if all(getattr(sec_settings, k) == v for k, v in kwargs.items()):
|
||||
# All desired properties already properly set. Nothing to do.
|
||||
return
|
||||
|
||||
# Removing the feature because it cannot be modified
|
||||
# due to a wmi exception.
|
||||
self._jobutils.remove_virt_feature(sec_settings)
|
||||
else:
|
||||
sec_settings = self._create_default_setting_data(
|
||||
self._PORT_SECURITY_SET_DATA)
|
||||
@ -562,7 +560,10 @@ class NetworkUtils(baseutils.BaseUtilsVirt):
|
||||
for k, v in kwargs.items():
|
||||
setattr(sec_settings, k, v)
|
||||
|
||||
self._jobutils.add_virt_feature(sec_settings, port_alloc)
|
||||
if exists:
|
||||
self._jobutils.modify_virt_feature(sec_settings)
|
||||
else:
|
||||
self._jobutils.add_virt_feature(sec_settings, port_alloc)
|
||||
|
||||
# TODO(claudiub): This will help solve the missing VSID issue, but it
|
||||
# comes with a performance cost. The root cause of the problem must
|
||||
|
Loading…
Reference in New Issue
Block a user