Commit 41c161c9 authored by Adrian Rossouw's avatar Adrian Rossouw

Remove the 'magic' from services. they now access the server properties...

Remove the 'magic' from services. they now access the server properties through the $this->server reference created during __construct.
parent 0eaafc86
......@@ -37,8 +37,8 @@ class provisionService_db extends provisionService {
}
function init() {
$this->setProperty('master_db');
$this->creds = array_map('urldecode', parse_url($this->master_db));
$this->server->setProperty('master_db');
$this->creds = array_map('urldecode', parse_url($this->server->master_db));
return TRUE;
}
......@@ -197,11 +197,11 @@ class provisionService_db extends provisionService {
//TODO - this should not be here at all
$creds['db_type'] = drush_set_option('db_type', $db_type, 'site');
$creds['db_host'] = drush_set_option('db_host', $this->remote_host, 'site');
$creds['db_host'] = drush_set_option('db_host', $this->server->remote_host, 'site');
$creds['db_passwd'] = drush_set_option('db_passwd', provision_password(), 'site');
$creds['db_name'] = drush_set_option('db_name', $this->suggest_db_name(), 'site');
$creds['db_user'] = drush_set_option('db_user', $creds['db_name'], 'site');
$creds['db_grant_host'] = $this->grant_host(d()->service('http')->server());
$creds['db_grant_host'] = $this->grant_host(d()->service('http')->server);
return $creds;
}
......@@ -214,7 +214,7 @@ class provisionService_db extends provisionService {
$creds[$key] = drush_get_option($key, '', 'site');
}
$creds['db_grant_host'] = $this->grant_host(d()->service('http')->server());
$creds['db_grant_host'] = $this->grant_host(d()->service('http')->server);
return $creds;
}
......
......@@ -83,7 +83,7 @@ class provisionService_db_mysql extends provisionService_db_pdo {
}
function grant_host(provisionServer $server) {
$server->shell_exec('mysql -u intntnllyInvalid -h ' . escapeshellarg($this->remote_host));
$server->shell_exec('mysql -u intntnllyInvalid -h ' . escapeshellarg($this->server->remote_host));
if (preg_match("/Access denied for user 'intntnllyInvalid'@'([^']*)'/", implode('', drush_shell_exec_output()), $match)) {
return $match[1];
}
......
......@@ -10,13 +10,13 @@ class provisionService_http_apache extends provisionService_http {
function init() {
parent::init();
$this->apache_site_conf_path = $this->config_path . '/vhost.d';
$this->apache_platform_conf_path = $this->config_path . '/platform.d';
$this->apache_conf_path = $this->config_path . '/apache.d';
$this->server->apache_site_conf_path = $this->server->config_path . '/vhost.d';
$this->server->apache_platform_conf_path = $this->server->config_path . '/platform.d';
$this->server->apache_conf_path = $this->server->config_path . '/apache.d';
// Commands
$this->setProperty('restart_cmd', _provision_default_restart_cmd());
$this->setProperty('web_ports', array(80));
$this->server->setProperty('restart_cmd', _provision_default_restart_cmd());
$this->server->setProperty('web_ports', array(80));
}
function create_site_config() {
......@@ -46,10 +46,10 @@ class provisionService_http_apache extends provisionService_http {
}
function create_server_config() {
provision_file()->create_dir($this->apache_site_conf_path, dt("Virtual host configuration"), 0700);
provision_file()->create_dir($this->apache_platform_conf_path, dt("Platforms configuration"), 0700);
provision_file()->create_dir($this->apache_conf_path , dt("Apache configuration"), 0700);
$this->sync($this->apache_conf_path);
provision_file()->create_dir($this->server->apache_site_conf_path, dt("Virtual host configuration"), 0700);
provision_file()->create_dir($this->server->apache_platform_conf_path, dt("Platforms configuration"), 0700);
provision_file()->create_dir($this->server->apache_conf_path , dt("Apache configuration"), 0700);
$this->sync($this->server->apache_conf_path);
$config = new provisionConfig_apache_server($this->context);
return $config->write();
......@@ -63,7 +63,7 @@ class provisionService_http_apache extends provisionService_http {
function parse_configs() {
// This is required to be configurable, due to the fact that different
// hosts might need to do this differently.
if ($this->server()->shell_exec($this->restart_cmd)) {
if ($this->server->shell_exec($this->server->restart_cmd)) {
drush_log(dt('Apache has been restarted'));
}
else {
......
......@@ -8,11 +8,11 @@ class provisionService_http_cluster extends provisionService_http {
}
function init() {
$this->setProperty('cluster_web_servers', array(), TRUE);
$this->server->setProperty('cluster_web_servers', array(), TRUE);
}
function _each_server($method) {
foreach ($this->cluster_web_servers as $server) {
foreach ($this->server->cluster_web_servers as $server) {
d($server)->service('http')->$method();
}
}
......
......@@ -20,11 +20,11 @@ class provisionService_http extends provisionService {
function init() {
parent::init();
// System account
$this->setProperty('web_group', _provision_default_web_group());
$this->server->setProperty('web_group', _provision_default_web_group());
// Redirection urls
$this->setProperty('web_disable_url', $this->master_url .'/hosting/disabled');
$this->setProperty('web_maintenence_url', $this->master_url .'/hosting/maintenance');
$this->server->setProperty('web_disable_url', $this->server->master_url .'/hosting/disabled');
$this->server->setProperty('web_maintenence_url', $this->server->master_url .'/hosting/maintenance');
}
function verify() {
......
......@@ -10,29 +10,12 @@ class provisionService extends provisionChainedState {
public $context;
function __get($name) {
return d($this->server)->$name;
}
function __set($name, $value) {
d($this->server)->$name = $value;
}
function __isset($name) {
return isset(d($this->server)->$name);
}
function __unset($name) {
unset(d($this->server)->$name);
}
function __construct($server) {
$this->server = $server;
$this->server = d($server);
}
function sync($path = NULL, $exclude_sites = FALSE) {
return d($this->server)->sync($path, $exclude_sites);
return $this->server->sync($path, $exclude_sites);
}
function verify() {
......@@ -43,20 +26,6 @@ class provisionService extends provisionChainedState {
return TRUE;
}
function setProperty($field, $default = NULL, $array = FALSE) {
d($this->server)->setProperty($field, $default, $array);
}
/**
* Find the server environment this service is running on.
*
* @return
* A provisionServer object.
*/
function server() {
return d($this->server);
}
/**
* Return service-specific configuration options for help.
*
......
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