Ejemplo n.º 1
0
 public static function getActionState($bid)
 {
     $result = array();
     $shellAdapter = new ShellAdapter();
     $execRes = $shellAdapter->syncExec("sudo -u root /opt/webdir/bin/bx-process -a status -t " . $bid . " -o json");
     $data = $shellAdapter->getLastOutput();
     if ($execRes) {
         $arData = json_decode($data, true);
         if (isset($arData["params"][$bid])) {
             $result = $arData["params"][$bid];
         }
         if ($result["status"] == "finished") {
             Logger::addRecord(Logger::LOG_LEVEL_INFO, "SCALE_ACTION_CHECK_STATE", $bid, Loc::getMessage("SCALE_ACTIONSDATA_ACTION_FINISHED"));
         } elseif ($result["status"] == "error") {
             Logger::addRecord(Logger::LOG_LEVEL_ERROR, "SCALE_ACTION_CHECK_STATE", $bid, Loc::getMessage("SCALE_ACTIONSDATA_ACTION_ERROR"));
         }
         if (self::$logLevel >= Logger::LOG_LEVEL_DEBUG) {
             Logger::addRecord(Logger::LOG_LEVEL_DEBUG, "SCALE_ACTION_CHECK_STATE", $bid, $data);
         }
     }
     return $result;
 }
Ejemplo n.º 2
0
 protected function log($level, $auditType, $actionId, $description)
 {
     if ($this->logLevel < $level) {
         return false;
     }
     return Logger::addRecord($level, $auditType, $actionId, $description);
 }
Ejemplo n.º 3
0
 /**
  * @param string $providerId Provider identifier.
  * @param string $configId Config idenifier.
  * @return int Task identifier.
  * @throws ArgumentNullException
  */
 public static function sendOrder($providerId, $configId)
 {
     if (strlen($providerId) <= 0) {
         throw new ArgumentNullException("providerId");
     }
     if (strlen($configId) <= 0) {
         throw new ArgumentNullException("configId");
     }
     $result = "";
     $shellAdapter = new ShellAdapter();
     $execRes = $shellAdapter->syncExec("sudo -u root /opt/webdir/bin/bx-provider -a order --provider " . $providerId . " --config_id " . $configId . " -o json");
     $jsonData = $shellAdapter->getLastOutput();
     if ($execRes) {
         $arData = json_decode($jsonData, true);
         if (isset($arData["params"]["provider_order"][$providerId]["task_id"])) {
             $result = $arData["params"]["provider_order"][$providerId]["task_id"];
         }
     }
     if (strlen($result) > 0) {
         $logLevel = Logger::LOG_LEVEL_INFO;
         $description = Loc::getMessage("SCALE_PROVIDER_SEND_ORDER_SUCCESS");
     } else {
         $logLevel = Logger::LOG_LEVEL_ERROR;
         $description = Loc::getMessage("SCALE_PROVIDER_SEND_ORDER_ERROR");
     }
     $description = str_replace(array("##PROVIDER##", "##CONFIG_ID##", "##ORDER_ID##"), array($providerId, $configId, $result), $description);
     Logger::addRecord($logLevel, "SCALE_PROVIDER_SEND_ORDER", $providerId . "::" . $configId, $description);
     return $result;
 }