Config-Model - Automatic upgrade of configuration data

Posted on Thu Jul 24 13:32:33 2008 by ddumont
Automatic upgrade of configuration data

The automatic upgrade is now working.

Here's how is declared the model that enable upgrade from 'syntax' to 'backend'.

Note that I do not use the 'compute' parameter in backend but a new parameter named 'migrate_from'. They work similarly except that "computed" values are considered as default value and shown as "standard" vallues in config-model-edit interface. But a migrated value is not a standard value. It just a copy of data that is shown as "customized" values in config-model-edit interface.

'syntax' => { type => 'leaf', value_type => 'enum', choice => [qw/cds perl ini custom/], status => 'deprecated', }, 'backend' => { type => 'leaf', value_type => 'enum', choice => [qw/cds_file perl_file ini_file augeas custom/], migrate_from => { formula => '$old' , variables => { old => '- syntax' } , replace => { perl => 'perl_file', ini => 'ini_file', cds => 'cds_file', }, }, } },

With this "migration" specification (and another one related to config_dir changes), I can update Sshd model easily:
- run "config-model-edit -model Sshd"
- click menu "File->save"

and here's the result:

$ svn diff lib/ Index: lib/Config/Model/models/Sshd.pl =================================================================== --- lib/Config/Model/models/Sshd.pl (revision 727) +++ lib/Config/Model/models/Sshd.pl (working copy) @@ -1,22 +1,22 @@ [ { - 'write_config_dir' => '/etc/ssh', 'read_config' => [ { 'function' => 'sshd_read', + 'backend' => 'custom', 'class' => 'Config::Model::OpenSsh', - 'syntax' => 'custom' + 'config_dir' => '/etc/ssh' } ], 'name' => 'Sshd', 'write_config' => [ { 'function' => 'sshd_write', + 'backend' => 'custom', 'class' => 'Config::Model::OpenSsh', - 'syntax' => 'custom' + 'config_dir' => '/etc/ssh' } ], - 'read_config_dir' => '/etc/ssh', 'element' => [ 'AcceptEnv', {

We see what occured during the upgrade:
- value of 'syntax' was moved to 'backend'
- value of 'write_config_dir' was moved on 'write_config/config_dir'
- value of 'read_config_dir' was moved on 'read_config/config_dir'

That's better than havings a bunch of rpmsave files ;-)

If you have a use case of configuration data migration, I'd like to hear from you so we can create a real case example of a configuration model that will handle smooth upgrades.

Hopefully, this example will be easier to understand that the one above ;-)

All the best

Write a response