1, "error" => "Invalid action", ) )); return; } include_once $stagesFile; header("Content-type: application/json"); $logger->log_info("Cluster Name: $clusterName Root Txn ID: $rootTxnId"); $progressStates = array(); foreach ($stagesInfo as $stage => $stageInfo) { array_push($progressStates, $stageInfo["description"]); } $jsonOutput = array ( 'progressStates'=> $progressStates, 'currentProgressStateIndex' => 0, // by default is state Sshable 'encounteredError' => false, 'stateInfo' => array(), ); // use the txn id for finding the status to pass back to the user // the orchestrator txn id could potentially return an error because // there is a potential race condition before the orchestrator txnId has // been committed to the db by the backgrounded process. $dbHandle = new HMCDBAccessor($GLOBALS["DB_PATH"]); $orchestratorTxnId = $dbHandle->getAllSubTransactionsInfo( $clusterName, $rootTxnId); if ($orchestratorTxnId['result'] != 0) { // encountered error $logger->log_error("Empty orchestrator txn id " . json_encode($orchestratorTxnId)); // Check if this should return error FIXME // $jsonOutput['encounteredError'] = true; print json_encode($jsonOutput); return; } //$logger->log_error(" ==== subTxns info is " . json_encode($orchestratorTxnId)); $keys = array_keys($orchestratorTxnId['subTxns']); if (count($keys) == 0) { print json_encode($jsonOutput); $logger->log_debug("No keys found in orchestrator's child transactions"); return; } $firstKey = $keys[0]; if ($firstKey == '') { print json_encode($jsonOutput); return; } $allSubTxns = $dbHandle->getAllSubTransactionsInfo( $clusterName, $firstKey); // the all sub txn ids could potentially return an error because // there is a potential race condition before the orchestrator's subTxnId has // been committed to the db by the backgrounded process. if ($allSubTxns['result'] != 0) { $logger->log_error("Empty orchestrator txn id " . json_encode($allSubTxns)); print json_encode($jsonOutput); exit(0); } $jsonOutput['currentProgressStateIndex'] = count($allSubTxns['subTxns']) - 1; if ($jsonOutput['currentProgressStateIndex'] < 0) { $jsonOutput['currentProgressStateIndex'] = 0; } $jsonOutput['stateInfo'] = $allSubTxns; // Decode log information store as part of state. foreach ($jsonOutput['stateInfo']['subTxns'] as $subTxnId => $subTxnInfo) { $jsonOutput['stateInfo']['subTxns'][$subTxnId]['state'] = json_decode($jsonOutput['stateInfo']['subTxns'][$subTxnId]['state'], true); } print json_encode($jsonOutput); ?>