Browse Source

AMBARI-3733. Register Host: need to check host OS type if specific os group been selected at Advanced Repo in step1 .(xiwang)

Xi Wang 11 years ago
parent
commit
dfde1a2135

+ 54 - 0
ambari-web/app/controllers/wizard/step3_controller.js

@@ -537,7 +537,10 @@ App.WizardStep3Controller = Em.Controller.extend({
 
   getHostInfoSuccessCallback: function (jsonData) {
     var hosts = this.get('bootHosts');
+    var self = this;
     this.parseWarnings(jsonData);
+    var repoWarnings = [];
+    var hostsContext = [];
     hosts.forEach(function (_host) {
       var host = (App.testMode) ? jsonData.items[0] : jsonData.items.findProperty('Hosts.host_name', _host.name);
       if (App.skipBootstrap) {
@@ -548,10 +551,25 @@ App.WizardStep3Controller = Em.Controller.extend({
         _host.cpu = host.Hosts.cpu_count;
         _host.memory = ((parseInt(host.Hosts.total_mem))).toFixed(2);
         _host.disk_info = host.Hosts.disk_info;
+        _host.os_type = host.Hosts.os_type;
 
+        var context = self.checkHostOSType(host.Hosts.os_type, host.Hosts.host_name);
+        if(context) {
+          hostsContext.push(context);
+        }
         console.log("The value of memory is: " + _host.memory);
       }
     });
+    if (hostsContext.length > 0) { // warning exist
+      var repoWarning = {
+        name: 'Repository for OS not available',
+        hosts: hostsContext,
+        category: 'repositories',
+        onSingleHost: false
+      };
+      repoWarnings.push(repoWarning);
+    }
+    this.set('repoCategoryWarnings', repoWarnings);
     this.set('bootHosts', hosts);
     console.log("The value of hosts: " + JSON.stringify(hosts));
     this.stopRegistration();
@@ -567,6 +585,32 @@ App.WizardStep3Controller = Em.Controller.extend({
     this.set('isRetryDisabled', !this.get('bootHosts').someProperty('bootStatus', 'FAILED'));
   },
 
+  /**
+   * Check if the customized os group contains the registered host os type. If not the repo on that host is invalid.
+   */
+  checkHostOSType: function (osType, hostName) {
+    var selectedStack = this.get('content.stacks').findProperty('isSelected', true);
+    var selectedOS = [];
+    var isValid = false;
+    if (selectedStack && selectedStack.operatingSystems) {
+      selectedStack.get('operatingSystems').filterProperty('selected', true).forEach( function(os) {
+        selectedOS.pushObject(os.osType);
+        if ( os.osType == osType) {
+          isValid = true;
+        }
+      });
+    }
+
+    if (!isValid) {
+      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);
+      return Em.I18n.t('installer.step3.hostWarningsPopup.repositories.context').format(hostName, osType, selectedOS);
+    } else {
+      return null;
+    }
+
+  },
+
   selectCategory: function(event, context){
     this.set('category', event.context);
   },
@@ -921,6 +965,7 @@ App.WizardStep3Controller = Em.Controller.extend({
    */
   hostWarningsPopup: function(event){
     var self = this;
+    var repoCategoryWarnings = this.get('repoCategoryWarnings');
     App.ModalPopup.show({
 
       header: Em.I18n.t('installer.step3.warnings.popup.header'),
@@ -1009,6 +1054,15 @@ App.WizardStep3Controller = Em.Controller.extend({
         content: function () {
           var categoryWarnings = this.get('categoryWarnings');
           return [
+             Ember.Object.create({
+                warnings: repoCategoryWarnings,
+                title: Em.I18n.t('installer.step3.hostWarningsPopup.repositories'),
+                message: Em.I18n.t('installer.step3.hostWarningsPopup.repositories.message'),
+                type: Em.I18n.t('common.issues'),
+                emptyName: Em.I18n.t('installer.step3.hostWarningsPopup.empty.repositories'),
+                action: Em.I18n.t('installer.step3.hostWarningsPopup.action.invalid'),
+                category: 'repositories'
+             }),
              Ember.Object.create({
                warnings: categoryWarnings.filterProperty('category', 'firewall'),
                title: Em.I18n.t('installer.step3.hostWarningsPopup.firewall'),

+ 7 - 0
ambari-web/app/messages.js

@@ -348,6 +348,8 @@ Em.I18n.translations = {
   'installer.step3.hosts.remove.popup.body':'Are you sure you want to remove the selected host(s)?',
   'installer.step3.hostInformation.popup.header':'Error in retrieving host Information',
   'installer.step3.hostInformation.popup.body' : 'All bootstrapped hosts registered but unable to retrieve cpu and memory related information',
+  'installer.step3.hostOsTypeCheck.popup.body' : 'Host registered successfully, but the host operating system type NOT match the selected group in step 1:Advanced Repository Option.<br> You can go back to step 1 OR remove this host. <br>' +
+    'The host type is {0}, but you selected group {1} in step 1.',
   'installer.step3.hostWarningsPopup.report':'Show Report',
   'installer.step3.hostWarningsPopup.report.header': '<p style="font-family: monospace">######################################<br># Host Checks Report<br>#<br># Generated: ',
   'installer.step3.hostWarningsPopup.report.hosts': '<br>######################################<br><br>######################################<br># Hosts<br>#<br># A space delimited list of hosts which have issues.<br># Provided so that administrators can easily copy hostnames into scripts, email etc.<br>######################################<br>HOSTS<br>',
@@ -364,6 +366,9 @@ Em.I18n.translations = {
     '<div class="alert alert-warn"><b>Note</b>: To clean up in interactive mode, remove <b>--silent</b> option. To clean up all resources, including <i>users</i>, remove <b>--skip=users</b> option. Use <b>--help</b> for a list of available options.</div>',
   'installer.step3.hostWarningsPopup.summary':'{0} on {1}',
   'installer.step3.hostWarningsPopup.firewall':'Firewall Issues',
+  'installer.step3.hostWarningsPopup.repositories':'Repositories Issues',
+  'installer.step3.hostWarningsPopup.repositories.context':'Host ({0}) has a {1} OS type, But the repositories chosen in "Select Stack" step was {2}.',
+  'installer.step3.hostWarningsPopup.repositories.message':'The following registered hosts have different Operating System types from the local repositories chosen in "Select Stack" step. You can go back to "Select Stack" step to select another os group OR remove related host.',
   'installer.step3.hostWarningsPopup.firewall.message':'Firewall is running on the following hosts. Please configure the firewall to allow communications on the ports documented in the <i>Configuring Ports</i> section of  the <a target=\"_blank\" href=\"http://incubator.apache.org/ambari/current/installing-hadoop-using-ambari/content/\">Ambari documentation</a>',
   'installer.step3.hostWarningsPopup.firewall.name':'<i>iptables</i> Running',
   'installer.step3.hostWarningsPopup.process':'Process Issues',
@@ -389,10 +394,12 @@ Em.I18n.translations = {
   'installer.step3.hostWarningsPopup.empty.services':'unwanted services',
   'installer.step3.hostWarningsPopup.empty.misc':'issues',
   'installer.step3.hostWarningsPopup.empty.firewall':'firewalls running',
+  'installer.step3.hostWarningsPopup.empty.repositories':'repositories OS type mis-match with registered hosts',
   'installer.step3.hostWarningsPopup.action.exists':'Exists on',
   'installer.step3.hostWarningsPopup.action.notRunning':'Not running on',
   'installer.step3.hostWarningsPopup.action.installed':'Installed on',
   'installer.step3.hostWarningsPopup.action.running':'Running on',
+  'installer.step3.hostWarningsPopup.action.invalid':'Invalid on',
   'installer.step3.hostWarningsPopup.host':'host',
   'installer.step3.hostWarningsPopup.hosts':'hosts',
   'installer.step3.hostWarningsPopup.moreHosts':'{0} more hosts...<br>Click on link to view all hosts.',

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

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

+ 2 - 2
ambari-web/app/views/wizard/step3_view.js

@@ -50,7 +50,7 @@ App.WizardStep3View = Em.View.extend({
       this.set('status', 'alert-warn');
       this.set('linkText', '');
       this.set('message', Em.I18n.t('installer.step3.warnings.missingHosts'));
-    } else if (this.get('controller.isHostHaveWarnings')) {
+    } else if (this.get('controller.isHostHaveWarnings') || this.get('controller.repoCategoryWarnings.length')) {
       this.set('status', 'alert-warn');
       this.set('linkText', Em.I18n.t('installer.step3.warnings.linkText'));
       this.set('message', Em.I18n.t('installer.step3.warnings.fails').format(hosts.length - failedHosts));
@@ -70,7 +70,7 @@ App.WizardStep3View = Em.View.extend({
         this.set('message', Em.I18n.t('installer.step3.warnings.someWarnings').format((hosts.length-failedHosts), failedHosts));
       }
     }
-  }.observes('controller.isHostHaveWarnings', 'controller.bootHosts.@each.bootStatus')
+  }.observes('controller.isHostHaveWarnings', 'controller.bootHosts.@each.bootStatus', 'controller.repoCategoryWarnings')
 });
 
 //todo: move it inside WizardStep3View