You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by hi...@apache.org on 2012/05/18 07:58:37 UTC

svn commit: r1339984 - in /incubator/ambari/branches/ambari-186: ./ hmc/html/ hmc/js/ hmc/php/frontend/

Author: hitesh
Date: Fri May 18 05:58:36 2012
New Revision: 1339984

URL: http://svn.apache.org/viewvc?rev=1339984&view=rev
Log:
AMBARI-249. Uninstall support from UI. Contributed by Vikram

Added:
    incubator/ambari/branches/ambari-186/hmc/html/uninstallWizard.php   (with props)
    incubator/ambari/branches/ambari-186/hmc/js/uninstall.js   (with props)
    incubator/ambari/branches/ambari-186/hmc/js/uninstallProgress.js   (with props)
    incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall.php   (with props)
    incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstallCleanup.php   (with props)
Modified:
    incubator/ambari/branches/ambari-186/CHANGES.txt
    incubator/ambari/branches/ambari-186/hmc/html/addNodesWizard.php
    incubator/ambari/branches/ambari-186/hmc/js/txnUtils.js
    incubator/ambari/branches/ambari-186/hmc/php/frontend/commandUtils.php
    incubator/ambari/branches/ambari-186/hmc/php/frontend/fetchTxnProgress.php

Modified: incubator/ambari/branches/ambari-186/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/CHANGES.txt?rev=1339984&r1=1339983&r2=1339984&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/CHANGES.txt (original)
+++ incubator/ambari/branches/ambari-186/CHANGES.txt Fri May 18 05:58:36 2012
@@ -2,6 +2,8 @@ Ambari Change log
 
 Release 0.x.x - unreleased
 
+  AMBARI-249. Uninstall support from UI. (Vikram via hitesh)
+
   AMBARI-277. API for getting cluster status. (Vikram via hitesh)
 
   AMBARI-274. Templeton data on hdfs needs to be readable by all users (Ramya via hitesh)

Modified: incubator/ambari/branches/ambari-186/hmc/html/addNodesWizard.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/html/addNodesWizard.php?rev=1339984&r1=1339983&r2=1339984&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/html/addNodesWizard.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/html/addNodesWizard.php Fri May 18 05:58:36 2012
@@ -111,6 +111,7 @@
 
             var freshInstallation = false;
             var clusterName = "<?php echo $_GET['clusterName']; ?>";
