deployPostProcess.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. include_once '../util/Logger.php';
  3. include_once '../conf/Config.inc';
  4. include_once 'localDirs.php';
  5. include_once "../util/lock.php";
  6. include_once '../db/HMCDBAccessor.php';
  7. include_once '../util/clusterState.php';
  8. include_once 'commandUtils.php';
  9. include_once "../util/HMCTxnUtils.php";
  10. function deployPostProcess($clusterName, $user, $txnId, $progress)
  11. {
  12. $logger = new HMCLogger("DeployPostProcess");
  13. $dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
  14. $result = 0;
  15. $error = "";
  16. $txnStatus = $dbAccessor->getTransactionStatusInfo($clusterName, $txnId);
  17. if ($txnStatus['result'] != 0) {
  18. $logger->log_error("Deploy post process get txn info failed");
  19. $result = $txnStatus['result'];
  20. $error = $txnStatus['error'];
  21. return (array("result" => $result, "error" => $error));
  22. }
  23. $txnStatus = !($progress['encounteredError']);
  24. $state = "DEPLOYED";
  25. if ($txnStatus) {
  26. $displayName = "Deployed successfully";
  27. } else {
  28. $displayName = "Deploy failed";
  29. }
  30. $context = array (
  31. 'status' => $txnStatus,
  32. 'txnId' => $txnId
  33. );
  34. // update state of the cluster
  35. $retval = updateClusterState($clusterName, $state, $displayName, $context);
  36. if ($retval['result'] != 0) {
  37. $logger->log_error("Update cluster state failed");
  38. $result = $retval['result'];
  39. $error = $retval['error'];
  40. }
  41. return (array("result" => $result, "error" => $error));
  42. }
  43. ?>