|
|
|
@ -102,13 +102,15 @@ def update_cine(request): |
|
|
|
|
else: |
|
|
|
|
cmd_dict[cmd['process']] = [cmd['id']] |
|
|
|
|
print(cmd_dict) |
|
|
|
|
|
|
|
|
|
# 增加状态 |
|
|
|
|
update_status = { |
|
|
|
|
'git': {'result': 'success', 'msg': ''}, |
|
|
|
|
'setup': {'result': 'success', 'msg': ''}, |
|
|
|
|
'db_compare': {'result': 'success', 'msg': ''}, |
|
|
|
|
'teardown': {'result': 'success', 'msg': ''}, |
|
|
|
|
'config': {'result': 'success', 'msg': ''}, |
|
|
|
|
'client': {'result': 'success', 'msg': ''}, |
|
|
|
|
'git': {'result': '', 'msg': ''}, |
|
|
|
|
'setup': {'result': '', 'msg': ''}, |
|
|
|
|
'sql': {'result': '', 'msg': ''}, |
|
|
|
|
'teardown': {'result': '', 'msg': ''}, |
|
|
|
|
'config': {'result': '', 'msg': ''}, |
|
|
|
|
'client': {'result': '', 'msg': ''}, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
short_release = req.get('version') |
|
|
|
@ -121,41 +123,98 @@ def update_cine(request): |
|
|
|
|
|
|
|
|
|
# 获取并写入cine.sql |
|
|
|
|
print('获取并写入cine.sql') |
|
|
|
|
git_util = GitUtil(short_release) |
|
|
|
|
git_result = git_util.handle_create_cine() |
|
|
|
|
try: |
|
|
|
|
git_util = GitUtil(short_release) |
|
|
|
|
git_output = git_util.handle_create_cine() |
|
|
|
|
update_status['git']['result'] = 'success' |
|
|
|
|
update_status['git']['msg'] = git_output |
|
|
|
|
except Exception as e: |
|
|
|
|
print('git', e) |
|
|
|
|
update_status['git']['result'] = 'fail' |
|
|
|
|
update_status['git']['msg'] = str(e) |
|
|
|
|
|
|
|
|
|
# 执行setup |
|
|
|
|
print('执行setup') |
|
|
|
|
setup_list = list(set(cmd_list) & set(cmd_dict['setup'])) |
|
|
|
|
update_cmd = UpdateCommandUtil() |
|
|
|
|
update_cmd.exec_cmd_by_type(cinema_ip, 'setup', setup_list, short_release) |
|
|
|
|
try: |
|
|
|
|
setup_list = list(set(cmd_list) & set(cmd_dict['setup'])) |
|
|
|
|
update_cmd = UpdateCommandUtil() |
|
|
|
|
setup_output = update_cmd.exec_cmd_by_type(cinema_ip, 'setup', setup_list, short_release) |
|
|
|
|
update_status['setup']['result'] = 'success' |
|
|
|
|
update_status['setup']['msg'] = setup_output |
|
|
|
|
except Exception as e: |
|
|
|
|
print('setup', e) |
|
|
|
|
update_status['setup']['result'] = 'fail' |
|
|
|
|
update_status['setup']['msg'] = str(e) |
|
|
|
|
|
|
|
|
|
# 数据库对比 |
|
|
|
|
sql_list = list(set(cmd_list) & set(cmd_dict['sql'])) |
|
|
|
|
if len(sql_list) > 0: |
|
|
|
|
print('数据库对比') |
|
|
|
|
db_compare = DbCompare(cinema_ip, short_release) |
|
|
|
|
db_compare.exec_diff_sql() |
|
|
|
|
try: |
|
|
|
|
db_compare = DbCompare(cinema_ip, short_release) |
|
|
|
|
sql_output = db_compare.exec_diff_sql() |
|
|
|
|
update_status['sql']['result'] = 'success' |
|
|
|
|
update_status['sql']['msg'] = sql_output |
|
|
|
|
except Exception as e: |
|
|
|
|
print('sql', e) |
|
|
|
|
update_status['sql']['result'] = 'fail' |
|
|
|
|
update_status['sql']['msg'] = str(e) |
|
|
|
|
|
|
|
|
|
# 修改设置 |
|
|
|
|
print('执行config(teardown前)') |
|
|
|
|
try: |
|
|
|
|
config_list = list(set(cmd_list) & set(cmd_dict['config'])) |
|
|
|
|
update_config = UpdateConfigUtil(cinema_ip, config_list, True) |
|
|
|
|
config_before_output = update_config.exec_config() |
|
|
|
|
update_status['config']['result'] = 'success' |
|
|
|
|
update_status['config']['msg'] = config_before_output |
|
|
|
|
except Exception as e: |
|
|
|
|
print('config', e) |
|
|
|
|
update_status['config']['result'] = 'fail' |
|
|
|
|
update_status['config']['msg'] = str(e) |
|
|
|
|
|
|
|
|
|
# 执行teardown |
|
|
|
|
teardown_list = list(set(cmd_list) & set(cmd_dict['teardown'])) |
|
|
|
|
if len(teardown_list) > 0: |
|
|
|
|
print('执行teardown') |
|
|
|
|
update_cmd.exec_cmd_by_type(cinema_ip, 'teardown', teardown_list, short_release) |
|
|
|
|
try: |
|
|
|
|
update_cmd = UpdateCommandUtil() |
|
|
|
|
teardown_output = update_cmd.exec_cmd_by_type(cinema_ip, 'teardown', teardown_list, short_release) |
|
|
|
|
update_status['teardown']['result'] = 'success' |
|
|
|
|
update_status['teardown']['msg'] = '执行升级脚本:执行成功' |
|
|
|
|
except Exception as e: |
|
|
|
|
print('teardown', e) |
|
|
|
|
update_status['teardown']['result'] = 'fail' |
|
|
|
|
update_status['teardown']['msg'] = str(e) |
|
|
|
|
|
|
|
|
|
# 修改设置 |
|
|
|
|
print('执行config_list') |
|
|
|
|
config_list = list(set(cmd_list) & set(cmd_dict['config'])) |
|
|
|
|
update_config = UpdateConfigUtil(cinema_ip, config_list) |
|
|
|
|
update_config.exec_config() |
|
|
|
|
print('执行config(teardown后)') |
|
|
|
|
try: |
|
|
|
|
config_list = list(set(cmd_list) & set(cmd_dict['config'])) |
|
|
|
|
update_config = UpdateConfigUtil(cinema_ip, config_list, False) |
|
|
|
|
config_after_output = update_config.exec_config() |
|
|
|
|
update_status['config']['result'] = 'success' |
|
|
|
|
update_status['config']['msg'] = update_status['config']['msg'] + '\n' + config_after_output |
|
|
|
|
except Exception as e: |
|
|
|
|
print('config', e) |
|
|
|
|
update_status['config']['result'] = 'fail' |
|
|
|
|
update_status['config']['msg'] = update_status['config']['msg'] + '\n' + str(e) |
|
|
|
|
|
|
|
|
|
# 传输客户端 |
|
|
|
|
client_list = list(set(cmd_list) & set(cmd_dict['client'])) |
|
|
|
|
if len(client_list) > 0: |
|
|
|
|
print('传输客户端') |
|
|
|
|
client_release = ClientUtil() |
|
|
|
|
client_release.client_process(cinema_ip, short_release) |
|
|
|
|
try: |
|
|
|
|
client_release = ClientUtil() |
|
|
|
|
client_release.client_process(cinema_ip, short_release) |
|
|
|
|
update_status['client']['result'] = 'success' |
|
|
|
|
update_status['client']['msg'] = '客户端上传成功' |
|
|
|
|
except Exception as e: |
|
|
|
|
print('client', e) |
|
|
|
|
update_status['client']['result'] = 'fail' |
|
|
|
|
update_status['client']['msg'] = str(e) |
|
|
|
|
|
|
|
|
|
print(update_status) |
|
|
|
|
return JsonResponse({'result': 'success', 'ip': cinema_ip}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|