+            var nodesAction = "addNodes";
 
             var InstallationWizard = {
 

Added: incubator/ambari/branches/ambari-186/hmc/html/uninstallWizard.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/html/uninstallWizard.php?rev=1339984&view=auto
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/html/uninstallWizard.php (added)
+++ incubator/ambari/branches/ambari-186/hmc/html/uninstallWizard.php Fri May 18 05:58:36 2012
@@ -0,0 +1,111 @@
+<html>
+  <head>
+    <title id="pageTitleId">Hortonworks Data Platform Portal</title>
+
+    <!-- CSS -->
+    <link type="text/css" rel="stylesheet" href="../yui-3.4.1/build/cssreset/cssreset-min.css"> 
+    <link type="text/css" rel="stylesheet" href="../css/bootstrap.css" media="screen"/>
+    <link type="text/css" rel="stylesheet" href="../css/common.css" media="screen"/>
+    <link type="text/css" rel="stylesheet" href="../css/common2.css" media="screen"/>
+    <link type="text/css" rel="stylesheet" href="../css/common3.css" media="screen"/>
+    <link type="text/css" rel="stylesheet" href="../css/selectHosts.css" media="screen"/>
+    <link rel="shortcut icon" href="../images/logo-micro.gif">
+    <!-- End CSS -->
+  </head>
+
+  <body class="yui3-skin-sam">
+    <?php require "./topnav.htmli"; ?>
+    <?php 
+     include_once ("../php/util/clusterState.php"); 
+    // $clusterName = "m4v1";
+    // $clusterState = needWipeOut($clusterName); 
+    ?>
+    <hr/>
+
+    <div name="ContentDiv" id="ContentDivId"> 
+
+      <!-- Installation Wizard -->
+      <div name="installationWizardDiv" id="installationWizardDivId" style="display:block">
+        <div name="installationWizardProgressBarDiv" id="installationWizardProgressBarDivId">
+          <ol id="installationWizardProgressBarListId">
+            <li id="addNodesStageId" class="installationWizardCurrentStage">
+              <div>
+                <span class="installationWizardStageNumber">
+                  1   
+                </span>
+                Wipe out cluster
+              </div>
+            </li>
+          </ol>
+        </div>
+        
+        <br/>
+
+        <?php require "./utils.htmli"; ?>
+
+        <div name="installationMainFormsDiv" id="installationMainFormsDivId">
+         
+          <br/>
+          <div id="addNodesCoreDivId" style="display:block">
+            <fieldset>
+              <form id="addNodesFilesFormId" enctype="multipart/form-data" method="post">
+              <p>
+              <label for="clusterDeployUserId">Cluster Deploy User</label>
+              <input type="text" name="ClusterDeployUser" id="clusterDeployUserId" value="root" placeholder="">
+              </p>
+              <br/>
+              <p>
+              <label for="clusterDeployUserIdentityFileId">Cluster Deploy User Identity File</label>
+              <input type="file" name="clusterDeployUserIdentityFile" id="clusterDeployUserIdentityFileId" value="" placeholder="">
+              </p>
+              <br/>
+              <p>
+              <div name="confirmWipeOutDiv" id="confirmWipeOutDivId">
+                <label for="confirmWipeOutId">Confirm Wipeout(Data will be lost)</label>
+                <input type="checkbox" id="confirmWipeOutCheckId" value="true">
+              </div>
+
+                    <div id="fileUploadWrapperDivId">
+                      <iframe name="fileUploadTarget" id="fileUploadTargetId" src="about:blank" style="display:none"></iframe>
+                    </div>
+                  <input type="button" id="addNodesSubmitButtonId" value="Confirm" class="submitButton">
+                </p>
+              </div>
+
+              <?php require "./txnUtils.htmli"; ?>
+
+              </div>
+            </div>
+            <!-- End of installation Wizard -->
+
+            <hr/>
+            <?php require "./footer.htmli"; ?>
+
+            <!-- Javascript Scaffolding -->
+            <script type="text/javascript">
+
+            var freshInstallation = false;
+            var nodesAction = "uninstall";
+            var clusterName = "<?php echo $_GET['clusterName']; ?>";
+
+            var InstallationWizard = {
+
+              AddNodes: 
+              {},
+              AddNodesProgress:
+              {}
+            };
+
+            var jsFilesToLoad = [ 
+                '../js/utils.js', 
+                '../js/txnUtils.js',
+                '../js/uninstall.js', 
+                '../js/uninstallProgress.js', 
+              ];
+            </script>
+
+            <?php require "./bootstrapJs.htmli"; ?>
+            <!-- End of Javascript Scaffolding -->
+
+          </body>
+        </html> 

Propchange: incubator/ambari/branches/ambari-186/hmc/html/uninstallWizard.php
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/ambari/branches/ambari-186/hmc/js/txnUtils.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/js/txnUtils.js?rev=1339984&r1=1339983&r2=1339984&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/js/txnUtils.js (original)
+++ incubator/ambari/branches/ambari-186/hmc/js/txnUtils.js Fri May 18 05:58:36 2012
@@ -40,6 +40,11 @@ function TxnProgressWidget( txnProgressC
   this.txnProgressContext = txnProgressContext;
   this.txnProgressStatusMessage = txnProgressStatusMessage;
   this.txnProgressPostCompletionFixup = txnProgressPostCompletionFixup;
+  var requestStr = '?clusterName=' + this.txnProgressContext.clusterName + '&txnId=' + this.txnProgressContext.txnId;
+
+  if ("deployUser" in this.txnProgressContext) {
+    requestStr += '&deployUser=' + this.txnProgressContext.deployUser;
+  }
 
   var pdpDataSourceContext = {
     source: '../php/frontend/fetchTxnProgress.php',
@@ -48,7 +53,8 @@ function TxnProgressWidget( txnProgressC
         progress: 'progress'
       }
     },
-    request: '?clusterName=' + this.txnProgressContext.clusterName + '&txnId=' + this.txnProgressContext.txnId,
+
+    request: requestStr, 
     pollInterval: 3000,
     maxFailedAttempts: 5
   };

Added: incubator/ambari/branches/ambari-186/hmc/js/uninstall.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/js/uninstall.js?rev=1339984&view=auto
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/js/uninstall.js (added)
+++ incubator/ambari/branches/ambari-186/hmc/js/uninstall.js Fri May 18 05:58:36 2012
@@ -0,0 +1,118 @@
+function getWipeOutConfirmation () {
+  var selections = globalYui.all("#confirmWipeOutDivId input[type=checkbox]");
+
+  var wipeOutChecked = false;
+  selections.each( function(selection) {
+    wipeOutChecked = selection.get('checked');
+  });
+
+  if (wipeOutChecked) {
+    return "wipeOut";
+  } else {
+    return "uninstall";
+  }
+
+}
+
+globalYui.one('#addNodesSubmitButtonId').on('click',function (e) {
+
+  var focusId = '';
+  var message = '';
+  var errCount = 0;
+
+  var userId = globalYui.Lang.trim(globalYui.one("#clusterDeployUserId").get('value'));
+  if (userId == '') {
+    errCount++;
+    focusId = '#clusterDeployUserId';
+    message += 'Cluster Deploy User cannot be empty';
+    globalYui.one("#clusterDeployUserId").addClass('formInputError');
+  } else {
+    globalYui.one("#clusterDeployUserId").removeClass('formInputError');
+  }
+
+  var fileName = globalYui.one("#clusterDeployUserIdentityFileId").get('value');
+  if (fileName == '') {
+    errCount++;
+    if (focusId == '') {
+      focusId = '#clusterDeployUserIdentityFileId';
+    }
+    if (message != '') {
+      message += ',';
+    } 
+    message += 'User Identity file not specified';
+    globalYui.one("#clusterDeployUserIdentityFileId").addClass('formInputError');
+  } else {
+    globalYui.one("#clusterDeployUserIdentityFileId").removeClass('formInputError');
+  }
+
+  if (nodesAction != "uninstall") {
+    fileName = globalYui.one("#clusterHostsFileId").get('value');
+    if (fileName == '') {
+      errCount++;
+      if (focusId == '') {
+        focusId = '#clusterHostsFileId';
+      }
+      if (message != '') {
+        message += ',';
+      } 
+      message += 'Hosts file not specified';
+      globalYui.one("#clusterHostsFileId").addClass('formInputError');
+    } else {
+      globalYui.one("#clusterHostsFileId").removeClass('formInputError');
+    }
+  }
+
+  if (errCount != 0) {
+    globalYui.one(focusId).focus();
+    setFormStatus(message, true);
+    return;
+  }
+
+  clearFormStatus();
+
+  showLoadingImg();
+
+  globalYui.log("About to upload files.");
+  e.target.set('disabled', true);
+
+  var addNodesFilesForm = globalYui.one("#addNodesFilesFormId");
+
+  addNodesFilesForm.set('action', '../php/frontend/addNodes.php?clusterName=' + 
+    clusterName + "&freshInstall=false");
+
+  /* Set the target of the first form's upload to be a hidden iframe 
+   * on the page so as not to redirect to the PHP page we're POSTing 
+   * to.
+   *
+   * See http://www.openjs.com/articles/ajax/ajax_file_upload/ for 
+   * more on this.
+   */
+  addNodesFilesForm.set('target', 'fileUploadTarget');
+
+  /* And then programmatically submit the first of the 2 forms. */ 
+  addNodesFilesForm.submit();
+  globalYui.log("Files submitted to server.");
+
+  e.target.set('disabled', false);
+});
+
+var setupNodesJson = "";
+
+globalYui.one("#fileUploadTargetId").on('load', function (e) {
+
+    e.target.set('disabled', true);
+
+    var action = getWipeOutConfirmation();
+
+    var uninstallRequestData = { };
+
+    var userId = globalYui.Lang.trim(globalYui.one("#clusterDeployUserId").get('value'));
+    var url = "../php/frontend/uninstall.php?clusterName=" + clusterName + "&action=" + action + "&clusterDeployUser=" + userId;
+    var requestData = uninstallRequestData;
+    var submitButton = e.target;
+    var thisScreenId = "#addNodesCoreDivId";
+    var nextScreenId = "#txnProgressCoreDivId";
+    var nextScreenRenderFunction = renderUninstallProgress;
+    submitDataAndProgressToNextScreen(url, requestData, submitButton, thisScreenId, nextScreenId, nextScreenRenderFunction);
+});
+

Propchange: incubator/ambari/branches/ambari-186/hmc/js/uninstall.js
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/ambari/branches/ambari-186/hmc/js/uninstallProgress.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/js/uninstallProgress.js?rev=1339984&view=auto
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/js/uninstallProgress.js (added)
+++ incubator/ambari/branches/ambari-186/hmc/js/uninstallProgress.js Fri May 18 05:58:36 2012
@@ -0,0 +1,195 @@
+function generateLogsContent(errorInfoJson) {
+/*
+  content = '<div id=\"ProgressLogsContainer\">'
+  for (i=0; i < errorInfoJson['progress'].length; i++) {
+    var subTxnId = errorInfoJson['progress'][i]['subTxnId'];
+    var state = errorInfoJson['progress'][i]['state'];
+    var desc = errorInfoJson['progress'][i]['description'];
+
+    var stateClass = 'ProgressLogsSubTxnState' + state;
+
+    var subTxnDiv = '<div id=\"'
+      + 'ProgressLogsSubTxnContainer' + subTxnId + 'Id\"'
+      + ' class=\"ProgressLogsSubTxnContainer ' + stateClass + ' \" name=\"' + desc + '\">';
+
+    for (hostName in errorInfoJson['logs'][subTxnId]['nodeLogs']) {
+      var nodeReport = errorInfoJson['logs'][subTxnId]['nodeLogs'][hostName];
+      var hostState = nodeReport['overall'];
+      var hostStateClass = 'ProgressLogsSubTxnNodeState' + hostState;
+      var reportContainer = '<div id=\"ProgressLogsSubTxnNodeContainer' + subTxnId + hostName + 'Id\"'
+        + ' class=\"ProgressLogsSubTxnNodeContainer ' + hostStateClass + '\"' + ' name=\"' + hostName + '\">'
+        + '<div class=\"ProgressLogsSubTxnNodeContainerLogs\">'
+        + globalYui.JSON.stringify(nodeReport.message)
+        + '</div>'
+        + '</div>' + '<br/>'
+      subTxnDiv += reportContainer;
+    }
+    subTxnDiv += '</div>' + '<br/>';
+    content += subTxnDiv;
+  }
+  content += '</div>';
+
+  return content;
+*/
+  return '<pre>' +
+           globalYui.JSON.stringify( errorInfoJson.logs, null, 4 ) +
+         '</pre>';
+
+}
+
+function generateClustersListUrl( clusterName ) {
+
+  var url = '';
+
+  var currentUrl = window.location.href;
+  globalYui.log('Current URL: ' + currentUrl);
+  var currentPathPos = currentUrl.indexOf(window.location.pathname);
+  globalYui.log('Current Path Pos: ' + currentPathPos);
+
+  if( -1 != currentPathPos ) {
+
+    /*
+    url = currentUrl.substr(0, currentPathPos) + 
+      '/hmc/html/manageServices.php?clusterName=' + clusterName;
+  globalYui.log('Services Page URL: ' + url);
+      */
+    // ClusterName is no longer needed
+    url = currentUrl.substr(0, currentPathPos) + '/hmc/html/index.php';
+  }
+
+  return url;
+}
+
+function renderUninstallProgress (uninstallProgressInfo) {
+
+  hideLoadingImg();
+
+  /* At this point, our users are done with the installation wizard
+   * and have asked for a uninstall, so there's no going back - remove
+   * all traces of #installationWizardProgressBarDivId.
+   */
+  globalYui.one('#installationWizardProgressBarDivId').setStyle('display', 'none');
+
+  var hmcRestartMsg = '';
+  if (uninstallProgressInfo.nagiosGangliaCoHosted != null
+      && uninstallProgressInfo.nagiosGangliaCoHosted) {
+    hmcRestartMsg = '<strong>Note:</strong> We detected that you need to restart HMC as'
+        + ' Nagios/Ganglia are co-hosted on this server. <br/>Please restart'
+        + ' HMC using \"service hmc restart\" and then head ';
+  } else {
+    hmcRestartMsg = 'May we be so bold as to suggest heading ';
+  }
+
+  hmcRestartMsg += 'on over to the ' +
+      '<a href="javascript:void(null)" id=clustersListLinkId>' +
+        'Cluster information' +
+      '</a>' +
+      ' page?';
+
+  var uninstallProgressStatusMessage = {
+
+    success:
+      '<p style=\"text-align:center\">' +
+        'All done with the uninstall! <br/>' + hmcRestartMsg +
+      '</p>',
+    failure:
+      '<p>' +
+        'We made a boo-boo! Take a look at the ' +
+          '<a href="javascript:void(null)" id=showUninstallTxnLogsLinkId>Uninstall Logs</a>' +
+        '?' +
+      '</p>'
+  };
+
+  var uninstallProgressPostCompletionFixup = {
+
+    success: function( txnProgressWidget ) {
+
+      globalYui.one("#clustersListLinkId").on( "click", function(e) {
+        window.open( generateClustersListUrl(txnProgressWidget.txnProgressContext.clusterName) );
+      });
+    },
+
+    failure: function( txnProgressWidget ) {
+
+      /* Create the panel that'll display our error info. */
+      var errorInfoPanel = 
+        createInformationalPanel( '#informationalPanelContainerDivId', 'Uninstall Logs' );
+
+      /* Prime the panel to start off showing our stock loading image. */
+      var errorInfoPanelBodyContent = 
+        '<img id=errorInfoPanelLoadingImgId class=loadingImg src=../images/loading.gif />';
+
+      /* Make the call to our backend to fetch the report for this txnId. */
+      globalYui.io('../php/frontend/fetchTxnLogs.php?clusterName=' + 
+        txnProgressWidget.txnProgressContext.clusterName + '&txnId=' + txnProgressWidget.txnProgressContext.txnId, {
+          
+          timeout: 10000,
+          on: {
+            success: function (x,o) {
+
+              globalYui.log("RAW JSON DATA: " + o.responseText);
+
+              var errorInfoJson = null;
+
+              // Process the JSON data returned from the server
+              try {
+                errorInfoJson = globalYui.JSON.parse(o.responseText);
+              }
+              catch (e) {
+                alert("JSON Parse failed!");
+                return;
+              }
+
+              /* TODO XXX Remove some of the noise from this to allow
+               * for better corelation - for now, just dump a 
+               * pretty-printed version of the returned JSON.
+               */
+              errorInfoPanelBodyContent = generateLogsContent(errorInfoJson);
+
+              /* Update the contents of errorInfoPanel (which was, till
+               * now, showing the loading image). 
+               */
+              errorInfoPanel.set( 'bodyContent', errorInfoPanelBodyContent );
+            },
+            failure: function (x,o) {
+              alert("Async call failed!");
+            }
+        }
+      });
+
+      var firstTimeShowingErrorInfoPanel = true;
+
+      /* Register a click-handler for #showUninstallTxnLogsLinkId to render 
+       * the contents inside errorInfoPanel (and make it visible). 
+       */
+      globalYui.one("#showUninstallTxnLogsLinkId").on( "click", function(e) {
+
+        errorInfoPanel.set( 'bodyContent', errorInfoPanelBodyContent );
+        errorInfoPanel.show();
+
+        if( firstTimeShowingErrorInfoPanel ) {
+
+          globalYui.one('#txnProgressStatusActionsDivId').setContent(  
+            '<a href="javascript:void(null)" id=clustersListLinkId>' + 
+              'Go Manage The Cluster\'s Services' +
+            '</a>' );
+
+          globalYui.one("#restartInstallationWizardLinkId").on( "click", function(e) {
+            window.open( window.location.href );
+          });
+
+          globalYui.one("#clustersListLinkId").on( "click", function(e) {
+            window.open( generateClustersListUrl(txnProgressWidget.txnProgressContext.clusterName) );
+          });
+
+          firstTimeShowingErrorInfoPanel = false;
+        }
+      });
+    }
+  };
+
+  var uninstallProgressWidget = new TxnProgressWidget
+    ( uninstallProgressInfo, uninstallProgressStatusMessage, uninstallProgressPostCompletionFixup );
+
+  uninstallProgressWidget.show();
+} 

Propchange: incubator/ambari/branches/ambari-186/hmc/js/uninstallProgress.js
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/commandUtils.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/commandUtils.php?rev=1339984&r1=1339983&r2=1339984&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/commandUtils.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/commandUtils.php Fri May 18 05:58:36 2012
@@ -2,6 +2,9 @@
 
 function launchCmd ($cmd)
 {
+
+  global $logger;
+  $logger->log_debug("WCOLL is ".json_encode(getenv("WCOLL")));
   $handle = popen($cmd, "r");
   while (!feof($handle)) {
     $read = fread($handle, 4096);
@@ -70,6 +73,7 @@ function runPdsh($clusterName, $operatio
   fclose($sshCmdFileHdl);
   chmod($sshCmdFile, 0555);
 
+  $logger->log_info("Hosts for this operation: ".json_encode($hosts));
   putenv("WCOLL=$hosts");
 
   $pdshCmd = "pdsh -R exec ".$sshCmdFile." %h ";

Modified: incubator/ambari/branches/ambari-186/hmc/php/frontend/fetchTxnProgress.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/fetchTxnProgress.php?rev=1339984&r1=1339983&r2=1339984&view=diff
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/fetchTxnProgress.php (original)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/fetchTxnProgress.php Fri May 18 05:58:36 2012
@@ -3,11 +3,21 @@
 include_once '../util/Logger.php';
 include_once "../conf/Config.inc";
 include_once "../orchestrator/HMC.php";
+include_once "uninstallCleanup.php";
 
 $dbPath = $GLOBALS["DB_PATH"];
 
 $clusterName = $_GET['clusterName'];
 $txnId = $_GET['txnId'];
+$deployUser = $_GET['deployUser'];
+
+$logger = new HMCLogger("TxnProgress");
+
+$map = array(
+  "HMC::uninstallHDP" => array (
+      "deBootStrap"
+  )
+);
 
 //REZXXX $dummyDeployProgressData = array(
 //REZXXX   // Sample 0
@@ -671,6 +681,30 @@ foreach( $progress['subTxns'] as &$progr
   }
 }
 
+$lastTransaction = $progressSubTxn;
+
+$dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
+
+if (($progress['processRunning'] == FALSE) || ($progress['encounteredError'] == TRUE)) {
+  // get the transaction status info from db
+  $retval = $dbAccessor->getTransactionStatusInfo($clusterName, $txnId);
+  if ($retval["result"] != 0) {
+    $progress['encounteredError'] = TRUE;
+  } else {
+    $statusInfo = json_decode($retval['statusInfo'], true);
+    $logger->log_debug("Status info function ".$statusInfo['function']);
+    // run the next script from the map
+    foreach ($map[$statusInfo['function']] as $postProcessFunc) {
+      $logger->log_debug("Post process function is ".$postProcessFunc);
+      $retval = $postProcessFunc($clusterName,$deployUser, $lastTransaction);
+      if ($retval["result"] != 0) {
+        $progress['encounteredError'] = TRUE;
+        break;
+      }
+    }
+  }
+}
+
 /* Clean up some more remnants that we don't need on the frontend. */
 unset( $progress['result'] );
 unset( $progress['error'] );
@@ -681,6 +715,10 @@ $jsonOutput = array(
     'txnId' => $txnId,
     'progress' => $atLeastOneSubTxnInProgress ? $progress : null );
 
+if ($deployUser != null) {
+    $jsonOutput['deployUser'] = $deployUser;
+}
+
 /* ...and spit it out. */
 header("Content-type: application/json");
 

Added: incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall.php?rev=1339984&view=auto
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall.php (added)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall.php Fri May 18 05:58:36 2012
@@ -0,0 +1,60 @@
+<?php
+include_once '../util/Logger.php';
+include_once '../conf/Config.inc';
+include_once 'localDirs.php';
+include_once "../util/lock.php";
+include_once '../db/HMCDBAccessor.php';
+include_once "../orchestrator/HMC.php";
+include_once "../db/OrchestratorDB.php";
+include_once "../puppet/DBReader.php";
+include_once "../puppet/PuppetInvoker.php";
+
+
+$logger = new HMCLogger("Uninstall");
+$dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
+
+$logger->log_debug("Uninstall invoked");
+$clusterName = $_GET['clusterName'];
+$action = $_GET['action'];
+$deployUser = $_GET['clusterDeployUser'];
+
+$wipeout = FALSE;
+if ($action == "wipeOut") {
+  $wipeout = TRUE;
+} else {
+  $wipeout = FALSE;
+}
+
+$logger->log_debug("Uninstall got wipeout value $wipeout");
+
+$dbPath = $GLOBALS["DB_PATH"];
+
+// call the wipeout script and return the transaction id
+$hmc = new HMC($dbPath, $clusterName);
+
+$startTime = time();
+$result = $hmc->uninstallHDP($wipeout);
+if ($result["result"] != 0) {
+  print json_encode($result);
+  return;
+}
+
+if (!isset($result["txnId"])) {
+  print json_encode ( array("result" => 1, "error" => "Could not obtain txn info for triggered command"));
+
+  return;
+}
+
+$txnId = $result["txnId"];
+
+$jsonOutput = array(
+    'startTime' => $startTime,
+    'clusterName' => $clusterName,
+    'deployUser' => $deployUser,
+    'txnId' => $txnId,
+  );
+
+header("Content-type: application/json");
+print (json_encode(array("result" => 0, "error" => 0, "response" => $jsonOutput)));
+
+?>

Propchange: incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstall.php
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstallCleanup.php
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstallCleanup.php?rev=1339984&view=auto
==============================================================================
--- incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstallCleanup.php (added)
+++ incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstallCleanup.php Fri May 18 05:58:36 2012
@@ -0,0 +1,117 @@
+<?php
+
+include_once '../util/Logger.php';
+include_once '../conf/Config.inc';
+include_once 'localDirs.php';
+include_once "../util/lock.php";
+include_once '../db/HMCDBAccessor.php';
+include_once "./uninstall/stages.php";
+
+include_once 'commandUtils.php';
+include_once "../util/HMCTxnUtils.php";
+
+$logger = new HMCLogger("uninstallCleanup");
+$dbAccessor = new HMCDBAccessor($GLOBALS["DB_PATH"]);
+
+// this function will launch the stages in the background 
+// and poll for completion.
+// upon completion, does the nodesActionProgress piece to update
+// status of the completed state
+function deBootStrap ($clusterName, $deployUser, $stageInfo)
+{
+  global $logger, $dbAccessor;
+
+  /////// launch the stages in the background.
+  $stagesFile = "./uninstall/stages.php";
+  error_log("ClusterName: ".$clusterName);
+  $logger->log_debug("ClusterName: $clusterName\n");
+  $logger->log_debug("Deploy User: $deployUser\n");
+  $status = "";         
+  $createTxResult = HMCTxnUtils::createNewTransaction($dbAccessor, $clusterName, $status);
+  if ($createTxResult == FALSE) {
+    $msg = "SETUP: Failed to create new transaction in background: $createTxResult\n";
+    $logger->log_error($msg);
+    return array("result" => 1, "error" => "$msg");
+  }
+
+  $rootTxnId = $createTxResult;
+  $logger->log_error("Txn Id ===== $rootTxnId\n");
+  $logger->log_error("Clustername ===== $clusterName");
+    
+  $cmd = $GLOBALS["PHP_EXEC_PATH"] . " " . "../util/sequentialScriptRunner.php";
+  // $cmd = $GLOBALS["PHP_EXEC_PATH"] . " " . "./addNodes/addNodesOrchestrator.php";
+  $hostsFile = getHostsFilePath($clusterName);
+    
+  $args = "$clusterName $deployUser $rootTxnId $hostsFile $stagesFile";
+
+  $execBackgroundResult = HMCTxnUtils::execBackgroundProcess($dbAccessor, $clusterName, $rootTxnId, $cmd, $args, "");
+  if ($execBackgroundResult == FALSE) {
+      $msg = "Failed to execute addNodesOrchestrator in background: $execBackgroundResult\n";
+      $logger->log_error($msg);
+      return array("result" => 1, "error" => "$msg");
+  } 
+
+  /////// done launching stages
+
+  /////// now monitor the stages
+
+  $allDone = false;
+  while ($allDone == false) {
+    sleep(2);
+    // 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;
+      return ($jsonOutput);
+    }
+
+    //$logger->log_error(" ==== subTxns info is  " . json_encode($orchestratorTxnId));
+    $keys = array_keys($orchestratorTxnId['subTxns']);
+    if (count($keys) == 0) {
+      $logger->log_debug("No keys found in orchestrator's child transactions");
+      continue;
+    }
+    $firstKey = $keys[0];
+    if ($firstKey == '') {
+      continue;
+    }
+
+    $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));
+      return ($jsonOutput);
+    }
+
+    $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']);
+    }
+
+    $allDone = true;
+  }
+
+  /////// done monitoring return back to the uninstall
+  
+  return array('result' => 0);
+}
+
+?>

Propchange: incubator/ambari/branches/ambari-186/hmc/php/frontend/uninstallCleanup.php
------------------------------------------------------------------------------
    svn:eol-style = native