extra checks for config and log files
@@ -40,13 +40,16 @@ class Parser:
def config(self, config_file, action, port, switch):
switch_found = None
+ # TODO check for other files
if not config_file:
# default to FAUCET default
config_file = '/etc/ryu/faucet/faucet.yaml'
- # TODO check for other files
+ try:
stream = open(config_file, 'r')
obj_doc = yaml.safe_load(stream)
stream.close()
+ except Exception as e:
+ return False
if action == 'mirror':
ok = True
@@ -127,6 +130,7 @@ class Parser:
# default to FAUCET default
log_file = '/var/log/ryu/faucet/faucet.log'
# NOTE very fragile, prone to errors
+ try:
with open(log_file, 'r') as f:
for line in f:
if 'L2 learned' in line:
@@ -147,5 +151,7 @@ class Parser:
mac_table[learned_mac[10]].insert(0, data)
else:
mac_table[learned_mac[10]] = [data]
+ except Exception as e:
+ print("%s" % str(e))
return mac_table
