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

cisco.nxos.nxos_lag_interfaces KeyError in overridden state #452

Closed
clammers opened this issue Mar 31, 2022 · 1 comment · Fixed by #464
Closed

cisco.nxos.nxos_lag_interfaces KeyError in overridden state #452

clammers opened this issue Mar 31, 2022 · 1 comment · Fixed by #464
Assignees
Labels
bug This issue/PR relates to a bug. has_pr This issue has an associated PR. lag_interfaces lag_interfaces resource module

Comments

@clammers
Copy link

clammers commented Mar 31, 2022

SUMMARY

We're trying to run the following playbook on a nxos 9000v where no port-channel exists. So we first create a interface "port-channel99" and then running the nxos_lag_interfaces for configuring the corresponding interface. The main problem we're struggling with is the "overridden" state cause the playbook fails with

"/var/folders/np/d5pmgqdj1q9_spgdts9h5hmm0000gn/T/ansible_nxos_lag_interfaces_payload_zHpOoI/ansible_nxos_lag_interfaces_payload.zip/ansible_collections/cisco/nxos/plugins/module_utils/network/nxos/config/lag_interfaces/lag_interfaces.py", line 202, in _state_overridden
KeyError: 'members'
ISSUE TYPE
  • Bug Report
COMPONENT NAME

nxos_lag_interfaces

ANSIBLE VERSION
ansible [core 2.12.4]
  config file = /config/ansible/fabrics/vrnx-dev/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /services/ansible-2.12/lib/python3.8/site-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /services/ansible-2.12/bin/ansible
  python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
  jinja version = 3.1.1
  libyaml = True
COLLECTION VERSION
Collection        Version
----------------- -------
ansible.netcommon 2.5.0
ansible.utils     2.4.3
cisco.nxos        2.8.2
STEPS TO REPRODUCE

Run the following playbook on a switch where no PortChannel exists

- hosts:
    <nxos-switch>
  check_mode: no
  gather_facts: no
  # 'never' used to prevent a task to run unless a tag is specified
  tasks:

    - name: Port-Channel Layer 2 Configuration
      nxos_interfaces:
        config:
        - name: port-channel99
          description: Ansible Resource LAG

    - name: Port-Channel LAG Configuration
      nxos_lag_interfaces:
        config:
        - name: port-channel99
          members:
          - member: Ethernet1/9
            mode: active
            force: yes
        state: overridden
EXPECTED RESULTS

Correctly configure Port-Channel99

ACTUAL RESULTS

Seems to be an problem in source

    def _state_overridden(self, want, have):
        """ The command generator when state is overridden

        :rtype: A list
        :returns: the commands necessary to migrate the current configuration
                  to the desired configuration
        """
        commands = []
        for h in have:
            obj_in_want = search_obj_in_list(h["name"], want, "name")
            if obj_in_want:
                diff = self.diff_list_of_dicts(
                    h["members"], obj_in_want["members"]
                )
                if not diff:
                    continue
            commands.extend(self.del_all_commands(h))
        for w in want:
            commands.extend(self.set_commands(w, have))
        return commands

and cause there is no really configured Port-Channel (only just the interface) h["members"] is the KeyError

This will fix the issue:

                diff = self.diff_list_of_dicts(
                    h.get('members', []), obj_in_want["members"]
                )
@NilashishC NilashishC added bug This issue/PR relates to a bug. lag_interfaces lag_interfaces resource module labels Apr 25, 2022
@NilashishC NilashishC added the has_pr This issue has an associated PR. label Apr 25, 2022
softwarefactory-project-zuul bot pushed a commit that referenced this issue Apr 27, 2022
[lag_interfaces] fix overriden for channels with no members

Signed-off-by: NilashishC nilashishchakraborty8@gmail.com
SUMMARY

Fixes #452

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
nxos_lag_interfaces.py

Reviewed-by: GomathiselviS <None>
@clammers
Copy link
Author

Thanks!

NilashishC added a commit to NilashishC/cisco.nxos that referenced this issue Oct 6, 2022
…collections#464)

[lag_interfaces] fix overriden for channels with no members

Signed-off-by: NilashishC nilashishchakraborty8@gmail.com
SUMMARY

Fixes ansible-collections#452

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME
nxos_lag_interfaces.py

Reviewed-by: GomathiselviS <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug. has_pr This issue has an associated PR. lag_interfaces lag_interfaces resource module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants