dmulyalin / ttp

Template Text Parser
MIT License
350 stars 34 forks source link

Joining corresponding fields #53

Closed narimantos closed 3 years ago

narimantos commented 3 years ago

Hi,

I was wondering if I could join relations from a fortinet config

For example:

FortiGate address definition:

config firewall address
    edit "Address-1"
        set subnet 192.168.2.0 255.255.255.0
    next
    edit "Address-2"
        set subnet 192.168.3.0 255.255.255.0
    next
 end

FortiGate policy definiton:

config firewall policy
    edit 1
        set name "policy-1"
        set srcintf "CORE"
        set dstintf "OFFICE"
        set srcaddr "Address-1"
        set dstaddr "Address-2"
        set action accept
    next
end

Is there a way to map this relation with TTP?

dmulyalin commented 3 years ago

Hi, have a look at group lookup function, it was designed to help with cases like this.

https://ttp.readthedocs.io/en/latest/Groups/Functions.html#lookup

dmulyalin commented 3 years ago

@narimantos how did you go with this one? Have you managed to get lookup working for you?

narimantos commented 3 years ago

@dmulyalin Sorry it was a little too complicated. I did the rest in python.