فهرست منبع

AMBARI-6359. Hosts page : mysterious "selected hosts" keep coming back (alexantonenko)

Alex Antonenko 11 سال پیش
والد
کامیت
630323d3ce

+ 34 - 34
ambari-shell/ambari-python-shell/src/main/python/ambari_shell/plugins/create_cluster.py

@@ -1,34 +1,34 @@
-#!/usr/bin/env python
-#
-#  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.
-
-
-import logging
-import textwrap
-
-
-LOG = logging.getLogger(__name__)
-
-
-def do_create_cluster(self, line):
-    #  logging = self.LOG
-    print "TODO"
-    self.prompt = "ambari>"
-
-
-def help_create_cluster(self):
-    print '\n'.join([' Usage:', '     create_cluster <cluster_name>'])
+#!/usr/bin/env python
+#
+#  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.
+
+
+import logging
+import textwrap
+
+
+LOG = logging.getLogger(__name__)
+
+
+def do_create_cluster(self, line):
+    #  logging = self.LOG
+    print "TODO"
+    self.prompt = "ambari>"
+
+
+def help_create_cluster(self):
+    print '\n'.join([' Usage:', '     create_cluster <cluster_name>'])

+ 125 - 125
ambari-shell/ambari-python-shell/src/main/python/ambari_shell/plugins/service.py

@@ -1,125 +1,125 @@
-#!/usr/bin/env python
-#
-#  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.
-
-
-import logging
-import textwrap
-
-
-LOG = logging.getLogger(__name__)
-
-
-def do_start_service(self, service):
-    if not service:
-        self.help_stop_service()
-        return None
-    clustername = self.global_shell_config['clustername']
-    if not clustername:
-        print("Error! No cluster currently selected")
-        return None
-
-    if self.t_service_action(service=service, action="start"):
-        print("%s is being started" % (service))
-    else:
-        print("Error! cannot start service")
-    return
-
-
-def do_stop_service(self, service):
-    if not service:
-        self.help_start_service()
-        return None
-
-    clustername = self.global_shell_config['clustername']
-    if not clustername:
-        print("Error! No cluster currently selected")
-        return None
-
-    if self.t_service_action(service=service, action="stop"):
-        print("%s is being stopped" % (service))
-    else:
-        print("Error! cannot stop service")
-        return
-
-
-def help_stop_service(self):
-    print textwrap.dedent("""
-    Usage:
-        > stop_service <service_name>
-    """)
-
-
-def help_start_service(self):
-    print textwrap.dedent("""
-    Usage:
-        > start_service <service_name>
-    """)
-
-
-def complete_start_service(self, pattern, line, start_index, end_index):
-    return self.services_complete(pattern, line, start_index, end_index)
-
-
-def complete_stop_service(self, pattern, line, start_index, end_index):
-    client = self.global_shell_config['client']
-    clustername = self.global_shell_config['clustername']
-    if not clustername:
-        return None
-    else:
-        if not self.SERVICES:
-            services = [
-                s.service_name for s in client.get_cluster(clustername).get_all_services()]
-            self.SERVICES = services
-
-    if pattern:
-        return [s for s in self.SERVICES if s.startswith(pattern)]
-    else:
-        return self.SERVICES
-
-
-def services_complete(self, pattern, line, start_index, end_index, append=[]):
-    client = self.global_shell_config['client']
-    clustername = self.global_shell_config['clustername']
-    if not clustername:
-        return None
-    else:
-        if not self.SERVICES:
-            services = [
-                s.service_name for s in client.get_cluster(clustername).get_all_services()]
-            self.SERVICES = services
-
-    if pattern:
-        return [s for s in self.SERVICES + append if s.startswith(pattern)]
-    else:
-        return self.SERVICES + append
-
-
-def t_service_action(self, service, action):
-    try:
-        client = self.global_shell_config['client']
-        cluster = self.global_shell_config['clustername']
-        service = client.get_cluster(cluster).get_service(service)
-    except Exception:
-        print("Service not found")
-        return None
-
-    if action == "start":
-        service.start(message='started by Ambari python CLI')
-    if action == "stop":
-        service.stop(message='stopped by Ambari python CLI')
-    return True
+#!/usr/bin/env python
+#
+#  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.
+
+
+import logging
+import textwrap
+
+
+LOG = logging.getLogger(__name__)
+
+
+def do_start_service(self, service):
+    if not service:
+        self.help_stop_service()
+        return None
+    clustername = self.global_shell_config['clustername']
+    if not clustername:
+        print("Error! No cluster currently selected")
+        return None
+
+    if self.t_service_action(service=service, action="start"):
+        print("%s is being started" % (service))
+    else:
+        print("Error! cannot start service")
+    return
+
+
+def do_stop_service(self, service):
+    if not service:
+        self.help_start_service()
+        return None
+
+    clustername = self.global_shell_config['clustername']
+    if not clustername:
+        print("Error! No cluster currently selected")
+        return None
+
+    if self.t_service_action(service=service, action="stop"):
+        print("%s is being stopped" % (service))
+    else:
+        print("Error! cannot stop service")
+        return
+
+
+def help_stop_service(self):
+    print textwrap.dedent("""
+    Usage:
+        > stop_service <service_name>
+    """)
+
+
+def help_start_service(self):
+    print textwrap.dedent("""
+    Usage:
+        > start_service <service_name>
+    """)
+
+
+def complete_start_service(self, pattern, line, start_index, end_index):
+    return self.services_complete(pattern, line, start_index, end_index)
+
+
+def complete_stop_service(self, pattern, line, start_index, end_index):
+    client = self.global_shell_config['client']
+    clustername = self.global_shell_config['clustername']
+    if not clustername:
+        return None
+    else:
+        if not self.SERVICES:
+            services = [
+                s.service_name for s in client.get_cluster(clustername).get_all_services()]
+            self.SERVICES = services
+
+    if pattern:
+        return [s for s in self.SERVICES if s.startswith(pattern)]
+    else:
+        return self.SERVICES
+
+
+def services_complete(self, pattern, line, start_index, end_index, append=[]):
+    client = self.global_shell_config['client']
+    clustername = self.global_shell_config['clustername']
+    if not clustername:
+        return None
+    else:
+        if not self.SERVICES:
+            services = [
+                s.service_name for s in client.get_cluster(clustername).get_all_services()]
+            self.SERVICES = services
+
+    if pattern:
+        return [s for s in self.SERVICES + append if s.startswith(pattern)]
+    else:
+        return self.SERVICES + append
+
+
+def t_service_action(self, service, action):
+    try:
+        client = self.global_shell_config['client']
+        cluster = self.global_shell_config['clustername']
+        service = client.get_cluster(cluster).get_service(service)
+    except Exception:
+        print("Service not found")
+        return None
+
+    if action == "start":
+        service.start(message='started by Ambari python CLI')
+    if action == "stop":
+        service.stop(message='stopped by Ambari python CLI')
+    return True

