Commit 0eaafc86 authored by Adrian Rossouw's avatar Adrian Rossouw

Replaced the file service with the provision_file() factory, that returns

the singular filesystem object now.

Sync is now a method of the server class, with a helpful method associated
to the services that redirect to the service's server.
parent e4696795
......@@ -5,7 +5,7 @@ function drush_db_pre_provision_backup() {
}
function drush_db_pre_provision_backup_rollback() {
d()->service('file')->unlink(d()->site_path . '/database.sql')
provision_file()->unlink(d()->site_path . '/database.sql')
->succeed('Deleted mysql dump from sites directory')
->fail('Could not delete mysql dump from sites directory');
}
......
......@@ -171,12 +171,12 @@ class provisionService_db extends provisionService {
$creds = $this->fetch_site_credentials();
$exists = d()->service('file')->exists($dump_file)
$exists = provision_file()->exists($dump_file)
->succeed('Found database dump at @path.')
->fail('No database dump was found at @path.', 'PROVISION_DB_DUMP_NOT_FOUND')
->status();
if ($exists) {
$readable = d()->service('file')->readable($dump_file)
$readable = provision_file()->readable($dump_file)
->succeed('Database dump at @path is readable')
->fail('The database dump at @path could not be read.', 'PROVISION_DB_DUMP_NOT_READABLE')
->status();
......
......@@ -16,7 +16,7 @@ function drush_db_provision_deploy_rollback() {
// Rollback doesn't apply here yet. Unless we trigger a deploy of the first dump
// made. Which could go on infinitely if something is really long.
function drush_db_post_provision_deploy() {
d()->service('file')->unlink(d()->site_path . '/database.sql')
provision_file()->unlink(d()->site_path . '/database.sql')
->succeed('Removed dump file @path after restoring from it')
->fail('Could not remove dump file @path', 'DRUSH_PERM_ERROR');
}
......@@ -32,7 +32,7 @@ function drush_db_pre_provision_restore_rollback() {
// Rollback doesn't apply here yet. Unless we trigger a restore of the first dump
// made. Which could go on infinitely if something is really long.
function drush_db_post_provision_restore() {
d()->service('file')->unlink(d()->site_path . '/database.sql')
provision_file()->unlink(d()->site_path . '/database.sql')
->succeed('Removed dump file @path after restoring from it')
->fail('Could not remove dump file @path', 'DRUSH_PERM_ERROR');
......
<?php
class provisionService_file_cluster extends provisionService_file {
function sync($path = NULL, $exclude_sites = FALSE) {
foreach ($this->cluster_web_servers as $server) {
d($server)->service('file')->sync($path, $exclude_sites);
}
}
}
<?php
class provisionService_file_local extends provisionService_file {
}
<?php
require_once DRUSH_BASE_PATH . '/commands/core/rsync.core.inc';
class provisionService_file_remote extends provisionService_file {
protected $operations = array();
function chmod($path, $perms) {
parent::chmod($path, $perms);
$this->operations[] = array(__FUNCTION__, func_get_args());
return $this;
}
function chgrp($path, $gid, $recursive = FALSE) {
parent::chgrp($path, $gid, $recursive);
$this->operations[] = array(__FUNCTION__, func_get_args());
return $this;
}
function chown($path, $owner, $recursive = FALSE) {
parent::chown($path, $owner, $recursive);
$this->operations[] = array(__FUNCTION__, func_get_args());
return $this;
}
function sync($path = NULL, $exclude_sites = FALSE) {
if (is_null($path)) {
$path = $this->config_path;
}
if ($this->exists($path)->status()) {
$options = array(
'relative' => TRUE,
'omit-dir-times' => TRUE,
'delete' => TRUE,
);
if ($exclude_sites) {
$options['exclude-sites'] = TRUE;
}
if (drush_core_call_rsync(escapeshellarg($path), escapeshellarg($this->script_user . '@' . $this->remote_host . ':/'), $options, TRUE, FALSE)) {
drush_log(dt('@path has been synced to remote server @remote_host.', array('@path' => $path, '@remote_host' => $this->remote_host)));
}
else {
drush_set_error('PROVISION_FILE_SYNC_FAILED', dt('Files could not be synced to remote server @remote_host. Changes might not be available until this has been done. (error: %msg)', array('@path' => $path, '@remote_host' => $this->remote_host, '%msg' => join("\n", drush_shell_exec_output()))));
}
}
else { // File does not exist, remove it.
if ($this->server()->shell_exec('rm -rf ' . escapeshellarg($path))) {
drush_log(dt('@path has been removed from remote server @remote_host.', array('@path' => $path, '@remote_host' => $this->remote_host)));
}
else {
drush_set_error('PROVISION_FILE_SYNC_FAILED', dt('Files could not be removed from remote server @remote_host. Changes might not be available until this has been done. (error: %msg)', array('@path' => $path, '@remote_host' => $this->remote_host, '%msg' => join("\n", drush_shell_exec_output()))));
}
}
}
}
......@@ -10,9 +10,9 @@ class provisionService_http_apache extends provisionService_http {
function init() {
parent::init();
$this->apache_site_conf_path = d()->config_path . '/vhost.d';
$this->apache_platform_conf_path = d()->web_server->config_path . '/platform.d';
$this->apache_conf_path = d()->config_path . '/apache.d';
$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';
// Commands
$this->setProperty('restart_cmd', _provision_default_restart_cmd());
......@@ -46,10 +46,10 @@ class provisionService_http_apache extends provisionService_http {
}
function create_server_config() {
d()->service('file')->create_dir($this->apache_site_conf_path, dt("Virtual host configuration"), 0700);
d()->service('file')->create_dir($this->apache_platform_conf_path, dt("Platforms configuration"), 0700);
d()->service('file')->create_dir($this->apache_conf_path , dt("Apache configuration"), 0700);
d()->service('file')->sync($this->apache_conf_path);
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);
$config = new provisionConfig_apache_server($this->context);
return $config->write();
......@@ -85,7 +85,7 @@ class provisionConfig_apache_server extends provisionConfig_apache {
public $description = 'apache server configuration file';
function filename() {
return d()->config_path . '/apache.conf';
return $this->config_path . '/apache.conf';
}
function process() {
......
......@@ -26,7 +26,7 @@ function drush_provision_drupal_provision_backup_validate($backup_file = NULL) {
}
if ($backup_file) {
if (d()->service('file')->exists($backup_file)->status()) {
if (provision_file()->exists($backup_file)->status()) {
drush_set_error('PROVISION_BACKUP_ALREADY_EXISTS', dt('Back up file @path already exists.', array('@path' => $backup_file)));
}
else {
......@@ -78,7 +78,7 @@ function drush_provision_drupal_provision_backup() {
function drush_provision_drupal_provision_backup_rollback() {
$backup_file = drush_get_option('backup_file');
if (file_exists($backup_file)) {
d()->service('file')->unlink($backup_file)
provision_file()->unlink($backup_file)
->succeed('Removed stale backup file @path')
->fail('Failed deleting backup file @path');
}
......
......@@ -27,7 +27,7 @@ function drush_provision_drupal_pre_provision_clone($new_url, $platform = null)
* Remove the extracted site directory
*/
function drush_provision_drupal_pre_provision_clone_rollback($new_url, $platform = null) {
$success = d()->service('file')->unlink(drush_get_option('backup_file'))
$success = provision_file()->unlink(drush_get_option('backup_file'))
->succeed('Removed unused clone site package')
->fail('Could not remove unused clone site package');
}
......
......@@ -19,7 +19,7 @@
* Make sure we have a valid site being deployd, and that the file being deployd from exists
*/
function drush_provision_drupal_provision_deploy_validate($backup_file = null) {
$exists = d()->service('file')->exists($backup_file)
$exists = provision_file()->exists($backup_file)
->succeed('Deploying site from @path')
->fail('Could not find backup file @path', 'PROVISION_BACKUP_NOT_FOUND')
->status();
......@@ -33,7 +33,7 @@ function drush_provision_drupal_provision_deploy_validate($backup_file = null) {
*/
function drush_provision_drupal_pre_provision_deploy($backup_file) {
// the url is likely to have changed in the deployment
$extracted = d()->service('file')->extract($backup_file, d()->site_path)
$extracted = provision_file()->extract($backup_file, d()->site_path)
->succeed('Successfully extracted the contents of @path')
->fail('Failed to extract the contents of @path to @target', 'PROVISION_BACKUP_EXTRACTION_FAILED')
->status();
......
......@@ -49,7 +49,7 @@ function drush_provision_drupal_pre_provision_migrate_rollback($platform) {
drush_log(dt("Bringing site out of maintenance"));
drush_set_option('site_offline', 0);
_provision_drupal_create_settings_file();
$success = d()->service('file')->unlink(drush_get_option('backup_file'))
$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();
......
......@@ -121,9 +121,9 @@ function _provision_drupal_site_exists() {
* finishing operations that affect the filesystem.
*/
function provision_drupal_sync_site() {
d()->service('file')->sync(d()->root, TRUE);
d()->service('http')->sync(d()->root, TRUE);
if (d()->type === 'site') {
d()->service('file')->sync(d()->site_path);
d()->service('http')->sync(d()->site_path);
}
}
......@@ -202,22 +202,22 @@ function _provision_drupal_create_directories($url = NULL, $profile = NULL) {
foreach ($mkdir as $path => $perm) {
if (!is_dir($path)) {
d()->service('file')->mkdir($path)
provision_file()->mkdir($path)
->succeed('Created <code>@path</code>')
->fail('Could not create <code>@path</code>', 'DRUSH_PERM_ERROR');
}
d()->service('file')->chmod($path, $perm, TRUE)
provision_file()->chmod($path, $perm, TRUE)
->succeed('Changed permissions of <code>@path</code> to @perm')
->fail('Could not change permissions <code>@path</code> to @perm');
}
foreach ($chown as $path => $owner) {
d()->service('file')->chown($path, $owner, TRUE)
provision_file()->chown($path, $owner, TRUE)
->succeed('Changed ownership of <code>@path</code> to @uid')
->fail('Could not change ownership <code>@path</code>', 'DRUSH_PERM_ERROR');
}
foreach ($chgrp as $path => $group) {
d()->service('file')->chgrp($path, $group, TRUE)
provision_file()->chgrp($path, $group, TRUE)
->succeed('Changed group ownership of <code>@path</code> to @gid')
->fail('Could not change group ownership <code>@path</code> to @gid');
}
......@@ -339,7 +339,7 @@ function _provision_drupal_maintain_aliases() {
}
foreach($aliases as $alias) {
if (trim($alias)) {
d()->service('file')->symlink(d()->uri, d()->root . '/sites/' . $alias)
provision_file()->symlink(d()->uri, d()->root . '/sites/' . $alias)
->succeed('Created symlink for alias @target')
->fail('Could not create symlink for alias @target');
}
......@@ -363,7 +363,7 @@ function _provision_drupal_delete_aliases($aliases, $silent = false) {
}
foreach ($aliases as $alias) {
if ($alias = trim($alias)) {
d()->service('file')->unlink(d()->root . '/sites/' . $alias)
provision_file()->unlink(d()->root . '/sites/' . $alias)
->succeed('Removed symlink for alias @path')
->fail($error);
}
......
......@@ -28,7 +28,7 @@ function drush_provision_drupal_pre_provision_rename($url, $new_url, $platform =
* Remove the extracted site directory
*/
function drush_provision_drupal_pre_provision_rename_rollback($url, $new_url, $platform = null) {
d()->service('file')->unlink(drush_get_option('backup_file'))
provision_file()->unlink(drush_get_option('backup_file'))
->succeed('Removed unused rename site package')
->fail('Could not remove unused site package');
}
......
......@@ -26,7 +26,7 @@
function drush_provision_drupal_provision_restore_validate($restore_file = null) {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
$exists = d()->service('file')->exists($restore_file)
$exists = provision_file()->exists($restore_file)
->succeed('Restoring site from @path')
->fail('Could not find backup file @path', 'PROVISION_BACKUP_NOT_FOUND')
->status();
......@@ -41,7 +41,7 @@ function drush_provision_drupal_provision_restore_validate($restore_file = null)
function drush_provision_drupal_pre_provision_restore($restore_file) {
drush_invoke('provision-backup');
d()->service('file')->extract(drush_get_option('restore_file'), d()->site_path . '.restore')
provision_file()->extract(drush_get_option('restore_file'), d()->site_path . '.restore')
->succeed('Successfully extracted the contents of @path')
->fail('Failed to extract the contents of @path', 'PROVISION_BACKUP_EXTRACTION_FAILED');
}
......@@ -59,7 +59,7 @@ function drush_provision_drupal_pre_provision_restore_rollback() {
function drush_provision_drupal_provision_restore() {
$old = d()->site_path . '.restore';
$new = d()->site_path;
d()->service('file')->switch_paths($old, $new)
provision_file()->switch_paths($old, $new)
->succeed('Swapping out the @path1 and @path2 directories was successful.')
->fail('Swapping the @path1 and @path2 directories has failed.', 'DRUSH_PERM_ERROR');
// make sure it has the latest site data available
......
......@@ -23,22 +23,22 @@ function drush_provision_drupal_provision_verify_validate() {
*/
function drush_provision_drupal_provision_verify() {
if (d()->type === 'server') {
d()->service('file')->create_dir(d()->config_path, dt('Provision configuration'), 0711);
d()->service('file')->create_dir(d()->config_path . '/includes', dt('Provision PHP configuration'), 0711);
if (!d()->service('file')->exists(d()->config_path . '/includes/global.inc')->succeed('Global configuration file exists')->status()) {
provision_file()->create_dir(d()->config_path, dt('Provision configuration'), 0711);
provision_file()->create_dir(d()->config_path . '/includes', dt('Provision PHP configuration'), 0711);
if (!provision_file()->exists(d()->config_path . '/includes/global.inc')->succeed('Global configuration file exists')->status()) {
// Create an empty global.inc so the include doesn't fail with
// open_basedir restrictions
$config = new provisionConfig_global_settings(d()->name);
$config->write();
}
d()->service('file')->sync(d()->config_path . '/includes');
d()->service('http')->sync(d()->config_path . '/includes');
if (d()->name == '@server_localhost') {
d()->service('file')->create_dir(d()->backup_path, dt('Backup'), 0700);
provision_file()->create_dir(d()->backup_path, dt('Backup'), 0700);
}
}
elseif (d()->type === 'platform') {
d()->service('file')->writable(d()->root . '/sites')
provision_file()->writable(d()->root . '/sites')
->succeed('Drupal sites directory @path is writable by the provisioning script')
->fail('Drupal sites directory @path is not writable by the provisioning script', 'PROVISION_SITES_DIR_NOT_WRITABLE');
......
......@@ -85,8 +85,8 @@ class provisionConfig {
function write() {
$filename = $this->filename();
// Make directory structure if it does not exist.
if (!d()->service('file')->exists(dirname($filename))->status()) {
d()->service('file')->mkdir(dirname($filename))
if (!provision_file()->exists(dirname($filename))->status()) {
provision_file()->mkdir(dirname($filename))
->succeed('Created directory @path.')
->fail('Could not create directory @path.');
}
......@@ -97,34 +97,34 @@ class provisionConfig {
if ($template = $this->load_template()) {
// Make sure we can write to the file
if (!is_null($this->mode) && !($this->mode & 0200) && d()->service('file')->exists($filename)->status()) {
d()->service('file')->chmod($filename, $this->mode | 0200)
if (!is_null($this->mode) && !($this->mode & 0200) && provision_file()->exists($filename)->status()) {
provision_file()->chmod($filename, $this->mode | 0200)
->succeed('Changed permissions of @path to @perm')
->fail('Could not change permissions of @path to @perm');
}
d()->service('file')->file_put_contents($filename, $this->render_template($template, $this->data), $this->append ? FILE_APPEND : 0)
provision_file()->file_put_contents($filename, $this->render_template($template, $this->data), $this->append ? FILE_APPEND : 0)
->succeed('Generated config ' . (empty($this->description) ? $filename : $this->description), 'success');
// Change the permissions of the file if needed
if (!is_null($this->mode)) {
d()->service('file')->chmod($filename, $this->mode)
provision_file()->chmod($filename, $this->mode)
->succeed('Changed permissions of @path to @perm')
->fail('Could not change permissions of @path to @perm');
}
if (!is_null($this->group)) {
d()->service('file')->chgrp($filename, $this->group)
provision_file()->chgrp($filename, $this->group)
->succeed('Change group ownership of @path to @gid')
->fail('Could not change group ownership of @path to @gid');
}
d()->service('file')->sync($this->filename());
#provision_file()->sync($this->filename());
}
}
}
function unlink() {
d()->service('file')->unlink($this->filename())->status();
d()->service('file')->sync($this->filename());
provision_file()->unlink($this->filename())->status();
#provision_file()->sync($this->filename());
}
}
......
......@@ -275,8 +275,8 @@ class provisionServer extends provisionEnvironment {
$this->setProperty('remote_host', 'localhost');
$this->setProperty('script_user', get_current_user());
$this->setProperty('aegir_root', '/var/aegir');
$this->setProperty('backup_path', $this->aegir_root . '/backups');
$this->setProperty('config_path', $this->aegir_root . '/config');
$this->backup_path = $this->aegir_root . '/backups';
$this->config_path = $this->aegir_root . '/config/' . ltrim($this->name, '@');
$this->setProperty('master_url');
$this->load_services();
}
......@@ -369,6 +369,48 @@ class provisionServer extends provisionEnvironment {
return drush_shell_exec('ssh ' . drush_get_option('ssh-options', '-o PasswordAuthentication=no') . ' %s %s', $this->script_user . '@' . $this->remote_host, escapeshellcmd($command));
}
}
/**
* If necessary, sync files out to a remote server.
*
* @param $path
* Full path to sync.
* @param $exclude_sites
* Exclude sites/*, except sites/*.
*/
function sync($path = NULL, $exclude_sites = FALSE) {
if (!drush_is_local_host($this->remote_host)) {
if (is_null($path)) {
$path = $this->config_path;
}
if (provision_path()->exists($path)->status()) {
$options = array(
'relative' => TRUE,
'omit-dir-times' => TRUE,
'delete' => TRUE,
);
if ($exclude_sites) {
$options['exclude-sites'] = TRUE;
}
if (drush_core_call_rsync(escapeshellarg($path), escapeshellarg($this->script_user . '@' . $this->remote_host . ':/'), $options, TRUE, FALSE)) {
drush_log(dt('@path has been synced to remote server @remote_host.', array('@path' => $path, '@remote_host' => $this->remote_host)));
}
else {
drush_set_error('PROVISION_FILE_SYNC_FAILED', dt('Files could not be synced to remote server @remote_host. Changes might not be available until this has been done. (error: %msg)', array('@path' => $path, '@remote_host' => $this->remote_host, '%msg' => join("\n", drush_shell_exec_output()))));
}
}
else { // File does not exist, remove it.
if ($this->server()->shell_exec('rm -rf ' . escapeshellarg($path))) {
drush_log(dt('@path has been removed from remote server @remote_host.', array('@path' => $path, '@remote_host' => $this->remote_host)));
}
else {
drush_set_error('PROVISION_FILE_SYNC_FAILED', dt('Files could not be removed from remote server @remote_host. Changes might not be available until this has been done. (error: %msg)', array('@path' => $path, '@remote_host' => $this->remote_host, '%msg' => join("\n", drush_shell_exec_output()))));
}
}
}
}
}
/**
......
<?php
// $Id$
/**
* @file Filesystem access module.
*
......@@ -8,14 +7,19 @@
* helper method, which will take care of verification and any error logging
* required.
*/
include_once('provision.inc');
include_once(dirname(__FILE__) . '/../provision.service.inc');
function provision_file() {
static $instance = null;
function file_provision_services() {
return array('file' => 'local');
if (is_null($instance)) {
$instance = new provisionFileSystem();
}
return $instance;
}
class provisionService_file extends provisionService {
class provisionFileSystem extends provisionChainedState {
/**
* Determine if $path can be written to.
*
......@@ -199,13 +203,13 @@ class provisionService_file extends provisionService {
$func = ($recursive) ? array($this, '_chgrp_recursive') : 'chgrp';
if ($group = provision_posix_groupname($gid)) {
if (provision_user_in_group($this->script_user, $gid)) {
if (provision_user_in_group(get_current_user(), $gid)) {
if (!call_user_func($func, $path, $group)) {
$this->tokens['@reason'] = dt("chgrp to @group failed on @path", array('@group' => $group, '@path' => $path));
}
}
else {
$this->tokens['@reason'] = dt("@user is not in @group group", array("@user" => $this->script_user, "@group" => $group));
$this->tokens['@reason'] = dt("@user is not in @group group", array("@user" => get_current_user(), "@group" => $group));
}
}
elseif (!@call_user_func($func, $path, $gid)) { # try to change the group anyways
......@@ -362,7 +366,7 @@ class provisionService_file extends provisionService {
}
if ($exists) {
$this->chown($path, $this->script_user)
$this->chown($path, get_current_user())
->succeed($name . ' ownership of @path has been changed to @uid.')
->fail($name . ' ownership of @path could not be changed to @uid.', 'DRUSH_PERM_ERROR');
......@@ -452,17 +456,5 @@ class provisionService_file extends provisionService {
return $this->_call_recursive('chgrp', $path, $group);
}
/**
* If necessary, sync files out to a remote server.
*
* @param $path
* Full path to sync.
* @param $exclude_sites
* Exclude sites/*, except sites/*.
*/
function sync($path = NULL, $exclude_sites = FALSE) {
if (is_null($path)) {
$path = $this->config_path;
}
}
}
<?php
// $Id$
include_once('provision.environment.inc');
include_once('provision.service.inc');
/**
* @file
......@@ -87,7 +85,7 @@ function _provision_recursive_delete($path) {
}
}
$rm = d()->service('file')->rmdir($path)
$rm = provision_file()->rmdir($path)
->succeed('Deleting @path directory successful.')
->fail('Deleting @path directory failed.')
->status();
......@@ -95,7 +93,7 @@ function _provision_recursive_delete($path) {
$ret = $ret && $rm;
}
else {
$rm = d()->service('file')->unlink($path)
$rm = provision_file()->unlink($path)
->fail('Deleting @path file failed.')
->status();
$ret = $ret && $rm;
......@@ -246,3 +244,84 @@ function _scrub_object($input) {
function provision_backend_invoke($target, $command, $arguments = array(), $options = array(), $mode = 'GET') {
return drush_backend_invoke_args('@' . ltrim($target, '@') . ' ' . $command, $arguments, $options + array('root' => null, 'uri' => null), $mode);
}
/**
* A base class for the service and file handling classes that implements chaining of methods.
*/
class provisionChainedState {
protected $last_status;
protected $tokens;
/**
* Clear internal state
*/
protected function _clear_state() {
$this->last_status = NULL;
$this->tokens = NULL;
}
/**
* Return the status of the last operation.
*
* @return
* TRUE or FALSE for success or failure; NULL if there was not a previous
* operation.
*/
function status() {
return $this->last_status;
}
/**
* Log a notice into the logging system, if the last operation completed
* succesfully.
*
* @param $message
* The message to log, a string.
*/
function succeed($message) {
if ($this->last_status === TRUE) {
drush_log(dt($message, $this->tokens), 'message');
}
return $this;
}
/**
* Log a notice into the logging system, if the last operation did not
* complete succesfully.
*
* @param $message
* Log this as a error to the logging system, if the $error_codes parameter
* has been set, otherwise, log this as a warning. If the operation
* specifies an additional reason for the operation failing, it will be
* appended to this message.
*
* @param error_codes
* Generate these system level errors using the provision error bitmasks.
*/
function fail($message, $error_codes = NULL) {
if (!empty($this->tokens['@reason'])) {
$message .= ' (@reason)';
}
if ($this->last_status === FALSE) {
if (is_null($error_codes)) {
// Trigger a warning
drush_log(dt($message, $this->tokens), 'warning');
}
else {
// Trigger a sysem halting error
drush_set_error($error_codes, dt($message, $this->tokens));
}
}
return $this;
}
}
include_once('provision.environment.inc');
include_once('provision.service.inc');
include_once('provision.file.inc');
include_once('provision.config.inc');
<?php
include_once('provision.config.inc');
require_once('provision.inc');
class provisionService {
protected $server = '@self';
require_once DRUSH_BASE_PATH . '/commands/core/rsync.core.inc';
class provisionService extends provisionChainedState {
protected $server = '@server_localhost';
public $context;
protected $last_status;
protected $tokens;
function __get($name) {
return d($this->server)->$name;
......@@ -29,6 +31,10 @@ class provisionService {
$this->server = $server;
}
function sync($path = NULL, $exclude_sites = FALSE) {
return d($this->server)->sync($path, $exclude_sites);
}
function verify() {
return TRUE;
}
......@@ -51,71 +57,6 @@ class provisionService {
return d($this->server);
}
/**
* Clear internal state
*/
protected function _clear_state() {
$this->last_status = NULL;
$this->tokens = NULL;
}
/**
* Return the status of the last operation.
*
* @return
* TRUE or FALSE for success or failure; NULL if there was not a previous
* operation.
*/
function status() {
return $this->last_status;
}
/**
* Log a notice into the logging system, if the last operation completed
* succesfully.
*
* @param $message
* The message to log, a string.
*/
function succeed($message) {
if ($this->last_status === TRUE) {
drush_log(dt($message, $this->tokens), 'message');
}
return $this;
}
/**
* Log a notice into the logging system, if the last operation did not
* complete succesfully.
*
* @param $message
* Log this as a error to the logging system, if the $error_codes parameter
* has been set, otherwise, log this as a warning. If the operation
* specifies an additional reason for the operation failing, it will be
* appended to this message.
*
* @param error_codes
* Generate these system level errors using the provision error bitmasks.