diff options
author | Yusaku Sako <yusaku@apache.org> | 2012-12-09 15:20:25 +0000 |
---|---|---|
committer | Yusaku Sako <yusaku@apache.org> | 2012-12-09 15:20:25 +0000 |
commit | 750bc81fc796b8b8bc348ea75336966f656de083 (patch) | |
tree | 5baadfa811db414bc92790bc7b6a317cb96345da /ambari-web | |
parent | 2327f56fb2651f737cea89f9ce7eed78703b956c (diff) |
AMBARI-1054. Implement retrying of bootstrap on confirm host page. (Jaimin Jetly via yusaku)
git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/branches/AMBARI-666@1419008 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'ambari-web')
-rw-r--r-- | ambari-web/app/controllers/installer.js | 37 | ||||
-rw-r--r-- | ambari-web/app/controllers/wizard/step2_controller.js | 26 | ||||
-rw-r--r-- | ambari-web/app/controllers/wizard/step3_controller.js | 60 | ||||
-rw-r--r-- | ambari-web/app/routes/installer.js | 3 | ||||
-rw-r--r-- | ambari-web/app/templates/wizard/step3.hbs | 2 | ||||
-rw-r--r-- | ambari-web/app/utils/db.js | 11 |
6 files changed, 82 insertions, 57 deletions
diff --git a/ambari-web/app/controllers/installer.js b/ambari-web/app/controllers/installer.js index 1516f91c29..f1e627a71b 100644 --- a/ambari-web/app/controllers/installer.js +++ b/ambari-web/app/controllers/installer.js @@ -111,7 +111,7 @@ App.InstallerController = App.WizardController.extend({ hostsInfo.localRepoPath = ''; } hostsInfo.bootRequestId = App.db.getBootRequestId() || null; - hostsInfo.sshKey = ''; + hostsInfo.sshKey = App.db.getSshKey() || ''; hostsInfo.passphrase = ''; hostsInfo.confirmPassphrase = ''; @@ -133,6 +133,7 @@ App.InstallerController = App.WizardController.extend({ App.db.setHosts(stepController.getHostInfo()); if (stepController.get('manualInstall') === false) { App.db.setInstallType({installType: 'ambari' }); + App.db.setSshKey(stepController.get('sshKey')); } else { App.db.setInstallType({installType: 'manual' }); } @@ -570,6 +571,7 @@ App.InstallerController = App.WizardController.extend({ this.set('content.advancedServiceConfig', configs); App.db.setAdvancedServiceConfig(configs); }, + /** * Generate serviceProperties save it to localdata * called form stepController step6WizardController @@ -607,6 +609,36 @@ App.InstallerController = App.WizardController.extend({ return serviceComponents; }, + + /* + Bootstrap selected hosts. + */ + launchBootstrap: function (bootStrapData) { + var self = this; + var requestId = null; + var method = App.testMode ? 'GET' : 'POST'; + var url = App.testMode ? '/data/wizard/bootstrap/bootstrap.json' : App.apiPrefix + '/bootstrap'; + $.ajax({ + type: method, + url: url, + async: false, + data: bootStrapData, + timeout: App.timeout, + contentType: 'application/json', + success: function (data) { + console.log("TRACE: POST bootstrap succeeded"); + requestId = data.requestId; + }, + error: function () { + console.log("ERROR: POST bootstrap failed"); + alert('Bootstrap call failed. Please try again.'); + }, + statusCode: require('data/statusCodes') + }); + return requestId; + }, + + /** * Clear all temporary data */ @@ -620,5 +652,6 @@ App.InstallerController = App.WizardController.extend({ App.db.setAllHostNames(undefined); } -}); +}) +; diff --git a/ambari-web/app/controllers/wizard/step2_controller.js b/ambari-web/app/controllers/wizard/step2_controller.js index cfbc562040..5dca8551de 100644 --- a/ambari-web/app/controllers/wizard/step2_controller.js +++ b/ambari-web/app/controllers/wizard/step2_controller.js @@ -129,27 +129,11 @@ App.WizardStep2Controller = Em.Controller.extend({ return true; } - var self = this; - var method = App.testMode ? 'GET' : 'POST'; - var url = App.testMode ? '/data/wizard/bootstrap/bootstrap.json' : App.apiPrefix + '/bootstrap'; - - $.ajax({ - type: method, - url: url, - data: bootStrapData, - timeout: App.timeout, - contentType: 'application/json', - success: function (data) { - console.log("TRACE: POST bootstrap succeeded"); - var requestId = data.requestId; - self.set('bootRequestId',requestId); - App.router.send('next'); - }, - error: function () { - console.log("ERROR: POST bootstrap failed"); - alert('Bootstrap call failed. Please try again.'); - } - }); + var requestId = App.get('router.installerController').launchBootstrap(bootStrapData); + if(requestId) { + this.set('bootRequestId',requestId); + App.router.send('next'); + } }, manualInstallPopup: function (event) { diff --git a/ambari-web/app/controllers/wizard/step3_controller.js b/ambari-web/app/controllers/wizard/step3_controller.js index a6549ff9b2..fe1d6da1ef 100644 --- a/ambari-web/app/controllers/wizard/step3_controller.js +++ b/ambari-web/app/controllers/wizard/step3_controller.js @@ -39,6 +39,10 @@ App.WizardStep3Controller = Em.Controller.extend({ return !(this.hosts.someProperty('isChecked', true)); }.property('hosts.@each.isChecked'), + isRetryDisabled: function () { + return !(this.get('bootHosts').someProperty('bootStatus', 'FAILED') && !this.get('isSubmitDisabled')); + }.property('bootHosts.@each.bootStatus','isSubmitDisabled'), + mockData: require('data/mock/step3_hosts'), mockRetryData: require('data/mock/step3_pollData'), @@ -70,7 +74,7 @@ App.WizardStep3Controller = Em.Controller.extend({ loadStep: function () { console.log("TRACE: Loading step3: Confirm Hosts"); - if(!this.get('hosts').length){ + if (!this.get('hosts').length) { this.clearStep(); var hosts = this.loadHosts(); // hosts.setEach('bootStatus', 'RUNNING'); @@ -149,7 +153,7 @@ App.WizardStep3Controller = Em.Controller.extend({ onPrimary: function () { App.router.send('removeHosts', hosts); self.hosts.removeObjects(hosts); - if(!self.hosts.length){ + if (!self.hosts.length) { self.set('isSubmitDisabled', true); } this.hide(); @@ -174,36 +178,30 @@ App.WizardStep3Controller = Em.Controller.extend({ } }, - retryHosts: function (hosts) { - var self = this; - - App.ModalPopup.show({ - header: Em.I18n.t('installer.step3.hosts.retry.popup.header'), - onPrimary: function () { - hosts.forEach(function (_host) { - console.log('Retrying: ' + _host.name); - }); - - //TODO: uncomment below code to hookup with @GET bootstrap API - self.set('bootHosts', hosts); - if (self.get('content.hosts.manualInstall') !== true) { - self.doBootstrap(); - } else { - self.isHostsRegistered(); - } - this.hide(); - }, - body: Em.I18n.t('installer.step3.hosts.retry.popup.body') - }); - }, - retryHost: function (hostInfo) { this.retryHosts([hostInfo]); }, + retryHosts: function (hosts) { + var bootStrapData = JSON.stringify({'verbose': true, 'sshKey': this.get('content.hosts.sshKey'), hosts: hosts.mapProperty('name')}); + this.numPolls = 0; + this.set('registrationAttempts', null); + if (this.get('content.hosts.manualInstall') !== true) { + var requestId = App.router.get('installerController').launchBootstrap(bootStrapData); + this.set('content.hosts.bootRequestId', requestId); + this.doBootstrap(); + } else { + this.isHostsRegistered(); + } + }, + retrySelectedHosts: function () { - if (!this.get('noHostsSelected')) { - var selectedHosts = this.get('visibleHosts').filterProperty('isChecked', true); + if (!this.get('isRetryDisabled')) { + var selectedHosts = this.get('bootHosts').filterProperty('bootStatus', 'FAILED'); + selectedHosts.forEach(function (_host) { + _host.set('bootStatus', 'RUNNING'); + _host.set('bootLog', 'Retrying ...'); + }, this); this.retryHosts(selectedHosts); } }, @@ -258,7 +256,7 @@ App.WizardStep3Controller = Em.Controller.extend({ //TODO: uncomment following line after the hook up with the API call console.log('stopBootstrap() called'); // this.set('isSubmitDisabled',false); - Ember.run.later(this, function(){ + Ember.run.later(this, function () { this.startRegistration(); }, 1000); }, @@ -416,7 +414,7 @@ App.WizardStep3Controller = Em.Controller.extend({ var self = this; var button = $(this.get('element')).find('.textTrigger'); button.click(function () { - if(self.get('isTextArea')){ + if (self.get('isTextArea')) { $(this).text('click to highlight'); } else { $(this).text('press CTRL+C'); @@ -437,7 +435,7 @@ App.WizardStep3Controller = Em.Controller.extend({ }, isTextArea: false, textArea: Em.TextArea.extend({ - didInsertElement: function(){ + didInsertElement: function () { var element = $(this.get('element')); element.width($(this.get('parentView').get('element')).width() - 10); element.height($(this.get('parentView').get('element')).height()); @@ -445,7 +443,7 @@ App.WizardStep3Controller = Em.Controller.extend({ element.css('resize', 'none'); }, readOnly: true, - value: function(){ + value: function () { return this.get('content'); }.property('content') }) diff --git a/ambari-web/app/routes/installer.js b/ambari-web/app/routes/installer.js index 4cc50577a8..d72e3dad7e 100644 --- a/ambari-web/app/routes/installer.js +++ b/ambari-web/app/routes/installer.js @@ -134,8 +134,7 @@ module.exports = Em.Route.extend({ var installerController = router.get('installerController'); var wizardStep3Controller = router.get('wizardStep3Controller'); installerController.saveConfirmedHosts(wizardStep3Controller); - - + App.db.setSshKey(null); App.db.setBootStatus(true); var displayOrderConfig = require('data/services'); var apiUrl = '/stacks/HDP/version/1.2.0'; diff --git a/ambari-web/app/templates/wizard/step3.hbs b/ambari-web/app/templates/wizard/step3.hbs index 471f99d953..c0ed52b007 100644 --- a/ambari-web/app/templates/wizard/step3.hbs +++ b/ambari-web/app/templates/wizard/step3.hbs @@ -24,7 +24,7 @@ <div class="box"> <div class="box-header"> <div class="button-section"> - <a class="btn btn-primary decommission" {{bindAttr disabled="noHostsSelected"}} + <a class="btn btn-primary decommission" {{bindAttr disabled="isRetryDisabled"}} href="#" {{action retrySelectedHosts target="controller"}}><i class="icon-repeat icon-white"></i> Retry diff --git a/ambari-web/app/utils/db.js b/ambari-web/app/utils/db.js index e611fbbd95..a1247a54e4 100644 --- a/ambari-web/app/utils/db.js +++ b/ambari-web/app/utils/db.js @@ -155,6 +155,12 @@ App.db.setBootStatus = function (status) { localStorage.setObject('ambari', App.db.data); }; +App.db.setSshKey = function (sshKey) { + App.db.data = localStorage.getObject('ambari'); + App.db.data.Installer.sshKey = sshKey; + localStorage.setObject('ambari', App.db.data); +}; + App.db.removeHosts = function (hostInfo) { console.log('TRACE: Entering db:setSoftRepo function'); var hostList = App.db.getHosts(); @@ -334,6 +340,11 @@ App.db.getBootRequestId = function () { return App.db.data.Installer.bootRequestId; }; +App.db.getSshKey = function () { + App.db.data = localStorage.getObject('ambari'); + return App.db.data.Installer.sshKey; +}; + App.db.getService = function () { App.db.data = localStorage.getObject('ambari'); return App.db.data.Installer.serviceInfo; |