|
|
@ -23,6 +23,7 @@ from update.utils.cmd_extcute import UpdateCommandUtil, UpdateConfigUtil |
|
|
|
from update.utils.db_compare import DbCompare |
|
|
|
from update.utils.db_compare import DbCompare |
|
|
|
from update.utils.client_util import ClientUtil |
|
|
|
from update.utils.client_util import ClientUtil |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# from consumers import UpdateConsumer |
|
|
|
# from consumers import UpdateConsumer |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -135,7 +136,7 @@ def update_cine(request): |
|
|
|
print('redis存在key', redis_key) |
|
|
|
print('redis存在key', redis_key) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': '该影院正在升级中,请稍后再试!'}) |
|
|
|
return JsonResponse({'result': 'fail', 'ip': cinema_ip, 'msg': '该影院正在升级中,请稍后再试!'}) |
|
|
|
else: |
|
|
|
else: |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 10*60) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
|
|
|
|
|
|
|
|
print('update_status', update_status) |
|
|
|
print('update_status', update_status) |
|
|
|
|
|
|
|
|
|
|
@ -154,11 +155,12 @@ def update_cine(request): |
|
|
|
print('获取并写入cine.sql') |
|
|
|
print('获取并写入cine.sql') |
|
|
|
try: |
|
|
|
try: |
|
|
|
update_status['git']['result'] = 'running' |
|
|
|
update_status['git']['result'] = 'running' |
|
|
|
|
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
git_util = GitUtil(short_release) |
|
|
|
git_util = GitUtil(short_release) |
|
|
|
git_output = git_util.handle_create_cine() |
|
|
|
git_output = git_util.handle_create_cine() |
|
|
|
update_status['git']['result'] = 'success' |
|
|
|
update_status['git']['result'] = 'success' |
|
|
|
update_status['git']['msg'] = git_output |
|
|
|
update_status['git']['msg'] = git_output |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5*60) |
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
except Exception as e: |
|
|
|
except Exception as e: |
|
|
|
print('git', e) |
|
|
|
print('git', e) |
|
|
|
update_status['git']['result'] = 'fail' |
|
|
|
update_status['git']['result'] = 'fail' |
|
|
@ -170,6 +172,7 @@ def update_cine(request): |
|
|
|
print('执行setup') |
|
|
|
print('执行setup') |
|
|
|
try: |
|
|
|
try: |
|
|
|
update_status['setup']['result'] = 'running' |
|
|
|
update_status['setup']['result'] = 'running' |
|
|
|
|
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
setup_list = list(set(cmd_list) & set(cmd_dict['setup'])) |
|
|
|
setup_list = list(set(cmd_list) & set(cmd_dict['setup'])) |
|
|
|
update_cmd = UpdateCommandUtil() |
|
|
|
update_cmd = UpdateCommandUtil() |
|
|
|
result, setup_output = update_cmd.exec_cmd_by_type(cinema_ip, 'setup', setup_list, short_release) |
|
|
|
result, setup_output = update_cmd.exec_cmd_by_type(cinema_ip, 'setup', setup_list, short_release) |
|
|
@ -191,6 +194,7 @@ def update_cine(request): |
|
|
|
print('数据库对比') |
|
|
|
print('数据库对比') |
|
|
|
try: |
|
|
|
try: |
|
|
|
update_status['sql']['result'] = 'running' |
|
|
|
update_status['sql']['result'] = 'running' |
|
|
|
|
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
db_compare = DbCompare(cinema_ip, short_release) |
|
|
|
db_compare = DbCompare(cinema_ip, short_release) |
|
|
|
sql_output = db_compare.exec_diff_sql() |
|
|
|
sql_output = db_compare.exec_diff_sql() |
|
|
|
update_status['sql']['result'] = 'success' |
|
|
|
update_status['sql']['result'] = 'success' |
|
|
@ -207,6 +211,7 @@ def update_cine(request): |
|
|
|
print('执行config(teardown前)') |
|
|
|
print('执行config(teardown前)') |
|
|
|
try: |
|
|
|
try: |
|
|
|
update_status['config']['result'] = 'running' |
|
|
|
update_status['config']['result'] = 'running' |
|
|
|
|
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
config_list = list(set(cmd_list) & set(cmd_dict['config'])) |
|
|
|
config_list = list(set(cmd_list) & set(cmd_dict['config'])) |
|
|
|
update_config = UpdateConfigUtil(cinema_ip, config_list, True) |
|
|
|
update_config = UpdateConfigUtil(cinema_ip, config_list, True) |
|
|
|
config_before_output = update_config.exec_config() |
|
|
|
config_before_output = update_config.exec_config() |
|
|
@ -226,6 +231,7 @@ def update_cine(request): |
|
|
|
print('执行teardown') |
|
|
|
print('执行teardown') |
|
|
|
try: |
|
|
|
try: |
|
|
|
update_status['teardown']['result'] = 'running' |
|
|
|
update_status['teardown']['result'] = 'running' |
|
|
|
|
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
update_cmd = UpdateCommandUtil() |
|
|
|
update_cmd = UpdateCommandUtil() |
|
|
|
result, teardown_output = update_cmd.exec_cmd_by_type(cinema_ip, 'teardown', teardown_list, short_release) |
|
|
|
result, teardown_output = update_cmd.exec_cmd_by_type(cinema_ip, 'teardown', teardown_list, short_release) |
|
|
|
if result is False: |
|
|
|
if result is False: |
|
|
@ -244,6 +250,7 @@ def update_cine(request): |
|
|
|
print('执行config(teardown后)') |
|
|
|
print('执行config(teardown后)') |
|
|
|
try: |
|
|
|
try: |
|
|
|
update_status['config']['result'] = 'running' |
|
|
|
update_status['config']['result'] = 'running' |
|
|
|
|
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
config_list = list(set(cmd_list) & set(cmd_dict['config'])) |
|
|
|
config_list = list(set(cmd_list) & set(cmd_dict['config'])) |
|
|
|
update_config = UpdateConfigUtil(cinema_ip, config_list, False) |
|
|
|
update_config = UpdateConfigUtil(cinema_ip, config_list, False) |
|
|
|
config_after_output = update_config.exec_config() |
|
|
|
config_after_output = update_config.exec_config() |
|
|
@ -262,6 +269,8 @@ def update_cine(request): |
|
|
|
if len(client_list) > 0: |
|
|
|
if len(client_list) > 0: |
|
|
|
print('传输客户端1') |
|
|
|
print('传输客户端1') |
|
|
|
try: |
|
|
|
try: |
|
|
|
|
|
|
|
update_status['client']['result'] = 'running' |
|
|
|
|
|
|
|
redis_conn.set(redis_key, json.dumps(update_status), 5 * 60) |
|
|
|
client_release = ClientUtil() |
|
|
|
client_release = ClientUtil() |
|
|
|
client_release.client_process(cinema_ip, short_release) |
|
|
|
client_release.client_process(cinema_ip, short_release) |
|
|
|
update_status['client']['result'] = 'success' |
|
|
|
update_status['client']['result'] = 'success' |
|
|
|