Commit 26211470 authored by Adrian Rossouw's avatar Adrian Rossouw

First stab at providing an upgrade path to migrate to the new multi-server code.

parent dcdcd91c
......@@ -8,7 +8,6 @@ function hosting_drush_command() {
);
$items['hosting-setup'] = array(
'callback' => 'hosting_setup',
'description' => dt('Set up initial configuration settings such as the cron entry for the queue dispatcher and more.'),
);
......
......@@ -424,7 +424,7 @@ function hosting_domain_allowed($url, $params = array()) {
* Runs the 'hosting-dispatch' command, and
* move on to setting up the crontab
*/
function hosting_setup() {
function drush_hosting_setup() {
if (drush_confirm("This command will replace your crontab for this user. continue?")) {
variable_set('hosting_dispatch_enabled', FALSE);
// attempt to run the dispatch command, to make sure it runs without the queue being enabled.
......@@ -757,6 +757,7 @@ function hosting_context_load($name) {
if ($obj = db_fetch_object($result)) {
return node_load($obj->nid);
}
return false;
}
/**
......
......@@ -152,13 +152,7 @@ function _hosting_queues_clean_output($return) {
function _hosting_dispatch_cmd() {
$cmd = sprintf("%s hosting-dispatch --root=%s", DRUSH_COMMAND, escapeshellarg(drush_get_option(array("r", "root"), $_SERVER['PWD'])));
if (function_exists('drush_get_option')) {
if ($uri = drush_get_option('uri')) {
$cmd .= ' --uri=' . escapeshellarg($uri);
}
}
$cmd = sprintf("%s %s hosting-dispatch ", DRUSH_COMMAND, escapeshellarg(d()->name));
return $cmd;
}
......
......@@ -4,7 +4,6 @@
function drush_hosting_package_pre_hosting_task() {
$task =& drush_get_context('HOSTING_TASK');
if ($task->ref->type == 'site') {
// populate the profile option, if it hasn't been specified yet.
if (empty($task->options['profile'])) {
$profile = node_load($task->ref->profile);
......
......@@ -6,14 +6,24 @@
include_once('hosting.inc');
function drush_hosting_hostmaster_resume($url) {
function drush_hosting_hostmaster_resume() {
drush_log('bootstrapping drupal');
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
$platform_root = drush_get_context('DRUSH_DRUPAL_ROOT');
$server_name = drush_get_option('server_name');
$old_platform = drush_get_option('old_platform_name');
$new_platform = drush_get_option('new_platform_name');
$nid = db_result(db_query('SELECT nid FROM {node} WHERE type = "site" AND status = 1 AND title = "%s"', $url));
$node = node_load($nid);
$node = hosting_context_load(d()->name);
// fix the old platform first
$platform_id = db_result(db_query('SELECT nid FROM {hosting_platform} WHERE publish_path = "%s"', d($old_platform)->root));
if (hosting_context_name($platform_id) != $old_platform) {
db_query("UPDATE {hosting_context} SET name='%s' WHERE nid=%d", ltrim($old_platform, '@'), $platform_id);
}
// if the new platform doesn't exist, create it.
$platform_root = d()->root;
if (!($platform_id = db_result(db_query('SELECT nid FROM {hosting_platform} WHERE publish_path = "%s"', $platform_root)))) {
drush_log(dt('Platform not found for path %path, adding platform node', array('%path' => $platform_root)));
// inherit settings from current platform node
......@@ -27,18 +37,25 @@ function drush_hosting_hostmaster_resume($url) {
$platform_id = $platform->nid;
}
else {
drush_log(dt('Platform found for path %path: #%id', array('%path' => $platform, '%id' => $platform_id)));
drush_log(dt('Platform found for path %path: #%id', array('%path' => $platform_root, '%id' => $platform_id)));
$platform = node_load($platform_id);
}
drush_log('fixing platform for site node');
if ($platform_id = db_result(db_query('SELECT nid FROM {hosting_platform} WHERE publish_path = "%s"', $platform_root))) {
$node->verified = 0;
$node->platform = $platform_id;
node_save($node);
drush_backend_invoke('hosting-setup', array('uri' => $url));
} else {
return drush_set_error('PROVISION_FRAMEWORK_ERROR', dt("Could not find the node for platform path %platform", array('%platform' => $platform_root)));
// fix the new platform alias name
if (hosting_context_name($platform_id) != $new_platform) {
db_query("UPDATE {hosting_context} SET name='%s' WHERE nid=%d", ltrim($new_platform, '@'), $platform_id);
}
// TODO: post migration tasks
// - save the drush log to the migrate task and set proper status
$server_id = $platform->web_server;
// fix the new platform alias name
if (hosting_context_name($server_id) != $server_name) {
db_query("UPDATE {hosting_context} SET name='%s' WHERE nid=%d", ltrim($server_name, '@'), $server_id);
}
drush_log('fixing platform for site node');
$node->verified = 0;
$node->platform = $platform_id;
node_save($node);
provision_backend_invoke(d()->name, 'hosting-setup');
}
......@@ -10,6 +10,9 @@ function hosting_site_context_options(&$task) {
$task->context_options['site_port'] = $task->ref->port;
$task->context_options['site_id'] = $task->ref->nid;
$task->context_options['language'] = $task->ref->site_language;
$profile = node_load($task->ref->profile);
$task->context_options['profile'] = $profile->short_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