Handle Ceph-related steps for using the RBD store
With this change, the api recipe will take care of the ceph-related things when the default_store attribute is set to rbd: - install dependency packages as specified in openstack[image][platform][ceph_packages] - create a cephx client keyring file with openstack-common's template and the key found in the data bag specified by the newly introduced attribute openstack[image][api][rbd][key_name] Change-Id: I92881e5a27fb5ec56d4f1fb72933749a3e8d8688
This commit is contained in:
parent
f47c0423d9
commit
6a5260a8c1
|
@ -117,7 +117,7 @@ Attributes for the Image service are in the ['openstack']['image'] namespace.
|
|||
* `openstack['image']['upload_images']` - Default list of images to upload to the glance repository as part of the install
|
||||
* `openstack['image']['upload_image']['<imagename>']` - URL location of the `<imagename>` image. There can be multiple instances of this line to define multiple imagess (eg natty, maverick, fedora17 etc)
|
||||
--- example `openstack['image']['upload_image']['natty']` - "http://c250663.r63.cf1.rackcdn.com/ubuntu-11.04-server-uec-amd64-multinic.tar.gz"
|
||||
* `openstack['image']['api']['default_store']` - Toggles the backend storage type. Currently supported is "file" and "swift"
|
||||
* `openstack['image']['api']['default_store']` - Toggles the backend storage type. Currently supported is "file", "swift" and "rbd".
|
||||
* `openstack['image']['api']['swift']['store_container']` - Set the container used by glance to store images and snapshots. Defaults to "glance"
|
||||
* `openstack['image']['api']['swift']['store_large_object_size']` - Set the size at which glance starts to chunnk files. Defaults to "200" MB
|
||||
* `openstack['image']['api']['swift']['store_large_object_chunk_size']` - Set the chunk size for glance. Defaults to "200" MB
|
||||
|
@ -127,6 +127,7 @@ Attributes for the Image service are in the ['openstack']['image'] namespace.
|
|||
* `openstack['image']['api']['rbd']['rbd_store_user']` - User for connecting to ceph store
|
||||
* `openstack['image']['api']['rbd']['rbd_store_pool']` - RADOS pool for images
|
||||
* `openstack['image']['api']['rbd']['rbd_store_chunk_size']` - Size in MB of chunks for RADOS Store, should be a power of 2
|
||||
* `openstack['image']['api']['rbd']['key_name']` - The data bag item name used for the Cephx key of the rbd_store_user.
|
||||
* `openstack['image']['cron']['redirection']` - Redirection of cron output
|
||||
TODO: Add DB2 support on other platforms
|
||||
* `openstack['image']['platform']['db2_python_packages']` - Array of DB2 python packages, only available on redhat platform
|
||||
|
|
|
@ -89,6 +89,8 @@ default['openstack']['image']['api']['rbd']['rbd_store_ceph_conf'] = '/etc/ceph/
|
|||
default['openstack']['image']['api']['rbd']['rbd_store_user'] = 'glance'
|
||||
default['openstack']['image']['api']['rbd']['rbd_store_pool'] = 'images'
|
||||
default['openstack']['image']['api']['rbd']['rbd_store_chunk_size'] = '8'
|
||||
# The name used for the data bag item containing the Cephx user's password
|
||||
default['openstack']['image']['api']['rbd']['key_name'] = 'rbd-image'
|
||||
|
||||
# If set, glance registry service will bind to the address on this interface,
|
||||
# otherwise it will bind to the API endpoint's host.
|
||||
|
@ -126,6 +128,7 @@ when 'fedora', 'redhat', 'centos' # :pragma-foodcritic: ~FC024 - won't fix this
|
|||
'db2_python_packages' => ['db2-odbc', 'python-ibm-db', 'python-ibm-db-sa'],
|
||||
'image_packages' => ['openstack-glance', 'cronie', 'python-glanceclient'],
|
||||
'image_client_packages' => ['python-glanceclient'],
|
||||
'ceph_packages' => ['python-ceph'],
|
||||
'swift_packages' => ['openstack-swift'],
|
||||
'image_api_service' => 'openstack-glance-api',
|
||||
'image_registry_service' => 'openstack-glance-registry',
|
||||
|
@ -140,6 +143,7 @@ when 'suse'
|
|||
'mysql_python_packages' => ['python-mysql'],
|
||||
'image_packages' => ['openstack-glance', 'python-glanceclient'],
|
||||
'image_client_packages' => ['python-glanceclient'],
|
||||
'ceph_packages' => [],
|
||||
'swift_packages' => ['openstack-swift'],
|
||||
'image_api_service' => 'openstack-glance-api',
|
||||
'image_registry_service' => 'openstack-glance-registry',
|
||||
|
@ -154,6 +158,7 @@ when 'ubuntu'
|
|||
'mysql_python_packages' => ['python-mysqldb'],
|
||||
'image_packages' => ['glance'],
|
||||
'image_client_packages' => ['python-glanceclient'],
|
||||
'ceph_packages' => ['python-ceph'],
|
||||
'swift_packages' => ['python-swift'],
|
||||
'image_api_service' => 'glance-api',
|
||||
'image_registry_service' => 'glance-registry',
|
||||
|
|
|
@ -56,6 +56,31 @@ if node['openstack']['image']['api']['default_store'] == 'swift'
|
|||
options platform_options['package_overrides']
|
||||
end
|
||||
end
|
||||
|
||||
elsif node['openstack']['image']['api']['default_store'] == 'rbd'
|
||||
rbd_user = node['openstack']['image']['api']['rbd']['rbd_store_user']
|
||||
rbd_key = get_password 'service', node['openstack']['image']['api']['rbd']['key_name']
|
||||
|
||||
include_recipe 'openstack-common::ceph_client'
|
||||
|
||||
platform_options['ceph_packages'].each do |pkg|
|
||||
package pkg do
|
||||
options platform_options['package_overrides']
|
||||
action :upgrade
|
||||
end
|
||||
end
|
||||
|
||||
template "/etc/ceph/ceph.client.#{rbd_user}.keyring" do
|
||||
source 'ceph.client.keyring.erb'
|
||||
cookbook 'openstack-common'
|
||||
owner node['openstack']['image']['user']
|
||||
group node['openstack']['image']['group']
|
||||
mode '0600'
|
||||
variables(
|
||||
name: rbd_user,
|
||||
key: rbd_key
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
service 'glance-api' do
|
||||
|
|
|
@ -19,18 +19,65 @@ describe 'openstack-image::api' do
|
|||
expect(chef_run).not_to upgrade_package('python-swift')
|
||||
end
|
||||
|
||||
it 'upgrades swift package if openstack/image/api/default_store is swift' do
|
||||
node.set['openstack']['image']['api']['default_store'] = 'swift'
|
||||
describe 'using swift for default_store' do
|
||||
before do
|
||||
node.set['openstack']['image']['api']['default_store'] = 'swift'
|
||||
end
|
||||
|
||||
expect(chef_run).to upgrade_package('python-swift')
|
||||
it 'upgrades swift package if openstack/image/api/default_store is swift' do
|
||||
expect(chef_run).to upgrade_package('python-swift')
|
||||
end
|
||||
|
||||
it 'honors platform package name and option overrides for swift packages' do
|
||||
node.set['openstack']['image']['platform']['package_overrides'] = '--override1 --override2'
|
||||
node.set['openstack']['image']['platform']['swift_packages'] = ['my-swift']
|
||||
|
||||
expect(chef_run).to upgrade_package('my-swift').with(options: '--override1 --override2')
|
||||
end
|
||||
end
|
||||
|
||||
it 'honors platform package name and option overrides for swift packages' do
|
||||
node.set['openstack']['image']['platform']['package_overrides'] = '-o Dpkg::Options::=\'--force-confold\' -o Dpkg::Options::=\'--force-confdef\' --force-yes'
|
||||
node.set['openstack']['image']['api']['default_store'] = 'swift'
|
||||
node.set['openstack']['image']['platform']['swift_packages'] = ['my-swift']
|
||||
describe 'using rbd for default_store' do
|
||||
before do
|
||||
node.set['openstack']['image']['api']['default_store'] = 'rbd'
|
||||
end
|
||||
|
||||
expect(chef_run).to upgrade_package('my-swift').with(options: '-o Dpkg::Options::=\'--force-confold\' -o Dpkg::Options::=\'--force-confdef\' --force-yes')
|
||||
it 'upgrades python-ceph package' do
|
||||
expect(chef_run).to upgrade_package('python-ceph')
|
||||
end
|
||||
|
||||
it 'honors platform package name and option overrides for ceph packages' do
|
||||
node.set['openstack']['image']['platform']['package_overrides'] = '--override1 --override2'
|
||||
node.set['openstack']['image']['platform']['ceph_packages'] = ['my-ceph']
|
||||
|
||||
expect(chef_run).to upgrade_package('my-ceph').with(options: '--override1 --override2')
|
||||
end
|
||||
|
||||
it 'includes the ceph_client recipe from openstack-common' do
|
||||
expect(chef_run).to include_recipe('openstack-common::ceph_client')
|
||||
end
|
||||
|
||||
describe 'cephx client keyring file' do
|
||||
let(:file) { chef_run.template('/etc/ceph/ceph.client.glance.keyring') }
|
||||
it 'has the proper content' do
|
||||
[/^\[client\.glance\]$/,
|
||||
/^ key = rbd-pass$/].each do |content|
|
||||
expect(chef_run).to render_file(file.name).with_content(content)
|
||||
end
|
||||
end
|
||||
|
||||
it "is created using openstack-common's template" do
|
||||
expect(chef_run).to create_template(file.name).with(cookbook: 'openstack-common')
|
||||
end
|
||||
|
||||
it 'has the correct owner' do
|
||||
expect(file.owner). to eq('glance')
|
||||
expect(file.group). to eq('glance')
|
||||
end
|
||||
|
||||
it 'has the correct mode' do
|
||||
expect(sprintf('%o', file.mode)).to eq '600'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'starts glance api on boot' do
|
||||
|
@ -156,6 +203,31 @@ describe 'openstack-image::api' do
|
|||
expect(chef_run).to render_file(file.name).with_content(
|
||||
/^swift_store_region = test_region$/)
|
||||
end
|
||||
|
||||
it 'does set the default rbd_store settings' do
|
||||
[%r|^rbd_store_ceph_conf = /etc/ceph/ceph\.conf$|,
|
||||
/^rbd_store_user = glance$/,
|
||||
/^rbd_store_pool = images$/,
|
||||
/^rbd_store_chunk_size = 8$/
|
||||
].each do |line|
|
||||
expect(chef_run).to render_file(file.name).with_content(line)
|
||||
end
|
||||
end
|
||||
|
||||
it 'does set the rbd_store settings when overridden' do
|
||||
node.set['openstack']['image']['api']['rbd']['rbd_store_ceph_conf'] = '/etc/ceph.conf'
|
||||
node.set['openstack']['image']['api']['rbd']['rbd_store_user'] = 'openstack-image'
|
||||
node.set['openstack']['image']['api']['rbd']['rbd_store_pool'] = 'bootimages'
|
||||
node.set['openstack']['image']['api']['rbd']['rbd_store_chunk_size'] = 4
|
||||
|
||||
[%r|^rbd_store_ceph_conf = /etc/ceph\.conf$|,
|
||||
/^rbd_store_user = openstack-image$/,
|
||||
/^rbd_store_pool = bootimages$/,
|
||||
/^rbd_store_chunk_size = 4$/
|
||||
].each do |line|
|
||||
expect(chef_run).to render_file(file.name).with_content(line)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'rabbitmq' do
|
||||
|
|
|
@ -40,6 +40,9 @@ shared_context 'image-stubs' do
|
|||
Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('user', 'guest')
|
||||
.and_return('mq-pass')
|
||||
Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('service', 'rbd-image')
|
||||
.and_return('rbd-pass')
|
||||
|
||||
Chef::Application.stub(:fatal!)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue