From bf7ea559835ebdf0735ed26cafa54cbf209270b9 Mon Sep 17 00:00:00 2001 From: Edward Hope-Morley Date: Mon, 2 Jun 2014 19:37:32 +0100 Subject: [PATCH] [hopem] added support for libvirt RBD imagebackend --- config.yaml | 5 +++++ hooks/nova_compute_context.py | 18 +++++++++++++++++- revision | 2 +- templates/havana/nova.conf | 9 ++++++++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/config.yaml b/config.yaml index 0012bc0b..deea11af 100644 --- a/config.yaml +++ b/config.yaml @@ -105,3 +105,8 @@ options: juju-myservice-0 If you're running multiple environments with the same services in them this allows you to differentiate between them. + libvirt_image_backend: + type: string + description: + Tell Nova which libvirt image backend to use. Supported backends are rbd and lvm. + If no backend is specified, the Nova default is used (probably qcow2). diff --git a/hooks/nova_compute_context.py b/hooks/nova_compute_context.py index 1a6351b5..d37c83a9 100644 --- a/hooks/nova_compute_context.py +++ b/hooks/nova_compute_context.py @@ -12,10 +12,16 @@ from charmhelpers.core.hookenv import ( related_units, service_name, unit_get, + WARNING, ERROR, ) -from charmhelpers.contrib.openstack.utils import get_host_ip, os_release +from charmhelpers.contrib.openstack.utils import ( + get_host_ip, + os_release, + get_os_version_package, + get_os_version_codename +) from charmhelpers.contrib.network.ovs import add_bridge @@ -128,6 +134,16 @@ class NovaComputeCephContext(context.CephContext): ctxt['rbd_secret_uuid'] = CEPH_SECRET_UUID ctxt['rbd_pool'] = 'nova' + if config('libvirt_image_backend') == 'rbd': + os_ver = get_os_version_package('ceph-common') + if float(os_ver) >= float(get_os_version_codename('havana')): + ctxt['libvirt_images_type'] = 'rbd' + else: + log("RBD imagebackend only supported in openstack >= Havana " + "- ignoring", level=WARNING) + elif config('libvirt_image_backend') == 'lvm': + ctxt['libvirt_images_type'] = 'lvm' + return ctxt diff --git a/revision b/revision index 94361d49..6a4573e8 100644 --- a/revision +++ b/revision @@ -1 +1 @@ -132 +133 diff --git a/templates/havana/nova.conf b/templates/havana/nova.conf index 108c07c9..3e5ceebf 100644 --- a/templates/havana/nova.conf +++ b/templates/havana/nova.conf @@ -35,11 +35,18 @@ glance_api_servers = {{ glance_api_servers }} {% endif -%} {% if rbd_pool -%} -rbd_pool = {{ rbd_pool }} +libvirt_images_rbd_pool = {{ rbd_pool }} rbd_user = {{ rbd_user }} rbd_secret_uuid = {{ rbd_secret_uuid }} {% endif -%} +{% if libvirt_image_backend -%} +libvirt_images_type = {{ libvirt_images_type }} +libvirt_inject_password=false +libvirt_inject_key=false +libvirt_inject_partition=-2 +{% endif -%} + {% if neutron_plugin and neutron_plugin == 'ovs' -%} libvirt_vif_driver = nova.virt.libvirt.vif.LibvirtGenericVIFDriver {% if neutron_security_groups -%}