コード例 #1
0
 def __init__(self, config):
     super().__init__(max_nodes=config.getint(
         'clouds', 'upcloud_max_nodes', fallback=None))
     self.client = CloudManager(config.get('clouds', 'upcloud_login'),
                                config.get('clouds', 'upcloud_pass'))
     self.client.authenticate()
     self.config = config
コード例 #2
0
def test_infra_ops():
    global CREATED_SERVERS
    global CREATED_TAGS

    CREATED_TAGS = TAGS

    manager = CloudManager(USERNAME, PASSWORD, timeout=120)

    try:
        auth = manager.authenticate()
        assert True
    except Exception:
        assert False

    all_servers = create_cluster(manager, CLUSTER)

    # collect & populate servers from CLUSTER
    cluster_servers = []
    for name in CLUSTER:
        server = CLUSTER[name]
        server.populate()
        cluster_servers.append(server)

    CREATED_SERVERS = cluster_servers

    # assert all_servers contain cluster_servers
    for cs in cluster_servers:
        assert cs.state == 'started'

        found = False
        for server in all_servers:
            if server.uuid == cs.uuid:
                found = True

        if not found:
            raise Exception('server {0} not found in all_servers'.format(
                cs.uuid))

    # assert servers' states
    # TODO(elnygren): add more assertions here

    # web2 non default IP configuration
    web2 = CLUSTER['web2']
    assert len(web2.ip_addresses) == 1
    assert web2.ip_addresses[0].family == 'IPv6'

    test_server = CLUSTER['web1']

    test_server.populate()
    test_server._wait_for_state_change(['started'])
    test_server.stop()
    test_server._wait_for_state_change(['stopped'])

    # contain appropriate asserts
    firewall_test(manager, FIREWALL_RULES, test_server)
    server_test(manager, test_server)
    tag_servers_test(manager, TAGS, CLUSTER)
コード例 #3
0
def teardown_module(module):
    manager = CloudManager(USERNAME, PASSWORD, timeout=160)

    # if we are at CIRCLECI, clean up everything
    if os.environ.get('CIRCLECI', False):
        pool = multiprocessing.Pool()
        pool.map(destroy_server, manager.get_servers())
        pool.map(delete_tag, manager.get_tags())
    else:
        print('removing {0}'.format(CREATED_SERVERS))
        for server in CREATED_SERVERS:
            server.stop_and_destroy()

        print('removing {0}'.format(CREATED_TAGS))
        for tag in CREATED_TAGS:
            manager.delete_tag(tag)
コード例 #4
0
def test_infra_ops():
    global CREATED_SERVERS
    global CREATED_TAGS

    CREATED_TAGS = TAGS

    manager = CloudManager(USERNAME, PASSWORD, timeout=120)

    try:
        auth = manager.authenticate()
        assert True
    except Exception:
        assert False

    all_servers = create_cluster(manager, CLUSTER)

    # collect & populate servers from CLUSTER
    cluster_servers = []
    for name in CLUSTER:
        server = CLUSTER[name]
        server.populate()
        cluster_servers.append(server)

    CREATED_SERVERS = cluster_servers

    # assert all_servers contain cluster_servers
    for cs in cluster_servers:
        assert cs.state == 'started'

        found = False
        for server in all_servers:
            if server.uuid == cs.uuid:
                found = True

        if not found:
            raise Exception('server {} not found in all_servers'.format(
                cs.uuid))

    test_server = CLUSTER['web1']
    test_server.stop()
    test_server._wait_for_state_change(['stopped'])

    # contain appropriate asserts
    firewall_test(manager, FIREWALL_RULES, test_server)
    server_test(manager, test_server)
    tag_servers_test(manager, TAGS, CLUSTER)
コード例 #5
0
def teardown_module(module):
    manager = CloudManager(USERNAME, PASSWORD, timeout=120)

    # if we are at CIRCLECI, clean up everything
    if os.environ.get('CIRCLECI', False):
        for server in manager.get_servers():
            server.stop_and_destroy()

        for tag in manager.get_tags():
            tag.destroy()
    else:
        print('removing {}'.format(CREATED_SERVERS))
        for server in CREATED_SERVERS:
            server.stop_and_destroy()

        print('removing {}'.format(CREATED_TAGS))
        for tag in CREATED_TAGS:
            manager.delete_tag(tag)
コード例 #6
0
ファイル: upcloud.py プロジェクト: elnygren/upcloud-ansible
 def __init__(self, api_user, api_passwd):
     self.manager = CloudManager(api_user, api_passwd)
コード例 #7
0
#!/usr/bin/env python3
#
# Destroy a populated instance at UpCloud by IP address.
#
# pip3 install --user upcloud-api
# chmod 0700 ./upcloud_destroy_server.py
# ./upcloud_destroy_server.py IP-ADDRESS

import sys
from upcloud_api import CloudManager


# EDIT here
manager = CloudManager('USERNAME', 'PASSWORD')

manager.authenticate()

populated_server = manager.get_server_by_ip(sys.argv[1])
populated_server.stop_and_destroy()
コード例 #8
0
 def __init__(self, api_user, api_passwd, default_timeout):
     self.manager = CloudManager(api_user, api_passwd, default_timeout)