Add ability to provide another ephemeral storage for nova-compute
Nova has configuration option to specify ephemeral storage - images_type But right now this charm allows to specify only ceph via relation to ceph. This changeset adds ability to specify any images_type and add ability to provide configuration for the ephemeral backend via relation. Same functionality implemented in cinder charm via storage-backend interface. Change-Id: Id851e172aed53723d4d8fb6623ff1c4b4a03fefa
This commit is contained in:
parent
fd3687eafb
commit
88f14e168b
1
hooks/ephemeral-backend-relation-broken
Symbolic link
1
hooks/ephemeral-backend-relation-broken
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
nova_compute_hooks.py
|
1
hooks/ephemeral-backend-relation-changed
Symbolic link
1
hooks/ephemeral-backend-relation-changed
Symbolic link
@ -0,0 +1 @@
|
|||||||
|
nova_compute_hooks.py
|
@ -149,6 +149,9 @@ class NovaComputeLibvirtContext(context.OSContextGenerator):
|
|||||||
db.flush()
|
db.flush()
|
||||||
ctxt['host_uuid'] = host_uuid
|
ctxt['host_uuid'] = host_uuid
|
||||||
|
|
||||||
|
if config('libvirt-image-backend'):
|
||||||
|
ctxt['libvirt_images_type'] = config('libvirt-image-backend')
|
||||||
|
|
||||||
return ctxt
|
return ctxt
|
||||||
|
|
||||||
|
|
||||||
@ -169,7 +172,7 @@ class NovaComputeVirtContext(context.OSContextGenerator):
|
|||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
|
||||||
def assert_libvirt_imagebackend_allowed():
|
def assert_libvirt_rbd_imagebackend_allowed():
|
||||||
os_rel = "Juno"
|
os_rel = "Juno"
|
||||||
os_ver = get_os_version_package('nova-common')
|
os_ver = get_os_version_package('nova-common')
|
||||||
if float(os_ver) < float(get_os_version_codename(os_rel.lower())):
|
if float(os_ver) < float(get_os_version_codename(os_rel.lower())):
|
||||||
@ -196,11 +199,8 @@ class NovaComputeCephContext(context.CephContext):
|
|||||||
ctxt['rbd_pool'] = config('rbd-pool')
|
ctxt['rbd_pool'] = config('rbd-pool')
|
||||||
|
|
||||||
if (config('libvirt-image-backend') == 'rbd' and
|
if (config('libvirt-image-backend') == 'rbd' and
|
||||||
assert_libvirt_imagebackend_allowed()):
|
assert_libvirt_rbd_imagebackend_allowed()):
|
||||||
ctxt['libvirt_images_type'] = 'rbd'
|
|
||||||
ctxt['libvirt_rbd_images_ceph_conf'] = ceph_config_file()
|
ctxt['libvirt_rbd_images_ceph_conf'] = ceph_config_file()
|
||||||
elif config('libvirt-image-backend') == 'lvm':
|
|
||||||
ctxt['libvirt_images_type'] = 'lvm'
|
|
||||||
|
|
||||||
rbd_cache = config('rbd-client-cache') or ""
|
rbd_cache = config('rbd-client-cache') or ""
|
||||||
if rbd_cache.lower() == "enabled":
|
if rbd_cache.lower() == "enabled":
|
||||||
|
@ -83,7 +83,7 @@ from charmhelpers.core.unitdata import kv
|
|||||||
|
|
||||||
from nova_compute_context import (
|
from nova_compute_context import (
|
||||||
CEPH_SECRET_UUID,
|
CEPH_SECRET_UUID,
|
||||||
assert_libvirt_imagebackend_allowed
|
assert_libvirt_rbd_imagebackend_allowed
|
||||||
)
|
)
|
||||||
from charmhelpers.contrib.charmsupport import nrpe
|
from charmhelpers.contrib.charmsupport import nrpe
|
||||||
from charmhelpers.core.sysctl import create as create_sysctl
|
from charmhelpers.core.sysctl import create as create_sysctl
|
||||||
@ -173,7 +173,7 @@ def config_changed():
|
|||||||
set_ppc64_cpu_smt_state('off')
|
set_ppc64_cpu_smt_state('off')
|
||||||
|
|
||||||
if (config('libvirt-image-backend') == 'rbd' and
|
if (config('libvirt-image-backend') == 'rbd' and
|
||||||
assert_libvirt_imagebackend_allowed()):
|
assert_libvirt_rbd_imagebackend_allowed()):
|
||||||
for rid in relation_ids('ceph'):
|
for rid in relation_ids('ceph'):
|
||||||
for unit in related_units(rid):
|
for unit in related_units(rid):
|
||||||
ceph_changed(rid=rid, unit=unit)
|
ceph_changed(rid=rid, unit=unit)
|
||||||
@ -252,6 +252,16 @@ def image_service_changed():
|
|||||||
CONFIGS.write(NOVA_CONF)
|
CONFIGS.write(NOVA_CONF)
|
||||||
|
|
||||||
|
|
||||||
|
@hooks.hook('ephemeral-backend-relation-changed',
|
||||||
|
'ephemeral-backend-relation-broken')
|
||||||
|
@restart_on_change(restart_map())
|
||||||
|
def ephemeral_backend_hook():
|
||||||
|
if 'ephemeral-backend' not in CONFIGS.complete_contexts():
|
||||||
|
log('ephemeral-backend relation incomplete. Peer not ready?')
|
||||||
|
return
|
||||||
|
CONFIGS.write(NOVA_CONF)
|
||||||
|
|
||||||
|
|
||||||
@hooks.hook('cloud-compute-relation-joined')
|
@hooks.hook('cloud-compute-relation-joined')
|
||||||
def compute_joined(rid=None):
|
def compute_joined(rid=None):
|
||||||
# NOTE(james-page) in MAAS environments the actual hostname is a CNAME
|
# NOTE(james-page) in MAAS environments the actual hostname is a CNAME
|
||||||
@ -325,7 +335,7 @@ def ceph_changed(rid=None, unit=None):
|
|||||||
secret_uuid=CEPH_SECRET_UUID, key=key)
|
secret_uuid=CEPH_SECRET_UUID, key=key)
|
||||||
|
|
||||||
if (config('libvirt-image-backend') == 'rbd' and
|
if (config('libvirt-image-backend') == 'rbd' and
|
||||||
assert_libvirt_imagebackend_allowed()):
|
assert_libvirt_rbd_imagebackend_allowed()):
|
||||||
if is_request_complete(get_ceph_request()):
|
if is_request_complete(get_ceph_request()):
|
||||||
log('Request complete')
|
log('Request complete')
|
||||||
# Ensure that nova-compute is restarted since only now can we
|
# Ensure that nova-compute is restarted since only now can we
|
||||||
|
@ -174,7 +174,8 @@ BASE_RESOURCE_MAP = {
|
|||||||
NovaComputeCephContext(),
|
NovaComputeCephContext(),
|
||||||
context.SyslogContext(),
|
context.SyslogContext(),
|
||||||
context.SubordinateConfigContext(
|
context.SubordinateConfigContext(
|
||||||
interface=['neutron-plugin', 'nova-ceilometer'],
|
interface=['neutron-plugin', 'nova-ceilometer',
|
||||||
|
'ephemeral-backend'],
|
||||||
service=['nova-compute', 'nova'],
|
service=['nova-compute', 'nova'],
|
||||||
config_file=NOVA_CONF),
|
config_file=NOVA_CONF),
|
||||||
InstanceConsoleContext(),
|
InstanceConsoleContext(),
|
||||||
|
@ -41,6 +41,9 @@ requires:
|
|||||||
zeromq-configuration:
|
zeromq-configuration:
|
||||||
interface: zeromq-configuration
|
interface: zeromq-configuration
|
||||||
scope: container
|
scope: container
|
||||||
|
ephemeral-backend:
|
||||||
|
interface: ephemeral-backend
|
||||||
|
scope: container
|
||||||
peers:
|
peers:
|
||||||
compute-peer:
|
compute-peer:
|
||||||
interface: nova
|
interface: nova
|
||||||
|
@ -155,8 +155,10 @@ cpu_mode = {{ cpu_mode }}
|
|||||||
{% if cpu_model -%}
|
{% if cpu_model -%}
|
||||||
cpu_model = {{ cpu_model }}
|
cpu_model = {{ cpu_model }}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% if libvirt_images_type and rbd_pool -%}
|
{% if libvirt_images_type -%}
|
||||||
images_type = {{ libvirt_images_type }}
|
images_type = {{ libvirt_images_type }}
|
||||||
|
{% endif -%}
|
||||||
|
{% if libvirt_images_type and rbd_pool -%}
|
||||||
images_rbd_pool = {{ rbd_pool }}
|
images_rbd_pool = {{ rbd_pool }}
|
||||||
images_rbd_ceph_conf = {{ libvirt_rbd_images_ceph_conf }}
|
images_rbd_ceph_conf = {{ libvirt_rbd_images_ceph_conf }}
|
||||||
inject_password = false
|
inject_password = false
|
||||||
@ -169,3 +171,4 @@ rbd_secret_uuid = {{ rbd_secret_uuid }}
|
|||||||
disk_cachemodes = {{ disk_cachemodes }}
|
disk_cachemodes = {{ disk_cachemodes }}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
|
{% include "parts/section-ephemeral" %}
|
||||||
|
@ -148,8 +148,10 @@ cpu_mode = {{ cpu_mode }}
|
|||||||
{% if cpu_model -%}
|
{% if cpu_model -%}
|
||||||
cpu_model = {{ cpu_model }}
|
cpu_model = {{ cpu_model }}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% if libvirt_images_type and rbd_pool -%}
|
{% if libvirt_images_type -%}
|
||||||
images_type = {{ libvirt_images_type }}
|
images_type = {{ libvirt_images_type }}
|
||||||
|
{% endif -%}
|
||||||
|
{% if libvirt_images_type and rbd_pool -%}
|
||||||
images_rbd_pool = {{ rbd_pool }}
|
images_rbd_pool = {{ rbd_pool }}
|
||||||
images_rbd_ceph_conf = {{ libvirt_rbd_images_ceph_conf }}
|
images_rbd_ceph_conf = {{ libvirt_rbd_images_ceph_conf }}
|
||||||
inject_password = false
|
inject_password = false
|
||||||
@ -167,3 +169,4 @@ disk_cachemodes = {{ disk_cachemodes }}
|
|||||||
|
|
||||||
{% include "parts/section-cinder" %}
|
{% include "parts/section-cinder" %}
|
||||||
|
|
||||||
|
{% include "parts/section-ephemeral" %}
|
||||||
|
@ -156,8 +156,10 @@ cpu_mode = {{ cpu_mode }}
|
|||||||
{% if cpu_model -%}
|
{% if cpu_model -%}
|
||||||
cpu_model = {{ cpu_model }}
|
cpu_model = {{ cpu_model }}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% if libvirt_images_type and rbd_pool -%}
|
{% if libvirt_images_type -%}
|
||||||
images_type = {{ libvirt_images_type }}
|
images_type = {{ libvirt_images_type }}
|
||||||
|
{% endif -%}
|
||||||
|
{% if libvirt_images_type and rbd_pool -%}
|
||||||
images_rbd_pool = {{ rbd_pool }}
|
images_rbd_pool = {{ rbd_pool }}
|
||||||
images_rbd_ceph_conf = {{ libvirt_rbd_images_ceph_conf }}
|
images_rbd_ceph_conf = {{ libvirt_rbd_images_ceph_conf }}
|
||||||
inject_password = false
|
inject_password = false
|
||||||
@ -184,3 +186,5 @@ lock_path=/var/lock/nova
|
|||||||
|
|
||||||
[workarounds]
|
[workarounds]
|
||||||
disable_libvirt_livesnapshot = False
|
disable_libvirt_livesnapshot = False
|
||||||
|
|
||||||
|
{% include "parts/section-ephemeral" %}
|
||||||
|
@ -162,8 +162,10 @@ cpu_mode = {{ cpu_mode }}
|
|||||||
{% if cpu_model -%}
|
{% if cpu_model -%}
|
||||||
cpu_model = {{ cpu_model }}
|
cpu_model = {{ cpu_model }}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% if libvirt_images_type and rbd_pool -%}
|
{% if libvirt_images_type -%}
|
||||||
images_type = {{ libvirt_images_type }}
|
images_type = {{ libvirt_images_type }}
|
||||||
|
{% endif -%}
|
||||||
|
{% if libvirt_images_type and rbd_pool -%}
|
||||||
images_rbd_pool = {{ rbd_pool }}
|
images_rbd_pool = {{ rbd_pool }}
|
||||||
images_rbd_ceph_conf = {{ libvirt_rbd_images_ceph_conf }}
|
images_rbd_ceph_conf = {{ libvirt_rbd_images_ceph_conf }}
|
||||||
inject_password = false
|
inject_password = false
|
||||||
@ -190,3 +192,5 @@ lock_path=/var/lock/nova
|
|||||||
|
|
||||||
[workarounds]
|
[workarounds]
|
||||||
disable_libvirt_livesnapshot = False
|
disable_libvirt_livesnapshot = False
|
||||||
|
|
||||||
|
{% include "parts/section-ephemeral" %}
|
||||||
|
@ -161,8 +161,10 @@ cpu_mode = {{ cpu_mode }}
|
|||||||
{% if cpu_model -%}
|
{% if cpu_model -%}
|
||||||
cpu_model = {{ cpu_model }}
|
cpu_model = {{ cpu_model }}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{% if libvirt_images_type and rbd_pool -%}
|
{% if libvirt_images_type -%}
|
||||||
images_type = {{ libvirt_images_type }}
|
images_type = {{ libvirt_images_type }}
|
||||||
|
{% endif -%}
|
||||||
|
{% if libvirt_images_type and rbd_pool -%}
|
||||||
images_rbd_pool = {{ rbd_pool }}
|
images_rbd_pool = {{ rbd_pool }}
|
||||||
images_rbd_ceph_conf = {{ libvirt_rbd_images_ceph_conf }}
|
images_rbd_ceph_conf = {{ libvirt_rbd_images_ceph_conf }}
|
||||||
inject_password = false
|
inject_password = false
|
||||||
@ -189,3 +191,5 @@ lock_path=/var/lock/nova
|
|||||||
|
|
||||||
[workarounds]
|
[workarounds]
|
||||||
disable_libvirt_livesnapshot = False
|
disable_libvirt_livesnapshot = False
|
||||||
|
|
||||||
|
{% include "parts/section-ephemeral" %}
|
||||||
|
8
templates/parts/section-ephemeral
Normal file
8
templates/parts/section-ephemeral
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{% for section in sections -%}
|
||||||
|
{% if section != 'DEFAULT' -%}
|
||||||
|
[{{ section }}]
|
||||||
|
{% for key, value in sections[section] -%}
|
||||||
|
{{ key }} = {{ value }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{%- endfor %}
|
@ -63,7 +63,7 @@ TO_PATCH = [
|
|||||||
# misc_utils
|
# misc_utils
|
||||||
'ensure_ceph_keyring',
|
'ensure_ceph_keyring',
|
||||||
'execd_preinstall',
|
'execd_preinstall',
|
||||||
'assert_libvirt_imagebackend_allowed',
|
'assert_libvirt_rbd_imagebackend_allowed',
|
||||||
'is_request_complete',
|
'is_request_complete',
|
||||||
'send_request_if_needed',
|
'send_request_if_needed',
|
||||||
# socket
|
# socket
|
||||||
@ -467,7 +467,7 @@ class NovaComputeRelationsTests(CharmTestCase):
|
|||||||
service_name):
|
service_name):
|
||||||
self.test_config.set('libvirt-image-backend', 'rbd')
|
self.test_config.set('libvirt-image-backend', 'rbd')
|
||||||
self.is_request_complete.return_value = True
|
self.is_request_complete.return_value = True
|
||||||
self.assert_libvirt_imagebackend_allowed.return_value = True
|
self.assert_libvirt_rbd_imagebackend_allowed.return_value = True
|
||||||
configs.complete_contexts = MagicMock()
|
configs.complete_contexts = MagicMock()
|
||||||
configs.complete_contexts.return_value = ['ceph']
|
configs.complete_contexts.return_value = ['ceph']
|
||||||
configs.write = MagicMock()
|
configs.write = MagicMock()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user