Commit 0df8920a authored by 金凯强's avatar 金凯强 🎨

ssh用法修复

parent 5a2f20b1
......@@ -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
......@@ -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):
'''
......
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