1

Ultimately, I'm trying to diff out curly brace notation. Similar to a "show | compare" output in Junos. Unfortunately setting the syntax to 'junos' does not keep the curly braces in the output. However, setting it to 'ios' does. It seems to have done most of the work done when syntax is set to 'ios' on a F5 code, however, it's still complaining there is a diff on certain parts where it shouldn't be.

from ciscoconfparse import CiscoConfParse

BASELINE = """ltm virtual ACME {
    destination 192.168.1.191:http
    ip-protocol tcp
    mask 255.255.255.255
    pool pool1
    profiles {
        http { }
        tcp { }
    }
    rules {
        MOBILE
    }
    source 0.0.0.0/0
    source-address-translation {
        type automap
    }
    translate-address enabled
    translate-port enabled
    vs-index 17
}""".splitlines()

REQUIRED = """ltm virtual ACME {
    destination 192.168.2.191:http
    ip-protocol tcp
    mask 255.255.255.255
    pool pool2
    profiles {
        http { }
        tcp { }
    }
    rules {
        BLAH
    }
    source 0.0.0.0/0
    source-address-translation {
        type automap
    }
    translate-address enabled
    translate-port enabled
    vs-index 17
}""".splitlines()

parse = CiscoConfParse(BASELINE, syntax='ios')
print('\n'.join(parse.sync_diff(REQUIRED, ''))) 

Produces this:

ltm virtual ACME {
    no }
    no rules {
    no destination 192.168.1.191:http
    no pool pool1
        no MOBILE
ltm virtual ACME {
    destination 192.168.2.191:http
    pool pool2
    rules {
        BLAH
    }

Notice the second and third line from the output.

no }
no rules {

The order is different from the required code and I think, therefore it throws a 'diff'. Is there a way to ensure sequencing is kept in place?

Expected output:

ltm virtual ACME {
    no destination 192.168.1.191:http
    no pool pool1
    rules {
        no MOBILE
    }
ltm virtual ACME {
    destination 192.168.2.191:http
    pool pool2
    rules {
        BLAH
    }

0 Answers0