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

Fix multiple compatibility issues with 3.10.x and higher #29

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions plugins/modules/onyx_bgp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/onyx_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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('.',''))<int(self.ONYX_API_VERSION.replace('.','')):
for if_data in config:
if_name = self.get_if_name(if_data)
self._current_config[if_name] = self._create_if_data(
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/onyx_l2_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def get_access_vlan(cls, if_data):
return None

def _create_switchport_data(self, if_name, if_data):
if self._os_version >= self.ONYX_API_VERSION:
if int(self._os_version.replace('.',''))>int(self.ONYX_API_VERSION.replace('.','')):
if_data = if_data[0]

return {
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/onyx_l3_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/onyx_linkagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/onyx_magp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ', ''))
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/onyx_pfc_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/onyx_vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
56 changes: 41 additions & 15 deletions plugins/modules/onyx_vxlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down