- def __init__(self, of_uuid, of_connector, db, db_lock, of_test, pmp_with_same_vlan=False, debug='ERROR'):
+ def __init__(self, of_uuid, of_connector, db, of_test, pmp_with_same_vlan=False, logger_name=None,
+ debug=None):
- self.logger = logging.getLogger('vim.OF-' + of_uuid)
- self.logger.setLevel(getattr(logging, debug))
- self.logger.name = of_connector.name + " " + self.OF_connector.dpid
+ if logger_name:
+ self.logger_name = logger_name
+ else:
+ self.logger_name = "openvim.ofc." + of_uuid
+ self.logger = logging.getLogger(self.logger_name)
+ if debug:
+ self.logger.setLevel(getattr(logging, debug))
self.logger.error("processing task 'update-net' %s: %s", str(task[1]), c)
self.set_openflow_controller_status(OFC_STATUS_ERROR, "Error updating net {}".format(task[1]))
else:
UPDATE={'status':'ACTIVE', 'last_error': None}
self.logger.debug("processing task 'update-net' %s: OK", str(task[1]))
self.set_openflow_controller_status(OFC_STATUS_ACTIVE)
self.logger.error("processing task 'update-net' %s: %s", str(task[1]), c)
self.set_openflow_controller_status(OFC_STATUS_ERROR, "Error updating net {}".format(task[1]))
else:
UPDATE={'status':'ACTIVE', 'last_error': None}
self.logger.debug("processing task 'update-net' %s: OK", str(task[1]))
self.set_openflow_controller_status(OFC_STATUS_ACTIVE)
elif task[0] == 'clear-all':
r,c = self.clear_all_flows()
elif task[0] == 'clear-all':
r,c = self.clear_all_flows()
else:
self.logger.error("unknown task %s", str(task))
except openflow_conn.OpenflowconnException as e:
else:
self.logger.error("unknown task %s", str(task))
except openflow_conn.OpenflowconnException as e:
select_= ('type','admin_state_up', 'vlan', 'provider', 'bind_net','bind_type','uuid')
result, nets = self.db.get_table(FROM='nets', SELECT=select_, WHERE={'uuid':net_id} )
#get all the networks binding to this
select_= ('type','admin_state_up', 'vlan', 'provider', 'bind_net','bind_type','uuid')
result, nets = self.db.get_table(FROM='nets', SELECT=select_, WHERE={'uuid':net_id} )
#get all the networks binding to this
result, nets = self.db.get_table(FROM='nets', SELECT=select_,
WHERE_OR={'bind_net':bind_id, 'uuid':bind_id} )
result, nets = self.db.get_table(FROM='nets', SELECT=select_,
WHERE_OR={'bind_net':bind_id, 'uuid':bind_id} )
nb_ports, net_ports = self.db.get_table(
FROM='ports',
SELECT=('switch_port','vlan','uuid','mac','type','model'),
WHERE={'net_id':net_id, 'admin_state_up':'true', 'status':'ACTIVE'} )
nb_ports, net_ports = self.db.get_table(
FROM='ports',
SELECT=('switch_port','vlan','uuid','mac','type','model'),
WHERE={'net_id':net_id, 'admin_state_up':'true', 'status':'ACTIVE'} )
if result < 0:
error_msg = "DB error getting flows from net '{}': {}".format(net_id, database_net_flows)
# print self.name, ": update_of_flows() ERROR getting flows from database", database_flows
return -1, error_msg
database_flows += database_net_flows
# Get the name of flows where net_id==NULL that means net deleted (At DB foreign key: On delete set null)
if result < 0:
error_msg = "DB error getting flows from net '{}': {}".format(net_id, database_net_flows)
# print self.name, ": update_of_flows() ERROR getting flows from database", database_flows
return -1, error_msg
database_flows += database_net_flows
# Get the name of flows where net_id==NULL that means net deleted (At DB foreign key: On delete set null)
if result < 0:
error_msg = "DB error getting flows from net 'null': {}".format(database_net_flows)
# print self.name, ": update_of_flows() ERROR getting flows from database", database_flows
if result < 0:
error_msg = "DB error getting flows from net 'null': {}".format(database_net_flows)
# print self.name, ": update_of_flows() ERROR getting flows from database", database_flows
except FlowBadFormat as e:
# print self.name, ": Error Exception FlowBadFormat '%s'" % str(e), flow
return -1, str(e)
except FlowBadFormat as e:
# print self.name, ": Error Exception FlowBadFormat '%s'" % str(e), flow
return -1, str(e)
result, content = self.db.delete_row_by_key('of_flows', 'id', flow['id'])
result, content = self.db.delete_row_by_key('of_flows', 'id', flow['id'])
return 0, None
except openflow_conn.OpenflowconnException as e:
return -1, self.logger.error("Error deleting all flows {}", str(e))
return 0, None
except openflow_conn.OpenflowconnException as e:
return -1, self.logger.error("Error deleting all flows {}", str(e))
result, content = self.db.update_rows('ofcs', ofc, WHERE={'uuid': self.of_uuid}, log=False)
result, content = self.db.update_rows('ofcs', ofc, WHERE={'uuid': self.of_uuid}, log=False)