summaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-devtools/python/python-nova
diff options
context:
space:
mode:
authorVu Tran <vu.tran@windriver.com>2014-03-18 21:01:01 -0400
committerBruce Ashfield <bruce.ashfield@windriver.com>2014-03-24 16:41:59 -0400
commit3b5ec214c506a47cbd8abf7bd6557246980ddea5 (patch)
tree3d596654a8c53494d898a0fdfd140adefea0e741 /meta-openstack/recipes-devtools/python/python-nova
parentd156d7e1155fc325cb398f98ed41b540031c9df3 (diff)
downloadmeta-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')
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova/Fix-rbd-backend-not-working-for-none-admin-ceph-user.patch130
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova/Make-rbd.libvirt_info-parent-class-compatible.patch48
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova/nova.conf7
3 files changed, 185 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 @@
1Fix rbd backend not working for none admin ceph user
2
3commit 7104a6d8b1885f04d3012d621ec14f4be5145994 from
4https://github.com/openstack/nova
5
6The 'rbd_user' option allows nova administrators to override the default user
7account used for RBD operations, with one that has potentially lower
8privileges. Not all parts of the Nova code honoured the 'rbd_user' option,
9which resulted in failures when attempting to use a lesser privileged user for
10RBD. This fix ensures the '--id' and '--config' parameters are passed to the
11RBD command line tools in all cases.
12
13Change-Id: Id99aa303791143360ad78074184583048e4878f0
14Close-bug: 1255536
15
16Signed-off-by: Haomai Wang <haomai@unitedstack.com>
17[VT: Ported to Havana branch]
18Signed-off-by: Vu Tran <vu.tran@windriver.com>
19
20diff --git a/nova/tests/virt/libvirt/test_libvirt_utils.py b/nova/tests/virt/libvirt/test_libvirt_utils.py
21index 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()
69diff --git a/nova/virt/libvirt/imagebackend.py b/nova/virt/libvirt/imagebackend.py
70index 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):
86diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py
87index 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})
diff --git a/meta-openstack/recipes-devtools/python/python-nova/Make-rbd.libvirt_info-parent-class-compatible.patch b/meta-openstack/recipes-devtools/python/python-nova/Make-rbd.libvirt_info-parent-class-compatible.patch
new file mode 100644
index 0000000..542abf5
--- /dev/null
+++ b/meta-openstack/recipes-devtools/python/python-nova/Make-rbd.libvirt_info-parent-class-compatible.patch
@@ -0,0 +1,48 @@
1Make rbd.libvirt_info parent class compatible
2
3commit 7a34be0ec0cd0cb9555fe64ff6c486faae1ae91d from
4https://github.com/openstack/nova
5
6Rbd.libvirt_info function definition misses hypervisor_version argument added in change:
7https://review.openstack.org/32379
8
9Closes-Bug: #1233188
10Change-Id: Ib68d743e783af0f6d82d2ba180869ee642e86050
11
12diff --git a/nova/tests/virt/libvirt/test_imagebackend.py b/nova/tests/virt/libvirt/test_imagebackend.py
13index 2455ec8..5bfa94d 100644
14--- a/nova/tests/virt/libvirt/test_imagebackend.py
15+++ b/nova/tests/virt/libvirt/test_imagebackend.py
16@@ -20,6 +20,8 @@ import os
17 import fixtures
18 from oslo.config import cfg
19
20+from inspect import getargspec
21+
22 from nova import exception
23 from nova.openstack.common import uuidutils
24 from nova import test
25@@ -630,6 +632,10 @@ class RbdTestCase(_ImageTestCase, test.NoDBTestCase):
26
27 self.assertEqual(fake_processutils.fake_execute_get_log(), [])
28
29+ def test_parent_compatible(self):
30+ self.assertEqual(getargspec(imagebackend.Image.libvirt_info),
31+ getargspec(self.image_class.libvirt_info))
32+
33
34 class BackendTestCase(test.NoDBTestCase):
35 INSTANCE = {'name': 'fake-instance',
36diff --git a/nova/virt/libvirt/imagebackend.py b/nova/virt/libvirt/imagebackend.py
37index e900789..51872cf 100644
38--- a/nova/virt/libvirt/imagebackend.py
39+++ b/nova/virt/libvirt/imagebackend.py
40@@ -482,7 +482,7 @@ class Rbd(Image):
41 return hosts, ports
42
43 def libvirt_info(self, disk_bus, disk_dev, device_type, cache_mode,
44- extra_specs):
45+ extra_specs, hypervisor_version):
46 """Get `LibvirtConfigGuestDisk` filled for this image.
47
48 :disk_dev: Disk bus device name
diff --git a/meta-openstack/recipes-devtools/python/python-nova/nova.conf b/meta-openstack/recipes-devtools/python/python-nova/nova.conf
index 84ef48b..8aaf41a 100644
--- a/meta-openstack/recipes-devtools/python/python-nova/nova.conf
+++ b/meta-openstack/recipes-devtools/python/python-nova/nova.conf
@@ -21,6 +21,7 @@ my_ip = %CONTROLLER_IP%
21glance_host = %CONTROLLER_IP% 21glance_host = %CONTROLLER_IP%
22lock_path=/var/lock/nova/ 22lock_path=/var/lock/nova/
23state_path=/var/run/nova/ 23state_path=/var/run/nova/
24libvirt_images_type = %LIBVIRT_IMAGES_TYPE%
24 25
25#VNC 26#VNC
26vnc_enabled = true 27vnc_enabled = true
@@ -61,3 +62,9 @@ instance_usage_audit_period=hour
61notify_on_state_change=vm_and_task_state 62notify_on_state_change=vm_and_task_state
62notification_driver=nova.openstack.common.notifier.rpc_notifier 63notification_driver=nova.openstack.common.notifier.rpc_notifier
63notification_driver=ceilometer.compute.nova_notifier 64notification_driver=ceilometer.compute.nova_notifier
65
66# nova-compute configuration for ceph
67libvirt_images_rbd_pool=cinder-volumes
68libvirt_images_rbd_ceph_conf=/etc/ceph/ceph.conf
69rbd_user=cinder-volume
70#rbd_secret_uuid=