]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Copy ceph auth keys over to devstack node
authorZack Cerza <zack@cerza.org>
Thu, 6 Feb 2014 02:39:42 +0000 (20:39 -0600)
committerZack Cerza <zack@cerza.org>
Thu, 20 Feb 2014 23:46:06 +0000 (17:46 -0600)
Signed-off-by: Zack Cerza <zack.cerza@inktank.com>
teuthology/task/devstack.py

index 009c75d4dab682fe6d07defd50d9bda1cbb96e26..5912ca6e7f9eefb6ebec9db809723a49edb5b064 100644 (file)
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 import contextlib
 import logging
+from cStringIO import StringIO
 
 from ..orchestra import run
 from teuthology import misc
@@ -31,8 +32,8 @@ def task(ctx, config):
     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]
+    devstack_node = ctx.cluster.only(is_devstack_node).remotes.keys()[0]
+    an_osd_node = ctx.cluster.only(is_osd_node).remotes.keys()[0]
     install_devstack(devstack_node)
     try:
         # OTHER STUFF
@@ -46,9 +47,39 @@ def task(ctx, config):
         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'
+        ceph_auth_cmds = [
+            ['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'],  # noqa
+            ['ceph', 'auth', 'get-or-create', 'client.glance', 'mon',
+             'allow r', 'osd', 'allow class-read object_prefix rbd_children, allow rwx pool=images'],  # noqa
+            ['ceph', 'auth', 'get-or-create', 'client.cinder-backup', 'mon',
+             'allow r', 'osd', 'allow class-read object_prefix rbd_children, allow rwx pool=backups'],  # noqa
+        ]
+        for cmd in ceph_auth_cmds:
+            an_osd_node.run(args=cmd)
+
+        # Copy ceph auth keys to devstack node
+        def copy_key(from_remote, key_name, to_remote, dest_path, owner):
+            key_stringio = StringIO()
+            from_remote.run(
+                args=['ceph', 'auth', 'get-or-create', key_name],
+                stdout=key_stringio)
+            misc.sudo_write_file(to_remote, dest_path,
+                                 key_stringio, owner=owner)
+        keys = [
+            dict(name='client.glance',
+                 path='/etc/ceph/ceph.client.glance.keyring',
+                 owner='glance:glance'),
+            dict(name='client.cinder',
+                 path='/etc/ceph/ceph.client.cinder.keyring',
+                 owner='cinder:cinder'),
+            dict(name='client.cinder-backup',
+                 path='/etc/ceph/ceph.client.cinder-backup.keyring',
+                 owner='cinder:cinder'),
+        ]
+        for key_dict in keys:
+            copy_key(an_osd_node, key_dict['name'], devstack_node,
+                     key_dict['path'], key_dict['owner'])
 
         yield
     #except Exception as e: