From 41ab1426b9a8eb1f0ac3b3f3ebdd10b29b6295b9 Mon Sep 17 00:00:00 2001 From: Mark Vanderwiel Date: Wed, 10 Jun 2015 12:03:23 -0500 Subject: [PATCH] Add nova glance image file systems support Allow the configuration of file systems for nova images. Change-Id: I95d041f2dfe19df25933cfa2e53a409a65fd7899 Closes-Bug: 1463892 --- attributes/default.rb | 47 +++++++++++++++++++++++++++++++++ spec/nova-common_spec.rb | 34 +++++++++++++++++++++++- templates/default/nova.conf.erb | 13 +++++++++ 3 files changed, 93 insertions(+), 1 deletion(-) diff --git a/attributes/default.rb b/attributes/default.rb index 720e4d33..906b7d9d 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -121,6 +121,53 @@ default['openstack']['compute']['image']['ssl']['cert_file'] = nil # Private key file to use when starting the server securely default['openstack']['compute']['image']['ssl']['key_file'] = nil +# A list of url scheme that can be downloaded directly +# via the direct_url. Currently supported schemes: [file]. +default['openstack']['compute']['image']['allowed_direct_url_schemes'] = [] + +# Image file url support +# For each entry in the filesystem list a new configuration section must be +# added with the following format: +# +# filesystem name: +# +# id: +# An opaque string. In order for this module to know that the remote +# FS is the same one that is mounted locally it must share information +# with the glance deployment. Both glance and nova-compute must be +# configured with a unique matching string. This ensures that the +# file:// advertised URL is describing a file system that is known +# to nova-compute +# mountpoint: +# The location at which the file system is locally mounted. Glance +# may mount a shared file system on a different path than nova-compute. +# This value will be compared against the metadata advertised with +# glance and paths will be adjusted to ensure that the correct file +# is copied. +# +# For example: { +# 'some_fs' => { +# 'id' => '00000000-0000-0000-0000-000000000000', +# 'mountpoint' => '/mount/some_fs/images' +# }, +# 'another_fs' => { +# 'id' => '1111111-1111-1111-1111-1111111111111', +# 'mountpoint' => '/mount/another_fs/images' +# } +# } +# +# This will produce the following in nova.conf +# +# [image_file_url] +# filesystems=some_fs,another_fs +# [image_file_url:some_fs] +# id=00000000-0000-0000-0000-000000000000 +# mountpoint=/mount/some_fs/images +# [image_file_url:another_fs] +# id=1111111-1111-1111-1111-1111111111111 +# mountpoint=/mount/another_fs/images +default['openstack']['compute']['image']['filesystems'] = nil + # Neutron options # If True, this indicates that neutron api allows the client to perform # insecure SSL (https) requests. This should be the same as the setting diff --git a/spec/nova-common_spec.rb b/spec/nova-common_spec.rb index 445ab9ae..6956df2d 100644 --- a/spec/nova-common_spec.rb +++ b/spec/nova-common_spec.rb @@ -294,7 +294,8 @@ describe 'openstack-compute::nova-common' do [ /^insecure=false$/, - %r{^api_servers=http://127.0.0.1:9292$} + %r{^api_servers=http://127.0.0.1:9292$}, + /^allowed_direct_url_schemes=$/ ].each do |line| expect(chef_run).to render_config_file(file.name)\ .with_section_content('glance', line) @@ -874,6 +875,37 @@ describe 'openstack-compute::nova-common' do expect(chef_run).to render_config_file(file.name).with_section_content('upgrade_levels', /^#{key} = #{val}$/) end end + + context 'image file systems' do + it 'no image_file_url section by default' do + expect(chef_run).not_to render_file(file.name).with_content(/^\[image_file_url/) + end + + it 'build image_file_url sections' do + node.set['openstack']['compute']['image']['filesystems'] = { + 'some_fs' => { + 'id' => '00000000-0000-0000-0000-000000000000', + 'mountpoint' => '/mount/some_fs/images' + }, + 'another_fs' => { + 'id' => '1111111-1111-1111-1111-1111111111111', + 'mountpoint' => '/mount/another_fs/images' + } + } + [ + /^id=00000000-0000-0000-0000-000000000000$/, + %r{^mountpoint=/mount/some_fs/images$} + ].each do |line| + expect(chef_run).to render_config_file(file.name).with_section_content('image_file_url:some_fs', line) + end + [ + /^id=1111111-1111-1111-1111-1111111111111$/, + %r{^mountpoint=/mount/another_fs/images$} + ].each do |line| + expect(chef_run).to render_config_file(file.name).with_section_content('image_file_url:another_fs', line) + end + end + end end describe 'rootwrap.conf' do diff --git a/templates/default/nova.conf.erb b/templates/default/nova.conf.erb index 24efbb45..a29f3c44 100644 --- a/templates/default/nova.conf.erb +++ b/templates/default/nova.conf.erb @@ -757,6 +757,7 @@ metadata_proxy_shared_secret=<%= @neutron_metadata_proxy_shared_secret %> [glance] api_servers=<%= @glance_api_scheme %>://<%= @glance_api_ipaddress %>:<%= @glance_api_port %> insecure=<%= node['openstack']['compute']['image']['glance_insecure'] %> +allowed_direct_url_schemes=<%= node['openstack']['compute']['image']['allowed_direct_url_schemes'].join(',') %> [cinder] # Location of ca certificates file to use for cinder client requests @@ -882,3 +883,15 @@ rabbit_use_ssl=<%= node["openstack"]["mq"]["compute"]["rabbit"]["use_ssl"] %> <%= key %> = <%= val %> <% end -%> <% end -%> + +# Image file url support, add new sections here +<% if node['openstack']['compute']['image']['filesystems'] -%> +[image_file_url] +filesystems=node['openstack']['compute']['image']['filesystems'].join(',') +<% node['openstack']['compute']['image']['filesystems'].each do |section, opts| %> +[image_file_url:<%= section %>] +<% opts.each do |key, value| %> +<%= key %>=<%= value %> +<% end %> +<% end %> +<% end %>