Esempio n. 1
0
 public function getReport()
 {
     if ($this->error === false) {
         return array(sprintf(mt('monitoring', 'Command transport configuration has been successfully created: %s'), Config::resolvePath('modules/monitoring/commandtransports.ini')));
     } elseif ($this->error !== null) {
         return array(sprintf(mt('monitoring', 'Command transport configuration could not be written to: %s. An error occured:'), Config::resolvePath('modules/monitoring/commandtransports.ini')), sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->error)));
     }
 }
Esempio n. 2
0
 public function getReport()
 {
     if ($this->error === false) {
         return array(sprintf(mt('setup', 'General configuration has been successfully written to: %s'), Config::resolvePath('config.ini')));
     } elseif ($this->error !== null) {
         return array(sprintf(mt('setup', 'General configuration could not be written to: %s. An error occured:'), Config::resolvePath('config.ini')), sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->error)));
     }
 }
Esempio n. 3
0
 public function getReport()
 {
     $okMessage = mt('setup', 'Module "%s" has been successfully enabled.');
     $failMessage = mt('setup', 'Module "%s" could not be enabled. An error occured:');
     $report = array();
     foreach ($this->moduleNames as $moduleName) {
         if (isset($this->errors[$moduleName])) {
             $report[] = sprintf($failMessage, $moduleName);
             $report[] = sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->errors[$moduleName]));
         } else {
             $report[] = sprintf($okMessage, $moduleName);
         }
     }
     return $report;
 }
Esempio n. 4
0
 public function getReport()
 {
     $report = array();
     if ($this->backendIniError === false) {
         $report[] = sprintf(mt('monitoring', 'Monitoring backend configuration has been successfully written to: %s'), Config::resolvePath('modules/monitoring/backends.ini'));
     } elseif ($this->backendIniError !== null) {
         $report[] = sprintf(mt('monitoring', 'Monitoring backend configuration could not be written to: %s. An error occured:'), Config::resolvePath('modules/monitoring/backends.ini'));
         $report[] = sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->backendIniError));
     }
     if ($this->resourcesIniError === false) {
         $report[] = sprintf(mt('monitoring', 'Resource configuration has been successfully updated: %s'), Config::resolvePath('resources.ini'));
     } elseif ($this->resourcesIniError !== null) {
         $report[] = sprintf(mt('monitoring', 'Resource configuration could not be udpated: %s. An error occured:'), Config::resolvePath('resources.ini'));
         $report[] = sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->resourcesIniError));
     }
     return $report;
 }
Esempio n. 5
0
 /**
  * Validate the given form data and check whether a BIND-request is successful
  *
  * @param   array   $data   The data to validate
  *
  * @return  bool
  */
 public function isValid($data)
 {
     if (false === parent::isValid($data)) {
         return false;
     }
     if (isset($data['skip_validation']) && $data['skip_validation']) {
         return true;
     }
     if (isset($data['domain']) && $data['domain']) {
         try {
             $this->discovery = Discovery::discoverDomain($data['domain']);
             if ($this->discovery->isSuccess()) {
                 return true;
             }
         } catch (Exception $e) {
             $this->error(sprintf($this->translate('Could not find any LDAP servers on the domain "%s". An error occurred: %s'), $data['domain'], IcingaException::describe($e)));
         }
     } else {
         $labeller = new ErrorLabeller(array('element' => $this->getElement('domain')));
         $this->getElement('domain')->addError($labeller->translate(Zend_Validate_NotEmpty::IS_EMPTY));
     }
     return false;
 }
Esempio n. 6
0
 /**
  * Return this item rendered to HTML
  *
  * @return  string
  */
 public function __toString()
 {
     try {
         return $this->render();
     } catch (Exception $e) {
         return IcingaException::describe($e);
     }
 }
Esempio n. 7
0
 /**
  * Return a string representation of the passed arguments
  *
  * This method provides three different processing techniques:
  *  - If the only passed argument is a string it is returned unchanged
  *  - If the only passed argument is an exception it is formatted as follows:
  *    <name> in <file>:<line> with message: <message>[ <- <name> ...]
  *  - If multiple arguments are passed the first is interpreted as format-string
  *    that gets substituted with the remaining ones which can be of any type
  *
  * @param   array   $arguments      The arguments to format
  *
  * @return  string                  The formatted result
  */
 protected static function formatMessage(array $arguments)
 {
     if (count($arguments) === 1) {
         $message = $arguments[0];
         if ($message instanceof Exception) {
             $messages = array();
             $error = $message;
             do {
                 $messages[] = IcingaException::describe($error);
             } while ($error = $error->getPrevious());
             $message = implode(' <- ', $messages);
         }
         return $message;
     }
     return vsprintf(array_shift($arguments), array_map(function ($a) {
         return is_string($a) ? $a : ($a instanceof Exception ? IcingaException::describe($a) : json_encode($a));
     }, $arguments));
 }
