Commit f51931ee authored by 金凯强's avatar 金凯强 🎨

app列表的url地址修改

parent 53a92a8a
# -*- coding:utf-8 -*-
import json
import requests
if __name__ == '__main__':
data = {'user_name': 'jkq', 'password': 'jkq_test'}
# # 设置登录信息
# requests.post('http://localhost:5000/authorization/',json=data)
# # 登录
# res = requests.post('http://localhost:5000/authorization/login/',json=data)
# print(res.json())
# # 获取项目链接
# res = requests.get('http://localhost:5000/connection/')
# print(res.json())
# json_data = {"project_no": "jkq_test", "db_ip": "47.97.206.38", "db_port": "9610", "db_user": "huansi",
# "db_password": "huansi", "mes_db_name": "HSGmtMes", "tiip_db_name": "HSTIIP",
# "host_ip": "192.168.4.116","id":"1237937496479928320"}
#
# # 设置项目链接
# res = requests.post('http://localhost:5000/connection/', json=json_data)
# print(res.json())
# # 测试项目数据库连接
# res = requests.get('http://localhost:5000/connection/jkq_test/HSGmtMEs/')
# print(res.json())
# json_data = {"project_no": "jkq_test", "server_ip": "jkqjkq.top", "server_ssh_port": "22",
# "server_user": "root",
# "server_password": "Jin1Kai2"}
#
# # 设置远程服务器连接
# res = requests.post('http://localhost:5000/connection/remote_server/', json=json_data)
# print(res.json())
# # 获取远程服务器连接
# res = requests.get('http://localhost:5000/connection/remote_server/')
# print(res.json())
# # 测试端口是否开放
# res = requests.get('http://localhost:5000/connection/test_port/23002/')
# print(res.json())
# # 获取app_list
res = requests.get('http://localhost:5000/info/app_list/')
print(json.dumps(res.json(), indent=4))
......@@ -32,10 +32,11 @@ class InfoService(HSBaseUCService):
app_info = {}
app_info['app_name'] = container['Names'][0][1:] # "/***"这种格式
logger.info('容器{}信息:{}'.format(app_info['app_name'], container))
port = container['Ports']
if port:
app_info['app_url'] = f"{host_ip}:{port[0].get('PublicPort')}"
# logger.info('容器{}信息:{}'.format(app_info['app_name'], container))
port_list = container['Ports']
if port_list:
app_url_list = [f"{host_ip}:{port.get('PublicPort')}" for port in port_list if port.get('PublicPort')]
app_info['app_url'] = ' '.join(app_url_list)
else:
app_info['app_url'] = ''
image_name = container['Image']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment