issue:37307 Add support for changes in pfc output in onyx 3.6.6000 (#… (#38330)

* issue:37307 Add support for changes in pfc output in onyx 3.6.6000 (#37651)

* issue:37307 Add support for changes in pfc output in onyx 3.6.6000

Signed-off-by: Samer Deeb <samerd@mellanox.com>
(cherry picked from commit 9dfb665e43)

* fragment
pull/38341/head
John R Barker 7 years ago committed by GitHub
parent aed8aea3f3
commit 08029a38df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- onyx_pfc_interface - Add support for changes in pfc output in onyx 3.6.6000 https://github.com/ansible/ansible/pull/37651

@ -140,12 +140,20 @@ class OnyxPfcInterfaceModule(BaseOnyxModule):
def load_current_config(self):
# called in base class in run function
self._os_version = self._get_os_version()
self._current_config = dict()
pfc_config = self._get_pfc_config()
if not pfc_config:
return
if 'Table 2' in pfc_config:
pfc_config = pfc_config['Table 2']
if self._os_version >= self.ONYX_API_VERSION:
if len(pfc_config) >= 3:
pfc_config = pfc_config[2]
else:
pfc_config = dict()
else:
if 'Table 2' in pfc_config:
pfc_config = pfc_config['Table 2']
for if_name, if_pfc_data in iteritems(pfc_config):
match = self.PFC_IF_REGEX.match(if_name)
if not match:

@ -27,11 +27,15 @@ class TestOnyxPfcInterfaceModule(TestOnyxModule):
self.mock_load_config = patch(
'ansible.module_utils.network.onyx.onyx.load_config')
self.load_config = self.mock_load_config.start()
self.mock_get_version = patch.object(
onyx_pfc_interface.OnyxPfcInterfaceModule, "_get_os_version")
self.get_version = self.mock_get_version.start()
def tearDown(self):
super(TestOnyxPfcInterfaceModule, self).tearDown()
self.mock_get_config.stop()
self.mock_load_config.stop()
self.mock_get_version.stop()
def load_fixtures(self, commands=None, transport='cli'):
if self._pfc_enabled:
@ -42,6 +46,7 @@ class TestOnyxPfcInterfaceModule(TestOnyxModule):
self.get_config.return_value = load_fixture(config_file)
self.load_config.return_value = None
self.get_version.return_value = "3.6.5000"
def _test_pfc_if(self, if_name, enabled, changed, commands):
state = 'enabled' if enabled else 'disabled'

Loading…
Cancel
Save