From 10e12c2d5cad88906db2dea1c0ba3c862fb0c3ad Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Mon, 3 Feb 2014 15:50:07 -0600 Subject: [PATCH] Add skeleton devstack task Currently only installs devstack on one node, and creates some pools on the ceph cluster. Signed-off-by: Zack Cerza --- teuthology/task/devstack.py | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 teuthology/task/devstack.py diff --git a/teuthology/task/devstack.py b/teuthology/task/devstack.py new file mode 100644 index 0000000000..009c75d4da --- /dev/null +++ b/teuthology/task/devstack.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python +import contextlib +import logging + +from ..orchestra import run +from teuthology import misc + +""" +https://github.com/openstack-dev/devstack/blob/master/README.md +http://ceph.com/docs/master/rbd/rbd-openstack/ +""" +log = logging.getLogger(__name__) + +DEVSTACK_GIT_REPO = 'https://github.com/openstack-dev/devstack.git' +is_devstack_node = lambda role: role.startswith('devstack') +is_osd_node = lambda role: role.startswith('osd') + + +@contextlib.contextmanager +def task(ctx, config): + """ + Install OpenStack DevStack and configure it to use a Ceph cluster for + Glance and Cinder. + + Requires one node with a role 'devstack' + """ + if config is None: + config = {} + if not isinstance(config, dict): + raise TypeError("config must be a dict") + pool_size = config.get('pool_size', 128) + + # SETUP + devstack_node = ctx.cluster.only(is_devstack_node).remotes[0] + an_osd_node = ctx.cluster.only(is_osd_node).remotes[0] + install_devstack(devstack_node) + try: + # OTHER STUFF + + # Create pools on Ceph cluster + for pool_name in ['volumes', 'images', 'backups']: + args = ['ceph', 'osd', 'pool', 'create', pool_name, pool_size] + an_osd_node.run(args=args) + + # Copy ceph.conf to OpenStack node + misc.copy_file(an_osd_node, '/etc/ceph/ceph.conf', devstack_node) + # This is where we would install python-ceph and ceph-common but it + # appears the ceph task will do that for us. + # ceph auth get-or-create client.cinder mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=volumes, allow rx pool=images' + # ceph auth get-or-create client.glance mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=images' + # ceph auth get-or-create client.cinder-backup mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=backups' + + yield + #except Exception as e: + # FAIL + #pass + finally: + # CLEANUP + pass + + +def install_devstack(devstack_node): + log.info("Cloning devstack repo...") + args = ['git', 'clone', DEVSTACK_GIT_REPO] + devstack_node.run(args=args) + + log.info("Installing devstack...") + args = ['cd', 'devstack', run.Raw('&&'), './stack.sh'] + devstack_node.run(args=args) -- 2.39.5