-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_import.py
More file actions
24 lines (24 loc) · 833 Bytes
/
test_import.py
File metadata and controls
24 lines (24 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import requests
headers ={
"Authorization": "Token 8e233860bb6a1d3c9753dc131b534a3f1fc8e20d"
}
a = requests.get('http://opsdb.test-istio.gome.inc/v1/server', headers=headers)
tmp = a.json()
while tmp:
tmp = requests.get(tmp['next'], headers=headers).json()
for x in tmp['results']:
data = {
"name": x['name'],
"namespace": None,
"cpu": x['cpu'],
"ip": x['ip'],
"labels": [
{"k": "model_name", "v": x["model_name"]},
{"k": "site_name", "v": x["site_name"]},
{"k": "company", "v": x["company"]},
{"k": "os_id", "v": x["os_id"]},
{"k": "cpu", "v": x["cpu"]},
]
}
r = requests.post("http://127.0.0.1:8000/v1/mysql/", json=data)
print(r.text)