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
0df8920a
Commit
0df8920a
authored
Mar 12, 2020
by
金凯强
🎨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ssh用法修复
parent
5a2f20b1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
11 deletions
+39
-11
api_test.py
api_test.py
+29
-2
upgrade_service.py
app/upgrade/upgrade_service.py
+10
-9
No files found.
api_test.py
View file @
0df8920a
...
...
@@ -45,5 +45,32 @@ if __name__ == '__main__':
# print(res.json())
# # 获取app_list
res
=
requests
.
get
(
'http://localhost:5000/info/app_list/'
)
print
(
json
.
dumps
(
res
.
json
(),
indent
=
4
))
# 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/1238022723059486720/')
# 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
))
\ No newline at end of file
app/upgrade/upgrade_service.py
View file @
0df8920a
...
...
@@ -66,17 +66,18 @@ class UpgradeService():
# docker-compose
project_info
=
ConnectionService
()
.
get_project_info
()
host_ip
=
project_info
[
'host_ip'
]
ssh
=
SSHConnect
(
user_name
=
'root'
,
password
=
'huansi.net'
,
host_port
=
'1111'
,
host_ip
=
host_ip
)
out
,
err
=
ssh
.
exec_command
(
f
'''export HUANSI_REGISTRY_URL=47.110.145.204:8084 &&
\
ssh_conenct
=
SSHConnect
(
user_name
=
'root'
,
password
=
'huansi.net'
,
host_port
=
'1111'
,
host_ip
=
host_ip
)
with
ssh_conenct
as
ssh
:
out
,
err
=
ssh
.
exec_command
(
f
'''export HUANSI_REGISTRY_URL=47.110.145.204:8084 &&
\
source /etc/profile.d/huansi.sh &&
\
docker-compose -f /data/upgrade_tools_data/backup/{upgrade_no}/docker-compose.yml -p deploy up -d --force-recreate --no-deps {app_list}'''
)
if
err
:
raise
HSException
(
f
'回滚失败:{err}'
)
logger
.
info
(
f
'回滚{app_list}成功:{out}'
)
# 对应的版本信息修改为当前版本
session
.
exec_sql
(
f
'update app_upgrade_log set default_version=1 where id={log_id}'
)
# 注意异常情况下的处理
if
err
:
raise
HSException
(
f
'回滚失败:{err}'
)
logger
.
info
(
f
'回滚{app_list}成功:{out}'
)
# 对应的版本信息修改为当前版本
session
.
exec_sql
(
f
'update app_upgrade_log set default_version=1 where id={log_id}'
)
# 注意异常情况下的处理
def
find_compose_by_upgrade_no
(
self
,
upgrade_no
):
'''
...
...
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