HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //lib/python3.9/site-packages/ansible_collections/dellemc/os9/roles/os9_lldp/templates/os9_lldp.j2
#jinja2: trim_blocks: True,lstrip_blocks: True
{###################################################
Purpose:
Configure LLDP commands for os9 Devices.

os9_lldp:
  global_lldp_state: present
  enable: false
  mode: rx
  multiplier: 3
  iscsi_priority_bits: 3
  fcoe_priority_bits: 3
  hello: 8
  dcbx:
    version: auto
  management_interface:
     hello: 6
     multiplier: 3
     mode: tx
     enable: true
     advertise:
       port_descriptor: false
       management_tlv: management-address system-capabilities
       management_tlv_state: present
  advertise:
     dcbx_tlv: pfc
     dcbx_tlv_state: present
     dcbx_appln_tlv: fcoe
     dcbx_appln_tlv_state:
     dot1_tlv:
       port_tlv:
          protocol_vlan_id: true
          port_vlan_id: true
       vlan_tlv:
          vlan_range: 2-4
          state: present
     dot3_tlv:
       max_frame_size: true
     port_descriptor: true
     management_tlv: management-address system-capabilities
     management_tlv_state: present
     med:
       application:
         - name: guest-voice
           vlan_id: 2
           l2_priority: 3
           code_point_value: 4
         - name: voice
           priority_tagged: true
           l2_priority: 3
           code_point_value: 4
       location_identification:
         - loc_info: ecs-elin
           value: 12345678911
  local_interface:
     fortyGigE 1/3:
       lldp_state: present
       enable: false
       mode: rx
       multiplier: 3
       hello: 8
       dcbx:
         version: auto
       advertise:
         dcbx_tlv: pfc
         dcbx_tlv_state: present
         dcbx_appln_tlv: fcoe
         dcbx_appln_tlv_state:
         dot1_tlv:
           port_tlv:
             protocol_vlan_id: true
             port_vlan_id: true
           vlan_tlv:
             vlan_range: 2-4
             state: present
         dot3_tlv:
           max_frame_size: true
         port_descriptor: true
         management_tlv: management-address system-capabilities
         management_tlv_state: present
         med:
           application:
             - name: guest-voice
               vlan_id: 2
               l2_priority: 3
               code_point_value: 4
             - name: voice
               priority_tagged: true
               l2_priority: 3
               code_point_value: 4
           location_identification:
             - loc_info: ecs-elin
               value: 12345678911
    

####################################################}
{% if os9_lldp is defined and os9_lldp %}
  {% set global_state = [] %}
  {% if global_state.append(True) %}{% endif %}
 
  {% for key in os9_lldp.keys() %}
  {% set lldp_vars  = os9_lldp[key] %}
    {% if key == "global_lldp_state" and lldp_vars == "absent" %}
no protocol lldp
    {% if global_state.insert(False,0) %}{% endif %}
    {% endif %}
  {% endfor %}

{% if global_state[0] %}
protocol lldp
{% endif %}

{% for key in os9_lldp.keys() %}
{% set lldp_vars  = os9_lldp[key] %}
{% if global_state[0] %}
{% if key == "management_interface" %}
 management-interface
  {% if lldp_vars.hello is defined and lldp_vars.hello %}
  hello {{ lldp_vars.hello }}
  {% else %}
  no hello
  {% endif %}
  {% if lldp_vars.enable is defined and lldp_vars.enable %}
  no disable
  {% else %}
  disable
  {% endif %}
  {% if lldp_vars.mode is defined and lldp_vars.mode %}
  mode {{ lldp_vars.mode }}
  {% else %}
  no mode
  {% endif %}
  {% if lldp_vars.multiplier is defined and lldp_vars.multiplier %}
  multiplier {{ lldp_vars.multiplier }}
  {% else %}
  no multiplier
  {% endif %}
  {% if lldp_vars.advertise is defined and lldp_vars.advertise %}
    {% if lldp_vars.advertise.port_descriptor is defined %}
      {% if lldp_vars.advertise.port_descriptor %}
  advertise interface-port-desc
      {% else %}
  no advertise interface-port-desc
      {% endif %}
    {% endif %}
    {% if lldp_vars.advertise.management_tlv is defined and lldp_vars.advertise.management_tlv %}
      {% if lldp_vars.advertise.management_tlv_state is defined and lldp_vars.advertise.management_tlv_state == "absent" %}
  no advertise management-tlv {{ lldp_vars.advertise.management_tlv }}
      {% else %}
  advertise management-tlv {{ lldp_vars.advertise.management_tlv }}
      {% endif %}
    {% endif %}
  {% endif %}
{% endif %}
{% if key == "enable" %}
  {% if lldp_vars %}
 no disable
  {% else %}
 disable
  {% endif %}
{% endif %}
{% if key == "fcoe_priority_bits" %}
  {% if lldp_vars %}
 fcoe priority-bits {{ lldp_vars }}
  {% else %}
 no fcoe priority-bits
  {% endif %}
{% endif %}
{% if key == "hello" %}
  {% if lldp_vars %}
 hello {{ lldp_vars }}
  {% else %}
 no hello
  {% endif %}
{% endif %}
{% if key == "mode" %}
  {% if lldp_vars %}
 mode {{ lldp_vars }}
  {% else %}
 no mode
  {% endif %}
{% endif %}
{% if key == "multiplier" %}
  {% if lldp_vars %}
 multiplier {{ lldp_vars }}
  {% else %}
 no multiplier
  {% endif %}
{% endif %}
{% if key == "iscsi_priority_bits" %}
  {% if lldp_vars %}
 iscsi priority-bits {{ lldp_vars }}
  {% else %}
 no iscsi priority-bits
  {% endif %}
{% endif %}
{% if key == "dcbx" %}
  {% if lldp_vars.version is defined and lldp_vars.version %}
 dcbx version {{ lldp_vars.version }}
  {% else %}
 no dcbx version
  {% endif %}
{% endif %}
{% if key == "advertise"  %}
{% if lldp_vars.management_tlv is defined and lldp_vars.management_tlv %}
  {% if lldp_vars.management_tlv_state is defined and lldp_vars.management_tlv_state == "absent" %}
 no advertise management-tlv {{ lldp_vars.management_tlv }}
  {% else %}
 advertise management-tlv {{ lldp_vars.management_tlv }}
  {% endif %}
{% endif %}

{% if lldp_vars.port_descriptor is defined %}
  {% if lldp_vars.port_descriptor %}
 advertise interface-port-desc
  {% else %}
 no advertise interface-port-desc
  {% endif %}
{% endif %}

{% if lldp_vars.med is defined  and lldp_vars.med %}
  {% for med in lldp_vars.med.keys() %}
  {% set med_vars = lldp_vars.med[med] %}
    {% if med == "global_med" %}
      {% if med_vars %}
 advertise med
      {% else %}
 no advertise med 
      {% endif %}
    {% endif %}
    {% if med == "location_identification" %}
      {% for loc in med_vars %}
        {% if loc.loc_info is defined and loc.loc_info %}
          {% if loc.value is defined and loc.value %}
            {% if loc.state is defined and loc.state == "absent" %}
 no advertise med location-identification {{ loc.loc_info }} {{ loc.value }}
            {% else %}
 advertise med location-identification {{ loc.loc_info }} {{ loc.value }}
            {% endif %}
          {% endif %}
        {% endif %}
      {% endfor %}
    {% endif %}
    {% if med == "application" %}
      {% for app in med_vars %}
        {% if app.name is defined and app.name %}
          {% if app.vlan_id is defined and app.vlan_id %}
            {% set vlan_or_tag = app.vlan_id %}
          {% elif app.priority_tagged is defined and app.priority_tagged %}
            {% set vlan_or_tag = "priority-tagged" %}
          {% endif %}
          {% if vlan_or_tag is defined and vlan_or_tag %}
            {% if app.l2_priority is defined and app.l2_priority %}
              {% if app.code_point_value is defined and app.code_point_value %}
                {% if app.state is defined and app.state == "absent" %}
 no advertise med {{ app.name }} {{ vlan_or_tag }} {{ app.l2_priority }} {{ app.code_point_value }}
                {% else %}
 advertise med {{ app.name }} {{ vlan_or_tag }} {{ app.l2_priority }} {{ app.code_point_value }}
                {% endif %}
              {% endif %}
            {% endif %}
          {% endif %}
        {% endif %}
      {% endfor %}
    {% endif %}
  {% endfor %}
{% endif %}

{% if lldp_vars.dcbx_tlv is defined and lldp_vars.dcbx_tlv %}
  {% if lldp_vars.dcbx_tlv_state is defined and lldp_vars.dcbx_tlv_state == "absent" %}
 no advertise dcbx-tlv {{ lldp_vars.dcbx_tlv }}
  {% else %}
 advertise dcbx-tlv {{ lldp_vars.dcbx_tlv }}
  {% endif %}
{% endif %}

{% if lldp_vars.dcbx_appln_tlv is defined and lldp_vars.dcbx_appln_tlv %}
  {% if lldp_vars.dcbx_appln_tlv_state is defined and lldp_vars.dcbx_appln_tlv_state == "absent" %}
 no advertise dcbx-appln-tlv {{ lldp_vars.dcbx_appln_tlv }}
  {% else %}
 advertise dcbx-appln-tlv {{ lldp_vars.dcbx_appln_tlv }}
  {% endif %}
{% endif %}

{% if lldp_vars.dot3_tlv is defined  and lldp_vars.dot3_tlv %}
  {% for dot3 in lldp_vars.dot3_tlv.keys() %}
  {% set dot3_vars = lldp_vars.dot3_tlv[dot3] %}
    {% if dot3 == "max_frame_size" %}
      {% if dot3_vars %}
 advertise dot3-tlv max-frame-size
      {% else %}
 no advertise dot3-tlv max-frame-size
      {% endif %}
    {% endif %}
  {% endfor %}
{% endif %}

{% if lldp_vars.dot1_tlv is defined  and lldp_vars.dot1_tlv %}
  {% for dot1 in lldp_vars.dot1_tlv.keys() %}
  {% set dot1_vars = lldp_vars.dot1_tlv[dot1] %}
    {% if dot1 == "port_tlv" %}
      {% if dot1_vars.protocol_vlan_id is defined and dot1_vars.protocol_vlan_id %}
        {% if dot1_vars.port_vlan_id is defined %}
          {% if dot1_vars.port_vlan_id %}
 advertise dot1-tlv port-protocol-vlan-id port-vlan-id
          {% else %}
 advertise dot1-tlv port-protocol-vlan-id
 no advertise dot1-tlv port-vlan-id
          {% endif %}
        {% else %}
 advertise dot1-tlv port-protocol-vlan-id
        {% endif %}
      {% else %}
        {% if not dot1_vars.protocol_vlan_id %}
 no advertise dot1-tlv port-protocol-vlan-id
        {% endif %}
        {% if dot1_vars.port_vlan_id is defined %}
          {% if dot1_vars.port_vlan_id %}
 advertise dot1-tlv port-vlan-id
          {% else %}
 no advertise dot1-tlv port-vlan-id
          {% endif %}
        {% endif %}
      {% endif %}
    {% endif %}
    {% if dot1 == "vlan_tlv" %}
      {% if dot1_vars.vlan_range is defined and dot1_vars.vlan_range %}
        {% if dot1_vars.state is defined and dot1_vars.state == "absent" %}
 no advertise dot1-tlv vlan-name vlan-id {{ dot1_vars.vlan_range }}
        {% else %}
 advertise dot1-tlv vlan-name vlan-id {{ dot1_vars.vlan_range }}
        {% endif %}
      {% endif %}
    {% endif %}
  {% endfor %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{% if os9_lldp is defined and os9_lldp %}
{% for key in os9_lldp.keys() %}
{% set lldp_vars  = os9_lldp[key] %}
{% if key == "local_interface" %}
  {% for intf in lldp_vars.keys() %}
  {% set intf_vars = lldp_vars[intf] %}
interface {{ intf }}
  {% if intf_vars.lldp_state is defined and intf_vars.lldp_state == "absent" %}
 no protocol lldp
  {% else %}
 protocol lldp
    {% if intf_vars.hello is defined and intf_vars.hello %}
  hello {{ intf_vars.hello }}
    {% else %}
  no hello
    {% endif %}
    {% if intf_vars.enable is defined and intf_vars.enable %}
  no disable
    {% else %}
  disable
    {% endif %}
    {% if intf_vars.mode is defined and intf_vars.mode %}
  mode {{ intf_vars.mode }}
    {% else %}
  no mode
    {% endif %}
    {% if intf_vars.multiplier is defined and intf_vars.multiplier %}
  multiplier {{ intf_vars.multiplier }}
    {% else %}
  no multiplier
    {% endif %}
    {% if intf_vars.dcbx is defined and intf_vars.dcbx %}
      {% if intf_vars.dcbx.version is defined and intf_vars.dcbx.version %}
  dcbx version {{ intf_vars.dcbx.version }}
      {% else %}
  no dcbx version
      {% endif %}
    {% endif %}
    {% if intf_vars.advertise is defined and intf_vars.advertise %}
      {% if intf_vars.advertise.port_descriptor is defined %}
        {% if intf_vars.advertise.port_descriptor %}
  advertise interface-port-desc
        {% else %}
  no advertise interface-port-desc
        {% endif %}
      {% endif %}
      {% if intf_vars.advertise.management_tlv is defined and intf_vars.advertise.management_tlv %}
        {% if intf_vars.advertise.management_tlv_state is defined and intf_vars.advertise.management_tlv_state == "absent" %}
  no advertise management-tlv {{ intf_vars.advertise.management_tlv }}
        {% else %}
  advertise management-tlv {{ intf_vars.advertise.management_tlv }}
        {% endif %}
      {% endif %}
      {% if intf_vars.advertise.med is defined and intf_vars.advertise.med %}
        {% for med in intf_vars.advertise.med.keys() %}
        {% set med_vars = intf_vars.advertise.med[med] %}
          {% if med == "global_med" %}
            {% if med_vars %}
  advertise med
            {% else %}
  no advertise med
            {% endif %}
          {% endif %}
          {% if med == "location_identification" %}
            {% for loc in med_vars %}
              {% if loc.loc_info is defined and loc.loc_info %}
                {% if loc.value is defined and loc.value %}
                  {% if loc.state is defined and loc.state == "absent" %}
  no advertise med location-identification {{ loc.loc_info }} {{ loc.value }}
                  {% else %}
  advertise med location-identification {{ loc.loc_info }} {{ loc.value }}
                  {% endif %}
                {% endif %}
              {% endif %}
            {% endfor %}
          {% endif %}
          {% if med == "application" %}
            {% for app in med_vars %}
              {% if app.name is defined and app.name %}
                {% if app.vlan_id is defined and app.vlan_id %}
                  {% set vlan_or_tag = app.vlan_id %}
                {% elif app.priority_tagged is defined and app.priority_tagged %}
                  {% set vlan_or_tag = "priority-tagged" %}
                {% endif %}
                {% if vlan_or_tag is defined and vlan_or_tag %}
                  {% if app.l2_priority is defined and app.l2_priority %}
                    {% if app.code_point_value is defined and app.code_point_value %}
                      {% if app.state is defined and app.state == "absent" %}
  no advertise med {{ app.name }} {{ vlan_or_tag }} {{ app.l2_priority }} {{ app.code_point_value }}
                      {% else %}
  advertise med {{ app.name }} {{ vlan_or_tag }} {{ app.l2_priority }} {{ app.code_point_value }}
                      {% endif %}
                    {% endif %}
                  {% endif %}
                {% endif %}
              {% endif %}
            {% endfor %}
          {% endif %}
        {% endfor %}
      {% endif %}

      {% if intf_vars.advertise.dcbx_tlv is defined and intf_vars.advertise.dcbx_tlv %}
        {% if intf_vars.advertise.dcbx_tlv_state is defined and intf_vars.advertise.dcbx_tlv_state == "absent" %}
  no advertise dcbx-tlv {{ intf_vars.advertise.dcbx_tlv }}
        {% else %}
  advertise dcbx-tlv {{ intf_vars.advertise.dcbx_tlv }}
        {% endif %}
      {% endif %}

      {% if intf_vars.advertise.dcbx_appln_tlv is defined and intf_vars.advertise.dcbx_appln_tlv %}
        {% if intf_vars.advertise.dcbx_appln_tlv_state is defined and intf_vars.advertise.dcbx_appln_tlv_state == "absent" %}
  no advertise dcbx-appln-tlv {{ intf_vars.advertise.dcbx_appln_tlv }}
        {% else %}
  advertise dcbx-appln-tlv {{ intf_vars.advertise.dcbx_appln_tlv }}
        {% endif %}
      {% endif %}

      {% if intf_vars.advertise.dot3_tlv is defined  and intf_vars.advertise.dot3_tlv %}
        {% for dot3 in intf_vars.advertise.dot3_tlv.keys() %}
        {% set dot3_vars = intf_vars.advertise.dot3_tlv[dot3] %}
          {% if dot3 == "max_frame_size" %}
            {% if dot3_vars %}
  advertise dot3-tlv max-frame-size
            {% else %}
  no advertise dot3-tlv max-frame-size
             {% endif %}
          {% endif %}
        {% endfor %}
      {% endif %}
      {% if intf_vars.advertise.dot1_tlv is defined  and intf_vars.advertise.dot1_tlv %}
        {% for dot1 in intf_vars.advertise.dot1_tlv.keys() %}
        {% set dot1_vars = intf_vars.advertise.dot1_tlv[dot1] %}
          {% if dot1 == "port_tlv" %}
            {% if dot1_vars.protocol_vlan_id is defined and dot1_vars.protocol_vlan_id %}
              {% if dot1_vars.port_vlan_id is defined %}
                {% if dot1_vars.port_vlan_id %}
  advertise dot1-tlv port-protocol-vlan-id port-vlan-id
                {% else %}
  advertise dot1-tlv port-protocol-vlan-id
  no advertise dot1-tlv port-vlan-id
                {% endif %}
              {% else %}
  advertise dot1-tlv port-protocol-vlan-id
              {% endif %}
            {% else %}
              {% if not dot1_vars.protocol_vlan_id %}
  no advertise dot1-tlv port-protocol-vlan-id
              {% endif %}
              {% if dot1_vars.port_vlan_id is defined %}
                {% if dot1_vars.port_vlan_id %}
  advertise dot1-tlv port-vlan-id
                {% else %}
  no advertise dot1-tlv port-vlan-id
                {% endif %}
              {% endif %}
            {% endif %}
          {% endif %}
          {% if dot1 == "vlan_tlv" %}
            {% if dot1_vars.vlan_range is defined and dot1_vars.vlan_range %}
              {% if dot1_vars.state is defined and dot1_vars.state == "absent" %}
  no advertise dot1-tlv vlan-name vlan-id {{ dot1_vars.vlan_range }}
              {% else %}
  advertise dot1-tlv vlan-name vlan-id {{ dot1_vars.vlan_range }}
              {% endif %}
            {% endif %}
          {% endif %}
        {% endfor %}
      {% endif %}
    {% endif %}
  {% endif %}
  {% endfor %}
{% endif %}
{% endfor %}
{% endif %}