function do_refresh_task($task_id_)
{
    $task = Abstract_Task::load($task_id_);
    if (!is_object($task)) {
        Logger::error('main', '(ajax/installable_applications) Task ' . $task_id_ . ' not found');
        header('Content-Type: text/xml; charset=utf-8');
        $dom = new DomDocument('1.0', 'utf-8');
        $node = $dom->createElement('usage');
        $node->setAttribute('status', 'task not found');
        $dom->appendChild($node);
        die($dom->saveXML());
    }
    $task->refresh();
    if (!$task->succeed()) {
        header('Content-Type: text/xml; charset=utf-8');
        $dom = new DomDocument('1.0', 'utf-8');
        $node = $dom->createElement('task');
        $node->setAttribute('status', $task->status);
        $dom->appendChild($node);
        die($dom->saveXML());
    }
    $ret = $task->get_AllInfos();
    header('Content-Type: text/xml; charset=utf-8');
    die($ret['stdout']);
}
示例#2
0
 private static function create($task_)
 {
     Logger::debug('main', 'Starting Abstract_Task::create for \'' . $task_->id . '\'');
     if (Abstract_Task::exists($task_->id)) {
         Logger::error('main', 'Abstract_Task::create(\'' . $task_->id . '\') task already exists');
         return false;
     }
     $SQL = SQL::getInstance();
     $SQL->DoQuery('INSERT INTO @1 (@2) VALUES (%3)', $SQL->prefix . 'tasks', 'id', $task_->id);
     return true;
 }
示例#3
0
/**
 * Copyright (C) 2008-2013 Ulteo SAS
 * http://www.ulteo.com
 * Author Julien LANGLOIS <*****@*****.**> 2008-2013
 * Author Laurent CLOUET <*****@*****.**> 2008-2011
 * Author Jeremy DESVAGES <*****@*****.**> 2008-2011
 * Author Vincent ROULLIER <*****@*****.**> 2013
 * Author David LECHEVALIER <*****@*****.**> 2012
 * Author David PHAM-VAN <*****@*****.**> 2013
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; version 2
 * of the License.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 **/
function init_db($prefs_)
{
    // prefs must be valid
    Logger::debug('main', 'init_db');
    $modules_enable = $prefs_->get('general', 'module_enable');
    foreach ($modules_enable as $module_name) {
        if (!is_null($prefs_->get($module_name, 'enable'))) {
            $enable = $prefs_->get($module_name, 'enable');
            if (is_string($enable)) {
                $mod_name = $module_name . '_' . $enable;
                $ret_eval = call_user_func(array($mod_name, 'init'), $prefs_);
                if ($ret_eval !== true) {
                    Logger::error('main', 'init_db init module \'' . $mod_name . '\' failed');
                    return false;
                }
            } elseif (is_array($enable)) {
                foreach ($enable as $sub_module) {
                    $mod_name = $module_name . '_' . $sub_module;
                    $ret_eval = call_user_func(array($mod_name, 'init'), $prefs_);
                    if ($ret_eval !== true) {
                        Logger::error('main', 'init_db init module \'' . $mod_name . '\' failed');
                        return false;
                    }
                }
            }
        }
    }
    Logger::debug('main', 'init_db modules inited');
    // Init of Abstract
    Abstract_Server::init($prefs_);
    Abstract_ServersGroup::init($prefs_);
    Abstract_Session::init($prefs_);
    Abstract_Token::init($prefs_);
    Abstract_News::init($prefs_);
    Abstract_Script::init($prefs_);
    Abstract_Liaison::init($prefs_);
    if (class_exists("PremiumManager")) {
        PremiumManager::initdb($prefs_);
    }
    Abstract_Task::init($prefs_);
    Abstract_ReportServer::init($prefs_);
    Abstract_ReportSession::init($prefs_);
    Abstract_User_Preferences::init($prefs_);
    Abstract_UserGroup_Preferences::init($prefs_);
    Abstract_UserGroup_Rule::init($prefs_);
    Abstract_VDI::init($prefs_);
    Abstract_Network_Folder::init($prefs_);
    Abstract_AdminAction::init($prefs_);
    return true;
}
 public function refresh_all()
 {
     foreach ($this->tasks as $task) {
         /*if ($task->succeed())
         			continue;
         		if ($task->failed())
         			continue;*/
         $task->refresh();
         Abstract_Task::save($task);
     }
 }
示例#5
0
 public function isNotReady()
 {
     if ($this->getAttribute('status') == 'ready') {
         Logger::debug('main', 'Server::isNotReady server "' . $this->fqdn . ':' . $this->web_port . '" is "ready"');
         return false;
     }
     $sessions = Abstract_Session::getByServer($this->fqdn);
     foreach ($sessions as $session) {
         Abstract_Session::delete($session->id);
     }
     $tasks = Abstract_Task::load_by_server($this->fqdn);
     foreach ($tasks as $task) {
         Abstract_Task::delete($task->id);
     }
     $prefs = Preferences::getInstance();
     if (!$prefs) {
         Logger::critical('main', 'get Preferences failed in ' . __FILE__ . ' line ' . __LINE__);
         return false;
     }
     $buf = $prefs->get('general', 'slave_server_settings');
     if ($buf['action_when_as_not_ready'] == 1) {
         if ($this->getAttribute('locked') === false) {
             $this->setAttribute('locked', true);
         }
     }
     Abstract_Server::modify($this);
     return true;
 }