mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-16 08:32:45 +00:00
Enable debugs in quagga-reload
Ticket: CM-6695 Reviewed By: Donald Testing Done: <DETAILED DESCRIPTION (REPLACE)>
This commit is contained in:
parent
8a2951d36d
commit
76f69d1c77
@ -73,8 +73,6 @@ class Config(object):
|
|||||||
The internal representation has been marked appropriately by passing it
|
The internal representation has been marked appropriately by passing it
|
||||||
through vtysh with the -m parameter
|
through vtysh with the -m parameter
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if args.debug:
|
|
||||||
logger.debug('Loading Config object from file %s', filename)
|
logger.debug('Loading Config object from file %s', filename)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -100,8 +98,6 @@ class Config(object):
|
|||||||
The internal representation has been marked appropriately by passing it
|
The internal representation has been marked appropriately by passing it
|
||||||
through vtysh with the -m parameter
|
through vtysh with the -m parameter
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if args.debug:
|
|
||||||
logger.debug('Loading Config object from vtysh show running')
|
logger.debug('Loading Config object from vtysh show running')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -242,16 +238,12 @@ end
|
|||||||
ctx_keys = [line,]
|
ctx_keys = [line,]
|
||||||
current_context_lines = []
|
current_context_lines = []
|
||||||
|
|
||||||
if args.debug:
|
|
||||||
logger.debug('LINE %-50s: entering new context, %-50s', line, ctx_keys)
|
logger.debug('LINE %-50s: entering new context, %-50s', line, ctx_keys)
|
||||||
|
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
self.save_contexts(ctx_keys, current_context_lines)
|
||||||
new_ctx = True
|
new_ctx = True
|
||||||
|
|
||||||
elif line == "end":
|
elif line == "end":
|
||||||
self.save_contexts(ctx_keys, current_context_lines)
|
self.save_contexts(ctx_keys, current_context_lines)
|
||||||
|
|
||||||
if args.debug:
|
|
||||||
logger.debug('LINE %-50s: exiting old context, %-50s', line, ctx_keys)
|
logger.debug('LINE %-50s: exiting old context, %-50s', line, ctx_keys)
|
||||||
|
|
||||||
# Start a new context
|
# Start a new context
|
||||||
@ -268,8 +260,6 @@ end
|
|||||||
# Start a new context
|
# Start a new context
|
||||||
ctx_keys = copy.deepcopy(main_ctx_key)
|
ctx_keys = copy.deepcopy(main_ctx_key)
|
||||||
current_context_lines = []
|
current_context_lines = []
|
||||||
|
|
||||||
if args.debug:
|
|
||||||
logger.debug('LINE %-50s: popping from subcontext to ctx%-50s', line, ctx_keys)
|
logger.debug('LINE %-50s: popping from subcontext to ctx%-50s', line, ctx_keys)
|
||||||
|
|
||||||
elif new_ctx is True:
|
elif new_ctx is True:
|
||||||
@ -281,8 +271,6 @@ end
|
|||||||
|
|
||||||
current_context_lines = []
|
current_context_lines = []
|
||||||
new_ctx = False
|
new_ctx = False
|
||||||
|
|
||||||
if args.debug:
|
|
||||||
logger.debug('LINE %-50s: entering new context, %-50s', line, ctx_keys)
|
logger.debug('LINE %-50s: entering new context, %-50s', line, ctx_keys)
|
||||||
|
|
||||||
elif "address-family " in line:
|
elif "address-family " in line:
|
||||||
@ -293,9 +281,8 @@ end
|
|||||||
self.save_contexts(ctx_keys, current_context_lines)
|
self.save_contexts(ctx_keys, current_context_lines)
|
||||||
current_context_lines = []
|
current_context_lines = []
|
||||||
main_ctx_key = copy.deepcopy(ctx_keys)
|
main_ctx_key = copy.deepcopy(ctx_keys)
|
||||||
|
|
||||||
if args.debug:
|
|
||||||
logger.debug('LINE %-50s: entering sub-context, append to ctx_keys', line)
|
logger.debug('LINE %-50s: entering sub-context, append to ctx_keys', line)
|
||||||
|
|
||||||
if line == "address-family ipv6":
|
if line == "address-family ipv6":
|
||||||
ctx_keys.append("address-family ipv6 unicast")
|
ctx_keys.append("address-family ipv6 unicast")
|
||||||
else:
|
else:
|
||||||
@ -304,7 +291,6 @@ end
|
|||||||
else:
|
else:
|
||||||
# Continuing in an existing context, add non-commented lines to it
|
# Continuing in an existing context, add non-commented lines to it
|
||||||
current_context_lines.append(line)
|
current_context_lines.append(line)
|
||||||
if args.debug:
|
|
||||||
logger.debug('LINE %-50s: append to current_context_lines, %-50s', line, ctx_keys)
|
logger.debug('LINE %-50s: append to current_context_lines, %-50s', line, ctx_keys)
|
||||||
|
|
||||||
# Save the context of the last one
|
# Save the context of the last one
|
||||||
@ -470,12 +456,36 @@ if __name__ == '__main__':
|
|||||||
raise Exception('Must specify --reload or --test')
|
raise Exception('Must specify --reload or --test')
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# Verify the new config file is valid
|
||||||
|
if not os.path.isfile(args.filename):
|
||||||
|
print "Filename %s does not exist" % args.filename
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
if not os.path.getsize(args.filename):
|
||||||
|
print "Filename %s is an empty file" % args.filename
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
# Verify that 'service integrated-vtysh-config' is configured
|
||||||
|
vtysh_filename = '/etc/quagga/vtysh.conf'
|
||||||
|
fh = open(vtysh_filename, 'r')
|
||||||
|
service_integrated_vtysh_config = False
|
||||||
|
|
||||||
|
for line in fh.readlines():
|
||||||
|
line = line.strip()
|
||||||
|
|
||||||
|
if line == 'service integrated-vtysh-config':
|
||||||
|
service_integrated_vtysh_config = True
|
||||||
|
break
|
||||||
|
fh.close()
|
||||||
|
|
||||||
|
if not service_integrated_vtysh_config:
|
||||||
|
print "'service integrated-vtysh-config' is not configured, this is required for 'service quagga reload'"
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
# Create a Config object from the config generated by newconf
|
# Create a Config object from the config generated by newconf
|
||||||
newconf = Config()
|
newconf = Config()
|
||||||
newconf.load_from_file(args.filename)
|
newconf.load_from_file(args.filename)
|
||||||
#print "New config context"
|
|
||||||
#print newconf.get_contexts()
|
|
||||||
|
|
||||||
if args.test:
|
if args.test:
|
||||||
|
|
||||||
@ -487,8 +497,6 @@ if __name__ == '__main__':
|
|||||||
else:
|
else:
|
||||||
running.load_from_show_running()
|
running.load_from_show_running()
|
||||||
|
|
||||||
#print "Running config context"
|
|
||||||
#print running.get_contexts()
|
|
||||||
(lines_to_add, lines_to_del, restart_bgp) = compare_context_objects(newconf, running)
|
(lines_to_add, lines_to_del, restart_bgp) = compare_context_objects(newconf, running)
|
||||||
|
|
||||||
if lines_to_del:
|
if lines_to_del:
|
||||||
@ -516,9 +524,7 @@ if __name__ == '__main__':
|
|||||||
print cmd
|
print cmd
|
||||||
|
|
||||||
if restart_bgp:
|
if restart_bgp:
|
||||||
print "BGP local AS changed, restarting bgpd"
|
print "BGP local AS changed, restarting bgpd\n"
|
||||||
|
|
||||||
print ''
|
|
||||||
|
|
||||||
elif args.reload:
|
elif args.reload:
|
||||||
|
|
||||||
@ -610,13 +616,9 @@ if __name__ == '__main__':
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
cmd = line_to_vtysh_conft(ctx_keys, line, False)
|
cmd = line_to_vtysh_conft(ctx_keys, line, False)
|
||||||
|
|
||||||
if args.debug:
|
|
||||||
logger.debug(cmd)
|
logger.debug(cmd)
|
||||||
|
|
||||||
subprocess.call(cmd)
|
subprocess.call(cmd)
|
||||||
|
|
||||||
if restart_bgp:
|
if restart_bgp:
|
||||||
cmd = ['sudo', 'service', 'quagga', 'restart', 'bgpd']
|
cmd = ['sudo', 'service', 'quagga', 'restart', 'bgpd']
|
||||||
subprocess.call(cmd)
|
subprocess.call(cmd)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user