forked from ljm625/srv6-vpp-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsid_helper.py
27 lines (23 loc) · 897 Bytes
/
sid_helper.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import json
class SidHelper(object):
def __init__(self,etcd,vpp,sids):
self.etcd=etcd
self.sids=sids
self.vpp=vpp
pass
async def update_sid_to_etcd(self,prefix):
index=1
for sid_info in self.sids:
bsid = "{}{}".format(prefix,str(index)+'a')
result = self.vpp.create_sid(bsid,sid_info["action"],sid_info["interface"],sid_info["gateway"])
if result:
data = {
"sid":bsid,
"action":sid_info["action"],
"interface": sid_info["interface"],
"gateway": sid_info["gateway"]
}
await self.etcd.put("{}_{}".format(sid_info["ip_range"],sid_info["vrf_name"]),json.dumps(data))
else:
print("ERROR : {} could not create".format(bsid))
index=index+1