Merge pull request #534 from enovance/glance-file
Glance: add "local" backend
This commit is contained in:
		@@ -67,6 +67,11 @@
 | 
			
		||||
#   (optional) Syslog facility to receive log lines
 | 
			
		||||
#   Defaults to 'LOG_LOCAL0'
 | 
			
		||||
#
 | 
			
		||||
# [*backend*]
 | 
			
		||||
#   (optionnal) Backend to use to store images
 | 
			
		||||
#   Can be 'rbd' or 'file'.
 | 
			
		||||
#   Defaults to 'rbd' to maintain backward compatibility
 | 
			
		||||
#
 | 
			
		||||
 | 
			
		||||
class cloud::image::api(
 | 
			
		||||
  $glance_db_host                    = '127.0.0.1',
 | 
			
		||||
@@ -88,7 +93,9 @@ class cloud::image::api(
 | 
			
		||||
  $verbose                           = true,
 | 
			
		||||
  $debug                             = true,
 | 
			
		||||
  $log_facility                      = 'LOG_LOCAL0',
 | 
			
		||||
  $use_syslog                        = true
 | 
			
		||||
  $use_syslog                        = true,
 | 
			
		||||
  $backend                           = 'rbd',
 | 
			
		||||
  $filesystem_store_datadir          = undef
 | 
			
		||||
) {
 | 
			
		||||
 | 
			
		||||
  # Disable twice logging if syslog is enabled
 | 
			
		||||
@@ -144,20 +151,28 @@ class cloud::image::api(
 | 
			
		||||
    'DEFAULT/notifier_driver':          value => 'noop';
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  class { 'glance::backend::rbd':
 | 
			
		||||
    rbd_store_user => $glance_rbd_user,
 | 
			
		||||
    rbd_store_pool => $glance_rbd_pool
 | 
			
		||||
  }
 | 
			
		||||
  if ($backend == 'rbd') {
 | 
			
		||||
    class { 'glance::backend::rbd':
 | 
			
		||||
      rbd_store_user => $glance_rbd_user,
 | 
			
		||||
      rbd_store_pool => $glance_rbd_pool
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  Ceph::Key <<| title == $glance_rbd_user |>>
 | 
			
		||||
  file { '/etc/ceph/ceph.client.glance.keyring':
 | 
			
		||||
    owner   => 'glance',
 | 
			
		||||
    group   => 'glance',
 | 
			
		||||
    mode    => '0400',
 | 
			
		||||
    require => Ceph::Key[$glance_rbd_user],
 | 
			
		||||
    notify  => Service['glance-api','glance-registry']
 | 
			
		||||
    Ceph::Key <<| title == $glance_rbd_user |>>
 | 
			
		||||
    file { '/etc/ceph/ceph.client.glance.keyring':
 | 
			
		||||
      owner   => 'glance',
 | 
			
		||||
      group   => 'glance',
 | 
			
		||||
      mode    => '0400',
 | 
			
		||||
      require => Ceph::Key[$glance_rbd_user],
 | 
			
		||||
      notify  => Service['glance-api','glance-registry']
 | 
			
		||||
    }
 | 
			
		||||
    Concat::Fragment <<| title == 'ceph-client-os' |>>
 | 
			
		||||
  } elsif ($backend == 'file') {
 | 
			
		||||
    class { 'glance::backend::file':
 | 
			
		||||
      filesystem_store_datadir => $filesystem_store_datadir
 | 
			
		||||
    }
 | 
			
		||||
  } else {
 | 
			
		||||
    fail("${backend} is not a Glance supported backend.")
 | 
			
		||||
  }
 | 
			
		||||
  Concat::Fragment <<| title == 'ceph-client-os' |>>
 | 
			
		||||
 | 
			
		||||
  class { 'glance::cache::cleaner': }
 | 
			
		||||
  class { 'glance::cache::pruner': }
 | 
			
		||||
 
 | 
			
		||||
@@ -35,6 +35,7 @@ describe 'cloud::image::api' do
 | 
			
		||||
      :rabbit_password                   => 'secrete',
 | 
			
		||||
      :glance_rbd_user                   => 'glance',
 | 
			
		||||
      :glance_rbd_pool                   => 'images',
 | 
			
		||||
      :backend                           => 'rbd',
 | 
			
		||||
      :debug                             => true,
 | 
			
		||||
      :verbose                           => true,
 | 
			
		||||
      :use_syslog                        => true,
 | 
			
		||||
@@ -92,6 +93,25 @@ describe 'cloud::image::api' do
 | 
			
		||||
      should contain_class('glance::cache::pruner')
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with file Glance backend' do
 | 
			
		||||
      before :each do
 | 
			
		||||
        params.merge!(:backend => 'file')
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      it 'configure Glance with file backend' do
 | 
			
		||||
        should contain_class('glance::backend::file')
 | 
			
		||||
        should_not contain_class('glance::backend::rbd')
 | 
			
		||||
        should contain_glance_api_config('DEFAULT/filesystem_store_datadir').with('value' => '/var/lib/glance/images/')
 | 
			
		||||
        should contain_glance_api_config('DEFAULT/default_store').with('value' => 'file')
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    context 'with wrong Glance backend' do
 | 
			
		||||
      before :each do
 | 
			
		||||
        params.merge!(:backend => 'Something')
 | 
			
		||||
      end
 | 
			
		||||
      it { should compile.and_raise_error(/Something is not a Glance supported backend./) }
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  context 'on Debian platforms' do
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user