Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issue:38167 add support for onyx version 3.6.6000 for onyx_linkagg #38191

Merged
merged 1 commit into from
Apr 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 17 additions & 1 deletion lib/ansible/modules/network/onyx/onyx_linkagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class OnyxLinkAggModule(BaseOnyxModule):
CHANNEL_GROUP = 'channel-group'
MLAG_PORT_CHANNEL = 'mlag-port-channel'
MLAG_CHANNEL_GROUP = 'mlag-channel-group'
MLAG_SUMMARY = 'MLAG Port-Channel Summary'

LAG_TYPE = 'lag'
MLAG_TYPE = 'mlag'
Expand Down Expand Up @@ -225,7 +226,21 @@ def _get_port_channels(self, if_type):

def _parse_port_channels_summary(self, lag_type, lag_summary):
if lag_type == self.MLAG_TYPE:
lag_summary = lag_summary.get('MLAG Port-Channel Summary', {})
if self._os_version >= self.ONYX_API_VERSION:
found_summary = False
for summary_item in lag_summary:
if self.MLAG_SUMMARY in summary_item:
lag_summary = summary_item[self.MLAG_SUMMARY]
if lag_summary:
lag_summary = lag_summary[0]
else:
lag_summary = dict()
found_summary = True
break
if not found_summary:
lag_summary = dict()
else:
lag_summary = lag_summary.get(self.MLAG_SUMMARY, dict())
for lag_key, lag_data in iteritems(lag_summary):
lag_name, state = self._extract_lag_name(lag_key)
if not lag_name:
Expand All @@ -240,6 +255,7 @@ def _parse_port_channels_summary(self, lag_type, lag_summary):

def load_current_config(self):
self._current_config = dict()
self._os_version = self._get_os_version()
lag_types = set([lag_obj['type'] for lag_obj in self._required_config])
for lag_type in lag_types:
if_type = self.IF_TYPE_MAP[lag_type]
Expand Down
5 changes: 5 additions & 0 deletions test/units/modules/network/onyx/test_onyx_linkagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,20 @@ def setUp(self):
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_linkagg.OnyxLinkAggModule, "_get_os_version")
self.get_version = self.mock_get_version.start()

def tearDown(self):
super(TestOnyxLinkaggModule, self).tearDown()
self.mock_get_config.stop()
self.mock_load_config.stop()
self.mock_get_version.stop()

def load_fixture(self, config_file):
self.get_config.return_value = load_fixture(config_file)
self.load_config.return_value = None
self.get_version.return_value = "3.6.5000"

def load_port_channel_fixture(self):
config_file = 'onyx_port_channel_show.cfg'
Expand Down