Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
I
install.api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Script
install.api
Commits
b5d5d2cf
Commit
b5d5d2cf
authored
Mar 13, 2020
by
金凯强
🎨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
受黄总压迫增加分页
parent
94f5c4ca
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
80 deletions
+105
-80
api_test.py
api_test.py
+66
-66
info_api.py
app/info/info_api.py
+4
-2
info_service.py
app/info/info_service.py
+33
-10
test_get_info.py
tests/test_get_info.py
+2
-2
No files found.
api_test.py
View file @
b5d5d2cf
...
...
@@ -5,75 +5,75 @@ 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
())
#
#
设置登录信息
#
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"
:
"192.168.4.116"
,
"server_ssh_port"
:
"1111"
,
"server_user"
:
"root"
,
"server_password"
:
"huansi.net"
,
"id"
:
1237968030966910976
}
# 设置远程服务器连接
res
=
requests
.
post
(
'http://localhost:5000/connection/remote_server/'
,
json
=
json_data
)
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": "192.168.4.116", "server_ssh_port": "1111",
#
"server_user": "root",
#
"server_password": "huansi.net","id":1237968030966910976}
#
#
#
设置远程服务器连接
#
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
))
# 配置app升级信息
json_data
=
[
{
"app_code"
:
"rabbitMQ"
,
"app_name"
:
"rabbitMQ"
,
"app_image"
:
"47.110.145.204:8084/huansi/mq:latest"
},
{
"app_code"
:
"Redis"
,
"app_name"
:
"Redis"
,
"app_image"
:
"47.110.145.204:8084/huansi/redis:latest"
},
{
"app_code"
:
"Tool"
,
"app_name"
:
"tools工具集"
,
"app_image"
:
"47.110.145.204:8084/huansi/hs_tools:1.1"
}]
res
=
requests
.
post
(
'http://localhost:5000/info/app_upgrade/'
,
json
=
json_data
)
print
(
res
.
json
())
# 获取app升级日志列表
res
=
requests
.
get
(
'http://localhost:5000/info/upgrade_log/'
)
print
(
json
.
dumps
(
res
.
json
(),
indent
=
4
))
# 获取app单次升级日志明细
res
=
requests
.
get
(
'http://localhost:5000/info/upgrade_log_dtl/1237995081698545664/'
)
print
(
json
.
dumps
(
res
.
json
(),
indent
=
4
))
# 安装runner
res
=
requests
.
get
(
'http://localhost:5000/install/runner/'
)
print
(
json
.
dumps
(
res
.
json
(),
indent
=
4
))
# 回滚升级
res
=
requests
.
get
(
'http://localhost:5000/upgrade/rollback/1238022723059486720/'
)
print
(
json
.
dumps
(
res
.
json
(),
indent
=
4
))
# 远程升级
res
=
requests
.
get
(
'http://localhost:5000/upgrade/remote/'
)
print
(
json
.
dumps
(
res
.
json
(),
indent
=
4
))
#
#
#
测试端口是否开放
#
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))
#
#
#
配置app升级信息
#
json_data = [
#
{"app_code": "rabbitMQ", "app_name": "rabbitMQ", "app_image": "47.110.145.204:8084/huansi/mq:latest"},
#
{"app_code": "Redis", "app_name": "Redis", "app_image": "47.110.145.204:8084/huansi/redis:latest"},
#
{"app_code": "Tool", "app_name": "tools工具集", "app_image": "47.110.145.204:8084/huansi/hs_tools:1.1"}]
#
#
res = requests.post('http://localhost:5000/info/app_upgrade/', json=json_data)
#
print(res.json())
#
#
#
获取app升级日志列表
#
res = requests.get('http://localhost:5000/info/upgrade_log/')
#
print(json.dumps(res.json(), indent=4))
#
#
#
#
获取app单次升级日志明细
#
res = requests.get('http://localhost:5000/info/upgrade_log_dtl/1237995081698545664/')
#
print(json.dumps(res.json(), indent=4))
#
#
#
安装runner
#
res = requests.get('http://localhost:5000/install/runner/')
#
print(json.dumps(res.json(), indent=4))
#
#
#
回滚升级
#
res = requests.get('http://localhost:5000/upgrade/rollback/1238022723059486720/')
#
print(json.dumps(res.json(), indent=4))
#
#
#
远程升级
#
res = requests.get('http://localhost:5000/upgrade/remote/')
#
print(json.dumps(res.json(), indent=4))
app/info/info_api.py
View file @
b5d5d2cf
...
...
@@ -30,7 +30,8 @@ class InfoAPI(ApiController):
获取app升级日志列表
:return:
'''
return
InfoService
()
.
get_upgrade_log
()
args
=
request
.
args
return
InfoService
()
.
get_upgrade_log
(
args
)
@
api
(
'upgrade_log_dtl/<int:log_id>'
)
def
get_upgrade_log_dtl
(
self
,
log_id
):
...
...
@@ -39,4 +40,5 @@ class InfoAPI(ApiController):
:param log_id:
:return:
'''
return
InfoService
()
.
get_upgrade_log_dtl
(
log_id
)
args
=
request
.
args
return
InfoService
()
.
get_upgrade_log_dtl
(
log_id
,
args
)
app/info/info_service.py
View file @
b5d5d2cf
...
...
@@ -135,49 +135,72 @@ values
return
{
'message'
:
'写入成功'
}
def
get_upgrade_log
(
self
):
def
get_upgrade_log
(
self
,
args
):
'''
获取升级历史信息
:return:
'''
per_page
=
args
.
get
(
'per_page'
,
10
)
page
=
args
.
get
(
'page'
,
1
)
offset
=
(
int
(
page
)
-
1
)
*
int
(
per_page
)
sql
=
'''select A.*,(select count(*) from app_upgrade_log_dtl where log_id=A.id) as count
from app_upgrade_log A
order by A.default_version desc, A.upgrade_time desc
limit {},{}
'''
.
format
(
offset
,
per_page
)
count_sql
=
'''select count(*) as count
from app_upgrade_log A
order by A.default_version desc, A.upgrade_time desc
'''
with
db_driver
as
session
:
data
=
session
.
query_sql
(
sql
)
count_data
=
session
.
retrive_sql
(
count_sql
)
page_data
=
{
"paging"
:
{
"page"
:
1
,
"per_page"
:
10
,
"total"
:
1
0
"page"
:
page
,
"per_page"
:
per_page
,
"total"
:
count_data
[
'count'
]
if
count_data
else
0
},
"table"
:
data
"table"
:
data
if
data
else
[]
}
return
page_data
def
get_upgrade_log_dtl
(
self
,
log_id
):
def
get_upgrade_log_dtl
(
self
,
log_id
,
args
):
'''
获取升级历史信息详情
:param log_id:
:return:
'''
per_page
=
args
.
get
(
'per_page'
,
10
)
page
=
args
.
get
(
'page'
,
1
)
offset
=
(
int
(
page
)
-
1
)
*
int
(
per_page
)
sql
=
f
'''select A.*
from app_upgrade_log_dtl A
where A.log_id={log_id}
limit {offset},{per_page}
'''
count_sql
=
f
'''select count(*) as count
from app_upgrade_log_dtl A
where A.log_id={log_id}'''
with
db_driver
as
session
:
data
=
session
.
query_sql
(
sql
)
count_data
=
session
.
retrive_sql
(
count_sql
)
page_data
=
{
"paging"
:
{
"page"
:
1
,
"per_page"
:
10
,
"total"
:
1
0
"page"
:
page
,
"per_page"
:
per_page
,
"total"
:
count_data
[
'count'
]
if
count_data
else
0
},
"table"
:
data
"table"
:
data
if
data
else
[]
}
return
page_data
tests/test_get_info.py
View file @
b5d5d2cf
...
...
@@ -45,7 +45,7 @@ class TestGetInfo(unittest.TestCase):
print
(
res
.
json
)
def
test_get_upgrade_log_dtl
(
self
):
log_id
=
123
7310513316270080
res
=
self
.
client
.
get
(
'/info/upgrade_log_dtl/{}/'
.
format
(
log_id
))
log_id
=
123
8385199009665024
res
=
self
.
client
.
get
(
'/info/upgrade_log_dtl/{}/
?per_page=2&page=2
'
.
format
(
log_id
))
self
.
assertEqual
(
res
.
status_code
,
200
)
print
(
res
.
json
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment