예제 #1
0
    def test_collect_deployments(self):
        jd = DeploymentStateJobsDistributor()

        jd.api = Nuvla()
        jd.api.login_password('super', 'supeR8-supeR8')

        jd.collect_interval = 60
        print('collect_interval: {0}, to process: {1}'.format(
            jd.collect_interval, len(list(jd.job_generator()))))

        print(':::' * 6)

        jd.collect_interval = 10
        print('collect_interval: {0}, to process: {1}'.format(
            jd.collect_interval, len(list(jd.job_generator()))))
예제 #2
0
def nuvla_init(config):
    log.info("Authenticating with Nuvla...")
    nuvla = Nuvla(endpoint=config.get('nuvla', {}).get('endpoint'), insecure=True)
    n = 0
    ts = time.time()
    while True:
        try:
            nuvla.login_password(config['nuvla']['username'], config['nuvla']['password'])
            break
        except RETRY_EXCEPTIONS as ex:
            log.error("Authenticating with Nuvla... failed: {}".format(ex))
            st = 2 ** n
            log.info("Authenticating with Nuvla... re-attempting in {} sec.".format(st))
            time.sleep(st)
            n = (n < 7) and (n + 1) or 0
    log.info("Authenticating with Nuvla... done. (time took: {} sec)".format(int(time.time() - ts)))
    return nuvla
예제 #3
0
    try:
        import http.client as http_client
    except ImportError:
        # Python 2
        import httplib as http_client
    http_client.HTTPConnection.debuglevel = 1

    # You must initialize logging, otherwise you'll not see debug output.
    logging.basicConfig()
    logging.getLogger().setLevel(logging.DEBUG)
    requests_log = logging.getLogger("requests.packages.urllib3")
    requests_log.setLevel(logging.DEBUG)
    requests_log.propagate = True


nuvla = Nuvla(endpoint='https://localhost', insecure=True)
res = nuvla.login_password('super', 'supeR8-supeR8')
if not res.ok:
    raise Exception('Login failed: {}'.format(res.json().get('message', '')))

dpl_api = Deployment(nuvla)

module_id = 'module/20b6ea7a-ee55-44e7-93e7-7f26b4caef18'

data_records = ['data-record/36fe11cc-7f4f-4ee5-a123-0fafacf4a24b',
                'data-record/6803e2e4-1db6-42b4-8b8c-b3273c938366']
data_objects = ['data-object/36fe11cc-7f4f-4ee5-a123-0fafacf4a24b',
                'data-object/6803e2e4-1db6-42b4-8b8c-b3273c938366']
data_sets = [{'id': 'data-set/31d8ce24-7567-455e-9d39-4763c1d4010e',
              'time-start': '2020-02-14T23:00:00Z',
              'time-end': '2020-03-16T22:45:00Z'},
예제 #4
0
from pprint import pp

from nuvla.api import Api as Nuvla
from nuvla.api.resources.data import DataObjectS3
from nuvla.api.resources.user import User
from utils import nuvla_conf_user_pass


# Set to True to print Nuvla request / response messages to stdout.
debug = False

# Get username and password from configuration file.
username, password = nuvla_conf_user_pass()

# Create Nuvla client. No authentication required.
nuvla = Nuvla(debug=debug)
# nuvla = Nuvla(endpoint='https://localhost', insecure=True, debug=debug)

#
# Login to Nuvla.
#
user_api = User(nuvla)
user_api.login_password(username, password)

#
# Set correct values for variable below.
#

# REQUIRED: ID of S3 credential in Nuvla.
s3_cred_id = 'credential/362e6088-394d-4de9-9667-8e1a40136aa6'
예제 #5
0
#!/usr/bin/env python3

from nuvla.api import Api as Nuvla
from nuvla.api.resources.user import User

email = "valid@email"
password = "******"  # must contain uppercase letter, number and symbol.

template = {
    "template": {
        "href": "user-template/email-password",
        "email": email,
        "password": password
    }
}

# Create Nuvla client. No authentication required.
nuvla = Nuvla()
# nuvla = Nuvla(endpoint='https://nuvla.io', insecure=True)

# Create Nuvla API handler for User resource.
user_api = User(nuvla)

# Request creation of a new user.
user_id = user_api.create(template)

print(f'New user created: {user_id}')
print(f'Follow instructions in validation email that was sent to {email}.')