Example #1
0
def get_seamicro15k_api(version, ip, username, password):
    """Gets the api client depending on the version.
    Supports v0.9 and v2.0.

    :return: api for version, None if version not supported
    """
    if version == 'v0.9':
        api = SeaMicroAPIV09(compose_URL('http:///v0.9/', ip))
        try:
            api.login(username, password)
        except urllib.error.URLError:
            # Cannot reach using v0.9, might not be supported
            return None
        return api
    elif version == 'v2.0':
        url = compose_URL('http:///v2.0', ip)
        try:
            api = seamicro_client.Client(
                auth_url=url, username=username, password=password)
        except seamicro_exceptions.ConnectionRefused:
            # Cannot reach using v2.0, might no be supported
            return None
        return api
Example #2
0
import json

from seamicroclient.v2 import client

seamicro = client.Client("admin", "seamicro", "http://172.16.0.25/v2.0")

servers = seamicro.servers.list()

for server in servers:
    print(json.dumps(server))
    print("\n\n")