+ 5 - 5
ambari-web/app/models/cluster_states.js

@@ -143,10 +143,12 @@ App.clusterStatus = Em.Object.create(App.UserPref, {
         // restore HAWizard data if process was started
         var isHAWizardStarted = App.get('isAdmin') && !App.isEmptyObject(response.localdb.HighAvailabilityWizard);
         if (params.data.overrideLocaldb || isHAWizardStarted) {
+          var localdbTables = (App.db.data.app && App.db.data.app.tables) ? App.db.data.app.tables : {};
           App.db.data = response.localdb;
           App.db.setLocalStorage();
           App.db.setUser(params.data.user);
           App.db.setLoginName(params.data.login);
+          App.db.data.app.tables = localdbTables;
         }
       }
     }
@@ -189,7 +191,6 @@ App.clusterStatus = Em.Object.create(App.UserPref, {
     if (App.get('testMode')) return false;
     var user = App.db.getUser();
     var login = App.db.getLoginName();
-    var displayLength = App.db.data.app.tables.displayLength;
     var val = {clusterName: this.get('clusterName')};
     if (newValue) {
       App.db.cleanTmp();
@@ -213,18 +214,17 @@ App.clusterStatus = Em.Object.create(App.UserPref, {
           delete newValue.localdb.app.user;
         if (newValue.localdb.app && newValue.localdb.app.loginName)
           delete newValue.localdb.app.loginName;
-        if (newValue.localdb.app && newValue.localdb.app.tables && newValue.localdb.app.tables.displayLength)
-          delete newValue.localdb.app.tables.displayLength;
+        if (newValue.localdb.app && newValue.localdb.app.tables)
+          delete newValue.localdb.app.tables;
         this.set('localdb', newValue.localdb);
         val.localdb = newValue.localdb;
       } else {
         delete App.db.data.app.user;
         delete App.db.data.app.loginName;
-        delete App.db.data.app.tables.displayLength;
+        delete App.db.data.app.tables;
         val.localdb = App.db.data;
         App.db.setUser(user);
         App.db.setLoginName(login);
-        App.db.data.app.tables.displayLength = displayLength;
       }
 
       if (opt) {