def unbind_instance():

    global token

    headers = {"name": "unbind", "parameters": {"username": username, "password": password, "token": token}}

    url = "http://" + host + port + ":" + "/instances/<instance_id>/unbind"

    try:
        result, status_code = do_request("post", url, None, headers, None)
    except Exception, e:
        print e
def provision_instance():

    global token

    headers = {"username": username, "password": password, "token": token}

    url = "http://" + host + port + ":" + "/instances"

    try:
        result, status_code = do_request("post", url, None, headers, None)
    except Exception, e:
        print e
def get_last_operation():

    global token

    headers = {"username": username, "password": password, "token": token}

    url = "http://" + host + port + ":" + "/instances/<instance_id>/actions"

    try:
        result, status_code = do_request("post", url, None, headers, None)
    except Exception, e:
        print e
def login(username, password):

    headers = {
        'username':username,
        'password':password
    }
    url = 'http://' + host + port + ':' + '/login'

    try:
        result, status_code = do_request('post', url, None, headers, None)
    except Exception, e:
        print e
def list_services():

    global token

    headers = {"username": username, "password": password}

    url = "http://" + host + port + ":" + "/services"

    try:
        result, status_code = do_request("get", url, None, headers, None)
        token = result["token_expiration"].encode("utf-8")
    except Exception, e:
        print e