1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214
|
#
# Copyright (C) 2014 OpenStack Foundation
#
# Author: Emilien Macchi <emilien.macchi@enovance.com>
# Donald Talton <dotalton@cisco.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
# == Class: nova::compute::rbd
#
# Configure nova-compute to store virtual machines on RBD
#
# === Parameters
#
# [*libvirt_rbd_user*]
# (Required) The RADOS client name for accessing rbd volumes.
#
# [*libvirt_rbd_secret_uuid*]
# (optional) The libvirt uuid of the secret for the rbd_user.
# Required to use cephx.
# Default to undef.
#
# [*libvirt_rbd_secret_key*]
# (optional) The cephx key to use as key for the libvirt secret,
# it must be base64 encoded; when not provided this key will be
# requested to the ceph cluster, which assumes the node is
# provided of the client.admin keyring as well.
# Default to undef.
#
# [*libvirt_images_rbd_pool*]
# (optional) The RADOS pool in which rbd volumes are stored.
# Defaults to 'rbd'.
#
# [*libvirt_images_rbd_ceph_conf*]
# (optional) The path to the ceph configuration file to use.
# Defaults to '/etc/ceph/ceph.conf'.
#
# [*libvirt_images_rbd_glance_store_name*]
# (optional) Name of the Glance store that represents the local rbd cluster.
# If set, this will allow Nova to request that Glance copy an image from
# an existing non-local store into the one named by this option before
# booting so that proper Copy-on-Write behavior is maintained.
# Defaults to $facts['os_service_default'].
#
# [*libvirt_images_rbd_glance_copy_poll_interval*]
# (optional) The interval in seconds with which to poll Glance after asking
# for it to copy an image to the local rbd store.
# Defaults to $facts['os_service_default'].
#
# [*libvirt_images_rbd_glance_copy_timeout*]
# (optional) The overall maximum time we will wait for Glance to complete
# an image copy to our local rbd store.
# Defaults to $facts['os_service_default'].
#
# [*libvirt_rbd_connect_timeout*]
# (optional) The RADOS client timeout in seconds when initially connecting
# to the cluster.
# Defaults to $facts['os_service_default'].
#
# [*libvirt_rbd_destroy_volume_retry_interval*]
# (optional) Number of seconds to wait between each consecutive retry to
# destroy a RBD volume.
# Defaults to $facts['os_service_default'].
#
# [*libvirt_rbd_destroy_volume_retries*]
# (optional) Number of retries to destory a RBD volume.
# Defaults to $facts['os_service_default'].
#
# [*ephemeral_storage*]
# (optional) Whether or not to use the rbd driver for the nova
# ephemeral storage or for the cinder volumes only.
# Defaults to true.
#
# [*manage_ceph_client*]
# (optional) Whether to manage the ceph client package.
# Defaults to true.
#
# [*ceph_client_ensure*]
# (optional) Ensure value for ceph client package.
# Defaults to 'present'.
#
# [*package_ensure*]
# (optional) The state of qemu-block-extra package. This parameter has effect
# only in Ubuntu/Debian.
# Defaults to 'present'
#
# [*manage_libvirt_secret*]
# (optional) Manage the libvirt secret
# Defaults to true
#
# == Deprecated parameters
#
# [*rbd_keyring*]
# (optional) The keyring name to use when retrieving the RBD secret
# Default to undef
#
class nova::compute::rbd (
$libvirt_rbd_user,
$libvirt_rbd_secret_uuid = undef,
$libvirt_rbd_secret_key = undef,
$libvirt_images_rbd_pool = 'rbd',
$libvirt_images_rbd_ceph_conf = '/etc/ceph/ceph.conf',
$libvirt_images_rbd_glance_store_name = $facts['os_service_default'],
$libvirt_images_rbd_glance_copy_poll_interval = $facts['os_service_default'],
$libvirt_images_rbd_glance_copy_timeout = $facts['os_service_default'],
$libvirt_rbd_connect_timeout = $facts['os_service_default'],
$libvirt_rbd_destroy_volume_retry_interval = $facts['os_service_default'],
$libvirt_rbd_destroy_volume_retries = $facts['os_service_default'],
Boolean $ephemeral_storage = true,
Boolean $manage_ceph_client = true,
$ceph_client_ensure = 'present',
$package_ensure = 'present',
Boolean $manage_libvirt_secret = true,
## DEPRECATED PARAMETERS
$rbd_keyring = undef,
) {
include nova::deps
include nova::params
if $rbd_keyring != undef {
warning('The rbd_keyring parameter is deprecated and has no effect')
}
if $manage_ceph_client {
# Install ceph client libraries
package { 'ceph-client-package':
ensure => $ceph_client_ensure,
name => $nova::params::ceph_client_package_name,
tag => ['openstack', 'nova-support-package'],
}
}
if $facts['os']['family'] == 'Debian' {
package { 'qemu-block-extra':
ensure => $package_ensure,
tag => ['openstack', 'nova-support-package'],
}
}
nova_config {
'libvirt/rbd_user': value => $libvirt_rbd_user;
}
if $libvirt_rbd_secret_uuid != undef {
nova_config {
'libvirt/rbd_secret_uuid': value => $libvirt_rbd_secret_uuid;
}
# TODO(tobias-urdin): Remove these two when propagated
file { '/etc/nova/secret.xml':
ensure => 'absent',
}
file { '/etc/nova/virsh.secret':
ensure => 'absent',
}
if $manage_libvirt_secret {
if $libvirt_rbd_secret_key == undef {
fail('libvirt_rbd_secret_key is required when libvirt_rbd_secret_uuid is set')
}
nova::compute::libvirt::secret_ceph { $libvirt_rbd_secret_uuid:
uuid => $libvirt_rbd_secret_uuid,
value => $libvirt_rbd_secret_key,
}
}
} else {
nova_config {
'libvirt/rbd_secret_uuid': ensure => absent;
}
}
if $ephemeral_storage {
if defined('Class[nova::compute::libvirt]') {
if $::nova::compute::libvirt::images_type != 'rbd' {
fail('nova::compute::libvirt::images_type should be rbd if rbd ephemeral storage is used.')
}
}
nova_config {
'libvirt/images_rbd_pool': value => $libvirt_images_rbd_pool;
'libvirt/images_rbd_ceph_conf': value => $libvirt_images_rbd_ceph_conf;
'libvirt/images_rbd_glance_store_name': value => $libvirt_images_rbd_glance_store_name;
'libvirt/images_rbd_glance_copy_poll_interval': value => $libvirt_images_rbd_glance_copy_poll_interval;
'libvirt/images_rbd_glance_copy_timeout': value => $libvirt_images_rbd_glance_copy_timeout;
'libvirt/rbd_connect_timeout': value => $libvirt_rbd_connect_timeout;
'libvirt/rbd_destroy_volume_retry_interval': value => $libvirt_rbd_destroy_volume_retry_interval;
'libvirt/rbd_destroy_volume_retries': value => $libvirt_rbd_destroy_volume_retries;
}
} else {
nova_config {
'libvirt/images_rbd_pool': ensure => absent;
'libvirt/images_rbd_ceph_conf': ensure => absent;
'libvirt/images_rbd_glance_store_name': ensure => absent;
'libvirt/images_rbd_glance_copy_poll_interval': ensure => absent;
'libvirt/images_rbd_glance_copy_timeout': ensure => absent;
'libvirt/rbd_connect_timeout': ensure => absent;
'libvirt/rbd_destroy_volume_retry_interval': ensure => absent;
'libvirt/rbd_destroy_volume_retries': ensure => absent;
}
}
}
|