def ceph_client(request): class CephClient(object): def __init__(self, mon_host, username, key, pool_name): self.mon_host = mon_host self.username = username self.key = key self.pool_name = pool_name pool_name = 'data' result = ceph_server.up('onedata/ceph', [(pool_name, '8')], 'storage', '1') [container] = result['docker_ids'] username = result['username'] key = str(result['key']) mon_host = docker.inspect(container)['NetworkSettings']['IPAddress']. \ encode('ascii') def fin(): docker.exec_(container, ['btrfs', 'subvolume', 'delete', '/var/lib/ceph/osd/ceph-0/current']) docker.exec_(container, ['btrfs', 'subvolume', 'delete', '/var/lib/ceph/osd/ceph-0/snap_1']) docker.remove([container], force=True, volumes=True) request.addfinalizer(fin) return CephClient(mon_host, username, key, pool_name)
def ceph_client(request): class CephClient(object): def __init__(self, mon_host, username, key, pool_name): self.mon_host = mon_host self.username = username self.key = key self.pool_name = pool_name pool_name = 'data' result = ceph_server.up('onedata/ceph', [(pool_name, '8')], 'storage', '1') [container] = result['docker_ids'] username = result['username'] key = str(result['key']) mon_host = docker.inspect(container)['NetworkSettings']['IPAddress']. \ encode('ascii') def fin(): docker.exec_(container, [ 'btrfs', 'subvolume', 'delete', '/var/lib/ceph/osd/ceph-0/current' ]) docker.exec_(container, [ 'btrfs', 'subvolume', 'delete', '/var/lib/ceph/osd/ceph-0/snap_1' ]) docker.remove([container], force=True, volumes=True) request.addfinalizer(fin) return CephClient(mon_host, username, key, pool_name)
def server(request): class Server(object): def __init__(self, mon_host, username, key, pool_name): self.mon_host = mon_host self.username = username self.key = key self.pool_name = pool_name pool_name = 'data' result = ceph.up('onedata/ceph', [(pool_name, '8')], 'storage', common.generate_uid()) [container] = result['docker_ids'] username = result['username'].encode('ascii') key = result['key'].encode('ascii') mon_host = result['host_name'].encode('ascii') def fin(): docker.remove([container], force=True, volumes=True) request.addfinalizer(fin) return Server(mon_host, username, key, pool_name)
description='Bring up Ceph storage cluster.') parser.add_argument('-i', '--image', action='store', default='docker.onedata.org/ceph-base', help='docker image to use for the container', dest='image') parser.add_argument( '-p', '--pool', action='append', default=[], help='pool name and number of placement groups in format name:pg_num', dest='pools') parser.add_argument('-u', '--uid', action='store', default=common.generate_uid(), help='uid that will be concatenated to docker names', dest='uid') args = parser.parse_args() pools = map(lambda pool: tuple(pool.split(':')), args.pools) config = ceph.up(args.image, pools, 'storage', args.uid) print(json.dumps(config))
from __future__ import print_function import argparse import json from environment import ceph parser = argparse.ArgumentParser( formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Bring up Ceph storage cluster.') parser.add_argument( '-i', '--image', action='store', default='onedata/ceph', help='docker image to use for the container', dest='image') parser.add_argument( '-p', '--pool', action='append', default=[], help='pool name and number of placement groups in format name:pg_num', dest='pools') args = parser.parse_args() pools = map(lambda pool: tuple(pool.split(':')), args.pools) config = ceph.up(args.image, pools) print(json.dumps(config))
formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Bring up Ceph storage cluster.') parser.add_argument( '-i', '--image', action='store', default='onedata/ceph', help='docker image to use for the container', dest='image') parser.add_argument( '-p', '--pool', action='append', default=[], help='pool name and number of placement groups in format name:pg_num', dest='pools') parser.add_argument( '-u', '--uid', action='store', default=common.generate_uid(), help='uid that will be concatenated to docker names', dest='uid') args = parser.parse_args() pools = map(lambda pool: tuple(pool.split(':')), args.pools) config = ceph.up(args.image, pools, 'storage', args.uid) print(json.dumps(config))