예제 #1
0
def cli(ctx, url, user, passwd, json, links):
    """spp is a command line tool with which SPP operations
    can be carried out.
    """

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

    ctx.json = json
    ctx.links = links
    if ctx.links:
        ctx.json = True
예제 #2
0
def session_start():
    try:
        session = client.SppSession(options.host, options.username,
                                    options.password)
        session.login()
    except requests.exceptions.HTTPError as err:
        print("HTTP Error: {0}".format(err))
        print("exiting ...")
        sys.exit(1)
    except:
        print("unknown ERROR: ", sys.exc_info()[0])
        print("exiting ...")
        sys.exit(1)

    return session
예제 #3
0
def session_start():
    try:
        session = client.SppSession(options.host, options.username,
                                    options.password)
        session.login()
    except requests.exceptions.HTTPError as err:
        spputil.get_error_details(err)
        print("exiting ...")
        sys.exit(1)
    except:
        #print("other Exception: ", sys.exc_info()[0])
        print("other Exception: ", traceback.print_exc())
        print("exiting ...")
        sys.exit(1)

    return session
예제 #4
0
    backup['subtype'] = "vmware"
    if len(vm['storageProfiles']) < 1:
        logger.warning("VM is not assigned to an SLA policy")
        session.logout()
        sys.exit(4)
    if options.sla is not None:
        for sp in vm['storageProfiles']:
            if sp.upper() == options.sla.upper():
                backup['slaPolicyName'] = sp
    else:
        backup['slaPolicyName'] = vm['storageProfiles'][0]
    if 'slaPolicyName' not in backup:
        logger.warning("Provided SLA policy was not found assigned to this vm")
        session.logout()
        sys.exit(5)
    try:
        response = client.SppAPI(session, 'spphv').post(path='?action=adhoc',
                                                        data=backup)
        logger.info("Running backup job for vm " + options.vm)
    except:
        logger.warning(
            "Error running backup job, please see appliance logs for details, note that concurrent runs for the same job is not supported."
        )


validate_input()
session = client.SppSession(options.host, options.username, options.password)
session.login()
backup_vm()
session.logout()
예제 #5
0
    payload = {'changePassword': '******'}
    body = {"newPassword": options.password}
    r = requests.post(options.host + '/api/endeavour/session',
                      json=body,
                      auth=requests.auth.HTTPBasicAuth('admin', 'password'),
                      verify=False,
                      headers=hdrs,
                      params=payload)
    if 'sessionid' not in r.json():
        logger.info("Deployment not finished, trying again.")
        time.sleep(5)
        change_password()
    else:
        return r.json()['sessionid']


def init_onboard_vsnap():
    logger.info("Initializing onboard vsnap provider")
    initbody = {'async': True}
    response = client.SppAPI(session, 'corestorage').post(
        path='/2000/management?action=init', data=initbody)
    return response


validate_input()
wait_for_deployment()
sessionid = change_password()
session = client.SppSession(options.host, 'admin', options.password, sessionid)
init_onboard_vsnap()
session.logout()