-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_async.py
More file actions
89 lines (79 loc) · 2.35 KB
/
test_async.py
File metadata and controls
89 lines (79 loc) · 2.35 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import asyncio
import getpass
import json
from globalnoc.wsc import AsyncWSC
mappings = {
"w1.ll.k8s.grnoc.iu.edu": {
"v4": "149.165.134.16",
"v6": "2001:18e8:ff00:23:0:2:95a5:8610",
},
"w2.ll.k8s.grnoc.iu.edu": {
"v4": "149.165.134.17",
"v6": "2001:18e8:ff00:23:0:2:95a5:8611",
},
"w3.ll.k8s.grnoc.iu.edu": {
"v4": "149.165.134.18",
"v6": "2001:18e8:ff00:23:0:2:95a5:8612",
},
"w1.ll.k8s.net.internet2.edu": {
"v4": "149.165.134.19",
"v6": "2001:18e8:ff00:23:0:2:95a5:8613",
},
"w2.ll.k8s.net.internet2.edu": {
"v4": "149.165.134.20",
"v6": "2001:18e8:ff00:23:0:2:95a5:8614",
},
"w1.ll.k8s.net.cen.ct.gov": {
"v4": "149.165.134.21",
"v6": "2001:18e8:ff00:23:0:2:95a5:8615",
},
"w2.ll.k8s.net.cen.ct.gov": {
"v4": "149.165.134.22",
"v6": "2001:18e8:ff00:23:0:2:95a5:8616",
},
"w1.ll.k8s.oshean.org": {
"v4": "149.165.134.23",
"v6": "2001:18e8:ff00:23:0:2:95a5:8617",
},
"w2.ll.k8s.oshean.org": {
"v4": "149.165.134.24",
"v6": "2001:18e8:ff00:23:0:2:95a5:8618",
},
}
async def main():
password = getpass.getpass()
async with AsyncWSC(
url="https://db2.grnoc.iu.edu/cds2/netblock.cgi",
username="jdratlif",
password=password,
realm="https://idp.grnoc.iu.edu/idp/profile/SAML2/SOAP/ECP",
) as w:
w._load("/tmp/jdratlif.cookies")
promises = []
for hostname, addrs in mappings.items():
promises.append(
w.add_netblock(
allocatable=0,
name=hostname,
network_id=3,
prefix=addrs["v4"],
length=32,
version=4,
parent_netblock_id=8172,
)
)
promises.append(
w.add_netblock(
allocatable=0,
name=hostname,
network_id=3,
prefix=addrs["v6"],
length=128,
version=6,
parent_netblock_id=152095,
)
)
result = await asyncio.gather(*promises)
for r in result:
print(json.dumps(r, indent=2))
asyncio.run(main())