示例#1
0
def impl(context, host, cluster):
    request = requests.delete(
        context.SERVER_HTTP +
        '/api/v0/cluster/{}/hosts/{}'.format(cluster, host),
        auth=(VALID_USERNAME, VALID_PASSWORD))
    assert_status_code(request.status_code, 200)
    verify_storage_notify(context, ('updated', 'Cluster'))
示例#2
0
def impl(context, cluster):
    request = requests.put(context.SERVER_HTTP +
                           '/api/v0/cluster/{}'.format(cluster),
                           auth=(VALID_USERNAME, VALID_PASSWORD),
                           data=json.dumps({'container_manager': 'trivial'}))
    assert_status_code(request.status_code, 201)
    verify_storage_notify(context, ('created', 'Cluster'))
示例#3
0
def impl(context, operation, cluster):
    context.cluster = cluster
    if operation == 'get':
        context.request = requests.get(context.SERVER_HTTP +
                                       '/api/v0/cluster/{}'.format(cluster),
                                       auth=context.auth)
    elif operation == 'create':
        context.request = requests.put(context.SERVER_HTTP +
                                       '/api/v0/cluster/{}'.format(cluster),
                                       auth=context.auth,
                                       data={})
        if context.request.status_code == 201:
            verify_storage_notify(context, ('created', 'Cluster'))
    elif operation == 'delete':
        context.request = requests.delete(context.SERVER_HTTP +
                                          '/api/v0/cluster/{}'.format(cluster),
                                          auth=context.auth)
        if context.request.status_code == 200:
            verify_storage_notify(context, ('deleted', 'Cluster'))
    elif operation == 'get hosts in':
        context.request = requests.get(
            context.SERVER_HTTP + '/api/v0/cluster/{}/hosts'.format(cluster),
            auth=context.auth)
    else:
        raise NotImplementedError
示例#4
0
def impl(context, host):
    data = dict(context.HOST_DATA)
    data['address'] = host
    request = requests.put(context.SERVER_HTTP +
                           '/api/v0/host/{}'.format(host),
                           auth=(VALID_USERNAME, VALID_PASSWORD),
                           data=json.dumps(data))
    assert_status_code(request.status_code, 201)
    args = [('created', 'Host')]
    if 'cluster' in data:
        args.append(('updated', 'Cluster'))
    verify_storage_notify(context, *args)

    # Poll until the host is finished bootstrapping.
    # We can't watch an etcd key because the host record
    # is only written to etcd after a successful bootstrap.
    busy_states = (C.HOST_STATUS_INVESTIGATING, C.HOST_STATUS_BOOTSTRAPPING)
    status_is_busy = True
    while status_is_busy:
        time.sleep(1)
        request = requests.get(context.SERVER_HTTP +
                               '/api/v0/host/{}'.format(host),
                               auth=(VALID_USERNAME, VALID_PASSWORD))
        assert_status_code(request.status_code, 200)
        data = request.json()
        status_is_busy = data['status'] in busy_states

    assert data['status'] in (
        C.HOST_STATUS_ACTIVE, C.HOST_STATUS_DISASSOCIATED), \
        'Host failed to bootstrap (status: {})'.format(data['status'])

    # Purge notifications for interim state changes.
    context.NOTIFY_QUEUE.purge()
示例#5
0
def impl(context, host, cluster):
    context.cluster = cluster
    context.request = requests.delete(
        context.SERVER_HTTP +
        '/api/v0/cluster/{}/hosts/{}'.format(cluster, host),
        auth=context.auth)
    if context.request.status_code == 200:
        verify_storage_notify(context, ('updated', 'Cluster'))
示例#6
0
def impl(context, cluster):
    data = {}
    request = requests.put(context.SERVER_HTTP +
                           '/api/v0/cluster/{}'.format(cluster),
                           auth=(VALID_USERNAME, VALID_PASSWORD),
                           data={})
    assert_status_code(request.status_code, 201)
    verify_storage_notify(context, ('created', 'Cluster'))
示例#7
0
def impl(context):
    data = {'name': 'trivial', 'type': 'trivial', 'options': {}}
    request = requests.put(context.SERVER_HTTP +
                           '/api/v0/containermanager/trivial',
                           auth=(VALID_USERNAME, VALID_PASSWORD),
                           data=json.dumps(data))
    assert_status_code(request.status_code, 201)
    verify_storage_notify(context, ('created', 'ContainerManagerConfig'))
示例#8
0
def impl(context, cluster, json):
    context.cluster = cluster
    context.request = requests.put(context.SERVER_HTTP +
                                   '/api/v0/cluster/{}/hosts'.format(cluster),
                                   json=eval(json),
                                   auth=context.auth)
    if context.request.status_code == 200:
        verify_storage_notify(context, ('updated', 'Cluster'),
                              ('updated', 'Host'))  # Host.status
示例#9
0
def impl(context, host):
    request = requests.delete(context.SERVER_HTTP +
                              '/api/v0/host/{}'.format(host),
                              auth=(VALID_USERNAME, VALID_PASSWORD))
    assert_status_code(request.status_code, 200)
    args = [('deleted', 'Host')]
    if 'host_in_cluster' in context:
        args.append(('updated', 'Cluster'))
    verify_storage_notify(context, *args)
示例#10
0
def impl(context, operation, host):
    context.host = host
    if operation == 'get':
        context.request = requests.get(context.SERVER_HTTP +
                                       '/api/v0/host/{}'.format(context.host),
                                       auth=context.auth)
    elif operation == 'create':
        context.HOST_DATA['address'] = context.host
        context.request = requests.put(context.SERVER_HTTP +
                                       '/api/v0/host/{}'.format(context.host),
                                       data=json.dumps(context.HOST_DATA),
                                       auth=context.auth)
        if context.request.status_code == 201 and 'host_exists' not in context:
            verify_storage_notify(context, ('created', 'Host'))
    elif operation == 'delete':
        context.request = requests.delete(
            context.SERVER_HTTP + '/api/v0/host/{}'.format(context.host),
            auth=context.auth)
        if context.request.status_code == 200:
            verify_storage_notify(context, ('deleted', 'Host'))
示例#11
0
def impl(context, async_operation, cluster):
    context.cluster = cluster
    if async_operation == 'an upgrade':
        context.request = requests.put(
            context.SERVER_HTTP + '/api/v0/cluster/{}/upgrade'.format(cluster),
            auth=context.auth)
        if context.request.status_code == 201:
            verify_storage_notify(context, ('created', 'ClusterUpgrade'))
    elif async_operation == 'a restart':
        context.request = requests.put(
            context.SERVER_HTTP + '/api/v0/cluster/{}/restart'.format(cluster),
            auth=context.auth)
        if context.request.status_code == 201:
            verify_storage_notify(context, ('created', 'ClusterRestart'))
    elif async_operation == 'a tree deployment':
        context.request = requests.put(
            context.SERVER_HTTP + '/api/v0/cluster/{}/deploy'.format(cluster),
            auth=context.auth,
            data=json.dumps({'version': '1.2.3'}))
        if context.request.status_code == 201:
            verify_storage_notify(context, ('created', 'ClusterDeploy'))
    else:
        raise NotImplementedError