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

安装docker增加校验

parent a14f5621
Pipeline #21279 passed with stage
in 40 seconds
...@@ -166,6 +166,8 @@ class InstallService(HSBaseUCService): ...@@ -166,6 +166,8 @@ class InstallService(HSBaseUCService):
password=remote_server_info['server_password']) password=remote_server_info['server_password'])
with ssh_conenct as ssh: with ssh_conenct as ssh:
# 验证远端服务器有没有按照docker
self.validate_remote_server_install_docker(ssh)
# 先上传必要的文件 # 先上传必要的文件
logger.info('上传文件docker-19.03.4.tgz') logger.info('上传文件docker-19.03.4.tgz')
ssh.upload(os.path.join(system_file_dir, 'docker-19.03.4.tgz'), '/docker-19.03.4.tgz') ssh.upload(os.path.join(system_file_dir, 'docker-19.03.4.tgz'), '/docker-19.03.4.tgz')
...@@ -183,3 +185,15 @@ class InstallService(HSBaseUCService): ...@@ -183,3 +185,15 @@ class InstallService(HSBaseUCService):
logger.info(f'执行重启命令信息:{out2},错误信息:{err2}') logger.info(f'执行重启命令信息:{out2},错误信息:{err2}')
logger.info(f'执行成功,静等服务器重启。。。') logger.info(f'执行成功,静等服务器重启。。。')
logger.info('dokcer安装成功') logger.info('dokcer安装成功')
def validate_remote_server_install_docker(self, ssh):
'''
验证远端服务器是否安装docker
:param ssh:
:return:
'''
out, err = ssh.exec_command('docker -v')
if 'Docker version' in out or err:
logger.info('dokcer安装失败')
raise HSException('远端服务器已经安装docker,不需要重新安装')
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