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

Signed-off-by: Samer Deeb <samerd@mellanox.com>
pull/38276/head
Samer Deeb 7 years ago committed by Chris Alfonso
parent 19ca1b2b8a
commit 72d42bd065

@ -109,6 +109,7 @@ class OnyxLinkAggModule(BaseOnyxModule):
CHANNEL_GROUP = 'channel-group' CHANNEL_GROUP = 'channel-group'
MLAG_PORT_CHANNEL = 'mlag-port-channel' MLAG_PORT_CHANNEL = 'mlag-port-channel'
MLAG_CHANNEL_GROUP = 'mlag-channel-group' MLAG_CHANNEL_GROUP = 'mlag-channel-group'
MLAG_SUMMARY = 'MLAG Port-Channel Summary'
LAG_TYPE = 'lag' LAG_TYPE = 'lag'
MLAG_TYPE = 'mlag' MLAG_TYPE = 'mlag'
@ -225,7 +226,21 @@ class OnyxLinkAggModule(BaseOnyxModule):
def _parse_port_channels_summary(self, lag_type, lag_summary): def _parse_port_channels_summary(self, lag_type, lag_summary):
if lag_type == self.MLAG_TYPE: 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): for lag_key, lag_data in iteritems(lag_summary):
lag_name, state = self._extract_lag_name(lag_key) lag_name, state = self._extract_lag_name(lag_key)
if not lag_name: if not lag_name:
@ -240,6 +255,7 @@ class OnyxLinkAggModule(BaseOnyxModule):
def load_current_config(self): def load_current_config(self):
self._current_config = dict() self._current_config = dict()
self._os_version = self._get_os_version()
lag_types = set([lag_obj['type'] for lag_obj in self._required_config]) lag_types = set([lag_obj['type'] for lag_obj in self._required_config])
for lag_type in lag_types: for lag_type in lag_types:
if_type = self.IF_TYPE_MAP[lag_type] if_type = self.IF_TYPE_MAP[lag_type]

@ -26,15 +26,20 @@ class TestOnyxLinkaggModule(TestOnyxModule):
self.mock_load_config = patch( self.mock_load_config = patch(
'ansible.module_utils.network.onyx.onyx.load_config') 'ansible.module_utils.network.onyx.onyx.load_config')
self.load_config = self.mock_load_config.start() 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): def tearDown(self):
super(TestOnyxLinkaggModule, self).tearDown() super(TestOnyxLinkaggModule, self).tearDown()
self.mock_get_config.stop() self.mock_get_config.stop()
self.mock_load_config.stop() self.mock_load_config.stop()
self.mock_get_version.stop()
def load_fixture(self, config_file): def load_fixture(self, config_file):
self.get_config.return_value = load_fixture(config_file) self.get_config.return_value = load_fixture(config_file)
self.load_config.return_value = None self.load_config.return_value = None
self.get_version.return_value = "3.6.5000"
def load_port_channel_fixture(self): def load_port_channel_fixture(self):
config_file = 'onyx_port_channel_show.cfg' config_file = 'onyx_port_channel_show.cfg'

Loading…
Cancel
Save