The internal representation has been marked appropriately by passing it
through vtysh with the -m parameter
"""
- logger.debug('Loading Config object from file %s', filename)
+ logger.info('Loading Config object from file %s', filename)
try:
file_output = subprocess.check_output(['vtysh', '-m', '-f', filename])
The internal representation has been marked appropriately by passing it
through vtysh with the -m parameter
"""
- logger.debug('Loading Config object from vtysh show running')
+ logger.info('Loading Config object from vtysh show running')
try:
config_text = subprocess.check_output("vtysh -c 'show run' | tail -n +4 | vtysh -m -f -", shell=True)
# For --test log to stdout
# For --reload log to /var/log/quagga/quagga-reload.log
if args.test:
- logging.basicConfig(level=logging.DEBUG,
+ logging.basicConfig(level=logging.INFO,
format='%(asctime)s %(levelname)5s: %(message)s')
elif args.reload:
if not os.path.isdir('/var/log/quagga/'):
os.makedirs('/var/log/quagga/')
logging.basicConfig(filename='/var/log/quagga/quagga-reload.log',
- level=logging.DEBUG,
+ level=logging.INFO,
format='%(asctime)s %(levelname)5s: %(message)s')
# argparse should prevent this from happening but just to be safe...
print "'service integrated-vtysh-config' is not configured, this is required for 'service quagga reload'"
sys.exit(1)
+ status_error = int(subprocess.call('service quagga status', shell=True))
+
+ if status_error:
+ print "quagga is not running"
+ sys.exit(1)
+
+ if args.debug:
+ logger.setLevel(logging.DEBUG)
+
+ logger.info('Called via "%s"', str(args))
+
# Create a Config object from the config generated by newconf
newconf = Config()
newconf.load_from_file(args.filename)
elif args.reload:
- logger.debug('Called via "%s"', str(args))
- logger.info('New Quagga Config\n%s', newconf.get_lines())
+ logger.debug('New Quagga Config\n%s', newconf.get_lines())
# This looks a little odd but we have to do this twice...here is why
# If the user had this running bgp config:
for x in range(2):
running = Config()
running.load_from_show_running()
- logger.info('Running Quagga Config (Pass #%d)\n%s', x, running.get_lines())
+ logger.debug('Running Quagga Config (Pass #%d)\n%s', x, running.get_lines())
(lines_to_add, lines_to_del, restart_bgp) = compare_context_objects(newconf, running)
# quagga(config-if)#
while True:
-
- logger.info(cmd)
-
try:
_ = subprocess.check_output(cmd)
# 'no ip ospf authentication message-digest 1.1.1.1' in
# our example above
# - Split that last entry by whitespace and drop the last word
- logger.info('%s failed', str(cmd))
+ logger.warning('Failed to execute %s', ' '.join(cmd))
last_arg = cmd[-1].split(' ')
if len(last_arg) <= 2:
new_last_arg = last_arg[0:-1]
cmd[-1] = ' '.join(new_last_arg)
else:
- logger.info('%s worked', str(cmd))
+ logger.info('Executed "%s"', ' '.join(cmd))
break
continue
cmd = line_to_vtysh_conft(ctx_keys, line, False)
- logger.debug(cmd)
+ logger.info(' '.join(cmd))
subprocess.call(cmd)
if restart_bgp: