コード例 #1
0
ファイル: Task.class.php プロジェクト: skdong/nfs-ovd
 public function run()
 {
     Logger::debug('main', 'ServerStatusChangedTask::run');
     $needs_cleanup = false;
     $data = get_from_cache('events', 'ServerStatusChanged');
     if ($data == NULL) {
         $data[$this->ev->fqdn] = $this->ev->status;
         if ($this->ev->status != ServerStatusChanged::$ONLINE) {
             $needs_cleanup = true;
         }
     } else {
         if ($this->ev->status != ServerStatusChanged::$ONLINE) {
             $needs_cleanup = true;
         }
     }
     if ($needs_cleanup) {
         Logger::debug('main', 'ServerStatusChangedTask::run cleanup task for ' . $this->ev->fqdn);
         set_cache($data, 'events', 'ServerStatusChanged');
         $tm = new Tasks_Manager();
         $tm->load_from_server($this->ev->fqdn);
         foreach ($tm->tasks as $a_task) {
             $tm->remove($a_task->id);
         }
     }
     return true;
 }
コード例 #2
0
ファイル: actions.php プロジェクト: skdong/nfs-ovd
                $task = false;
                foreach ($tm->tasks as $t) {
                    if ($t->id == $id) {
                        $task = $t;
                        break;
                    }
                }
                if ($task === false) {
                    popup_error('Unable to find task id ' . $id);
                    redirect('tasks.php');
                }
                if (!($task->succeed() || $task->failed())) {
                    popup_error('Task ' . $id . ' not removable');
                    redirect('tasks.php');
                }
                $tm->remove($id);
                popup_info(_('Task successfully deleted'));
                redirect('tasks.php');
            }
        }
        redirect('tasks.php');
    }
}
function action_add_sharedfolder()
{
    $sharedfolderdb = SharedFolderDB::getInstance();
    $sharedfolder_name = $_REQUEST['sharedfolder_name'];
    if ($sharedfolder_name == '') {
        popup_error(_('You must provide a name to your shared folder'));
        return false;
    }
コード例 #3
0
ファイル: api.php プロジェクト: bloveing/openulteo
 public function task_remove($task_id_)
 {
     $tm = new Tasks_Manager();
     $tm->load_all();
     $tm->refresh_all();
     $task = false;
     foreach ($tm->tasks as $t) {
         if ($task_id_ = $t->id) {
             $task = $t;
             break;
         }
     }
     if ($task === false) {
         Logger::error('api', sprintf('Unknown task "%s"', $task_id_));
         return false;
     }
     if (!($task->succeed() || $task->failed())) {
         Logger::error('api', sprintf('Task "%s" not removable', $task_id_));
         return false;
     }
     $tm->remove($task_id_);
     $this->log_action('task_remove', array('id' => $task_id_));
     return true;
 }
コード例 #4
0
 public static function removeRole($fqdn_, $role_)
 {
     Logger::debug('main', "Starting Abstract_Server::removeRole for '{$fqdn_}' removing '{$role_}'");
     if (substr($fqdn_, -1) == '.') {
         $fqdn_ = substr($fqdn_, 0, strlen($fqdn_) - 1);
     }
     $a_server = Abstract_Server::load($fqdn_);
     if (is_object($a_server) == false) {
         Logger::error('main', "Starting Abstract_Server::removeRole error failed to load server '{$fqdn_}'");
         return false;
     }
     $roles = $a_server->getAttribute('roles');
     if (is_array($roles) == false) {
         return false;
     }
     if (in_array($role_, $roles) == false) {
         return false;
     }
     switch ($role_) {
         case Server::SERVER_ROLE_APS:
             $prefs = Preferences::getInstance();
             if (!$prefs) {
                 die_error('get Preferences failed', __FILE__, __LINE__);
             }
             $slave_server_settings = $prefs->get('general', 'slave_server_settings');
             $remove_orphan = (bool) $slave_server_settings['remove_orphan'];
             Abstract_Liaison::delete('ApplicationServer', NULL, $fqdn_);
             if ($remove_orphan) {
                 $apps = $a_server->getApplications();
                 $applicationDB = ApplicationDB::getInstance();
                 // remove the orphan applications
                 if (is_array($apps)) {
                     foreach ($apps as $an_application) {
                         if ($an_application->isOrphan()) {
                             Logger::debug('main', "Abstract_Server::delete {$an_application} is orphan");
                             $applicationDB->remove($an_application);
                         }
                     }
                 }
             }
             $tm = new Tasks_Manager();
             $tm->load_from_server($fqdn_);
             foreach ($tm->tasks as $a_task) {
                 $tm->remove($a_task->id);
             }
             break;
         case Server::SERVER_ROLE_FS:
             if (Preferences::moduleIsEnabled('ProfileDB')) {
                 $profiledb = ProfileDB::getInstance();
                 $folders = $profiledb->importFromServer($fqdn_);
                 foreach ($folders as $a_folder) {
                     $profiledb->remove($a_folder->id);
                 }
             }
             if (Preferences::moduleIsEnabled('SharedFolderDB')) {
                 $sharedfolderdb = SharedFolderDB::getInstance();
                 $folders = $sharedfolderdb->importFromServer($fqdn_);
                 foreach ($folders as $a_folder) {
                     $profiledb->remove($a_folder->id);
                 }
             }
             break;
             // 			case Server::SERVER_ROLE_GATEWAY:
             // 			break;
     }
     return true;
 }