ansible-collections / arista.eos

Ansible Network Collection for Arista EOS
GNU General Public License v3.0
82 stars 68 forks source link

eos_interfaces.config.speed unable to correctly apply or parse breakout ports #551

Open diego-lopez8 opened 1 month ago

diego-lopez8 commented 1 month ago
SUMMARY

eos_interfaces.config.speed and eos_interfaces.config.duplex are not parsing correctly when using a breakout configuration on a interface. When trying to gather interface information from a device, the speed and duplex is not parsed correctly, and the module is unable to apply a breakout via the speed command which is possible on the device itself.

ISSUE TYPE
COMPONENT NAME

eos_interfaces.config.speed and eos_interfaces.config.duplex

ANSIBLE VERSION
ansible [core 2.15.12]
  config file = /Users/diego/.ansible.cfg
  configured module search path = ['/Users/diego/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/diego/miniforge3/envs/net/lib/python3.9/site-packages/ansible
  ansible collection location = /Users/diego/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/diego/miniforge3/envs/net/bin/ansible
  python version = 3.9.18 | packaged by conda-forge | (main, Aug 30 2023, 03:53:08) [Clang 15.0.7 ] (/Users/diego/miniforge3/envs/net/bin/python3.9)
  jinja version = 3.1.3
  libyaml = True
COLLECTION VERSION
# /Users/diego/.ansible/collections/ansible_collections
Collection Version
---------- -------
arista.eos 10.0.0 
CONFIGURATION
CONFIG_FILE() = /Users/diego/.ansible.cfg
DEFAULT_TIMEOUT(/Users/diego/.ansible.cfg) = 30
OS / ENVIRONMENT

Arista DCS-7050DX4-32S-F Software image version: 4.32.1F

STEPS TO REPRODUCE

Run a play with "Gather" state to fetch configuration of an interface which has a breakout already applied via speed 100g-2:

Switch has the following configuration

interface Ethernet1/1
   description Just a Breakout Interface
   mtu 9100
   speed 100g-2
   channel-group 1 mode active
!
interface Ethernet1/3
!
interface Ethernet1/4
!
interface Ethernet1/5
!
interface Ethernet1/6
!
interface Ethernet1/7
!
interface Ethernet1/8
!

Run the following play

- name: Configure interfaces on Arista switches
  hosts: all
  gather_facts: true
  connection: network_cli
  tasks:
  - name: Gather interfaces facts from the device
    arista.eos.interfaces:
      state: gathered
    register: if
  - name: debugging
    debug:
      var: if
EXPECTED RESULTS

I expect

            {
                "description": "Just a Breakout Interface",
                "enabled": true,
                "mtu": 9100,
                "name": "Ethernet1/1",
                "speed": "100g-2"
            },
ACTUAL RESULTS

The actual results of the gather play is

            {
                "description": "Just a Breakout Interface",
                "duplex": "0g-2",
                "enabled": true,
                "mtu": 9100,
                "name": "Ethernet1/1",
                "speed": "10"
            },
            {
                "enabled": true,
                "name": "Ethernet1/3"
            },
            {
                "enabled": true,
                "name": "Ethernet1/4"
            },
            {
                "enabled": true,
                "name": "Ethernet1/5"
            },
            {
                "enabled": true,
                "name": "Ethernet1/6"
            },
            {
                "enabled": true,
                "name": "Ethernet1/7"
            },
            {
                "enabled": true,
                "name": "Ethernet1/8"
            },

The parser believes that the speed is 10 and the duplex is 0g-2.

Output of show interfaces ethernet 1/1 hardware:

Ethernet1/1
  Model: DCS-7050DX4-32S
  Type: 400GBASE-DR4
  Speed/duplex: 100G-2/full,400G-8/full(default)
  Flowcontrol: rx-(off,on),tx-(off,on)
  Error correction: reed-solomon(100G-2(default),400G-8(default)), fire-code(none), disabled(none)

Another example for state: merged:

Run the play:

- name: Configure interfaces on Arista switches
  hosts: all
  gather_facts: true
  connection: network_cli
  tasks:
  - name: Gather interfaces facts from the device
    arista.eos.interfaces:
      config:
        - name: Ethernet5/1
          speed: 100g-2
      state: merged
EXPECTED RESULTS

I expect the speed 100g-2 to be applied to the switch, and for the breakout to be created.

ACTUAL RESULTS

Results of the play:

fatal: [hsrn-sw22a-1mt]: FAILED! => {
    "changed": false,
    "module_stderr": "speed 100g-2None\r\n% Invalid input\r\nHSRN-SW22A-1MT(config-s-ansible_17-if-Et5/1)#",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error"
}
wanzel commented 2 weeks ago

I can see the issue. It tries to configure

interface Ethernet5/1
 speed 100g-2None

This None is coming here:

There are more combinations of speed that the template does not follow ( lanes )

ceos1(config)#interface eth5/1
! Interface does not exist. The configuration will not take effect until the module is inserted.
ceos1(config-if-Et5/1)#speed ?
  100full        Disable autoneg and force 100 Mbps/full duplex operation
  100g           Disable autoneg and force 100 Gbps/full duplex operation over 4 or 10 lanes
  100g-1         Disable autoneg and force 100 Gbps/full duplex operation over 1 lane
  100g-2         Disable autoneg and force 100 Gbps/full duplex operation over 2 lanes
  100g-4         Disable autoneg and force 100 Gbps/full duplex operation over 4 lanes
  100half        Disable autoneg and force 100 Mbps/half duplex operation
  10full         Disable autoneg and force 10 Mbps/full duplex operation
  10g            Disable autoneg and force 10 Gbps/full duplex operation over 1 lane
  10half         Disable autoneg and force 10 Mbps/half duplex operation
  1g             Disable autoneg and force 1 Gbps/full duplex operation over 1 lane
  200g           Disable autoneg and force 200 Gbps/full duplex operation over 4 lanes
  200g-2         Disable autoneg and force 200 Gbps/full duplex operation over 2 lanes
  200g-4         Disable autoneg and force 200 Gbps/full duplex operation over 4 lanes
  25g            Disable autoneg and force 25 Gbps/full duplex operation over 1 lane
  400g           Disable autoneg and force 400 Gbps/full duplex operation over 8 lanes
  400g-4         Disable autoneg and force 400 Gbps/full duplex operation over 4 lanes
  400g-8         Disable autoneg and force 400 Gbps/full duplex operation over 8 lanes
  40g            Disable autoneg and force 40 Gbps/full duplex operation over 4 lanes
  50g            Disable autoneg and force 50 Gbps/full duplex operation over 2 lanes
  50g-1          Disable autoneg and force 50 Gbps/full duplex operation over 1 lane
  50g-2          Disable autoneg and force 50 Gbps/full duplex operation over 2 lane
  800g-8         Disable autoneg and force 800 Gbps/full duplex operation over 8 lanes
  auto           Enable autoneg for speed, duplex, and flowcontrol
  forced         Disable autoneg and force speed/duplex/flowcontrol
  sfp-1000baset  Configure autoneg and speed/duplex on 1000BASE-T SFP

ceos1(config-if-Et5/1)#speed forced ?
  10000full  Disable autoneg and force 10 Gbps/full duplex operation
  1000full   Disable autoneg and force 1 Gbps/full duplex operation
  1000half   Disable autoneg and force 1 Gbps/half duplex operation
  100full    Disable autoneg and force 100 Mbps/full duplex operation
  100gfull   Disable autoneg and force 100 Gbps/full duplex operation
  100half    Disable autoneg and force 100 Mbps/half duplex operation
  10full     Disable autoneg and force 10 Mbps/full duplex operation
  10half     Disable autoneg and force 10 Mbps/half duplex operation
  25gfull    Disable autoneg and force 25 Gbps/full duplex operation
  40gfull    Disable autoneg and force 40 Gbps/full duplex operation
  50gfull    Disable autoneg and force 50 Gbps/full duplex operation