diff options
| author | Vu Tran <vu.tran@windriver.com> | 2014-03-18 21:01:01 -0400 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@windriver.com> | 2014-03-24 16:41:59 -0400 |
| commit | 3b5ec214c506a47cbd8abf7bd6557246980ddea5 (patch) | |
| tree | 3d596654a8c53494d898a0fdfd140adefea0e741 /meta-openstack/recipes-devtools/python/python-nova/Fix-rbd-backend-not-working-for-none-admin-ceph-user.patch | |
| parent | d156d7e1155fc325cb398f98ed41b540031c9df3 (diff) | |
| download | meta-cloud-services-3b5ec214c506a47cbd8abf7bd6557246980ddea5.tar.gz | |
nova-compute: enable to use ceph
Enable nova-compute to:
* use cinder volume stored in a ceph pool as a block device
* store glance image into a ceph pool.
Also port 2 patches from https://github.com/openstack/nova
branch master into Havana branch.
Signed-off-by: Vu Tran <vu.tran@windriver.com>
Diffstat (limited to 'meta-openstack/recipes-devtools/python/python-nova/Fix-rbd-backend-not-working-for-none-admin-ceph-user.patch')
| -rw-r--r-- | meta-openstack/recipes-devtools/python/python-nova/Fix-rbd-backend-not-working-for-none-admin-ceph-user.patch | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/meta-openstack/recipes-devtools/python/python-nova/Fix-rbd-backend-not-working-for-none-admin-ceph-user.patch b/meta-openstack/recipes-devtools/python/python-nova/Fix-rbd-backend-not-working-for-none-admin-ceph-user.patch new file mode 100644 index 0000000..c5fbbbb --- /dev/null +++ b/meta-openstack/recipes-devtools/python/python-nova/Fix-rbd-backend-not-working-for-none-admin-ceph-user.patch | |||
| @@ -0,0 +1,130 @@ | |||
| 1 | Fix rbd backend not working for none admin ceph user | ||
| 2 | |||
| 3 | commit 7104a6d8b1885f04d3012d621ec14f4be5145994 from | ||
| 4 | https://github.com/openstack/nova | ||
| 5 | |||
| 6 | The 'rbd_user' option allows nova administrators to override the default user | ||
| 7 | account used for RBD operations, with one that has potentially lower | ||
| 8 | privileges. Not all parts of the Nova code honoured the 'rbd_user' option, | ||
| 9 | which resulted in failures when attempting to use a lesser privileged user for | ||
| 10 | RBD. This fix ensures the '--id' and '--config' parameters are passed to the | ||
| 11 | RBD command line tools in all cases. | ||
| 12 | |||
| 13 | Change-Id: Id99aa303791143360ad78074184583048e4878f0 | ||
| 14 | Close-bug: 1255536 | ||
| 15 | |||
| 16 | Signed-off-by: Haomai Wang <haomai@unitedstack.com> | ||
| 17 | [VT: Ported to Havana branch] | ||
| 18 | Signed-off-by: Vu Tran <vu.tran@windriver.com> | ||
| 19 | |||
| 20 | diff --git a/nova/tests/virt/libvirt/test_libvirt_utils.py b/nova/tests/virt/libvirt/test_libvirt_utils.py | ||
| 21 | index ea83d3a..74f4a9e 100644 | ||
| 22 | --- a/nova/tests/virt/libvirt/test_libvirt_utils.py | ||
| 23 | +++ b/nova/tests/virt/libvirt/test_libvirt_utils.py | ||
| 24 | @@ -40,3 +40,44 @@ blah BLAH: bb | ||
| 25 | self.mox.ReplayAll() | ||
| 26 | disk_type = libvirt_utils.get_disk_type(path) | ||
| 27 | self.assertEqual(disk_type, 'raw') | ||
| 28 | + | ||
| 29 | + def test_list_rbd_volumes(self): | ||
| 30 | + conf = '/etc/ceph/fake_ceph.conf' | ||
| 31 | + pool = 'fake_pool' | ||
| 32 | + user = 'user' | ||
| 33 | + self.flags(images_rbd_ceph_conf=conf, group='libvirt') | ||
| 34 | + self.flags(rbd_user=user, group='libvirt') | ||
| 35 | + fn = self.mox.CreateMockAnything() | ||
| 36 | + self.mox.StubOutWithMock(libvirt_utils.utils, | ||
| 37 | + 'execute') | ||
| 38 | + libvirt_utils.utils.execute('rbd', '-p', pool, 'ls', '--id', | ||
| 39 | + user, | ||
| 40 | + '--conf', conf).AndReturn(("Out", "Error")) | ||
| 41 | + self.mox.ReplayAll() | ||
| 42 | + | ||
| 43 | + libvirt_utils.list_rbd_volumes(pool) | ||
| 44 | + | ||
| 45 | + self.mox.VerifyAll() | ||
| 46 | + | ||
| 47 | + def test_remove_rbd_volumes(self): | ||
| 48 | + conf = '/etc/ceph/fake_ceph.conf' | ||
| 49 | + pool = 'fake_pool' | ||
| 50 | + user = 'user' | ||
| 51 | + names = ['volume1', 'volume2', 'volume3'] | ||
| 52 | + self.flags(images_rbd_ceph_conf=conf, group='libvirt') | ||
| 53 | + self.flags(rbd_user=user, group='libvirt') | ||
| 54 | + fn = self.mox.CreateMockAnything() | ||
| 55 | + libvirt_utils.utils.execute('rbd', '-p', pool, 'rm', 'volume1', | ||
| 56 | + '--id', user, '--conf', conf, attempts=3, | ||
| 57 | + run_as_root=True) | ||
| 58 | + libvirt_utils.utils.execute('rbd', '-p', pool, 'rm', 'volume2', | ||
| 59 | + '--id', user, '--conf', conf, attempts=3, | ||
| 60 | + run_as_root=True) | ||
| 61 | + libvirt_utils.utils.execute('rbd', '-p', pool, 'rm', 'volume3', | ||
| 62 | + '--id', user, '--conf', conf, attempts=3, | ||
| 63 | + run_as_root=True) | ||
| 64 | + self.mox.ReplayAll() | ||
| 65 | + | ||
| 66 | + libvirt_utils.remove_rbd_volumes(pool, *names) | ||
| 67 | + | ||
| 68 | + self.mox.VerifyAll() | ||
| 69 | diff --git a/nova/virt/libvirt/imagebackend.py b/nova/virt/libvirt/imagebackend.py | ||
| 70 | index 51872cf..89fe494 100644 | ||
| 71 | --- a/nova/virt/libvirt/imagebackend.py | ||
| 72 | +++ b/nova/virt/libvirt/imagebackend.py | ||
| 73 | @@ -460,8 +460,10 @@ class Rbd(Image): | ||
| 74 | |||
| 75 | def _ceph_args(self): | ||
| 76 | args = [] | ||
| 77 | - args.extend(['--id', CONF.rbd_user]) | ||
| 78 | - args.extend(['--conf', self.ceph_conf]) | ||
| 79 | + if CONF.rbd_user: | ||
| 80 | + args.extend(['--id', CONF.rbd_user]) | ||
| 81 | + if self.ceph_conf: | ||
| 82 | + args.extend(['--conf', self.ceph_conf]) | ||
| 83 | return args | ||
| 84 | |||
| 85 | def _get_mon_addrs(self): | ||
| 86 | diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py | ||
| 87 | index d7c92b7..db533e1 100644 | ||
| 88 | --- a/nova/virt/libvirt/utils.py | ||
| 89 | +++ b/nova/virt/libvirt/utils.py | ||
| 90 | @@ -262,12 +262,27 @@ def import_rbd_image(*args): | ||
| 91 | execute('rbd', 'import', *args) | ||
| 92 | |||
| 93 | |||
| 94 | +def _run_rbd(*args, **kwargs): | ||
| 95 | + total = list(args) | ||
| 96 | + | ||
| 97 | + if CONF.rbd_user: | ||
| 98 | + total.extend(['--id', str(CONF.rbd_user)]) | ||
| 99 | + if CONF.libvirt_images_rbd_ceph_conf: | ||
| 100 | + total.extend(['--conf', str(CONF.libvirt_images_rbd_ceph_conf)]) | ||
| 101 | + | ||
| 102 | + return utils.execute(*total, **kwargs) | ||
| 103 | + | ||
| 104 | + | ||
| 105 | def list_rbd_volumes(pool): | ||
| 106 | """List volumes names for given ceph pool. | ||
| 107 | |||
| 108 | :param pool: ceph pool name | ||
| 109 | """ | ||
| 110 | - out, err = utils.execute('rbd', '-p', pool, 'ls') | ||
| 111 | + try: | ||
| 112 | + out, err = _run_rbd('rbd', '-p', pool, 'ls') | ||
| 113 | + except processutils.ProcessExecutionError: | ||
| 114 | + # No problem when no volume in rbd pool | ||
| 115 | + return [] | ||
| 116 | |||
| 117 | return [line.strip() for line in out.splitlines()] | ||
| 118 | |||
| 119 | @@ -275,9 +290,9 @@ def list_rbd_volumes(pool): | ||
| 120 | def remove_rbd_volumes(pool, *names): | ||
| 121 | """Remove one or more rbd volume.""" | ||
| 122 | for name in names: | ||
| 123 | - rbd_remove = ('rbd', '-p', pool, 'rm', name) | ||
| 124 | + rbd_remove = ['rbd', '-p', pool, 'rm', name] | ||
| 125 | try: | ||
| 126 | - execute(*rbd_remove, attempts=3, run_as_root=True) | ||
| 127 | + _run_rbd(*rbd_remove, attempts=3, run_as_root=True) | ||
| 128 | except processutils.ProcessExecutionError: | ||
| 129 | LOG.warn(_("rbd remove %(name)s in pool %(pool)s failed"), | ||
| 130 | {'name': name, 'pool': pool}) | ||
