コード例 #1
0
 /**
  * Move configuration files 
  * 
  */
 public function moveConfig()
 {
     try {
         /* Get Path */
         $event = $this->di->get('events');
         $eventObj = new CopyFiles($this->pollerId);
         $event->emit('centreon-configuration.copy.files', array($eventObj));
         $this->output = array_merge($this->output, $eventObj->getOutput());
         /* Event for external commands */
         $eventObj = new SynchronizeFiles($this->pollerId);
         $event->emit('centreon-configuration.synchronize.files', array($eventObj));
         $this->output = array_merge($this->output, $eventObj->getOutput());
         /* Synchronize Database */
         $eventObj = new SynchronizeDatabase($this->pollerId);
         $event->emit('centreon-configuration.synchronize.database', array($eventObj));
         $this->output = array_merge($this->output, $eventObj->getOutput());
     } catch (Exception $e) {
         $this->output[] = $e->getMessage();
         $this->status = false;
     }
 }
コード例 #2
0
ファイル: CopyFiles.php プロジェクト: NicolasLarrouy/centreon
 /**
  * Execute action 
  *
  * @param \CentreonConfiguration\Events\CopyFiles $event
  * @throws Exception
  */
 public static function execute(CopyFilesEvent $event)
 {
     $config = Di::getDefault()->get('config');
     $tmpdir = $config->get('global', 'centreon_generate_tmp_dir');
     if (false === is_dir($tmpdir . '/broker/apply/' . $event->getPollerId())) {
         if (false === mkdir($tmpdir . '/broker/apply/' . $event->getPollerId())) {
             throw new Exception("Error while prepare copy of Broker configuration files\n");
         }
     }
     $output = array();
     exec("rm -rf {$tmpdir}/broker/apply/{$event->getPollerId()}/* 2>&1", $output, $statusDelete);
     if ($statusDelete) {
         $event->setOutput(_('Error while deleting Broker configuration files') . "\n" . implode("\n", $output));
     }
     exec("cp -Rpf {$tmpdir}/broker/generate/{$event->getPollerId()}/* {$tmpdir}/broker/apply/{$event->getPollerId()}/ 2>&1", $output, $status);
     if ($status) {
         $event->setOutput(_('Error while copying Broker configuration files') . "\n" . implode("\n", $output));
     } else {
         $event->setOutput(_('Successfully copied files for Broker.'));
     }
 }