Repository: ambari Updated Branches: refs/heads/trunk 698d030bd -> 0bf26f36e
AMBARI-9101 Kerberos Wizard: Integrate "Test Connectivity" on "Customize Kerberos" page. (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/0bf26f36 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/0bf26f36 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/0bf26f36 Branch: refs/heads/trunk Commit: 0bf26f36e90538cfb23ff01a26a48425f09d267e Parents: 698d030 Author: aBabiichuk <[email protected]> Authored: Tue Jan 13 12:05:51 2015 +0200 Committer: aBabiichuk <[email protected]> Committed: Tue Jan 13 12:05:51 2015 +0200 ---------------------------------------------------------------------- ambari-web/app/assets/data/requests/1.json | 23 +++++ ambari-web/app/config.js | 6 +- .../main/admin/kerberos/step2_controller.js | 32 ++++++ ambari-web/app/data/HDP2/site_properties.js | 1 + ambari-web/app/messages.js | 5 + ambari-web/app/models/service_config.js | 2 + ambari-web/app/routes/add_kerberos_routes.js | 58 +++++++---- .../common/form/check_db_connection.hbs | 4 +- .../app/templates/main/admin/kerberos/step2.hbs | 2 +- ambari-web/app/utils/ajax/ajax.js | 13 ++- ambari-web/app/views/wizard/controls_view.js | 101 +++++++++++++++---- ambari-web/test/models/service_config_test.js | 7 ++ .../test/views/wizard/controls_view_test.js | 8 ++ 13 files changed, 215 insertions(+), 47 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/0bf26f36/ambari-web/app/assets/data/requests/1.json ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/data/requests/1.json b/ambari-web/app/assets/data/requests/1.json new file mode 100644 index 0000000..b012e36 --- /dev/null +++ b/ambari-web/app/assets/data/requests/1.json @@ -0,0 +1,23 @@ +{ + "Tasks": { + "attempt_cnt": 0, + "command": "ACTIONEXECUTE", + "command_detail": "check_host ACTIONEXECUTE", + "end_time": -1, + "exit_code": 999, + "host_name": "dev01.hortonworks.com", + "id": 116, + "request_id": 58, + "role": "check_host", + "stage_id": 1, + "start_time": -1, + "status": "COMPLETED", + "stderr": "", + "stdout": "", + "structured_out": { + "db_connection_check": { + "exit_code": 0 + } + } + } +} http://git-wip-us.apache.org/repos/asf/ambari/blob/0bf26f36/ambari-web/app/config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/config.js b/ambari-web/app/config.js index 4b5f41c..bdecdfd 100644 --- a/ambari-web/app/config.js +++ b/ambari-web/app/config.js @@ -58,12 +58,12 @@ App.healthStatusOrange = '#FF8E00'; App.enableExperimental = false; App.supports = { - preKerberizeCheck: false, preUpgradeCheck: true, stackUpgrade: true, autoRollbackHA: false, - alwaysEnableManagedMySQLForHive: false, - automatedKerberos: false, + alwaysEnableManagedMySQLForHive: true, + preKerberizeCheck: false, + automatedKerberos: true, customizeAgentUserAccount: false, installGanglia: false }; http://git-wip-us.apache.org/repos/asf/ambari/blob/0bf26f36/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js b/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js index 753b8f7..ae0cdff 100644 --- a/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js +++ b/ambari-web/app/controllers/main/admin/kerberos/step2_controller.js @@ -35,6 +35,28 @@ App.KerberosWizardStep2Controller = App.WizardStep7Controller.extend({ addMiscTabToPage: false, + /** + * @type {boolean} true if test conection to hosts is in progress + */ + testConnectionInProgress: false, + + /** + * Should Back-button be disabled + * @type {boolean} + */ + isBackBtnDisabled: function() { + return this.get('testConnectionInProgress'); + }.property('testConnectionInProgress'), + + /** + * Should Next-button be disabled + * @type {boolean} + */ + isSubmitDisabled: function () { + if (!this.get('stepConfigs.length') || this.get('testConnectionInProgress') || this.get('submitButtonClicked')) return true; + return (!this.get('stepConfigs').filterProperty('showConfig', true).everyProperty('errorCount', 0) || this.get("miscModalVisible")); + }.property('[email protected]', 'miscModalVisible', 'submitButtonClicked', 'testConnectionInProgress'), + hostNames: function () { return this.get('content.hosts'); }.property('content.hosts'), @@ -257,6 +279,16 @@ App.KerberosWizardStep2Controller = App.WizardStep7Controller.extend({ }] } }); + }, + + /** + * shows popup with to warn user + * @param primary + */ + showConnectionInProgressPopup: function(primary) { + var primaryText = Em.I18n.t('common.exitAnyway'); + var msg = Em.I18n.t('services.service.config.connection.exitPopup.msg'); + App.showConfirmationPopup(primary, msg, null, null, primaryText) } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/0bf26f36/ambari-web/app/data/HDP2/site_properties.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/data/HDP2/site_properties.js b/ambari-web/app/data/HDP2/site_properties.js index 7a154a3..fd89933 100644 --- a/ambari-web/app/data/HDP2/site_properties.js +++ b/ambari-web/app/data/HDP2/site_properties.js @@ -1998,6 +1998,7 @@ module.exports = "isOverridable": false, "isVisible": true, "isRequiredByAgent": true, + "displayType": "supportTextConnection", "serviceName": "KERBEROS", "filename": "krb5-conf.xml", "category": "KDC", http://git-wip-us.apache.org/repos/asf/ambari/blob/0bf26f36/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index f08c270..42384bc 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -191,6 +191,7 @@ Em.I18n.translations = { 'common.package': 'Package', 'common.proceed': 'Proceed', 'common.proceedAnyway': 'Proceed Anyway', + 'common.exitAnyway': 'Exit Anyway', 'common.process': 'Process', 'common.property': 'Property', 'common.installed': 'Installed', @@ -409,6 +410,8 @@ Em.I18n.translations = { 'installer.controls.slaveComponentGroups':' Groups', 'installer.controls.serviceConfigPopover.title':'{0}<br><small>{1}</small>', + 'installer.controls.checkConnection.popover':'This action will check accessibility of all hosts to Ambari installed {0} host and port ' + + 'and accessibility of Ambari installed {0} host to external {0} host', 'installer.controls.serviceConfigMultipleHosts.other':'1 other', 'installer.controls.serviceConfigMultipleHosts.others':'{0} others', 'installer.controls.serviceConfigMasterHosts.header':'{0} Hosts', @@ -1635,7 +1638,9 @@ Em.I18n.translations = { 'services.service.config.propertyFilterPopover.content':'Enter keywords to filter properties by property name, value, or description.', 'services.service.config.hive.oozie.postgresql': 'Existing PostgreSQL Database', 'services.service.config.database.connection.success': 'Connection OK', + 'services.service.config.database.connection.inProgress': 'Checking connectivity', 'services.service.config.database.connection.failed': 'Connection Failed', + 'services.service.config.connection.exitPopup.msg': 'Test connection is in progress. It\'s recommended to wait until it wil be complete. Are you sure you want to exit Enable Kerberos Wizard?', 'services.service.config.database.btn.idle': 'Test Connection', 'services.service.config.database.btn.connecting': 'Connecting...', 'services.service.config.database.msg.jdbcSetup': 'Be sure you have run:<br/>' + http://git-wip-us.apache.org/repos/asf/ambari/blob/0bf26f36/ambari-web/app/models/service_config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/service_config.js b/ambari-web/app/models/service_config.js index cb1b693..cba475d 100644 --- a/ambari-web/app/models/service_config.js +++ b/ambari-web/app/models/service_config.js @@ -866,6 +866,8 @@ App.ServiceConfigProperty = Em.Object.extend({ return App.ServiceConfigMasterHostsView; case 'slaveHosts': return App.ServiceConfigSlaveHostsView; + case 'supportTextConnection': + return App.checkConnectionView; default: if (this.get('unit')) { return App.ServiceConfigTextFieldWithUnit; http://git-wip-us.apache.org/repos/asf/ambari/blob/0bf26f36/ambari-web/app/routes/add_kerberos_routes.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/add_kerberos_routes.js b/ambari-web/app/routes/add_kerberos_routes.js index 50cb30e..624db82 100644 --- a/ambari-web/app/routes/add_kerberos_routes.js +++ b/ambari-web/app/routes/add_kerberos_routes.js @@ -34,31 +34,39 @@ module.exports = App.WizardRoute.extend({ secondary: null, onClose: function () { - var self = this; - var kerberosProgressPageController = App.router.get('kerberosProgressPageController'); - var controller = App.router.get('kerberosWizardController'); - controller.clearTasksData(); - controller.finish(); - App.router.get('updateController').set('isWorking', true); - if (App.get('testMode')) { - App.router.transitionTo('adminKerberos.index'); - location.reload(); + var step2Controller = router.get('kerberosWizardStep2Controller') + if (step2Controller.get('testConnectionInProgress')) { + step2Controller.showConnectionInProgressPopup(this.exitWizard); + } else { + this.exitWizard(); } - App.clusterStatus.setClusterStatus({ - clusterName: App.router.getClusterName(), - clusterState: 'DEFAULT', - localdb: App.db.data - }, { - alwaysCallback: function () { - self.hide(); - App.router.transitionTo('adminKerberos.index'); - } - }); - }, didInsertElement: function () { this.fitHeight(); - } + }, + + exitWizard: function() { + var self = this; + var kerberosProgressPageController = App.router.get('kerberosProgressPageController'); + var controller = App.router.get('kerberosWizardController'); + controller.clearTasksData(); + controller.finish(); + App.router.get('updateController').set('isWorking', true); + if (App.get('testMode')) { + App.router.transitionTo('adminKerberos.index'); + location.reload(); + } + App.clusterStatus.setClusterStatus({ + clusterName: App.router.getClusterName(), + clusterState: 'DEFAULT', + localdb: App.db.data + }, { + alwaysCallback: function () { + self.hide(); + App.router.transitionTo('adminKerberos.index'); + } + }); + } }); kerberosWizardController.set('popup', popup); var currentClusterStatus = App.clusterStatus.get('value'); @@ -130,7 +138,13 @@ module.exports = App.WizardRoute.extend({ unroutePath: function () { return false; }, - back: Em.Router.transitionTo('step1'), + back: function(router) { + var controller = router.get('kerberosWizardStep2Controller'); + if (!controller.get('isBackBtnDisabled')) { + Em.Router.transitionTo('step1') + } + }, + next: function (router) { var kerberosWizardController = router.get('kerberosWizardController'); var kerberosWizardStep2Controller = router.get('kerberosWizardStep2Controller'); http://git-wip-us.apache.org/repos/asf/ambari/blob/0bf26f36/ambari-web/app/templates/common/form/check_db_connection.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/common/form/check_db_connection.hbs b/ambari-web/app/templates/common/form/check_db_connection.hbs index 1a62242..a044289 100644 --- a/ambari-web/app/templates/common/form/check_db_connection.hbs +++ b/ambari-web/app/templates/common/form/check_db_connection.hbs @@ -22,10 +22,10 @@ <div class="control-group"> <div class="span9"> <span {{bindAttr class=":pull-left :btn :btn-primary view.isBtnDisabled:disabled"}} {{action connectToDatabase target="view"}}>{{view.btnCaption}}</span> - <div {{bindAttr class=":spinner :mll :pull-left view.isConnecting::hide"}}></div> <div class="pull-left connection-result mll"> - <a {{bindAttr class="view.isConnectionSuccess:mute:action view.isRequestResolved::hide"}} {{action showLogsPopup target="view"}}>{{view.responseCaption}}</a> + <a {{bindAttr class="view.isConnectionSuccess:mute:action"}} {{action showLogsPopup target="view"}}>{{view.responseCaption}}</a> </div> + <div {{bindAttr class=":spinner :mll :pull-left view.isConnecting::hide"}}></div> <i {{bindAttr class=":pull-right view.isConnectionSuccess:icon-ok-sign:icon-warning-sign view.isRequestResolved::hide"}}></i> </div> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/0bf26f36/ambari-web/app/templates/main/admin/kerberos/step2.hbs ---------------------------------------------------------------------- diff --git a/ambari-web/app/templates/main/admin/kerberos/step2.hbs b/ambari-web/app/templates/main/admin/kerberos/step2.hbs index c91167b..ebfd35a 100644 --- a/ambari-web/app/templates/main/admin/kerberos/step2.hbs +++ b/ambari-web/app/templates/main/admin/kerberos/step2.hbs @@ -30,7 +30,7 @@ {{/if}} <div class="btn-area"> - <a id="back-kerberos-step2" class="btn" {{action back}}>← {{t common.back}}</a> + <a id="back-kerberos-step2" class="btn" {{bindAttr disabled="isBackBtnDisabled"}} {{action back}}>← {{t common.back}}</a> <a id="submit-kerberos-step2" class="btn btn-success pull-right" {{bindAttr disabled="isSubmitDisabled"}} {{action submit target="controller"}}>{{t common.next}} →</a> </div> http://git-wip-us.apache.org/repos/asf/ambari/blob/0bf26f36/ambari-web/app/utils/ajax/ajax.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js index acf2354..1756a99 100644 --- a/ambari-web/app/utils/ajax/ajax.js +++ b/ambari-web/app/utils/ajax/ajax.js @@ -1404,6 +1404,17 @@ var urls = { 'mock': '/data/stack_versions/pre_upgrade_check.json' }, + 'admin.kerberos_security.test_connection': { + 'real': '/kdc_check/{kdcHostname}', + 'mock': '', + 'format': function (data) { + return { + type: 'POST', + data: JSON.stringify(data) + } + } + }, + 'wizard.advanced_repositories.valid_url': { 'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems/{osType}/repositories/{repoId}', 'mock': '', @@ -1991,7 +2002,7 @@ var urls = { }, 'custom_action.request': { 'real': '/requests/{requestId}/tasks/{taskId}', - 'mock': '', + 'mock': '/data/requests/1.json', 'format': function (data) { return { requestId: data.requestId, http://git-wip-us.apache.org/repos/asf/ambari/blob/0bf26f36/ambari-web/app/views/wizard/controls_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/wizard/controls_view.js b/ambari-web/app/views/wizard/controls_view.js index 4bfefdb..7ac3511 100644 --- a/ambari-web/app/views/wizard/controls_view.js +++ b/ambari-web/app/views/wizard/controls_view.js @@ -553,6 +553,20 @@ App.ServiceConfigMasterHostView = Ember.View.extend(App.ServiceConfigHostPopover }); /** + * text field property view that enables possibility + * for check connectio + * @type {*} + */ +App.checkConnectionView = App.ServiceConfigTextField.extend({ + didInsertElement: function() { + this._super(); + var kdc = this.get('categoryConfigsAll').findProperty('name', 'kdc_type'); + var propertyAppendTo = this.get('categoryConfigsAll').findProperty('name', 'admin_password'); + if (propertyAppendTo) propertyAppendTo.set('additionalView', App.CheckDBConnectionView.extend({databaseName: kdc && kdc.get('value')})); + } +}); + +/** * Show value as plain label in italics * @type {*} */ @@ -826,6 +840,8 @@ App.CheckDBConnectionView = Ember.View.extend({ hostNameProperty: function() { if (!/wizard/i.test(this.get('controller.name')) && this.get('parentView.service.serviceName') === 'HIVE') { return this.get('parentView.service.serviceName').toLowerCase() + '_hostname'; + } else if (this.get('parentView.service.serviceName') === 'KERBEROS') { + return 'kdc_host'; } return '{0}_existing_{1}_host'.format(this.get('parentView.service.serviceName').toLowerCase(), this.get('databaseName').toLowerCase()); }.property('databaseName'), @@ -837,27 +853,32 @@ App.CheckDBConnectionView = Ember.View.extend({ requiredProperties: function() { var propertiesMap = { OOZIE: ['oozie.db.schema.name','oozie.service.JPAService.jdbc.username','oozie.service.JPAService.jdbc.password','oozie.service.JPAService.jdbc.driver','oozie.service.JPAService.jdbc.url'], - HIVE: ['ambari.hive.db.schema.name','javax.jdo.option.ConnectionUserName','javax.jdo.option.ConnectionPassword','javax.jdo.option.ConnectionDriverName','javax.jdo.option.ConnectionURL'] + HIVE: ['ambari.hive.db.schema.name','javax.jdo.option.ConnectionUserName','javax.jdo.option.ConnectionPassword','javax.jdo.option.ConnectionDriverName','javax.jdo.option.ConnectionURL'], + KERBEROS: ['kdc_host'] }; return propertiesMap[this.get('parentView.service.serviceName')]; }.property(), /** @property {Object} propertiesPattern - check pattern according to type of connection properties **/ propertiesPattern: function() { - return { - user_name: /(username|dblogin)$/ig, - user_passwd: /(dbpassword|password)$/ig, - db_connection_url: /jdbc\.url|connectionurl/ig + var patterns = { + db_connection_url: /jdbc\.url|connectionurl|kdc_host/ig + }; + if (this.get('parentView.service.serviceName') != "KERBEROS") { + patterns.user_name = /(username|dblogin)$/ig; + patterns.user_passwd = /(dbpassword|password)$/ig; } - }.property(), + return patterns; + }.property('parentView.service.serviceName'), /** @property {String} masterHostName - host name location of Master Component related to Service **/ masterHostName: function() { var serviceMasterMap = { 'OOZIE': 'oozieserver_host', 'HDFS': 'hadoop_host', - 'HIVE': 'hive_ambari_host' + 'HIVE': 'hive_ambari_host', + 'KERBEROS': 'kdc_host' }; return this.get('parentView.categoryConfigsAll').findProperty('name', serviceMasterMap[this.get('parentView.service.serviceName')]).get('value'); - }.property(), + }.property('parentView.service.serviceName', '[email protected]'), /** @property {Object} connectionProperties - service specific config values mapped for custom action request **/ connectionProperties: function() { var propObj = {}; @@ -882,6 +903,16 @@ App.CheckDBConnectionView = Ember.View.extend({ }.property(), /** Check validation and load ambari properties **/ didInsertElement: function() { + var kdc = this.get('parentView.categoryConfigsAll').findProperty('name', 'kdc_type'); + if (kdc) { + var name = kdc.get('value') == 'Existing MIT KDC' ? 'KDC' : 'Active Directory'; + App.popover(this.$(), { + title: Em.I18n.t('services.service.config.database.btn.idle'), + content: Em.I18n.t('installer.controls.checkConnection.popover').format(name), + placement: 'right', + trigger: 'hover' + }); + } this.handlePropertiesValidation(); this.getAmbariProperties(); }, @@ -960,13 +991,47 @@ App.CheckDBConnectionView = Ember.View.extend({ * @method connectToDatabase **/ connectToDatabase: function() { - if (this.get('isBtnDisabled')) return false; - var self = this; - self.set('isRequestResolved', false); + if (this.get('isBtnDisabled')) return; + this.set('isRequestResolved', false); App.db.set('tmp', this.get('parentView.service.serviceName') + '_connection', {}); this.setConnectingStatus(true); - this.createCustomAction(); + if (App.get('testMode')) { + this.startPolling(); + } else { + this.runCheckConnection(); + } }, + + /** + * runs check connections methods depending on service + * @return {void} + * @method runCheckConnection + */ + runCheckConnection: function() { + if (this.get('parentView.service.serviceName') === 'KERBEROS') { + this.runKDCCheck(); + } else { + this.createCustomAction(); + } + }, + + /** + * send ajax request to perforn kdc host check + * @return {App.ajax} + * @method runKDCCheck + */ + runKDCCheck: function() { + return App.ajax.send({ + name: 'admin.kerberos_security.test_connection', + sender: this, + data: { + kdcHostname: this.get('masterHostName') + }, + success: 'onCreateActionSuccess', + error: 'onCreateActionError' + }); + }, + /** * Run custom action for database connection. * @@ -1030,6 +1095,10 @@ App.CheckDBConnectionView = Ember.View.extend({ getTaskInfoSuccess: function(data) { var task = data.Tasks; + this.set('responseFromServer', { + stderr: task.stderr, + stdout: task.stdout + }); if (task.status === 'COMPLETED') { var structuredOut = task.structured_out.db_connection_check; if (structuredOut.exit_code != 0) { @@ -1045,10 +1114,6 @@ App.CheckDBConnectionView = Ember.View.extend({ } } if (task.status === 'FAILED') { - this.set('responseFromServer', { - stderr: task.stderr, - stdout: task.stdout - }); this.setResponseStatus('failed'); } if (/PENDING|QUEUED|IN_PROGRESS/.test(task.status)) { @@ -1078,9 +1143,9 @@ App.CheckDBConnectionView = Ember.View.extend({ */ setConnectingStatus: function(active) { if (active) { - this.set('responseCaption', null); - this.set('responseFromServer', null); + this.set('responseCaption', Em.I18n.t('services.service.config.database.connection.inProgress')); } + this.set('controller.testConnectionInProgress', !!active); this.set('btnCaption', !!active ? Em.I18n.t('services.service.config.database.btn.connecting') : Em.I18n.t('services.service.config.database.btn.idle')); this.set('isConnecting', !!active); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/0bf26f36/ambari-web/test/models/service_config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/service_config_test.js b/ambari-web/test/models/service_config_test.js index 2b9e458..3c77fd7 100644 --- a/ambari-web/test/models/service_config_test.js +++ b/ambari-web/test/models/service_config_test.js @@ -331,6 +331,13 @@ var serviceConfig, displayType: 'type' }, viewClass: App.ServiceConfigTextField + }, + { + initial: { + unit: false, + displayType: 'supportTextConnection' + }, + viewClass: App.checkConnectionView } ]; http://git-wip-us.apache.org/repos/asf/ambari/blob/0bf26f36/ambari-web/test/views/wizard/controls_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/wizard/controls_view_test.js b/ambari-web/test/views/wizard/controls_view_test.js index 18ed797..a01f6f3 100644 --- a/ambari-web/test/views/wizard/controls_view_test.js +++ b/ambari-web/test/views/wizard/controls_view_test.js @@ -564,6 +564,10 @@ describe('App.CheckDBConnectionView', function () { value: 'h0' }, { + serviceName: 'KERBEROS', + value: 'h1' + }, + { serviceName: 'HIVE', value: 'h2' } @@ -574,6 +578,10 @@ describe('App.CheckDBConnectionView', function () { value: 'h0' }), Em.Object.create({ + name: 'kdc_host', + value: 'h1' + }), + Em.Object.create({ name: 'hive_ambari_host', value: 'h2' })
