ansible-dcnm icon indicating copy to clipboard operation
ansible-dcnm copied to clipboard

cisco.dcnm.dcnm_interface - Duplex Setting

Open xXAzazelXx opened this issue 1 year ago • 8 comments

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Would it be please possible to add "duplex" to the cisco.dcnm.dcnm_interface module? At the moment we are unable to specify the duplex setting in cisco.dcnm.dcnm_interface playbooks

New or Affected modules(s):

  • dcnm_3.4.3

DCNM version

  • V 12.1.2e

Potential ansible task config

# Copy-paste your ansible playbook
- name: Create Access Port using variables
  cisco.dcnm.dcnm_interface:
    fabric: "{{ fabric_name }}"
    state: merged
    config:
      - name: '{{ item.Interface }}'
        type: eth
        switch: 
        - '{{ item.Hostname }}'
        deploy: false
        profile:
          admin_state: true
          mode: access
          access_vlan: '{{ item.VLAN }}'
          bpdu_guard: '{{ item.BPDU_Guard }}'
          description: '{{ item.Description }}'
          mtu: jumbo
          port_type_fast: true
          speed: '{{ item.Speed }}'
          duplex: full <-------

References

Additional context Add any other context or screenshots about the feature request here.

xXAzazelXx avatar Apr 12 '24 07:04 xXAzazelXx

Does not look like NDFC exposes duplex as a property but you can set it using the cmds option from the module.

Something like this:

- name: Create Access Port using variables
  cisco.dcnm.dcnm_interface:
    fabric: "{{ fabric_name }}"
    state: merged
    config:
      - name: '{{ item.Interface }}'
        type: eth
        switch: 
        - '{{ item.Hostname }}'
        deploy: false
        profile:
          admin_state: true
          mode: access
          access_vlan: '{{ item.VLAN }}'
          bpdu_guard: '{{ item.BPDU_Guard }}'
          description: '{{ item.Description }}'
          mtu: jumbo
          port_type_fast: true
          speed: '{{ item.Speed }}'
          cmds:
              - duplex full

mikewiebe avatar Apr 12 '24 19:04 mikewiebe

Thank you, So the reason I suspected I needed duplex specified was that after editing the template to add duplex as a enum var for the user to select, I started getting this error:

*
failed: [XXXX_NDFC_IP] (item={'Hostname': 'XXXX_HOSTNAME', 'Interface': 'Eth1/30', 'Description': 'XXXXX', 'Speed': '100Mb', 'VLAN': '1', 'BPDU_Guard': 'true'}) => {"ansible_loop_var": "item", "changed": false, "item": {"BPDU_Guard": "true", "Description": "XXXXX", "Hostname": "XXXX_HOSTNAME", "Interface": "Eth1/30", "Speed": "100Mb", "VLAN": "1"}, "msg": {"CHANGED": [{"debugs": [], "deleted": [], "deploy": [], "merged": [{"interfaceType": "INTERFACE_ETHERNET", "interfaces": [{"ifName": "Ethernet1/30", "nvPairs": {"CONF": "duplex auto", "SPEED": "100Mb"}}]}], "overridden": [], "query": [], "replaced": []}], "DATA": [{"column": 0, "entity": "XXXX_HOSTNAME:Ethernet1/30", "line": 0, "message": "Traceback (most recent call last):\n  File \"<string>\", line 74, in add\n  File \"<string>\", line 74, in add\nNameError: global name 'DUPLEX' is not defined\n", "reportItemType": "ERROR"}], "MESSAGE": "Internal Server Error", "METHOD": "PUT", "REQUEST_PATH": "https://XXXX_NDFC_IP:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/interface", "RETURN_CODE": 500}}

However, i am still getting the same issue with cmds.

xXAzazelXx avatar Apr 12 '24 22:04 xXAzazelXx

failed: [XXXX_NDFC_IP] (item={'Hostname': 'XXXX_HOSTNAME', 'Interface': 'Eth1/30', 'Description': 'XXXXX', 'Speed': '100Mb', 'VLAN': '1', 'BPDU_Guard': 'true'}) => {"ansible_loop_var": "item", "changed": false, "item": {"BPDU_Guard": "true", "Description": "XXXXX", "Hostname": "XXXX_HOSTNAME", "Interface": "Eth1/30", "Speed": "100Mb", "VLAN": "1"}, "msg": {"CHANGED": [{"debugs": [], "deleted": [], "deploy": [], "merged": [{"interfaceType": "INTERFACE_ETHERNET", "interfaces": [{"ifName": "Ethernet1/30", "nvPairs": {"CONF": "duplex auto", "SPEED": "100Mb"}}]}], "overridden": [], "query": [], "replaced": []}], "DATA": [{"column": 0, "entity": "XXXX_HOSTNAME:Ethernet1/30", "line": 0, "message": "Traceback (most recent call last):\n  File \"<string>\", line 74, in add\n  File \"<string>\", line 74, in add\nNameError: global name 'DUPLEX' is not defined\n", "reportItemType": "ERROR"}], "MESSAGE": "Internal Server Error", "METHOD": "PUT", "REQUEST_PATH": "https://XXXX_NDFC_IP:443/appcenter/cisco/ndfc/api/v1/lan-fabric/rest/interface", "RETURN_CODE": 500}}

Are you still working with the edited template? If so, can you go back to the original template?

mikewiebe avatar Apr 13 '24 19:04 mikewiebe

Yes, I was. Sorry, are you suggesting removing the new duplex settings from the interface template and just using cmds to hard code? the issue will be if a person were to update the interface description for example, NDFC will try to remove the duplex setting as the template knows nothing about it.

xXAzazelXx avatar Apr 13 '24 23:04 xXAzazelXx

Yes, I was. Sorry, are you suggesting removing the new duplex settings from the interface template and just using cmds to hard code? the issue will be if a person were to update the interface description for example, NDFC will try to remove the duplex setting as the template knows nothing about it.

Yes that is what I am suggesting. The cmds property under the profile section of the module maps to the Freeform Config section in NDFC under the interface.

NDFC_Screenshot_Interface_Edit

mikewiebe avatar Apr 22 '24 16:04 mikewiebe

Just a quick note. If you use state: merged it will try and merge any commands you supply using the cmds option. If you don't want the commands to be merged, use state:replaced

mikewiebe avatar Apr 25 '24 14:04 mikewiebe

@xXAzazelXx Just checking if you saw my last response and if you had a chance to try it. NDFC should not remove what you add under the cmds option.

mikewiebe avatar May 02 '24 13:05 mikewiebe

Hey @mikewiebe ,

Thanks for following up. No sorry I could not get the cmd option to work, as I wanted to also have a GUI drop-down option to keep it all consistent (not just freeform). What I ended up doing is using speed settings as cisco.dcnm.dcnm_interface file manually to make a duplex setting for myself.

xXAzazelXx avatar May 03 '24 23:05 xXAzazelXx