Esempio n. 1
0
def cli(ctx, url, user, passwd, json, links):
    """ecx is a command line tool with which ECX operations
    can be carried out.
    """

    if user and passwd:
        ctx.ecx_session = client.EcxSession(url,
                                            username=user,
                                            password=passwd)
        save_config(user, ctx.ecx_session.sessionid)
    else:
        ctx.ecx_session = client.EcxSession(
            url, sessionid=get_existing_session(user))

    ctx.json = json
    ctx.links = links
    if ctx.links:
        ctx.json = True
Esempio n. 2
0
        logger.info("Cleaning up job %s" % job['name'])
        sessioninfo = jobsession['id'] + "?action=resume&actionname=end_iv"
        return client.EcxAPI(session, 'jobsession').post(path=sessioninfo)
    logger.info("Running job %s" % job['name'])
    if (options.mode.upper() == "TEST"):
        run = client.JobAPI(session).run(job['id'], "start_test_iv")
    elif (options.mode.upper() == "PRODUCTION"):
        run = client.JobAPI(session).run(job['id'], "start_recovery_iv")
    elif (options.mode.upper() == "CLONE"):
        run = client.JobAPI(session).run(job['id'], "start_clone_iv")
    return run


def update_policy_and_run_restore():
    job = get_restore_job()
    if (options.vms is not None and options.cancel.upper() != "TRUE"):
        policy = get_policy_for_job(job)
        vmlist = get_info_for_vms()
        sourceinfo = build_source_info_for_vms(vmlist)
        updatedpolicy = build_policy_for_update(policy, sourceinfo, vmlist)
        newpolicy = update_policy(updatedpolicy)
        logger.info("Updating job %s" % job['name'])
    run_restore_job(job)


session = client.EcxSession(options.host, options.username, options.password)
session.login()
update_policy_and_run_restore()

session.delete('endeavour/session/')