diff --git a/plugins/modules/onyx_bgp.py b/plugins/modules/onyx_bgp.py index 0025ed0..5a79f57 100644 --- a/plugins/modules/onyx_bgp.py +++ b/plugins/modules/onyx_bgp.py @@ -111,7 +111,7 @@ - router bgp 320 vrf default neighbor evpn send-community extended - router bgp 320 vrf default address-family l2vpn-evpn neighbor evpn next-hop-unchanged - router bgp 320 vrf default address-family l2vpn-evpn neighbor evpn activate - - router bgp 320 vrf default address-family l2vpn-evpn auto-create + - router bgp 320 vrf default address-family l2vpn-evpn vni auto-create - router bgp 320 vrf default neighbor 10.3.3.4 remote-as 321 - router bgp 320 vrf default neighbor 10.3.3.4 ebgp-multihop 250 - router bgp 320 vrf default neighbor 10.3.3.5 remote-as 322 @@ -152,7 +152,7 @@ class OnyxBgpModule(BaseOnyxModule): EVPN_ACTIVATE_REGEX = re.compile( r'^\s.*router bgp\s+(\d+)\s+vrf\s+(\S+)\s+address-family l2vpn\-evpn neighbor evpn activate.*') EVPN_AUTO_CREATE_REGEX = re.compile( - r'^\s.*router bgp\s+(\d+)\s+vrf\s+(\S+)\s+address-family l2vpn\-evpn auto-create.*') + r'^\s.*router bgp\s+(\d+)\s+vrf\s+(\S+)\s+address-family l2vpn\-evpn vni auto-create.*') _purge = False @@ -166,7 +166,7 @@ class OnyxBgpModule(BaseOnyxModule): EVPN_SEND_COMMUNITY_EXTENDED_CMD = "router bgp %s vrf %s neighbor evpn send-community extended" EVPN_NEXT_HOP_UNCHANGED_CMD = "router bgp %s vrf %s address-family l2vpn-evpn neighbor evpn next-hop-unchanged" EVPN_ACTIVATE_CMD = "router bgp %s vrf %s address-family l2vpn-evpn neighbor evpn activate" - EVPN_AUTO_CREATE_CMD = "router bgp %s vrf %s address-family l2vpn-evpn auto-create" + EVPN_AUTO_CREATE_CMD = "router bgp %s vrf %s address-family l2vpn-evpn vni auto-create" EVPN_ENABLE_ATTRS = [EVPN_PEER_GROUP_ATTR, EVPN_SEND_COMMUNITY_EXTENDED_ATTR, EVPN_NEXT_HOP_UNCHANGED_ATTR, EVPN_ACTIVATE_ATTR, EVPN_AUTO_CREATE_ATTR] diff --git a/plugins/modules/onyx_interface.py b/plugins/modules/onyx_interface.py index 6926d24..a838239 100644 --- a/plugins/modules/onyx_interface.py +++ b/plugins/modules/onyx_interface.py @@ -340,7 +340,7 @@ def load_current_config(self): config = self._get_interfaces_config() if not config: return - if self._os_version < self.ONYX_API_VERSION: + if int(self._os_version.replace('.',''))= self.ONYX_API_VERSION: + if int(self._os_version.replace('.',''))>int(self.ONYX_API_VERSION.replace('.','')): if_data = if_data[0] return { diff --git a/plugins/modules/onyx_l3_interface.py b/plugins/modules/onyx_l3_interface.py index c28c84f..f04025d 100644 --- a/plugins/modules/onyx_l3_interface.py +++ b/plugins/modules/onyx_l3_interface.py @@ -192,7 +192,7 @@ def _get_interfaces_config(self, interface_type): return get_interfaces_config(self._module, interface_type) def _parse_interfaces_config(self, if_type, if_config): - if self._os_version < self.ONYX_API_VERSION: + if int(self._os_version.replace('.',''))>int(self.ONYX_API_VERSION.replace('.','')): for if_data in if_config: if_name = self.get_config_attr(if_data, 'header') self._get_if_attributes(if_type, if_name, if_data) diff --git a/plugins/modules/onyx_linkagg.py b/plugins/modules/onyx_linkagg.py index 7ed02a7..dccb219 100644 --- a/plugins/modules/onyx_linkagg.py +++ b/plugins/modules/onyx_linkagg.py @@ -221,7 +221,7 @@ def _get_port_channels(self, if_type): def _parse_port_channels_summary(self, lag_type, lag_summary): if lag_type == self.MLAG_TYPE: - if self._os_version >= self.ONYX_API_VERSION: + if int(self._os_version.replace('.',''))>=int(self.ONYX_API_VERSION.replace('.','')): found_summary = False for summary_item in lag_summary: if self.MLAG_SUMMARY in summary_item: diff --git a/plugins/modules/onyx_magp.py b/plugins/modules/onyx_magp.py index 94189cd..20ed759 100644 --- a/plugins/modules/onyx_magp.py +++ b/plugins/modules/onyx_magp.py @@ -129,7 +129,7 @@ def _create_magp_instance_data(self, magp_id, item): router_mac=self.get_config_attr(item, "Virtual MAC")) def _update_magp_data(self, magp_data): - if self._os_version >= self.ONYX_API_VERSION: + if int(self._os_version.replace('.',''))>=int(self.ONYX_API_VERSION.replace('.','')): for magp_config in magp_data: for magp_name, data in iteritems(magp_config): magp_id = int(magp_name.replace('MAGP ', '')) diff --git a/plugins/modules/onyx_pfc_interface.py b/plugins/modules/onyx_pfc_interface.py index 21ab4fb..b191ed8 100644 --- a/plugins/modules/onyx_pfc_interface.py +++ b/plugins/modules/onyx_pfc_interface.py @@ -140,7 +140,7 @@ def load_current_config(self): pfc_config = self._get_pfc_config() if not pfc_config: return - if self._os_version >= self.ONYX_API_VERSION: + if int(self._os_version.replace('.',''))>=int(self.ONYX_API_VERSION.replace('.','')): if len(pfc_config) >= 3: pfc_config = pfc_config[2] else: diff --git a/plugins/modules/onyx_vlan.py b/plugins/modules/onyx_vlan.py index d4e10cc..5eff6cf 100644 --- a/plugins/modules/onyx_vlan.py +++ b/plugins/modules/onyx_vlan.py @@ -134,7 +134,7 @@ def get_required_config(self): self._required_config.append(params) def _create_vlan_data(self, vlan_id, vlan_data): - if self._os_version >= self.ONYX_API_VERSION: + if int(self._os_version.replace('.',''))>=int(self.ONYX_API_VERSION.replace('.','')): vlan_data = vlan_data[0] return { 'vlan_id': vlan_id, diff --git a/plugins/modules/onyx_vxlan.py b/plugins/modules/onyx_vxlan.py index 747e62e..101feea 100644 --- a/plugins/modules/onyx_vxlan.py +++ b/plugins/modules/onyx_vxlan.py @@ -116,35 +116,60 @@ def _set_vxlan_config(self, vxlan_config): vxlan_config = vxlan_config[0] if not vxlan_config: return - nve_header = vxlan_config.get("header") - match = self.NVE_ID_REGEX.match(nve_header) - if match: - current_nve_id = int(match.group(1)) - self._current_config['nve_id'] = current_nve_id - if int(current_nve_id) != self._required_config.get("nve_id"): - return - self._current_config['mlag_tunnel_ip'] = vxlan_config.get("Mlag tunnel IP") - controller_mode = vxlan_config.get("Controller mode") + if int(self._os_version.replace('.',''))>int(self.ONYX_API_VERSION.replace('.','')): + interface_key='' + for key in vxlan_config.keys(): + if key.startswith('Interface NVE'): + match = self.NVE_ID_REGEX.match(key) + if match: + interface_key=key + current_nve_id = int(match.group(1)) + self._current_config['nve_id'] = current_nve_id + if int(current_nve_id) != self._required_config.get("nve_id"): + return + else: + nve_header = vxlan_config.get("header") + match = self.NVE_ID_REGEX.match(nve_header) + if match: + current_nve_id = int(match.group(1)) + self._current_config['nve_id'] = current_nve_id + if int(current_nve_id) != self._required_config.get("nve_id"): + return + if int(self._os_version.replace('.',''))>int(self.ONYX_API_VERSION.replace('.','')): + self._current_config['mlag_tunnel_ip'] = vxlan_config.get(interface_key)[0].get("MLAG tunnel ip") + controller_mode = vxlan_config.get(interface_key)[0].get("Controller mode") + else: + self._current_config['mlag_tunnel_ip'] = vxlan_config.get("Mlag tunnel IP") + controller_mode = vxlan_config.get("Controller mode") + if controller_mode == "BGP": self._current_config['bgp'] = True else: self._current_config['bgp'] = False - loopback_str = vxlan_config.get("Source interface") + if int(self._os_version.replace('.',''))>int(self.ONYX_API_VERSION.replace('.','')): + loopback_str = vxlan_config.get(interface_key)[0].get("Source interface") + else: + loopback_str = vxlan_config.get("Source interface") match = self.LOOPBACK_REGEX.match(loopback_str) if match: loopback_id = match.group(1) self._current_config['loopback_id'] = int(loopback_id) - self._current_config['global_neigh_suppression'] = vxlan_config.get("Global Neigh-Suppression") + if int(self._os_version.replace('.',''))>int(self.ONYX_API_VERSION.replace('.','')): + self._current_config['global_neigh_suppression'] = vxlan_config.get(interface_key)[0].get("Global neigh-suppression") + else: + self._current_config['global_neigh_suppression'] = vxlan_config.get("Global Neigh-Suppression") vni_vlan_mapping = self._current_config['vni_vlan_mapping'] = dict() nve_detail = self._show_nve_detail() if nve_detail is not None: - nve_detail = nve_detail[0] - + if int(self._os_version.replace('.',''))>int(self.ONYX_API_VERSION.replace('.','')): + nve_detail = nve_detail[1] + else: + nve_detail = nve_detail[0] if nve_detail: for vlan_id in nve_detail: vni_vlan_mapping[int(vlan_id)] = dict( @@ -161,6 +186,7 @@ def _show_nve_detail(self): def load_current_config(self): self._current_config = dict() + self._os_version = self._get_os_version() vxlan_config = self._show_vxlan_config() if vxlan_config: self._set_vxlan_config(vxlan_config) @@ -203,9 +229,9 @@ def generate_commands(self): def _generate_vni_vlan_cmds(self, vni_vlan_list, nve_id, arp_suppression): current_global_arp_suppression = self._current_config.get('global_neigh_suppression') - if arp_suppression is True and current_global_arp_suppression != "Enable": + if arp_suppression is True and (not current_global_arp_suppression.startswith("Enable")): self._commands.append('interface nve {0} nve neigh-suppression'.format(nve_id)) - + current_vni_vlan_mapping = self._current_config.get('vni_vlan_mapping') if current_vni_vlan_mapping is None: for vni_vlan in vni_vlan_list: