Repository: ambari Updated Branches: refs/heads/trunk cc799863d -> 630323d3c
AMBARI-6359. Hosts page : mysterious "selected hosts" keep coming back (alexantonenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/630323d3 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/630323d3 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/630323d3 Branch: refs/heads/trunk Commit: 630323d3ceaac07e7a353c007c47811c3b315cdf Parents: cc79986 Author: Alex Antonenko <[email protected]> Authored: Wed Jul 2 21:11:13 2014 +0300 Committer: Alex Antonenko <[email protected]> Committed: Wed Jul 2 21:11:13 2014 +0300 ---------------------------------------------------------------------- .../ambari_shell/plugins/create_cluster.py | 68 ++--- .../main/python/ambari_shell/plugins/service.py | 250 +++++++++---------- ambari-web/app/models/cluster_states.js | 10 +- 3 files changed, 164 insertions(+), 164 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/630323d3/ambari-shell/ambari-python-shell/src/main/python/ambari_shell/plugins/create_cluster.py ---------------------------------------------------------------------- diff --git a/ambari-shell/ambari-python-shell/src/main/python/ambari_shell/plugins/create_cluster.py b/ambari-shell/ambari-python-shell/src/main/python/ambari_shell/plugins/create_cluster.py index f9947d7..307bf24 100644 --- a/ambari-shell/ambari-python-shell/src/main/python/ambari_shell/plugins/create_cluster.py +++ b/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>']) http://git-wip-us.apache.org/repos/asf/ambari/blob/630323d3/ambari-shell/ambari-python-shell/src/main/python/ambari_shell/plugins/service.py ---------------------------------------------------------------------- diff --git a/ambari-shell/ambari-python-shell/src/main/python/ambari_shell/plugins/service.py b/ambari-shell/ambari-python-shell/src/main/python/ambari_shell/plugins/service.py index d44769a..51fd51c 100644 --- a/ambari-shell/ambari-python-shell/src/main/python/ambari_shell/plugins/service.py +++ b/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 http://git-wip-us.apache.org/repos/asf/ambari/blob/630323d3/ambari-web/app/models/cluster_states.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/cluster_states.js b/ambari-web/app/models/cluster_states.js index 1fdb084..4eab62a 100644 --- a/ambari-web/app/models/cluster_states.js +++ b/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) {
