Exemplo n.º 1
0
def _container_creator(storage_url, token, container):
    http_conn = client.http_connection(storage_url)
    try:
        client.head_container(storage_url, token, container,
                              http_conn=http_conn)
    except client.ClientException:
        client.put_container(storage_url, token, container,
                             http_conn=http_conn)
Exemplo n.º 2
0
def _container_creator(storage_urls, token, container, policy=None):
    put_headers = None if policy is None else {'x-storage-policy': policy}
    storage_url = random.choice(storage_urls)
    http_conn = client.http_connection(storage_url)
    try:
        client.head_container(storage_url, token, container,
                              http_conn=http_conn)
    except client.ClientException:
        client.put_container(storage_url, token, container,
                             headers=put_headers, http_conn=http_conn)
Exemplo n.º 3
0
def _container_creator(storage_urls, token, container):
    storage_url = random.choice(storage_urls)
    http_conn = client.http_connection(storage_url)
    try:
        client.head_container(storage_url,
                              token,
                              container,
                              http_conn=http_conn)
    except client.ClientException:
        client.put_container(storage_url,
                             token,
                             container,
                             http_conn=http_conn)
Exemplo n.º 4
0
def _container_creator(storage_urls, token, container, policy=None):
    put_headers = None if policy is None else {'x-storage-policy': policy}
    storage_url = random.choice(storage_urls)
    http_conn = client.http_connection(storage_url)
    try:
        client.head_container(storage_url,
                              token,
                              container,
                              http_conn=http_conn)
    except client.ClientException:
        client.put_container(storage_url,
                             token,
                             container,
                             headers=put_headers,
                             http_conn=http_conn)
Exemplo n.º 5
0
def _container_deleter(concurrency, storage_urls, token, container_info):
    container_name = container_info['name']
    logging.info('deleting %r (%d objs)', container_name,
                 container_info['count'])
    storage_url = random.choice(storage_urls)
    http_conn = client.http_connection(storage_url)
    _, obj_list = client.get_container(
        random.choice(storage_urls), token, container_name,
        http_conn=http_conn)

    pool = gevent.pool.Pool(concurrency)
    for obj_name in [o['name'] for o in obj_list]:
        pool.spawn(client.delete_object, random.choice(storage_urls), token,
                   container_name, obj_name)
    pool.join()

    client.delete_container(
        random.choice(storage_urls), token, container_name,
        http_conn=http_conn)
Exemplo n.º 6
0
def _container_deleter(concurrency, storage_urls, token, container_info):
    container_name = container_info['name']
    logging.info('deleting %r (%d objs)', container_name,
                 container_info['count'])
    storage_url = random.choice(storage_urls)
    http_conn = client.http_connection(storage_url)
    _, obj_list = client.get_container(random.choice(storage_urls),
                                       token,
                                       container_name,
                                       http_conn=http_conn)

    pool = gevent.pool.Pool(concurrency)
    for obj_name in [o['name'] for o in obj_list]:
        pool.spawn(client.delete_object, random.choice(storage_urls), token,
                   container_name, obj_name)
    pool.join()

    client.delete_container(random.choice(storage_urls),
                            token,
                            container_name,
                            http_conn=http_conn)
Exemplo n.º 7
0
 def create(self):
     return client.http_connection(self.storage_url)