ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lpus...@apache.org
Subject [09/38] ambari git commit: AMBARI-21929. UI task for Host Recovery. (Ishan via Jaimin)
Date Thu, 14 Sep 2017 14:38:45 GMT
AMBARI-21929. UI task for Host Recovery. (Ishan via Jaimin)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/bb4645f7
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/bb4645f7
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/bb4645f7

Branch: refs/heads/feature-branch-AMBARI-21307
Commit: bb4645f7c0e8242a397b192cabd326bef0d99700
Parents: 9316ea8
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Tue Sep 12 11:13:39 2017 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Tue Sep 12 11:13:39 2017 -0700

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host/details.js | 143 +++++++++++++++++++
 ambari-web/app/messages.js                      |   8 ++
 ambari-web/app/templates/main/host/details.hbs  |   3 +
 .../main/host/details/recoverHostErrorPopup.hbs |  23 +++
 .../main/host/details/recoverHostPopup.hbs      |  22 +++
 5 files changed, 199 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/bb4645f7/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js
index cf223d7..ad2ac98 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -3101,5 +3101,148 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
     } else {
       this.set('isConfigsLoadingInProgress', false);
     }
+  },
+  
+  recoverHost: function() {
+    var components = this.get('content.hostComponents');
+    var hostName = this.get('content.publicHostName');
+    var self = this;
+    var batches = [
+      {
+        "order_id": 1,
+        "type": "PUT",
+        "uri": App.get('apiPrefix') + "/clusters/" + App.get('clusterName') + "/hosts/" +
hostName + "/host_components",
+        "RequestBodyInfo": {
+          "RequestInfo": {
+            context: Em.I18n.t('hosts.host.recover.initAllComponents.context'),
+            operation_level: {
+              level: "HOST",
+              cluster_name: App.get('clusterName'),
+              host_name: hostName
+            },
+            query: "HostRoles/component_name.in(" + components.mapProperty('componentName').join(',')
+ ")"
+          },
+          "Body": {
+            HostRoles: {
+              state: "INIT"
+            }
+          }
+        }
+    }];
+    batches.push(
+      {
+        "order_id": 2,
+        "type": "PUT",
+        "uri": App.get('apiPrefix') + "/clusters/" + App.get('clusterName') + "/hosts/" +
hostName + "/host_components",
+        "RequestBodyInfo": {
+          "RequestInfo": {
+            context: Em.I18n.t('hosts.host.recover.installAllComponents.context'),
+            operation_level: {
+              level: "HOST",
+              cluster_name: App.get('clusterName'),
+              host_name: hostName
+            },
+            query: "HostRoles/component_name.in(" + components.mapProperty('componentName').join(',')
+ ")"
+          },
+          "Body": {
+            HostRoles: {
+              state: "INSTALLED"
+            }
+          }
+        }
+    });
+
+    if(App.get('isKerberosEnabled')) {
+      batches.push({
+        "order_id": 3,
+        "type": "PUT",
+        "uri": App.get('apiPrefix') + "/clusters/" + App.get('clusterName'),
+        "RequestBodyInfo": {
+          "RequestInfo": {
+            context: Em.I18n.t('hosts.host.recover.regenerateKeytabs.context'),
+            query: "regenerate_keytabs=all&regenerate_hosts=" + hostName + "&ignore_config_updates=true",
+          },
+          "Body": {
+            Clusters: {
+             security_type: "KERBEROS"
+            }
+          }
+        }
+      });
+    }
+    App.get('router.mainAdminKerberosController').getSecurityType(function () {
+      App.get('router.mainAdminKerberosController').getKDCSessionState(function () {
+        self._doRecoverHost(batches);
+      });
+    });
+  },
+
+  _doRecoverHost: function (batches) {
+    App.ajax.send ({
+      name: 'common.batch.request_schedules',
+      sender: this,
+      data: {
+        intervalTimeSeconds: 1,
+        tolerateSize: 0,
+        batches: batches
+      },
+      success:'recoverHostSuccessCallback',
+      showLoadingPopup: true
+    });
+  },
+
+  recoverHostSuccessCallback: function (data) {
+    if (data && (data.Requests || data.resources[0].RequestSchedule)) {
+      this.showBackgroundOperationsPopup();
+      return true;
+    } else {
+      return false;
+    }
+  },
+
+  recoverHostDisabled: function() {
+
+    var isDisabled = false;
+    var allowedStates = [App.HostComponentStatus.stopped, App.HostComponentStatus.install_failed,
App.HostComponentStatus.init];
+    this.get('content.hostComponents').forEach(function (component) {
+      isDisabled = isDisabled ? true : !allowedStates.contains(component.get('workStatus'));
+    });
+    return isDisabled;
+  }.property('content.hostComponents.@each.workStatus'),
+
+  confirmRecoverHost: function() {
+    var self = this;
+    var componentsNotStopped = [];
+    var allowedStates = [App.HostComponentStatus.stopped, App.HostComponentStatus.install_failed,
App.HostComponentStatus.init];
+    this.get('content.hostComponents').forEach(function (component) {
+      if(!allowedStates.contains(component.get('workStatus'))) {
+        componentsNotStopped.push(component.get('componentName'));
+      }
+    });
+    if(componentsNotStopped.length) {
+      App.ModalPopup.show({
+        header: Em.I18n.t('hosts.recover.error.popup.title'),
+        recoverErrorPopupBody: Em.I18n.t('hosts.recover.error.popup.body').format(componentsNotStopped.toString()),
+        componentsStr: componentsNotStopped.toString(),
+        bodyClass: Em.View.extend({
+          templateName: require('templates/main/host/details/recoverHostErrorPopup')
+        }),
+        secondary: false
+      });
+    } else {
+      App.ModalPopup.show({
+        header: Em.I18n.t('hosts.recover.popup.title'),
+        bodyClass: Em.View.extend({
+          templateName: require('templates/main/host/details/recoverHostPopup')
+        }),
+        primary: Em.I18n.t('yes'),
+        secondary: Em.I18n.t('no'),
+        onPrimary: function () {
+          self.recoverHost();
+          this.hide();
+        }
+      });
+    }
   }
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/bb4645f7/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index bda8228..869608a 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -2697,6 +2697,7 @@ Em.I18n.translations = {
   'hosts.host.details.refreshConfigs':'Refresh configs',
   'hosts.host.details.for.postfix':'{0} for host',
   'hosts.host.details.setRackId':'Set Rack',
+  'hosts.host.details.recoverHost': 'Recover Host',
   'host.host.details.installClients': 'Install clients',
   'host.host.details.reinstallClients': 'Reinstall clients',
   'host.host.details.checkHost': 'Check host',
@@ -2762,6 +2763,9 @@ Em.I18n.translations = {
   'hosts.host.maintainance.stopAllComponents.context': 'Stop All Host Components',
   'hosts.host.maintainance.startAllComponents.context': 'Start All Host Components',
   'hosts.host.maintainance.reinstallFailedComponents.context': 'Reinstall Failed Components',
+  'hosts.host.recover.initAllComponents.context': 'Init All Host Components',
+  'hosts.host.recover.installAllComponents.context': 'Install All Host Components',
+  'hosts.host.recover.regenerateKeytabs.context': 'Regenerate keytabs',
   'hosts.host.alerts.st':'&nbsp;!&nbsp;',
   'hosts.decommission.popup.body':'Are you sure?',
   'hosts.decommission.popup.header':'Confirmation',
@@ -2777,6 +2781,10 @@ Em.I18n.translations = {
   'hosts.delete.popup.header':'Confirmation',
   'hosts.delete.popup.title':'Delete Host',
   'hosts.delete.popup.unknownComponents':'The following components have unknown status:',
+  'hosts.recover.popup.title': 'Confirmation',
+  'hosts.recover.popup.body': 'This action will completely re-install all components on this
host, and should only be used when restoring a host using replacement hardware. <strong>Are
you sure you want to continue?<strong>',
+  'hosts.recover.error.popup.title': 'Cannot Recover Host',
+  'hosts.recover.error.popup.body': 'Host cannot be recovered unless every host component
is not in Stopped, Install Failed or Init state',
   'hosts.cant.do.popup.title':'Unable to Delete Host',
   'hosts.cant.do.popup.masterList.body':'This host cannot be deleted since it has the following
master components:',
   'hosts.cant.do.popup.masterList.body.end':'To delete this host, you must first move all
the master components listed above.',

http://git-wip-us.apache.org/repos/asf/ambari/blob/bb4645f7/ambari-web/app/templates/main/host/details.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/details.hbs b/ambari-web/app/templates/main/host/details.hbs
index bd75f5c..15b0f4a 100644
--- a/ambari-web/app/templates/main/host/details.hbs
+++ b/ambari-web/app/templates/main/host/details.hbs
@@ -65,6 +65,9 @@
                   </div>
                 </li>
               {{/if}}
+              <li>
+                <a {{action "confirmRecoverHost" target="controller"}}><i class="icon-time"></i>
{{t hosts.host.details.recoverHost}} </a>
+              </li>
             </ul>
           </div>
         </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/bb4645f7/ambari-web/app/templates/main/host/details/recoverHostErrorPopup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/details/recoverHostErrorPopup.hbs b/ambari-web/app/templates/main/host/details/recoverHostErrorPopup.hbs
new file mode 100644
index 0000000..1152801
--- /dev/null
+++ b/ambari-web/app/templates/main/host/details/recoverHostErrorPopup.hbs
@@ -0,0 +1,23 @@
+{{!
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+}}
+
+<div class="dialog-delete-component">
+  <div class="warning">
+    <i class="icon-warning-sign"></i> {{recoverErrorPopupBody}}
+  </div>
+</div>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/bb4645f7/ambari-web/app/templates/main/host/details/recoverHostPopup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/details/recoverHostPopup.hbs b/ambari-web/app/templates/main/host/details/recoverHostPopup.hbs
new file mode 100644
index 0000000..2534bc6
--- /dev/null
+++ b/ambari-web/app/templates/main/host/details/recoverHostPopup.hbs
@@ -0,0 +1,22 @@
+{{!
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+}}
+
+
+<div class="alert">
+  {{t hosts.recover.popup.body}}
+</div>


Mime
View raw message