Esempio n. 8
0
 public function getReport()
 {
     $report = array();
     if ($this->groupIniError === false) {
         $report[] = sprintf(mt('setup', 'User Group Backend configuration has been successfully written to: %s'), Config::resolvePath('groups.ini'));
     } elseif ($this->groupIniError !== null) {
         $report[] = sprintf(mt('setup', 'User Group Backend configuration could not be written to: %s. An error occured:'), Config::resolvePath('groups.ini'));
         $report[] = sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->groupIniError));
     }
     if ($this->groupError === false) {
         $report[] = sprintf(mt('setup', 'User Group "%s" has been successfully created.'), mt('setup', 'Administrators', 'setup.role.name'));
     } elseif ($this->groupError !== null) {
         $report[] = sprintf(mt('setup', 'Unable to create user group "%s". An error occured:'), mt('setup', 'Administrators', 'setup.role.name'));
         $report[] = sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->groupError));
     }
     if ($this->memberError === false) {
         $report[] = sprintf(mt('setup', 'Account "%s" has been successfully added as member to user group "%s".'), $this->data['username'], mt('setup', 'Administrators', 'setup.role.name'));
     } elseif ($this->memberError !== null) {
         $report[] = sprintf(mt('setup', 'Unable to add account "%s" as member to user group "%s". An error occured:'), $this->data['username'], mt('setup', 'Administrators', 'setup.role.name'));
         $report[] = sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->memberError));
     }
     return $report;
 }
Esempio n. 9
0
 public function getReport()
 {
     $report = array();
     if ($this->authIniError === false) {
         $report[] = sprintf(mt('setup', 'Authentication configuration has been successfully written to: %s'), Config::resolvePath('authentication.ini'));
     } elseif ($this->authIniError !== null) {
         $report[] = sprintf(mt('setup', 'Authentication configuration could not be written to: %s. An error occured:'), Config::resolvePath('authentication.ini'));
         $report[] = sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->authIniError));
     }
     if ($this->dbError === false) {
         $report[] = sprintf(mt('setup', 'Account "%s" has been successfully created.'), $this->data['adminAccountData']['username']);
     } elseif ($this->dbError !== null) {
         $report[] = sprintf(mt('setup', 'Unable to create account "%s". An error occured:'), $this->data['adminAccountData']['username']);
         $report[] = sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->dbError));
     }
     if ($this->permIniError === false) {
         $report[] = isset($this->data['adminAccountData']['username']) ? sprintf(mt('setup', 'Account "%s" has been successfully defined as initial administrator.'), $this->data['adminAccountData']['username']) : sprintf(mt('setup', 'The members of the user group "%s" were successfully defined as initial administrators.'), $this->data['adminAccountData']['groupname']);
     } elseif ($this->permIniError !== null) {
         $report[] = isset($this->data['adminAccountData']['username']) ? sprintf(mt('setup', 'Unable to define account "%s" as initial administrator. An error occured:'), $this->data['adminAccountData']['username']) : sprintf(mt('setup', 'Unable to define the members of the user group "%s" as initial administrators. An error occured:'), $this->data['adminAccountData']['groupname']);
         $report[] = sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->permIniError));
     }
     return $report;
 }
Esempio n. 10
0
 public function getReport()
 {
     if ($this->error === false) {
         $report = $this->messages;
         $report[] = mt('setup', 'The database has been fully set up!');
         return $report;
     } elseif ($this->error !== null) {
         $report = $this->messages;
         $report[] = mt('setup', 'Failed to fully setup the database. An error occured:');
         $report[] = sprintf(mt('setup', 'ERROR: %s'), IcingaException::describe($this->error));
         return $report;
     }
 }
Esempio n. 11
0
 public function dispatch(Params $overrideParams = null)
 {
     if ($this->commandName === null) {
         echo $this->docs()->usage($this->moduleName);
         return false;
     } elseif ($this->actionName === null) {
         echo $this->docs()->usage($this->moduleName, $this->commandName);
         return false;
     }
     try {
         if ($this->moduleName) {
             $this->app->getModuleManager()->loadModule($this->moduleName);
             $obj = $this->getModuleCommandInstance($this->moduleName, $this->commandName);
         } else {
             $obj = $this->getCommandInstance($this->commandName);
         }
         if ($overrideParams !== null) {
             $obj->setParams($overrideParams);
         }
         $obj->init();
         return $obj->{$this->actionName . 'Action'}();
     } catch (Exception $e) {
         if ($obj && $obj instanceof Command && $obj->showTrace()) {
             echo $this->formatTrace($e->getTrace());
         }
         $this->fail(IcingaException::describe($e));
     }
 }
Esempio n. 12
0
 /**
  * Create links w/ {@link createLink()} in the given text that matches to the subject from {@link getPattern()}
  *
  * In case of errors a debug message is recorded to the log and any subsequent call to {@link createLinks()} will
  * be a no-op.
  *
  * @param   string $text
  *
  * @return  string
  */
 public final function createLinks($text)
 {
     if ($this->lastError !== null) {
         return $text;
     }
     try {
         $pattern = $this->getPattern();
     } catch (Exception $e) {
         $this->fail('Can\'t create ticket links: Retrieving the pattern failed: %s', IcingaException::describe($e));
         return $text;
     }
     if (empty($pattern)) {
         $this->fail('Can\'t create ticket links: Pattern is empty');
         return $text;
     }
     if (is_array($pattern)) {
         $text = $this->applyTicketPatterns($text, $pattern);
     } else {
         try {
             $text = preg_replace_callback($pattern, array($this, 'createLink'), $text);
         } catch (ErrorException $e) {
             $this->fail('Can\'t create ticket links: Pattern is invalid: %s', IcingaException::describe($e));
             return $text;
         } catch (Exception $e) {
             $this->fail('Can\'t create ticket links: %s', IcingaException::describe($e));
             return $text;
         }
     }
     return $text;
 }