Commit b470b176 authored by Adrian Rossouw's avatar Adrian Rossouw

First attempt at a working migration path. provision-migrate command still needs lots of love

parent ff6cf68a
......@@ -15,15 +15,63 @@ function drush_provision_hostmaster_migrate_validate($site, $platform) {
}
}
$data = drush_get_merged_options();
$data['r'] = $data['root'] = realpath($platform);
drush_backend_invoke('provision-verify', $data);
// verify the current platform
drush_backend_invoke('provision-verify', array('root' => drush_get_option(array('r', 'root'), drush_locate_root())));
// verify the site prior to migration
drush_backend_invoke('provision-verify', array($site));
$data = drush_get_merged_options();
// add a server record :
$server = '@server_' . preg_replace("/[!\W\.\-]/", "", $data['web_host']);
drush_backend_invoke_args("provision-save", array($server), array(
'context_type' => 'server',
// files
'file_service_type' => 'local',
'aegir_root' => dirname(rtrim($data['config_path'], '/')),
'config_path' => $data['config_path'],
'backup_path' => $data['backup_path'],
// apache
'http_service_type' => 'apache',
'web_group' => $data['web_group'],
'master_url' => $data['master_url'],
'script_user' => $data['script_user'],
'restart_cmd' => $data['restart_cmd'],
// mysql
'db_service_type' => 'mysql',
'master_db' => $data['master_db'],
));
provision_backend_invoke($server, 'provision-verify');
drush_set_option('server_name', $server);
$old_platform = '@platform_' . preg_replace("/[!\W]/", "", basename(rtrim($data['publish_path'], '/')));
drush_backend_invoke_args("provision-save", array($old_platform), array(
'context_type' => 'platform',
'server' => $server,
'web_server' => $server,
'root' => $data['publish_path'],
));
provision_backend_invoke($old_platform, 'provision-verify');
drush_set_option('old_platform', $old_platform);
$new_platform = '@platform_' . preg_replace("/[!\W]/", "", basename(rtrim($platform, '/')));
drush_backend_invoke_args("provision-save", array($new_platform), array(
'context_type' => 'platform',
'server' => $server,
'web_server' => $server,
'root' => $platform,
));
provision_backend_invoke($new_platform, 'provision-verify');
drush_set_option('new_platform', $new_platform);
$site_name = '@' . $site;
drush_backend_invoke_args("provision-save", array($site_name), array(
'context_type' => 'site',
'platform' => $old_platform,
'db_server' => $server,
'uri' => $site,
'profile' => 'hostmaster',
));
provision_backend_invoke($site_name, 'provision-verify');
drush_set_option('site_name', $site_name);
}
function drush_provision_pre_hostmaster_migrate($site, $platform) {
if (!drush_confirm("This command will replace your crontab entry. continue?")) {
return drush_set_error('PROVISION_CANCEL_MIGRATE', 'Cancelling');
......@@ -32,14 +80,22 @@ function drush_provision_pre_hostmaster_migrate($site, $platform) {
exec('crontab -r');
// we can't rely on the park command to exist in pre-0.4 alpha 2 releases
drush_backend_invoke('hostmaster-pause', array($site, 'uri' => $site));
provision_backend_invoke(drush_get_option('site_name'), 'hostmaster-pause');
}
function drush_provision_hostmaster_migrate($site, $platform) {
function drush_provision_hostmaster_migrate($site, $platform) {
provision_backend_invoke(drush_get_option('site_name'), 'provision-migrate', drush_get_option('new_platform'));
drush_backend_invoke('provision-migrate', array($site, $platform));
}
function drush_provision_post_hostmaster_migrate($site, $platform) {
drush_backend_invoke('hostmaster-resume', array($site, 'uri' => $site, 'root' => $platform));
// we pass the context names we generated to the task so we can enforce that the names
// stay the same.
provision_backend_invoke(drush_get_option('site_name'), 'hostmaster-resume', array(),
'old_platform_name' => drush_get_option('old_platform'),
'new_platform_name' => drush_get_option('new_platform'),
'server_name' => drush_get_option('server_name'),
);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment