swap add remove ips
This commit is contained in:
parent
6322bd5bee
commit
6f5552fcc1
1 changed files with 8 additions and 7 deletions
|
@ -63,13 +63,6 @@ if result['status'] == 'ok':
|
||||||
#compare the current value with the cache
|
#compare the current value with the cache
|
||||||
newdataflag = False
|
newdataflag = False
|
||||||
difference = DictDiffer(new_list, current_list)
|
difference = DictDiffer(new_list, current_list)
|
||||||
if len(difference.added()) is not 0:
|
|
||||||
for ipkey in difference.added():
|
|
||||||
ip = ipkey
|
|
||||||
vlan = new_list[ipkey]
|
|
||||||
print('added {} to {}'.format(ip, vlan))
|
|
||||||
newdataflag = True
|
|
||||||
subprocess.call('python3 /root/frankenrouter/frankenrouter.py ipadd {} {}'.format(ip, vlan), shell=True)
|
|
||||||
if len(difference.removed()) is not 0:
|
if len(difference.removed()) is not 0:
|
||||||
for ipkey in difference.removed():
|
for ipkey in difference.removed():
|
||||||
ip = ipkey
|
ip = ipkey
|
||||||
|
@ -77,6 +70,14 @@ if result['status'] == 'ok':
|
||||||
print('removed {} from {}'.format(ip, vlan))
|
print('removed {} from {}'.format(ip, vlan))
|
||||||
newdataflag = True
|
newdataflag = True
|
||||||
subprocess.call('python3 /root/frankenrouter/frankenrouter.py ipdel {} {}'.format(ip, vlan), shell=True)
|
subprocess.call('python3 /root/frankenrouter/frankenrouter.py ipdel {} {}'.format(ip, vlan), shell=True)
|
||||||
|
if len(difference.added()) is not 0:
|
||||||
|
for ipkey in difference.added():
|
||||||
|
ip = ipkey
|
||||||
|
vlan = new_list[ipkey]
|
||||||
|
print('added {} to {}'.format(ip, vlan))
|
||||||
|
newdataflag = True
|
||||||
|
subprocess.call('python3 /root/frankenrouter/frankenrouter.py ipadd {} {}'.format(ip, vlan), shell=True)
|
||||||
|
|
||||||
|
|
||||||
if newdataflag:
|
if newdataflag:
|
||||||
# move the old cache and write the new data
|
# move the old cache and write the new data
|
||||||
|
|
Loading…
Reference in a new issue