Esempio n. 1
0
def list_machines(uri, cloud_id, cookie=None, csrf=None):
    req = MyRequests(uri=uri + "/clouds/" + cloud_id + "/machines", cookie=cookie, csrf=csrf)
    response = req.get()
    assert response.ok, u"\nGot %d Response Status: %s \n%s" % (response.status_code, response.reason, response.text)
    try:
        params = response.json()
        return params
    except Exception as e:
        assert False, u"Exception: %s" % e
Esempio n. 2
0
def list_machines(uri, backend_id, cookie=None):
    req = MyRequests(uri=uri+'/backends/'+backend_id+"/machines", cookie=cookie)
    response = req.get()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)
    try:
        params = response.json()
        return params
    except Exception as e:
        assert False, u'Exception: %s' % e
Esempio n. 3
0
def list_clouds(uri, cookie=None, csrf=None):
    req = MyRequests(uri=uri + '/clouds', cookie=cookie, csrf=csrf)
    response = req.get()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)

    try:
        params = response.json()
        return params
    except Exception as e:
        assert False, u'Exception: %s' %e
Esempio n. 4
0
def list_machines(uri, backend_id, cookie=None, csrf=None):
    req = MyRequests(uri=uri+'/backends/'+backend_id+"/machines",
                     cookie=cookie, csrf=csrf)
    response = req.get()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)
    try:
        params = response.json()
        return params
    except Exception as e:
        assert False, u'Exception: %s' % e
Esempio n. 5
0
def get_public_key(uri, key_id, cookie=None):
    req = MyRequests(uri=uri+"/keys/"+key_id+"?action=public", cookie=cookie)
    response = req.get()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)

    try:
        params = response.json()
        return params
    except Exception as e:
        print response.text
        assert False, u'Exception: %s' %e
Esempio n. 6
0
def supported_providers(uri, cookie=None, csrf=None):
    req = MyRequests(uri=uri+'/providers', cookie=cookie, csrf=csrf)
    response = req.get()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)

    try:
        params = response.json()
    except Exception as e:
        assert False, u'Exception: %s' %e

    SUPPORTED_PROVIDERS = params['supported_providers']
    print '\nSupported providers:'
    return SUPPORTED_PROVIDERS
Esempio n. 7
0
def supported_providers(uri, cookie=None, csrf=None):
    req = MyRequests(uri=uri + '/providers', cookie=cookie, csrf=csrf)
    response = req.get()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (
        response.status_code, response.reason, response.text)

    try:
        params = response.json()
    except Exception as e:
        assert False, u'Exception: %s' % e

    SUPPORTED_PROVIDERS = params['supported_providers']
    print '\nSupported providers:'
    return SUPPORTED_PROVIDERS
Esempio n. 8
0
def get_public_key(uri, key_id, cookie=None, csrf=None):
    req = MyRequests(uri=uri + "/keys/" + key_id + "/public",
                     cookie=cookie,
                     csrf=csrf)
    response = req.get()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (
        response.status_code, response.reason, response.text)

    try:
        params = response.json()
        return params
    except Exception as e:
        print response.text
        assert False, u'Exception: %s' % e
Esempio n. 9
0
def list_images(uri, backend_id, search_term=None, cookie=None):
    payload = {
        'search_term': search_term
    }
    if not search_term:
        req = MyRequests(uri=uri+"/backends/"+backend_id+"/images", cookie=cookie)
        response = req.post()
    else:
        req = MyRequests(uri=uri+"/backends/"+backend_id+"/images", data=json.dumps(payload), cookie=cookie)
        response = req.get()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (response.status_code, response.reason, response.text)

    try:
        params = response.json()
        return params
    except Exception as e:
        assert False, u'Exception: %s' % e
Esempio n. 10
0
def list_images(uri, backend_id, search_term=None, cookie=None, csrf=None):
    payload = {'search_term': search_term}
    if not search_term:
        req = MyRequests(uri=uri + "/backends/" + backend_id + "/images",
                         cookie=cookie,
                         csrf=csrf)
        response = req.post()
    else:
        req = MyRequests(uri=uri + "/backends/" + backend_id + "/images",
                         data=json.dumps(payload),
                         cookie=cookie,
                         csrf=csrf)
        response = req.get()
    assert response.ok, u'\nGot %d Response Status: %s \n%s' % (
        response.status_code, response.reason, response.text)

    try:
        params = response.json()
        return params
    except Exception as e:
        assert False, u'Exception: %s' % e