Explorar o código

AMBARI-10296. UI hard codes OS family mappings causing hostChecks to fail (alexantonenko)

Alex Antonenko %!s(int64=10) %!d(string=hai) anos
pai
achega
72cf909a82

+ 6 - 28
ambari-web/app/controllers/wizard/step3_controller.js

@@ -1107,7 +1107,7 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin, {
           self._setHostDataFromLoadedHostInfo(_host, host);
           var host_name = Em.get(host, 'Hosts.host_name');
 
-          var context = self.checkHostOSType(host.Hosts.os_type, host_name);
+          var context = self.checkHostOSType(host.Hosts.os_family, host_name);
           if (context) {
             hostsContext.push(context);
             hostsRepoNames.push(host_name);
@@ -1195,6 +1195,7 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin, {
       return h.mountpoint != "/boot"
     }));
     host.set('os_type', Em.get(hostInfo, 'Hosts.os_type'));
+    host.set('os_family', Em.get(hostInfo, 'Hosts.os_family'));
     host.set('os_arch', Em.get(hostInfo, 'Hosts.os_arch'));
     host.set('ip', Em.get(hostInfo, 'Hosts.ip'));
     return host;
@@ -1241,16 +1242,15 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin, {
    * @return {string} error-message or empty string
    * @method checkHostOSType
    */
-  checkHostOSType: function (osType, hostName) {
+  checkHostOSType: function (osFamily, hostName) {
     if (this.get('content.stacks')) {
       var selectedStack = this.get('content.stacks').findProperty('isSelected', true);
       var selectedOS = [];
-      var self = this;
       var isValid = false;
       if (selectedStack && selectedStack.get('operatingSystems')) {
         selectedStack.get('operatingSystems').filterProperty('isSelected', true).forEach(function (os) {
           selectedOS.pushObject(os.get('osType'));
-          if (self.repoToAgentOsType(os.get('osType')).indexOf(osType) >= 0) {
+          if (os.get('osType') === osFamily) {
             isValid = true;
           }
         });
@@ -1259,36 +1259,14 @@ App.WizardStep3Controller = Em.Controller.extend(App.ReloadPopupMixin, {
         return '';
       } else {
         console.log('WARNING: Getting host os type does NOT match the user selected os group in step1. ' +
-          'Host Name: ' + hostName + '. Host os type:' + osType + '. Selected group:' + selectedOS.uniq());
-        return Em.I18n.t('installer.step3.hostWarningsPopup.repositories.context').format(hostName, osType, selectedOS.uniq());
+          'Host Name: ' + hostName + '. Host os type:' + osFamily + '. Selected group:' + selectedOS.uniq());
+        return Em.I18n.t('installer.step3.hostWarningsPopup.repositories.context').format(hostName, osFamily, selectedOS.uniq());
       }
     } else {
       return '';
     }
   },
 
-  /**
-   * return the supported agent os types for a repo os type
-   * @param {String} repoType
-   * @return {Array} supported agent os type array
-   * @method repoToAgentOsType
-   */
-  repoToAgentOsType : function (repoType) {
-    /* istanbul ignore next */
-    switch (repoType) {
-      case "redhat6":
-        return ["redhat6", "centos6", "oraclelinux6", "rhel6"];
-      case "redhat5":
-        return ["redhat5", "centos5", "oraclelinux5", "rhel5"];
-      case "suse11":
-        return ["suse11", "sles11", "opensuse11"];
-      case "ubuntu12":
-        return ["debian12", "ubuntu12"];
-      default:
-        return [];
-    }
-  },
-
   /**
    * Check if current host has enough free disk usage.
    * @param {string} hostName

+ 1 - 1
ambari-web/app/utils/ajax/ajax.js

@@ -1784,7 +1784,7 @@ var urls = {
     'mock': '/data/requests/host_check/jdk_check_results.json'
   },
   'wizard.step3.host_info': {
-    'real': '/hosts?fields=Hosts/total_mem,Hosts/cpu_count,Hosts/disk_info,Hosts/last_agent_env,Hosts/host_name,Hosts/os_type,Hosts/os_arch,Hosts/ip',
+    'real': '/hosts?fields=Hosts/total_mem,Hosts/cpu_count,Hosts/disk_info,Hosts/last_agent_env,Hosts/host_name,Hosts/os_type,Hosts/os_arch,Hosts/os_family,Hosts/ip',
     'mock': '/data/wizard/bootstrap/two_hosts_information.json',
     'format': function () {
       return {

+ 2 - 0
ambari-web/test/controllers/wizard/step3_test.js

@@ -2176,6 +2176,7 @@ describe('App.WizardStep3Controller', function () {
             total_mem: 12345,
             os_type: 't1',
             os_arch: 'os1',
+            os_family: 'osf1',
             ip: '0.0.0.0',
             disk_info: [
               {mountpoint: '/boot'},
@@ -2189,6 +2190,7 @@ describe('App.WizardStep3Controller', function () {
       expect(host.get('cpu')).to.equal(2);
       expect(host.get('os_type')).to.equal('t1');
       expect(host.get('os_arch')).to.equal('os1');
+      expect(host.get('os_family')).to.equal('osf1')
       expect(host.get('ip')).to.equal('0.0.0.0');
       expect(host.get('memory')).to.equal('12345.00');
       expect(host.get('disk_info.length')).to.equal(2);