[Python] Set ttp variable based on previous line

Discussão em 'Python' iniciado por Stack, Março 10, 2025.

  1. Stack

    Stack Membro Participativo

    I'm trying to bring information from Cisco targets import and export but the variable doesn't change! Can you help me?

    I tried this:

    Config from Cisco

    vrf teste
    address-family ipv4 unicast
    import route-target
    11:11
    22:22
    !
    export route-target
    33:33
    44:44
    55:55
    !
    !
    !


    TTP template:

    <group name="VRFS.{{ ip_vrf }}">
    vrf {{ ip_vrf }}

    import route-target{{ _start_ | _exact_ }}
    {{ rt_import | _line_ | joinmatches(', ') }}
    !{{ _end_ | _exact_ }}

    export route-target{{ _start_ | _exact_ }}
    {{ rt_export | _line_ | joinmatches(', ') }}
    !{{ _end_ | _exact_ }}

    </group>


    =============================================

    Incorrect result, both are "rt_import":


    [
    {
    "VRFS": {
    "test": [
    {
    "rt_import": "11:11, 22:22"
    },
    {
    "rt_import": "33:33, 44:44, 55:55"
    }
    ]
    }
    }
    ]

    Continue reading...

Compartilhe esta Página