set active to 0 instead of deleting
@@ -154,7 +154,8 @@ class Parser:
data['mac'] = message['L2_LEARN']['eth_src']
data['segment'] = str(message['dp_id'])
data['port'] = str(message['L2_LEARN']['port_no'])
- data['tenant'] = "VLAN"+str(message['L2_LEARN']['vid'])
+ data['tenant'] = "VLAN"+str(message['L2_LEARN']['vid']),
+ data['active'] = 1
if message['L2_LEARN']['eth_src'] in self.mac_table:
dup = False
for d in self.mac_table[message['L2_LEARN']['eth_src']]:
@@ -168,7 +169,7 @@ class Parser:
elif 'L2_EXPIRE' in message:
self.logger.info("got faucet message for l2_expire: {0}".format(message))
if message['L2_EXPIRE']['eth_src'] in self.mac_table:
- del self.mac_table[message['L2_EXPIRE']['eth_src']]
+ self.mac_table[message['L2_EXPIRE']['eth_src']][0]['active'] = 0
elif 'PORT_CHANGE' in message:
self.logger.info("got faucet message for port_change: {0}".format(message))
if not message['PORT_CHANGE']['status']:
@@ -178,7 +179,7 @@ class Parser:
if (str(message['PORT_CHANGE']['port_no']) == data['port'] and
str(message['dp_id']) == data['segment']):
if mac in self.mac_table:
- del self.mac_table[mac]
+ self.mac_table[mac][0]['active'] = 0
# TODO update the endpoint state if it was removed from the mac_table
return
@@ -198,7 +199,8 @@ class Parser:
'mac': learned_mac[10],
'segment': learned_mac[7][1:-1],
'port': learned_mac[22],
- 'tenant': learned_mac[24] + learned_mac[25]}
+ 'tenant': learned_mac[24] + learned_mac[25]},
+ 'active': 1
if learned_mac[10] in self.mac_table:
dup = False
for d in self.mac_table[learned_mac[10]]:
@@ -213,7 +215,7 @@ class Parser:
expired_mac = line.split(', expired [')
expired_mac = expired_mac[1].split()[0]
if expired_mac in self.mac_table:
- del self.mac_table[expired_mac]
+ self.mac_table[expired_mac][0]['active'] = 0
elif ' Port ' in line:
# try and see if it was a port down event
# this will break if more than one port expires at the same time TODO
@@ -226,7 +228,7 @@ class Parser:
for data in m_table[mac]:
if (port_change[0] == data['port'] and
dpid == data['segment']):
- del self.mac_table[mac]
+ self.mac_table[mac][0]['active'] = 0
except Exception as e:
self.logger.debug("error {0}".format(str(e)))
# TODO update the endpoint state if it was removed from the mac_table
