Commit 27a7b049 authored by Jon Pugh's avatar Jon Pugh

Issue #1966886: First pass at Search and Replace "Context" for "Entity" and "context" and "entity".

parent 534b17a0
......@@ -6,10 +6,10 @@ class Provision_Service_db extends Provision_Service {
/**
* Register the db handler for sites, based on the db_server option.
*/
static function subscribe_site($context) {
$context->setProperty('db_server', '@server_master');
$context->is_oid('db_server');
$context->service_subscribe('db', $context->db_server->name);
static function subscribe_site($entity) {
$entity->setProperty('db_server', '@server_master');
$entity->is_oid('db_server');
$entity->service_subscribe('db', $entity->db_server->name);
}
static function option_documentation() {
......@@ -52,7 +52,7 @@ class Provision_Service_db extends Provision_Service {
* Find a viable database name, based on the site's uri.
*/
function suggest_db_name() {
$uri = $this->context->uri;
$uri = $this->entity->uri;
$suggest_base = substr(str_replace(array('.', '-'), '' , preg_replace('/^www\./', '', $uri)), 0, 16);
......@@ -231,7 +231,7 @@ class Provision_Service_db extends Provision_Service {
* access to the site database.
*/
function grant_host_list() {
return array_unique(array_map(array($this, 'grant_host'), $this->context->service('http')->grant_server_list()));
return array_unique(array_map(array($this, 'grant_host'), $this->entity->service('http')->grant_server_list()));
}
/**
......
......@@ -5,11 +5,11 @@ class Provision_Config_Bind_slave extends Provision_Config_Dns_Server {
function process() {
parent::process();
if ($this->context->type == 'server') {
$ips = $this->context->ip_addresses;
if ($this->entity->type == 'server') {
$ips = $this->entity->ip_addresses;
}
else {
$ips = $this->context->server->ip_addresses;
$ips = $this->entity->server->ip_addresses;
}
$this->data['master_ip_list'] = implode(';', $ips);
}
......
......@@ -69,12 +69,12 @@ class Provision_Service_dns extends Provision_Service {
function init_site() {
parent::init_site();
$this->context->setProperty('dns_zone', NULL);
if (is_null($this->context->dns_zone)) {
$this->context->dns_zone = $this->guess_zone($this->context->uri);
$this->entity->setProperty('dns_zone', NULL);
if (is_null($this->entity->dns_zone)) {
$this->entity->dns_zone = $this->guess_zone($this->entity->uri);
}
$this->context->dns_zone_subdomain = trim(str_replace($this->context->dns_zone, '', $this->context->uri), '.');
$this->entity->dns_zone_subdomain = trim(str_replace($this->entity->dns_zone, '', $this->entity->uri), '.');
}
/**
......@@ -95,7 +95,7 @@ class Provision_Service_dns extends Provision_Service {
$ret = TRUE;
foreach ($this->server->slave_servers as $server) {
// If any methods return false, return false for the whole operation.
$result = call_user_func_array(array(d($server)->service($this->service, $this->context), $method), $args);
$result = call_user_func_array(array(d($server)->service($this->service, $this->entity), $method), $args);
$ret = $ret && $result;
}
return $ret;
......@@ -212,10 +212,10 @@ class Provision_Service_dns extends Provision_Service {
* This creates a zone, which mostly consists of adding the SOA record.
*/
function create_zone($zone = NULL) {
if (is_null($zone) && ($this->context->type == 'site')) {
$host = $this->context->uri;
$zone = $this->context->dns_zone;
$sub = $this->context->dns_zone_subdomain;
if (is_null($zone) && ($this->entity->type == 'site')) {
$host = $this->entity->uri;
$zone = $this->entity->dns_zone;
$sub = $this->entity->dns_zone_subdomain;
}
if (empty($zone)) {
return drush_set_error('DRUSH_DNS_NO_ZONE', "Could not determine the zone to create");
......@@ -258,7 +258,7 @@ class Provision_Service_dns extends Provision_Service {
* Thing.
*
* @arg $host string the hostname to create. If NULL, we look in the
* current context (should be a site) for a URI.
* current entity (should be a site) for a URI.
*/
function create_host($host = NULL) {
if (!is_null($host)) {
......@@ -266,11 +266,11 @@ class Provision_Service_dns extends Provision_Service {
$sub = $this->guess_zone($host, 'subdomain');
$aliases = array();
}
elseif ($this->context->type == 'site') {
$host = $this->context->uri;
$zone = $this->context->dns_zone;
$sub = $this->context->dns_zone_subdomain;
$aliases = $this->context->aliases;
elseif ($this->entity->type == 'site') {
$host = $this->entity->uri;
$zone = $this->entity->dns_zone;
$sub = $this->entity->dns_zone_subdomain;
$aliases = $this->entity->aliases;
}
else {
return drush_set_error('DRUSH_DNS_NO_ZONE', "Could not determine the zone to create");
......@@ -301,7 +301,7 @@ class Provision_Service_dns extends Provision_Service {
* Similar to create host, this will seek and destroy that host throughout zonefiles.
*
* @arg $host string the hostname to create. If NULL, we look in the
* current context (should be a site) for a URI.
* current entity (should be a site) for a URI.
*/
function delete_host($host = NULL) {
if (!is_null($host)) {
......@@ -309,11 +309,11 @@ class Provision_Service_dns extends Provision_Service {
$sub = $this->guess_zone($host, 'subdomain');
$aliases = array();
}
elseif ($this->context->type == 'site') {
$host = $this->context->uri;
$zone = $this->context->dns_zone;
$sub = $this->context->dns_zone_subdomain;
$aliases = $this->context->aliases;
elseif ($this->entity->type == 'site') {
$host = $this->entity->uri;
$zone = $this->entity->dns_zone;
$sub = $this->entity->dns_zone_subdomain;
$aliases = $this->entity->aliases;
}
else {
return drush_set_error('DRUSH_DNS_NO_ZONE', "Could not determine the zone to create");
......
......@@ -52,10 +52,10 @@ class Provision_Service_dns_bind_slave extends Provision_Service_dns {
* @see Provision_Service_dns::create_zone()
*/
function create_zone($zone = null) {
if (is_null($zone) && ($this->context->type == 'site')) {
$host = $this->context->uri;
$zone = $this->context->dns_zone;
$sub = $this->context->dns_zone_subdomain;
if (is_null($zone) && ($this->entity->type == 'site')) {
$host = $this->entity->uri;
$zone = $this->entity->dns_zone;
$sub = $this->entity->dns_zone_subdomain;
}
if (empty($zone)) {
return drush_set_error('DRUSH_DNS_NO_ZONE', "Could not determine the zone to create");
......
......@@ -124,7 +124,7 @@ class Provision_Service_example_basic extends Provision_Service_example {
*/
function verify() {
parent::verify();
if ($this->context->type == 'server') {
if ($this->entity->type == 'server') {
// Create the configuration file directory.
provision_file()->create_dir($this->server->example_config_path, dt("Example configuration"), 0700);
// Sync the directory to the remote server if needed.
......
......@@ -24,16 +24,16 @@ function drush_example_provision_install() {
* Using the d() accessor.
*
* Every object that aegir manages (namely servers, platforms and sites),
* has an associated 'named context' that we manage for it.
* has an associated 'named entity' that we manage for it.
*
* You can run the provision commands on different objects, simply
* by specifying the context name before the drush command, such as:
* by specifying the entity name before the drush command, such as:
*
* drush @server_master provision-verify
*
* When you have called a command in this way, you can use the d()
* function without any arguments to retrieve the object representing
* the current context.
* the current entity.
*/
if (d()->type == 'site') {
// only run this code on site objects.
......@@ -41,7 +41,7 @@ function drush_example_provision_install() {
/**
* Calling service methods.
*
* All the provision context objects can register which
* All the provision entity objects can register which
* servers handle specific services for them.
*
* To call the correct methods, you just need to use the
......
......@@ -7,9 +7,9 @@ class Provision_Service_site_data extends Provision_Service {
public $service = 'site_data';
/**
* Add the needed properties to the site context.
* Add the needed properties to the site entity.
*/
static function subscribe_site($context) {
$context->setProperty('site_data');
static function subscribe_site($entity) {
$entity->setProperty('site_data');
}
}
......@@ -22,7 +22,7 @@ class Provision_Config_Apache_Subdir extends Provision_Config_Http {
drush_log("Subdirectory alias `$alias` found. Creating configuration files.", 'notice');
$uri_path = $this->data['http_subdird_path'] . '/' . $this->uri();
provision_file()->create_dir($uri_path, dt("Webserver subdir configuration for domain"), 0700);
$this->context->platform->server->sync($uri_path, array(
$this->entity->platform->server->sync($uri_path, array(
'exclude' => $uri_path . '/*', // Make sure remote directory is created
));
parent::write();
......
......@@ -96,7 +96,7 @@ class Provision_Config_Apache_SubdirVhost extends Provision_Config_Http {
// Unfortunatelly, it doesn't work with Drush 5 and current Aegir 2.x,
// and is even more dangerous, because instead of creating separate
// re-verify task for the parent site, it will run it "inline",
// immediatelly, so in the wrong context, which, depending on other
// immediatelly, so in the wrong entity, which, depending on other
// conditions will destroy *hostmaster* database, so it is mentioned
// here as a nostalgic reminiscence of good old Drush 4, which allowed
// to create frontend tasks from the backend, safely.
......
......@@ -8,6 +8,6 @@ class Provision_Config_Http_Platform extends Provision_Config_Http {
public $description = 'platform configuration file';
function filename() {
return $this->data['http_platformd_path'] . '/' . ltrim($this->context->name, '@') . '.conf';
return $this->data['http_platformd_path'] . '/' . ltrim($this->entity->name, '@') . '.conf';
}
}
......@@ -22,7 +22,7 @@ class Provision_Config_Nginx_Subdir extends Provision_Config_Http {
drush_log("Subdirectory alias `$alias` found. Creating configuration files.", 'notice');
$uri_path = $this->data['http_subdird_path'] . '/' . $this->uri();
provision_file()->create_dir($uri_path, dt("Webserver subdir configuration for domain"), 0700);
$this->context->platform->server->sync($uri_path, array(
$this->entity->platform->server->sync($uri_path, array(
'exclude' => $uri_path . '/*', // Make sure remote directory is created
));
parent::write();
......
......@@ -96,7 +96,7 @@ class Provision_Config_Nginx_SubdirVhost extends Provision_Config_Http {
// Unfortunatelly, it doesn't work with Drush 5 and current Aegir 2.x,
// and is even more dangerous, because instead of creating separate
// re-verify task for the parent site, it will run it "inline",
// immediatelly, so in the wrong context, which, depending on other
// immediatelly, so in the wrong entity, which, depending on other
// conditions will destroy *hostmaster* database, so it is mentioned
// here as a nostalgic reminiscence of good old Drush 4, which allowed
// to create frontend tasks from the backend, safely.
......
......@@ -15,17 +15,17 @@ class Provision_Service_http extends Provision_Service {
function verify_server_cmd() {
$this->create_config($this->context->type);
$this->create_config($this->entity->type);
$this->parse_configs();
}
function verify_platform_cmd() {
$this->create_config($this->context->type);
$this->create_config($this->entity->type);
$this->parse_configs();
}
function verify_site_cmd() {
$this->create_config($this->context->type);
$this->create_config($this->entity->type);
$this->parse_configs();
}
......@@ -33,10 +33,10 @@ class Provision_Service_http extends Provision_Service {
/**
* Register the http handler for platforms, based on the web_server option.
*/
static function subscribe_platform($context) {
$context->setProperty('web_server', '@server_master');
$context->is_oid('web_server');
$context->service_subscribe('http', $context->web_server->name);
static function subscribe_platform($entity) {
$entity->setProperty('web_server', '@server_master');
$entity->is_oid('web_server');
$entity->service_subscribe('http', $entity->web_server->name);
}
}
......@@ -23,7 +23,7 @@ class Provision_Service_http_cluster extends Provision_Service_http {
$ret = TRUE;
foreach ($this->server->cluster_web_servers as $server) {
// If any methods return false, return false for the whole operation.
$result = call_user_func_array(array(d($server)->service('http', $this->context), $method), $args);
$result = call_user_func_array(array(d($server)->service('http', $this->entity), $method), $args);
$ret = $ret && $result;
}
return $ret;
......@@ -70,7 +70,7 @@ class Provision_Service_http_cluster extends Provision_Service_http {
function grant_server_list() {
return array_merge(
array_map('d', $this->server->cluster_web_servers),
array($this->context->platform->server)
array($this->entity->platform->server)
);
}
}
......@@ -48,7 +48,7 @@ class Provision_Service_http_pack extends Provision_Service_http {
$ret = TRUE;
foreach ($servers as $server) {
// If any methods return false, return false for the whole operation.
$result = call_user_func_array(array(d($server)->service('http', $this->context), $method), $args);
$result = call_user_func_array(array(d($server)->service('http', $this->entity), $method), $args);
$ret = $ret && $result;
}
return $ret;
......@@ -101,7 +101,7 @@ class Provision_Service_http_pack extends Provision_Service_http {
return array_merge(
array_map('d', $this->server->master_web_servers),
array_map('d', $this->server->slave_web_servers),
array($this->context->platform->server)
array($this->entity->platform->server)
);
}
}
......@@ -24,7 +24,7 @@ class Provision_Service_http_public extends Provision_Service_http {
if ($config == 'site') {
// DO not create it with the port here. Protocol only is enough.
$data['redirect_url'] = "http://{$this->context->uri}";
$data['redirect_url'] = "http://{$this->entity->uri}";
$data = array_merge($data, drush_get_context('site'));
}
......@@ -114,7 +114,7 @@ class Provision_Service_http_public extends Provision_Service_http {
function grant_server_list() {
return array(
$this->server,
$this->context->platform->server,
$this->entity->platform->server,
);
}
}
......@@ -36,9 +36,9 @@ class Provision_Service_http_ssl extends Provision_Service_http_public {
function init_site() {
parent::init_site();
$this->context->setProperty('ssl_enabled', 0);
$this->context->setProperty('ssl_key', NULL);
$this->context->setProperty('ip_addresses', array());
$this->entity->setProperty('ssl_enabled', 0);
$this->entity->setProperty('ssl_key', NULL);
$this->entity->setProperty('ip_addresses', array());
}
......@@ -46,8 +46,8 @@ class Provision_Service_http_ssl extends Provision_Service_http_public {
$data = parent::config_data($config, $class);
$data['http_ssl_port'] = $this->server->http_ssl_port;
if ($config == 'site' && $this->context->ssl_enabled) {
foreach ($this->context->ip_addresses as $server => $ip_address) {
if ($config == 'site' && $this->entity->ssl_enabled) {
foreach ($this->entity->ip_addresses as $server => $ip_address) {
if ($server == $this->server->name || '@' . $server == $this->server->name) {
$data['ip_address'] = $ip_address;
break;
......@@ -57,12 +57,12 @@ class Provision_Service_http_ssl extends Provision_Service_http_public {
drush_log(dt('No proper IP provided by the frontend for server %servername, using wildcard', array('%servername' => $this->server->name)), 'info');
$data['ip_address'] = '*';
}
if ($this->context->ssl_enabled == 2) {
if ($this->entity->ssl_enabled == 2) {
$data['ssl_redirection'] = TRUE;
$data['redirect_url'] = "https://{$this->context->uri}";
$data['redirect_url'] = "https://{$this->entity->uri}";
}
if ($ssl_key = $this->context->ssl_key) {
if ($ssl_key = $this->entity->ssl_key) {
// Retrieve the paths to the cert and key files.
// they are generated if not found.
$certs = $this->get_certificates($ssl_key);
......@@ -141,7 +141,7 @@ class Provision_Service_http_ssl extends Provision_Service_http_public {
|| drush_set_error('SSL_KEY_GEN_FAIL', dt('failed to generate SSL key in %path', array('%path' => $path . '/openssl.key')));
// Generate the CSR to make the key certifiable by third parties
$ident = "/CN={$this->context->uri}/emailAddress=abuse@{$this->context->uri}";
$ident = "/CN={$this->entity->uri}/emailAddress=abuse@{$this->entity->uri}";
drush_shell_exec("openssl req -new -subj '%s' -key %s/openssl.key -out %s/openssl.csr -batch", $ident, $path, $path)
|| drush_log(dt('failed to generate signing request for certificate in %path', array('%path' => $path . '/openssl.csr')));
......@@ -259,7 +259,7 @@ class Provision_Service_http_ssl extends Provision_Service_http_public {
* Verify server.
*/
function verify() {
if ($this->context->type === 'server') {
if ($this->entity->type === 'server') {
provision_file()->create_dir($this->server->ssld_path, dt("Central SSL certificate repository."), 0700);
provision_file()->create_dir($this->server->http_ssld_path,
......
......@@ -176,8 +176,8 @@ function drush_provision_hostmaster_install($site = NULL) {
$aegir_db_host = drush_get_option('aegir_db_host');
$server = '@server_master';
$master_context = array(
'context_type' => 'server',
$master_entity = array(
'entity_type' => 'server',
// files
'remote_host' => $aegir_http_host,
'aegir_root' => $aegir_root,
......@@ -192,22 +192,22 @@ function drush_provision_hostmaster_install($site = NULL) {
$master_db = sprintf("mysql://%s:%s@%s:%s", urlencode($aegir_db_user), urlencode($aegir_db_pass), $aegir_db_host, $aegir_db_port);
if ($aegir_http_host == $aegir_db_host) {
$master_context['db_service_type'] = 'mysql';
$master_context['master_db'] = $master_db;
$master_entity['db_service_type'] = 'mysql';
$master_entity['master_db'] = $master_db;
$dbserver = $server;
} else {
$dbserver = '@server_' . $aegir_db_host;
$dbserver_context = array(
$dbserver_entity = array(
'remote_host' => $aegir_db_host,
'context_type' => 'server',
'entity_type' => 'server',
'db_service_type' => 'mysql',
'master_db' => $master_db,
'db_port' => $aegir_db_port,
);
drush_invoke_process('@none', "provision-save", array($dbserver), $dbserver_context);
drush_invoke_process('@none', "provision-save", array($dbserver), $dbserver_entity);
provision_backend_invoke($dbserver, 'provision-verify');
}
drush_invoke_process('@none', "provision-save", array($server), $master_context);
drush_invoke_process('@none', "provision-save", array($server), $master_entity);
provision_backend_invoke($server, 'provision-verify');
// exit if an error has occured.
......@@ -221,7 +221,7 @@ function drush_provision_hostmaster_install($site = NULL) {
$platform_name = '@platform_hostmaster';
drush_invoke_process('@none', "provision-save", array($platform_name), array(
'context_type' => 'platform',
'entity_type' => 'platform',
'server' => $server,
'web_server' => $server,
'root' => $platform,
......@@ -244,7 +244,7 @@ function drush_provision_hostmaster_install($site = NULL) {
$site_name = '@hostmaster';
drush_invoke_process('@none', "provision-save", array($site_name), array(
'context_type' => 'site',
'entity_type' => 'site',
'platform' => $platform_name,
'db_server' => $dbserver,
'uri' => $site,
......@@ -272,7 +272,7 @@ function drush_provision_hostmaster_install($site = NULL) {
drush_print("");
drush_print(dt("You should now log in to the Aegir frontend by opening the following link in your web browser:"));
drush_print("");
drush_print($data['context']['login_link']);
drush_print($data['entity']['login_link']);
drush_print("");
drush_print("");
drush_print("==============================================================================");
......
......@@ -45,7 +45,7 @@ We are making the following assumptions:
$new_platform = '@platform_' . preg_replace("/[!\W]/", "", basename(rtrim($platform, '/')));
drush_invoke_process('@none', "provision-save", array($new_platform), array(
'context_type' => 'platform',
'entity_type' => 'platform',
'server' => '@server_master',
'web_server' => '@server_master',
'root' => $platform,
......@@ -66,14 +66,14 @@ We are making the following assumptions:
* @deprecated in drush3 it's 'options', in drush 4 it's 'cli', drop
* 'options' when we drop drush3 support
*/
$context = drush_get_context('cli') ? 'cli' : 'options';
$entity = drush_get_context('cli') ? 'cli' : 'options';
drush_invoke_process('@none', "provision-save", array($server), array(
'context_type' => 'server',
'entity_type' => 'server',
'aegir_root' => dirname(rtrim($data['config_path'], '/')),
'remote_host' => php_uname('n'),
'script_user' => $data['script_user'],
// apache or nginx or..
'http_service_type' => drush_get_option('http_service_type', 'apache', $context),
'http_service_type' => drush_get_option('http_service_type', 'apache', $entity),
'web_group' => $data['web_group'],
'master_url' => $data['master_url'],
'restart_cmd' => $data['restart_cmd'],
......@@ -92,7 +92,7 @@ We are making the following assumptions:
$old_platform = '@platform_' . preg_replace("/[!\W]/", "", basename(rtrim($data['publish_path'], '/')));
drush_invoke_process('@none', "provision-save", array($old_platform), array(
'context_type' => 'platform',
'entity_type' => 'platform',
'server' => $server,
'web_server' => $server,
'root' => $data['publish_path'],
......@@ -106,7 +106,7 @@ We are making the following assumptions:
$new_platform = '@platform_' . preg_replace("/[!\W]/", "", basename(rtrim($platform, '/')));
drush_invoke_process('@none', "provision-save", array($new_platform), array(
'context_type' => 'platform',
'entity_type' => 'platform',
'server' => $server,
'web_server' => $server,
'root' => $platform,
......@@ -122,7 +122,7 @@ We are making the following assumptions:
$site_name = '@hostmaster';
drush_invoke_process('@none', "provision-save", array($site_name), array(
'context_type' => 'site',
'entity_type' => 'site',
'platform' => $old_platform,
'db_server' => $server,
'uri' => $site,
......@@ -156,7 +156,7 @@ function drush_provision_hostmaster_migrate($site, $platform) {
function drush_provision_post_hostmaster_migrate($site, $platform) {
provision_backend_invoke(drush_get_option('site_name'), 'cache-clear', array('drush'));
// we pass the context names we generated to the task so we can enforce that the names
// we pass the entity 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(), array(
'old_platform_name' => drush_get_option('old_platform'),
......
......@@ -370,7 +370,7 @@ function install_main() {
/**
* Batch callback for batch installation of modules.
*/
function _install_module_batch($module, $module_name, &$context) {
function _install_module_batch($module, $module_name, &$entity) {
drush_log(dt("Enabling module : !module", array("!module" => $module)), 'success');
_drupal_install_module($module);
// We enable the installed module right away, so that the module will be
......@@ -378,7 +378,7 @@ function _install_module_batch($module, $module_name, &$context) {
// modules possibly depending on it can safely perform their installation
// steps.
module_enable(array($module));
$context['results'][] = $module;
$context['message'] = st('Installed %module module.', array('%module' => $module_name));
$entity['results'][] = $module;
$entity['message'] = st('Installed %module module.', array('%module' => $module_name));
}
install_main();
......@@ -8,7 +8,7 @@
/**
* Import the information about the existing site, and return it in the $data context array
* Import the information about the existing site, and return it in the $data entity array
*/
function drush_provision_drupal_provision_import() {
if (d()->type === 'site') {
......
......@@ -59,7 +59,7 @@ function drush_provision_drupal_provision_install() {
// call a backend task to do the actual installation.
$result = provision_backend_invoke(d()->name, "provision-install-backend", array(), array('client_email' => drush_get_option('client_email')));
// pass the login link back to the front end.
drush_set_option('login_link', $result['context']['login_link']);
drush_set_option('login_link', $result['entity']['login_link']);
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL);
drush_set_option('installed', TRUE, 'site');
......
......@@ -762,15 +762,15 @@ function provision_prepare_environment() {
* For the changes to become available, and more importantly passed to the
* front end, we need to call this function after calling provision commands.
*/
function provision_reload_config($context, $file = NULL) {
$file = ($file) ? $file : _drush_config_file($context);
function provision_reload_config($entity, $file = NULL) {
$file = ($file) ? $file : _drush_config_file($entity);
if (file_exists($file)) {
drush_log("Reloading $context drushrc.php from $file");
drush_log("Reloading $entity drushrc.php from $file");
include($file);
// $options will be defined by the config file included above.
if (sizeof($options)) {
$options = array_merge(drush_get_context($context, array()), $options);
drush_set_context($context, $options);
$options = array_merge(drush_get_context($entity, array()), $options);
drush_set_context($entity, $options);
}
}
}
......
......@@ -110,7 +110,7 @@ function drush_provision_tests_install_platform($platform_name, $platform_alias
);
$options = array(
'root' => "/var/aegir/platforms/$platform_alias",
'context_type' => 'platform',
'entity_type' => 'platform',
);
drush_invoke_process('@none', 'provision-save', $args, $options);
provision_backend_invoke('@hostmaster', 'hosting-import', array("@platform_$platform_alias",));
......@@ -136,7 +136,7 @@ function drush_provision_tests_install_site($platform_name, $site, $profile_name
);
$options = array(
'uri' => "$site.aegir.example.com",
'context_type' => 'site',
'entity_type' => 'site',
'platform' => "@platform_$platform_name",
'profile' => $profile_name,
'db_server' => '@server_localhost',
......@@ -157,7 +157,7 @@ function drush_provision_tests_dl_module_to_site($module, $site) {
$module,
);
$options = array(
// Normally 'dl' in a site context should know to put it in the site-
// Normally 'dl' in a site entity should know to put it in the site-
// specific modules directory, but not through provision_backend_invoke()?
'destination' => "sites/$site.aegir.example.com/modules",
);
......
<?php
/**
* @file Provision named context base classes.
* @file Provision named entity base classes.
*/
/**
* Store and access context objects by alias name.
* Store and access entity objects by alias name.
*
* @param $name
* A Drush alias name, including leading @.
* @param $_root_object
* Internal use only, set default object returned by d().
* @param $allow_creation
* Defaults to TRUE. Allows creating a new context object with the specified
* Defaults to TRUE. Allows creating a new entity object with the specified
* $name.
*
* @return
......@@ -39,13 +39,13 @@ function & d($name = NULL, $_root_object = FALSE, $allow_creation = TRUE) {
$default_instance = $name;
}
$name = provision_normalise_context_name($name);
$name = provision_normalise_entity_name($name);
if (isset($instances[$name])) {
return $instances[$name];
}
else {
$instances[$name] = provision_context_factory($name, $allow_creation);
$instances[$name] = provision_entity_factory($name, $allow_creation);
if (!is_null($instances[$name])) {
$instances[$name]->method_invoke('init');
$instances[$name]->type_invoke('init');
......@@ -65,7 +65,7 @@ function & d($name = NULL, $_root_object = FALSE, $allow_creation = TRUE) {
function provision_sitealias_get_record($name) {
static $cache = array();
$name = provision_normalise_context_name($name);
$name = provision_normalise_entity_name($name);
if (!isset($cache[$name])) {
$cache[$name] = drush_sitealias_get_record($name);
......@@ -75,18 +75,18 @@ function provision_sitealias_get_record($name) {
}
/**
* Create a new context object.
* Create a new entity object.
*
* @param $name
* The name of the context object to instantiate.
* The name of the entity object to instantiate.
* @param $allow_creation
* Defaults to TRUE. Allows creating a new context object with the specified
* Defaults to TRUE. Allows creating a new entity object with the specified
* $name.
*
* @return
* An instance of the specified context, or NULL if it could not be loaded.
* An instance of the specified entity, or NULL if it could not be loaded.
*/
function provision_context_factory($name, $allow_creation = TRUE) {
function provision_entity_factory($name, $allow_creation = TRUE) {
// the default type, can also be 'platform' or 'site'
$type = 'server';
......@@ -97,11 +97,11 @@ function provision_context_factory($name, $allow_creation = TRUE) {
}
$options = array_merge(drush_get_context('stdin'), drush_get_context('options'), drush_get_context('cli'));
if (isset($record['context_type'])) {
$type = $record['context_type'];
if (isset($record['entity_type'])) {
$type = $record['entity_type'];
}
elseif (isset($options['context_type'])) {
$type = $options['context_type'];
elseif (isset($options['entity_type'])) {
$type = $options['entity_type'];
}
$classname = "Provision_Entity_{$type}";
......
......@@ -23,8 +23,8 @@
* or used for an upgrade.
* disable - Disable an installed Drupal site. Changes the virtual host config file so that it redirects to provision_disabled_site_redirect_url
* enable - Re-enable a site that has already been disabled. Recreates the virtual host file.
* delete - In a site context: generates a back up of the site, and then removes all references to it.
* In a platform context: removes the platform and its vhost config from the server if no sites are currently running on it
* delete - In a site entity: generates a back up of the site, and then removes all references to it.
* In a platform entity: removes the platform and its vhost config from the server if no sites are currently running on it