Last active
October 8, 2019 03:09
-
-
Save clay584/ad4c510e00ab451d181aab51e6d6075d to your computer and use it in GitHub Desktop.
ttp test of multiple host objects in ASA object-groups
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from ttp import ttp | |
data_to_parse = """ | |
object-group network BRAZIL_VIPS | |
network-object host 1.2.2.2 | |
network-object host 2.2.2.2 | |
network-object host 3.3.3.3 | |
object-group network GERMANY_VIP | |
network-object host 4.4.4.4 | |
object-group network CAN_VIP | |
network-object host 5.4.4.4 | |
""" | |
ttp_template = """ | |
<group name="object-groups"> | |
object-group network {{ name }} | |
<group name="network-objects"> | |
network-object host {{ ip }} | |
</group> | |
</group> | |
""" | |
parser = ttp(data=data_to_parse, template=ttp_template) | |
parser.parse() | |
results = parser.result(format='json')[0] | |
print(results) | |
############################ | |
# Output # | |
############################ | |
# [ | |
# { | |
# "object-groups": [ | |
# { | |
# "name": "BRAZIL_VIPS", | |
# "network-objects": [ | |
# { | |
# "ip": "1.2.2.2" | |
# }, | |
# { | |
# "ip": "2.2.2.2" | |
# }, | |
# { | |
# "ip": "3.3.3.3" | |
# } | |
# ] | |
# }, | |
# { | |
# "name": "GERMANY_VIP", | |
# "network-objects": { | |
# "ip": "4.4.4.4" | |
# } | |
# }, | |
# { | |
# "name": "CAN_VIP", | |
# "network-objects": { | |
# "ip": "5.4.4.4" | |
# } | |
# } | |
# ] | |
# } | |
# ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment