Permalink
Browse files

Perform explicit db migrations

The db sync script should be used to create
the initial db schema so that it will create
a migration revision table.

This migration revision table allows for schema upgrades.

This commit adds an exec resource for glance-manage db_sync
and ensures that it only occurs if the registry.conf file,
package, or db resource change.
  • Loading branch information...
1 parent 52cbb6f commit 4b95b9dae7d39034e5046c982b628ea05e4d99c0 Dan Bode committed Apr 12, 2012
Showing with 26 additions and 9 deletions.
  1. +11 −0 manifests/registry.pp
  2. +15 −9 spec/classes/glance_registry_spec.rb
View
@@ -33,6 +33,17 @@
content => template('glance/glance-registry-paste.ini.erb'),
}
+ Database<| title == 'glance' |> ~> Exec['glance-manage db_sync']
+
+ exec { 'glance-manage db_sync':
+ path => '/usr/bin',
+ refreshonly => true,
+ logoutput => on_failure,
+ subscribe => [Package['glance'], File['/etc/glance/glance-registry.conf']],
+ notify => Service['glance-registry'],
+ }
+
+
service { 'glance-registry':
name => $::glance::params::registry_service_name,
ensure => running,
@@ -44,16 +44,22 @@
it { should contain_class 'glance::registry' }
- it do
- should contain_service('glance-registry').with(
- 'ensure' => 'running',
- 'enable' => 'true',
- 'hasstatus' => 'true',
+ it { should contain_service('glance-registry').with(
+ 'ensure' => 'running',
+ 'enable' => 'true',
+ 'hasstatus' => 'true',
'hasrestart' => 'true',
- 'subscribe' => 'File[/etc/glance/glance-registry.conf]',
- 'require' => 'Class[Glance]'
- )
- end
+ 'subscribe' => 'File[/etc/glance/glance-registry.conf]',
+ 'require' => 'Class[Glance]'
+ )}
+
+ it { should contain_exec('glance-manage db_sync').with(
+ 'path' => '/usr/bin',
+ 'refreshonly' => true,
+ 'logoutput' => 'on_failure',
+ 'subscribe' => ['Package[glance]', 'File[/etc/glance/glance-registry.conf]'],
+ 'notify' => 'Service[glance-registry]'
+ )}
it 'should compile the template based on the class parameters' do
content = param_value(subject, 'file', '/etc/glance/glance-registry.conf', 'content')

0 comments on commit 4b95b9d

Please sign in to comment.