Commit d0bcac8a authored by drumm's avatar drumm Committed by Neil Drumm

Remove boilerplate code and get db server verify working

parent 16db51a6
......@@ -38,11 +38,14 @@ class provisionService_db extends provisionService {
}
function verify() {
if (!$this->can_create_database()) {
drush_set_error('PROVISION_CREATE_DB_FAILED');
}
else {
drush_log(dt('Provision can create new databases.'), 'message');
if (d($this->owner)->type === 'server') {
$this->connect();
if ($this->can_create_database()) {
drush_log(dt('Provision can create new databases.'), 'message');
}
else {
drush_set_error('PROVISION_CREATE_DB_FAILED');
}
}
}
......
......@@ -46,18 +46,22 @@ class provisionService_http_apache extends provisionService_http {
}
function verify() {
if (PROVISION_CONTEXT_PLATFORM) {
$this->create_platform_config();
}
elseif (PROVISION_CONTEXT_SERVER) {
provision_service('file')->create_dir(drush_get_option('vhost_path'), dt("Virtual host configuration"), 0700);
provision_service('file')->create_dir(drush_get_option('platform_conf_path'), dt("Platforms configuration"), 0700);
provision_service('file')->create_dir(drush_get_option('config_path') . '/apache.d' , dt("Apache configuration"), 0700);
$this->create_server_config();
}
elseif (PROVISION_CONTEXT_SITE) {
$this->create_site_config();
switch (d($this->owner)->type) {
case 'server':
provision_service('file')->create_dir(drush_get_option('vhost_path'), dt("Virtual host configuration"), 0700);
provision_service('file')->create_dir(drush_get_option('platform_conf_path'), dt("Platforms configuration"), 0700);
provision_service('file')->create_dir(drush_get_option('config_path') . '/apache.d' , dt("Apache configuration"), 0700);
$this->create_server_config();
break;
case 'platform':
$this->create_platform_config();
break;
case 'site':
$this->create_site_config();
break;
}
$this->parse_configs();
......
......@@ -62,7 +62,6 @@ include_once('provision.inc');
function provision_drush_init() {
d(drush_get_option('hosting-name', '@self'), TRUE);
print_r(d());
$load = sys_getloadavg();
if (provision_load_critical($load)) {
drush_set_error('PROVISION_OVERLOAD', dt("load on system too heavy (@load), aborting", array('@load' => join(" ", $load))));
......@@ -216,15 +215,19 @@ function drush_provision_hostmaster_make($platform) {
drush_backend_invoke('make', array(dirname(__FILE__) . '/aegir.make', $platform));
}
function drush_http_provision_named_context_save() {
function drush_provision_named_context_save() {
d()->write_alias();
}
function drush_http_provision_named_context_delete() {
function drush_provision_named_context_delete() {
$config = new provisionConfig_drushrc_alias(drush_get_option('hosting_name'));
$config->unlink();
}
function drush_provision_verify() {
d()->verify();
}
function _provision_default_restart_cmd() {
$command = '/usr/sbin/apachectl'; // A proper default for most of the world
foreach (explode(':', $_SERVER['PATH']) as $path) {
......
......@@ -63,7 +63,7 @@ class provisionEnvironment {
protected $name = null;
protected $properties = array();
protected $type = null;
public $type = null;
protected $oid_map = array();
protected $map = array();
......@@ -235,6 +235,7 @@ class provisionServer extends provisionEnvironment {
$object = new $className($this->name);
$object->init();
$this->services[$service] = $object;
$this->setProperty($type_option, $type);
}
}
else {
......@@ -258,11 +259,13 @@ class provisionServer extends provisionEnvironment {
* An array of return values from method implementations.
*/
function services_invoke($callback) {
$return = array();
foreach ($this->services as $service) {
$return = array_merge($return, $service->$callback());
$service->$callback();
}
return $return;
}
function verify() {
$this->services_invoke('verify');
}
}
......
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