Developer

 View Only
last person joined: 5 days ago 

Expand all | Collapse all

AOSCX programmatically addressing lldp_neighbors

This thread has been viewed 21 times
  • 1.  AOSCX programmatically addressing lldp_neighbors

    Posted Jun 07, 2022 10:05 AM
    Hi all,

    I likely could be going about this in all the wrong ways, but does anyone have a programmatic way to call out the lldp_neighbors in an AOSCX switch?

    I have been able to do this:
    "{{ (ansible_facts['net_interfaces']['line_card,1/1']['1/1/25']['lldp_neighbors']) | first }}"​

    Which will output the neighbor's MAC,INT:
    1a:2b:3c:4d:5e:6f,1/7/19​


    How can I address that fact to get to the underlying facts without baking that into my playbook?




    ------------------------------
    Don Rhodes
    ------------------------------


  • 2.  RE: AOSCX programmatically addressing lldp_neighbors

    MVP GURU
    Posted Jul 05, 2022 08:57 AM
    Hi Don,

    Do you have try to use * (wildcard) for port ?

    ------------------------------
    PowerArubaSW : Powershell Module to use Aruba Switch API for Vlan, VlanPorts, LACP, LLDP...

    PowerArubaCP: Powershell Module to use ClearPass API (create NAD, Guest...)

    PowerArubaCL: Powershell Module to use Aruba Central

    PowerArubaCX: Powershell Module to use ArubaCX API (get interface/vlan/ports info)..

    ACEP / ACMX #107 / ACDX #1281
    ------------------------------



  • 3.  RE: AOSCX programmatically addressing lldp_neighbors

    Posted Jul 22, 2022 04:34 PM
    I have tried a few different way and receive the following:

    "{{ (ansible_facts['net_interfaces']['line_card,1/1']['1/1/51']['lldp_neighbors'][*]) }}"

    msg: 'template error while templating string: unexpected ''*''. String: {{ (ansible_facts[''net_interfaces''][''line_card,1/1''][''1/1/51''][''lldp_neighbors''][*]) }}'



    "{{ (ansible_facts['net_interfaces']['line_card,1/1']['1/1/51']['lldp_neighbors']['*']) }}"

    msg: |-
    The task includes an option with an undefined variable. The error was: 'dict object' has no attribute '*'





  • 4.  RE: AOSCX programmatically addressing lldp_neighbors

    MVP GURU
    Posted Jul 29, 2022 08:00 AM
    What do you try to make ?

    ------------------------------
    PowerArubaSW : Powershell Module to use Aruba Switch API for Vlan, VlanPorts, LACP, LLDP...

    PowerArubaCP: Powershell Module to use ClearPass API (create NAD, Guest...)

    PowerArubaCL: Powershell Module to use Aruba Central

    PowerArubaCX: Powershell Module to use ArubaCX API (get interface/vlan/ports info)..

    ACEP / ACMX #107 / ACDX #1281
    ------------------------------



  • 5.  RE: AOSCX programmatically addressing lldp_neighbors

    Posted Aug 17, 2022 04:37 PM
    .


  • 6.  RE: AOSCX programmatically addressing lldp_neighbors

    Posted Aug 17, 2022 04:40 PM
    Trying to output some of the information in under neighbor_info.


  • 7.  RE: AOSCX programmatically addressing lldp_neighbors

    Posted Aug 22, 2022 02:18 PM
    I figured this out

    ---
      - name: __INCLUDED_TASK__ set_fact, 6100 - 12p
        set_fact:
          neighbor_1_1_13: "{{ (ansible_facts ['net_interfaces']['line_card,1/1']['1/1/13']['lldp_neighbors']) | first | default() }}"
          neighbor_1_1_14: "{{ (ansible_facts ['net_interfaces']['line_card,1/1']['1/1/14']['lldp_neighbors']) | first | default() }}"
        when:
          (ansible_facts ['net_product_info']['chassis,1']['part_number'] == "JL679A")
    
      - name: __INCLUDED_TASK__ Display transceiver information, 6100 - 12p
        debug:
          msg:
            - "{{ ansible_net_hostname }} 1/1/13 ({{ ansible_facts ['net_interfaces']['line_card,1/1']['1/1/13']['description'] | default('not_set') }}): {{ ansible_facts ['net_interfaces']['line_card,1/1']['1/1/13']['lldp_neighbors'][neighbor_1_1_13]['neighbor_info']['chassis_name'] | default() }} {{ ansible_facts ['net_interfaces']['line_card,1/1']['1/1/13']['lldp_neighbors'][neighbor_1_1_13]['port_id'] | default('not_defined') }} {{ ansible_facts ['net_interfaces']['line_card,1/1']['1/1/13']['lldp_neighbors'][neighbor_1_1_13]['neighbor_info']['port_description'] | default('not_defined') }}"
            - "{{ ansible_net_hostname }} 1/1/14 ({{ ansible_facts ['net_interfaces']['line_card,1/1']['1/1/14']['description'] | default('not_set') }}): {{ ansible_facts ['net_interfaces']['line_card,1/1']['1/1/14']['lldp_neighbors'][neighbor_1_1_14]['neighbor_info']['chassis_name'] | default() }} {{ ansible_facts ['net_interfaces']['line_card,1/1']['1/1/14']['lldp_neighbors'][neighbor_1_1_14]['port_id'] | default('not_defined') }} {{ ansible_facts ['net_interfaces']['line_card,1/1']['1/1/14']['lldp_neighbors'][neighbor_1_1_14]['neighbor_info']['port_description'] | default('not_defined') }}"
        when:
          (ansible_facts ['net_product_info']['chassis,1']['part_number'] == "JL679A")
    

    Maybe it could be done on a single line, but those lines are already hard to read.