Commit 6ffd84fb authored by Adrian Rossouw's avatar Adrian Rossouw

Merge branch 'master' into omega-nginx

parents 55e81c4f 6bfb7cd0
......@@ -64,14 +64,14 @@ class provisionService_db extends provisionService {
function suggest_db_name() {
$uri = $this->context->uri;
$suggest_base = str_replace(array('.', '-'), '' , ereg_replace('^www\.', '', $uri));
$suggest_base = substr(str_replace(array('.', '-'), '' , ereg_replace('^www\.', '', $uri)), 0, 16);
$suggest[] = substr($suggest_base, 0, 16);
for ($i = 0; $i < 100; $i++) {
$suggest[] = sprintf("%s_%d", substr($suggest_base, 0, 15 - strlen( (string) $i) ), $i);
if (!$this->database_exists($suggest_base)) {
return $suggest_base;
}
foreach ($suggest as $option) {
for ($i = 0; $i < 100; $i++) {
$option = sprintf("%s_%d", substr($suggest_base, 0, 15 - strlen( (string) $i) ), $i);
if (!$this->database_exists($option)) {
return $option;
}
......
......@@ -18,10 +18,21 @@ class provisionService_http_cluster extends provisionService_http {
}
}
/**
* Run a method on each server in the cluster.
*
* This function does a logical AND on the return status of each of the
* methods, and returns TRUE only if they all returned something that
* can be interpreted as TRUE.
*/
function _each_server($method, $args = array()) {
// Return True by default.
$result = TRUE;
foreach ($this->server->cluster_web_servers as $server) {
call_user_func_array(array(d($server)->service('http', $this->context), $method), $args);
// If any methods return false, return false for the whole operation.
$result = $result && call_user_func_array(array(d($server)->service('http', $this->context), $method), $args);
}
return $result;
}
function parse_configs() {
......@@ -29,17 +40,27 @@ class provisionService_http_cluster extends provisionService_http {
}
function create_config($config) {
$this->each_server(__FUNCTION__, array($config));
$this->_each_server(__FUNCTION__, array($config));
}
function delete_config($config) {
$this->each_server(__FUNCTION__, array($config));
$this->_each_server(__FUNCTION__, array($config));
}
function restart() {
$this->_each_server(__FUNCTION__);
}
/**
* Support the ability to cloak database credentials using environment variables.
*
* The cluster supports this functionality only if ALL the servers it maintains
* supports this functionality.
*/
function cloaked_db_creds() {
return $this->_each_server(__FUNCTION__);
}
function sync() {
$args = func_get_args();
$this->_each_server(__FUNCTION__, $args);
......
......@@ -11,6 +11,15 @@ function http_provision_services() {
class provisionService_http extends provisionService {
public $service = 'http';
protected $ssl_enabled = FALSE;
/**
* Support the ability to cloak the database credentials using environment variables.
*/
function cloaked_db_creds() {
return FALSE;
}
}
// Public http service , as in non-encrypted and listening on a port.
......@@ -117,13 +126,6 @@ class provisionService_http_public extends provisionService_http {
return TRUE;
}
/**
* Support the ability to cloak the database credentials using environment variables.
*/
function cloaked_db_creds() {
return FALSE;
}
/**
* Return a list of servers that will need database access.
*/
......
......@@ -50,7 +50,7 @@ function drush_provision_drupal_pre_provision_migrate_rollback($platform, $new_u
$success = provision_file()->unlink(drush_get_option('backup_file'))
->succeed('Removed unused migration site package')
->fail('Could not remove unused migration site package');
d()->service('http')->create_site_config();
d()->service('http')->create_config('site');
d()->service('http')->parse_configs();
}
......
......@@ -13,7 +13,7 @@
'database' => "<?php print $this->creds['db_name']; ?>",
'username' => "<?php print $this->creds['db_user']; ?>",
'password' => "<?php print $this->creds['db_passwd']; ?>",
'host' => <?php print $this->creds['db_host']; ?>,
'host' => "<?php print $this->creds['db_host']; ?>",
);
$db_url = "<?php print strtr("%db_type://%db_user:%db_passwd@%db_host/%db_name", array(
'%db_type' => $this->creds['db_type'],
......
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