service_engine_deploy.py
1.9 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
# coding=utf-8
#author: 4N
#createtime: 2021/9/14
#email: nheweijun@sina.com
from app.util.component.ApiTemplate import ApiTemplate
from app.modules.service.models import ServiceEngine
from app.util.component.StructurePrint import StructurePrint
import requests
import uuid
class Api(ApiTemplate):
api_name = "影像服务引擎Depoly"
def process(self):
res = {}
try:
res["data"] = []
image_servers = ServiceEngine.query.filter_by(type="ImageServer").all()
for imgs in image_servers:
try :
url = "{}/API/Deploy/Topology".format(imgs.url)
resp: requests.Response = requests.get(url, timeout=1)
resp.encoding = "utf-8"
resp_json = resp.json()
res["data"].append({"id":uuid.uuid1().__str__(),
"name":"影像服务器",
"url":imgs.url,
"type": 0,
"children":[{
"name": "数据服务器",
"url": ser,
"type": 1,
"id":uuid.uuid1().__str__()
} for ser in resp_json.get("data")]})
except:
StructurePrint().print("连接影像服务引擎失败!","error")
res["result"] = True
except Exception as e:
raise e
return res
api_doc = {
"tags": ["引擎接口"],
"parameters": [
],
"responses": {
200: {
"schema": {
"properties": {
}
}
}
}
}