Enable debugs in quagga-reload

Ticket: CM-6695
Reviewed By: Donald
Testing Done:

<DETAILED DESCRIPTION (REPLACE)>
This commit is contained in:
Daniel Walton 2015-07-28 03:43:32 +00:00
parent 8a2951d36d
commit 76f69d1c77

View File

@ -73,8 +73,6 @@ class Config(object):
The internal representation has been marked appropriately by passing it
through vtysh with the -m parameter
"""
if args.debug:
logger.debug('Loading Config object from file %s', filename)
try:
@ -100,8 +98,6 @@ class Config(object):
The internal representation has been marked appropriately by passing it
through vtysh with the -m parameter
"""
if args.debug:
logger.debug('Loading Config object from vtysh show running')
try:
@ -242,16 +238,12 @@ end
ctx_keys = [line,]
current_context_lines = []
if args.debug:
logger.debug('LINE %-50s: entering new context, %-50s', line, ctx_keys)
self.save_contexts(ctx_keys, current_context_lines)
new_ctx = True
elif line == "end":
self.save_contexts(ctx_keys, current_context_lines)
if args.debug:
logger.debug('LINE %-50s: exiting old context, %-50s', line, ctx_keys)
# Start a new context
@ -268,8 +260,6 @@ end
# Start a new context
ctx_keys = copy.deepcopy(main_ctx_key)
current_context_lines = []
if args.debug:
logger.debug('LINE %-50s: popping from subcontext to ctx%-50s', line, ctx_keys)
elif new_ctx is True:
@ -281,8 +271,6 @@ end
current_context_lines = []
new_ctx = False
if args.debug:
logger.debug('LINE %-50s: entering new context, %-50s', line, ctx_keys)
elif "address-family " in line:
@ -293,9 +281,8 @@ end
self.save_contexts(ctx_keys, current_context_lines)
current_context_lines = []
main_ctx_key = copy.deepcopy(ctx_keys)
if args.debug:
logger.debug('LINE %-50s: entering sub-context, append to ctx_keys', line)
if line == "address-family ipv6":
ctx_keys.append("address-family ipv6 unicast")
else:
@ -304,7 +291,6 @@ end
else:
# Continuing in an existing context, add non-commented lines to it
current_context_lines.append(line)
if args.debug:
logger.debug('LINE %-50s: append to current_context_lines, %-50s', line, ctx_keys)
# Save the context of the last one
@ -470,12 +456,36 @@ if __name__ == '__main__':
raise Exception('Must specify --reload or --test')
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
newconf = Config()
newconf.load_from_file(args.filename)
#print "New config context"
#print newconf.get_contexts()
if args.test:
@ -487,8 +497,6 @@ if __name__ == '__main__':
else:
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)
if lines_to_del:
@ -516,9 +524,7 @@ if __name__ == '__main__':
print cmd
if restart_bgp:
print "BGP local AS changed, restarting bgpd"
print ''
print "BGP local AS changed, restarting bgpd\n"
elif args.reload:
@ -610,13 +616,9 @@ if __name__ == '__main__':
continue
cmd = line_to_vtysh_conft(ctx_keys, line, False)
if args.debug:
logger.debug(cmd)
subprocess.call(cmd)
if restart_bgp:
cmd = ['sudo', 'service', 'quagga', 'restart', 'bgpd']
subprocess.call(cmd)