when removing a whole address-family block from ldpd config
we were erroneously trying to also remove each of the interface
sub-sub-contexts that belonged to it; this would effectively
re-enable the AF we just removed. Work around this by ignoring
these sub-sub-contexts if we detect that we are already
removing the parent block.
Signed-off-by: Emanuele Di Pascale <emanuele@voltanet.io>
add_cmd = ('no ' + running_ctx_keys[0],)
lines_to_add.append((add_cmd, None))
+ # if this an interface sub-subcontext in an address-family block in ldpd and
+ # we are already deleting the whole context, then ignore this
+ elif (len(running_ctx_keys) > 2 and running_ctx_keys[0].startswith('mpls ldp') and
+ running_ctx_keys[1].startswith('address-family') and
+ (running_ctx_keys[:2], None) in lines_to_del):
+ continue
+
# Non-global context
elif running_ctx_keys and not any("address-family" in key for key in running_ctx_keys):
lines_to_del.append((running_ctx_keys, None))