Ejemplo n.º 1
0
async def push(tag):
    cfg = await get_slow_config(tag)
    if cfg['code'] != 200:
        return cfg

    ssh = ssh_helper(cfg)
    ftp = ftp_helper(cfg)

    res = await transfer_remote_file_slow(cfg,ssh,ftp)
    if res['code'] != 200:
        return {'code': -1, 'msg': 'ransfer_remote_file error!'}

    if cfg['msg']['server_os'] != 'Windows':
        res = await run_remote_cmd_slow(cfg,ssh)
        if res['code'] != 200:
            return {'code': -1, 'msg': 'run_remote_cmd error!'}

    if cfg['msg']['server_os'] != 'Windows':
       res = await write_remote_crontab_slow(cfg,ssh)
       if res['code'] != 200:
            return {'code': -1, 'msg': 'write_remote_crontab error!'}

    ssh.close()
    ftp.close()
    return res
Ejemplo n.º 2
0
async def push(tag):
    cfg = await get_db_sync_config(tag)
    print('cfg=', cfg)
    if cfg['code'] != 200:
        return cfg

    ssh = ssh_helper(cfg)
    ftp = ftp_helper(cfg)

    res = transfer_remote_file_sync(cfg, ssh, ftp)
    if res['code'] != 200:
        raise Exception('transfer_remote_file error!')

    res = run_remote_cmd_sync(cfg, ssh)
    if res['code'] != 200:
        raise Exception('run_remote_cmd error!')

    res = write_remote_crontab_sync(cfg, ssh)
    if res['code'] != 200:
        traceback.print_exc()
        raise Exception('write_remote_crontab error!')

    ssh.close()
    ftp.close()
    return res
Ejemplo n.º 3
0
async def push(tag):
    cfg = await get_db_transfer_config(tag)
    if cfg['code'] != 200:
        return cfg

    ssh = ssh_helper(cfg)
    ftp = ftp_helper(cfg)

    res = await transfer_remote_file_transfer(cfg, ssh, ftp)
    if res['code'] != 200:
        raise Exception('transfer_remote_file error!')

    res = await run_remote_cmd_transfer(cfg, ssh)
    if res['code'] != 200:
        raise Exception('run_remote_cmd error!')

    ssh.close()
    ftp.close()
    return res
Ejemplo n.º 4
0
async def push(tag):
    cfg = await get_datax_sync_config(tag)
    if cfg['code'] != 200:
        return cfg

    ssh = ssh_helper(cfg)
    ftp = ftp_helper(cfg)

    res = await transfer_datax_remote_file_sync(cfg, ssh, ftp)
    if res['code'] != 200:
        raise Exception('transfer_datax_remote_file_sync error!')

    res = await run_datax_remote_cmd_sync(cfg, ssh)
    if res['code'] != 200:
        raise Exception('run_datax_remote_cmd_sync error!')

    res = await write_datax_remote_crontab_sync(cfg, ssh)
    if res['code'] != 200:
        raise Exception('write_datax_remote_crontab_sync error!')

    ssh.close()
    ftp.close()
    return res
Ejemplo n.º 5
0
async def push(tag):
    cfg = await get_db_archive_config(tag)
    if cfg['code'] != 200:
        return cfg

    ssh = ssh_helper(cfg)
    ftp = ftp_helper(cfg)

    res = await transfer_remote_file_archive(cfg, ssh, ftp)
    if res['code'] != 200:
        raise Exception('transfer_remote_file error!')

    res = await run_remote_cmd_archive(cfg, ssh)
    if res['code'] != 200:
        print(res['msg'])
        raise Exception('run_remote_cmd error!')

    res = await write_remote_crontab_archive(cfg, ssh)
    if res['code'] != 200:
        raise Exception('write_remote_crontab error!')

    ssh.close()
    ftp.close()
    return res
Ejemplo n.º 6
0
async def transfer_remote_file_inst(v_inst_id):
    cfg = await get_db_inst_config(v_inst_id)
    if cfg['code'] != 200:
        return cfg

    ssh = ssh_helper(cfg)
    ftp = ftp_helper(cfg)
    cmd = 'mkdir -p {0}'.format(cfg['msg']['script_path'])
    res = ssh.exec(cmd)
    if not res['status']:
        return {'code': -1, 'msg': 'failure!'}

    f_local, f_remote = gen_transfer_file(cfg, 'instance',
                                          cfg['msg']['script_file'])
    if not ftp.transfer(f_local, f_remote):
        return {'code': -1, 'msg': 'failure!'}

    f_local, f_remote = gen_transfer_file(cfg, 'instance', 'db_creator.sh')
    if not ftp.transfer(f_local, f_remote):
        return {'code': -1, 'msg': 'failure!'}

    ssh.close()
    ftp.close()
    return {'code': 200, 'msg': 'success!'}