Hello,
while working with automating policy maps on a router I have encountered quite a weird behavior - my script was working for one loop, but for anything more it was sticking all the commands to the last child in policy-map instead of one for each class-map. Trying it on much simpler example (modified append_to_family example) the effect was the same:
config = [
'!',
'interface Serial1/0',
' ip address 1.1.1.1 255.255.255.252',
' test line 1',
'interface Serial1/1',
]
parse = CiscoConfParse(config)
for obj in parse.find_objects(r'^interface'):
obj.append_to_family(' carrier-delay msec 500')
!
interface Serial1/0
ip address 1.1.1.1 255.255.255.252
carrier-delay msec 500
test line 1
interface Serial1/1
carrier-delay msec 500
I think the problem is that it should look for a last child in a block not the first one, for my use I have modified the function in ccp_abc.py file by adding
while len(last_child.children) > 0: last_child = last_child.children[-1]
before insert_after function, which now preserves parent/child relationship on lower than one levels:
interface Serial1/0
ip address 1.1.1.1 255.255.255.252
test line 1
carrier-delay msec 500
interface Serial1/1
carrier-delay msec 500
Hello, while working with automating policy maps on a router I have encountered quite a weird behavior - my script was working for one loop, but for anything more it was sticking all the commands to the last child in policy-map instead of one for each class-map. Trying it on much simpler example (modified append_to_family example) the effect was the same:
I think the problem is that it should look for a last child in a block not the first one, for my use I have modified the function in ccp_abc.py file by adding
before insert_after function, which now preserves parent/child relationship on lower than one levels:
which in my opinion is the expected behavior.