Ver Fonte

AMBARI-17358. After switching to external database in hive, user should be allowed to delete mysql server (alexantonenko)

Alex Antonenko há 9 anos atrás
pai
commit
d1da45b8c8

+ 1 - 1
ambari-web/app/models/stack_service_component.js

@@ -103,7 +103,7 @@ App.StackServiceComponent = DS.Model.extend({
   /** @property {Boolean} isDeletable - component supports delete action **/
   isDeletable: function() {
     var ignored = [];
-    return this.get('isAddableToHost') && !ignored.contains(this.get('componentName'));
+    return (this.get('isAddableToHost') && !ignored.contains(this.get('componentName'))) || (this.get('componentName') == 'MYSQL_SERVER');
   }.property('componentName'),
 
   /** @property {Boolean} isShownOnInstallerAssignMasterPage - component visible on "Assign Masters" step of Install Wizard **/

+ 12 - 0
ambari-web/app/routes/main.js

@@ -216,9 +216,21 @@ module.exports = Em.Route.extend(App.RouterRedirections, {
         connectOutlets: function (router, context) {
           router.get('mainController').dataLoading().done(function() {
             var controller = router.get('mainHostDetailsController');
+            var tags =[{
+            	siteName: 'hive-env'
+            	}];
             if ( App.Service.find().mapProperty('serviceName').contains('OOZIE')) {
               controller.loadConfigs('loadOozieConfigs');
               controller.isOozieConfigLoaded.always(function () {
+                if(App.Service.find().mapProperty('serviceName').contains('HIVE')){
+                  App.router.get('configurationController').getConfigsByTags(tags).always(function () {
+            	    controller.connectOutlet('mainHostSummary');
+            	  });
+            	} else
+            	  controller.connectOutlet('mainHostSummary');  
+              });
+            } else if(App.Service.find().mapProperty('serviceName').contains('HIVE')) {
+              App.router.get('configurationController').getConfigsByTags(tags).always(function () {
                 controller.connectOutlet('mainHostSummary');
               });
             } else {

+ 8 - 0
ambari-web/app/views/main/host/details/host_component_view.js

@@ -192,6 +192,14 @@ App.HostComponentView = Em.View.extend({
   isDeleteComponentDisabled: function () {
     var stackComponentCount = App.StackServiceComponent.find(this.get('hostComponent.componentName')).get('minToInstall');
     var installedCount = App.HostComponent.getCount(this.get('hostComponent.componentName'), 'totalCount');
+    if(this.get('hostComponent.componentName') == 'MYSQL_SERVER' && this.get('hostComponent.serviceDisplayName') == 'Hive') {
+      var db_type=App.db.getConfigs().findProperty('type','hive-env').properties['hive_database'];
+      var status=[App.HostComponentStatus.stopped, App.HostComponentStatus.unknown, App.HostComponentStatus.install_failed, App.HostComponentStatus.upgrade_failed, App.HostComponentStatus.init].contains(this.get('workStatus'));
+      if(db_type.indexOf('Existing') > -1 && status)
+        return false;
+      else
+    	return true;
+    }    
     return (installedCount <= stackComponentCount)
       || ![App.HostComponentStatus.stopped, App.HostComponentStatus.unknown, App.HostComponentStatus.install_failed, App.HostComponentStatus.upgrade_failed, App.HostComponentStatus.init].contains(this.get('workStatus'));
   }.property('workStatus'),

+ 2 - 1
ambari-web/test/models/stack_service_component_test.js

@@ -292,7 +292,8 @@ var componentPropertiesValidationTests = [
   {
     componentName: 'MYSQL_SERVER',
     expected: {
-      isShownOnInstallerAssignMasterPage: false
+      isShownOnInstallerAssignMasterPage: false,
+      isDeletable: true
     }
   }
 ];

+ 18 - 1
ambari-web/test/views/main/host/details/host_component_view_test.js

@@ -107,7 +107,15 @@ describe('App.HostComponentView', function() {
   App.TestAliases.testAsComputedEqual(getView(), 'isActive', 'content.passiveState', 'OFF');
 
   describe('#isDeleteComponentDisabled', function() {
-
+    var configs=[
+    {
+      properties: {
+        'hive_database': 'Existing MYSQL Database'
+      },
+      tag: 'version2',
+      type: 'hive-env'
+    }
+    ];
     beforeEach(function() {
       this.mock = sinon.stub(App.StackServiceComponent, 'find');
       sinon.stub(App.HostComponent, 'getCount').returns(1);
@@ -137,6 +145,15 @@ describe('App.HostComponentView', function() {
       hostComponentView.propertyDidChange('isDeleteComponentDisabled');
       expect(hostComponentView.get('isDeleteComponentDisabled')).to.be.true;
     });
+    
+    it('delete is enabled because mysql server is stopped and hive is using external database', function() {
+      App.db.setConfigs(configs);
+      this.mock.returns(Em.Object.create({minToInstall: 0}));
+      hostComponentView.get('hostComponent').set('componentName', 'MYSQL_SERVER');
+      hostComponentView.get('hostComponent').set('workStatus', 'STOPPED');
+      hostComponentView.propertyDidChange('isDeleteComponentDisabled');
+      expect(hostComponentView.get('isDeleteComponentDisabled')).to.be.true;
+    });
   });
 
   describe('#componentTextStatus', function() {