ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject ambari git commit: AMBARI-13694 Code to read keysdir cannot handle space in the front (dsen)
Date Tue, 03 Nov 2015 14:54:38 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk f24058f79 -> b5406c597


AMBARI-13694 Code to read keysdir cannot handle space in the front (dsen)


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

Branch: refs/heads/trunk
Commit: b5406c597f2b7bf83a070fd6f0c69a233a2e1064
Parents: f24058f
Author: Dmytro Sen <dsen@apache.org>
Authored: Tue Nov 3 11:43:59 2015 +0200
Committer: Dmytro Sen <dsen@apache.org>
Committed: Tue Nov 3 16:54:23 2015 +0200

----------------------------------------------------------------------
 ambari-agent/conf/unix/ambari-agent             |  3 ++
 .../main/python/ambari_agent/AmbariConfig.py    |  4 +-
 .../test/python/ambari_agent/TestActionQueue.py |  3 --
 .../python/ambari_agent/TestAmbariConfig.py     | 47 ++++++++++++++++++++
 4 files changed, 51 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b5406c59/ambari-agent/conf/unix/ambari-agent
----------------------------------------------------------------------
diff --git a/ambari-agent/conf/unix/ambari-agent b/ambari-agent/conf/unix/ambari-agent
index ea59216..c1e7fe7 100755
--- a/ambari-agent/conf/unix/ambari-agent
+++ b/ambari-agent/conf/unix/ambari-agent
@@ -59,6 +59,9 @@ if [ "$EUID" -ne 0 ] ; then
 fi
 
 keysdir=$(awk -F "=" '/keysdir/ {print $2}' /etc/ambari-agent/conf/ambari-agent.ini)
+# trim spaces
+keysdir=${keysdir// }
+keysdir=${keysdir%% }
 
 change_files_permissions() {
     if [ ! -z "$keysdir" ]; then

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5406c59/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py b/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py
index 03e14ad..2c82ca5 100644
--- a/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py
+++ b/ambari-agent/src/main/python/ambari_agent/AmbariConfig.py
@@ -140,8 +140,6 @@ pidPathVars = [
 ]
 
 
-
-
 class AmbariConfig:
   TWO_WAY_SSL_PROPERTY = "security.server.two_way_ssl"
   AMBARI_PROPERTIES_CATEGORY = 'agentConfig'
@@ -159,7 +157,7 @@ class AmbariConfig:
 
   def get(self, section, value, default=None):
     try:
-      return self.config.get(section, value)
+      return str(self.config.get(section, value)).strip()
     except ConfigParser.Error, err:
       if default != None:
         return default

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5406c59/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py b/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
index a583131..10bfe1a 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
@@ -24,7 +24,6 @@ from ambari_agent.LiveStatus import LiveStatus
 from ambari_agent.ActionQueue import ActionQueue
 from ambari_agent.AmbariConfig import AmbariConfig
 import os, errno, time, pprint, tempfile, threading
-import StringIO
 import sys
 from threading import Thread
 import copy
@@ -33,10 +32,8 @@ from mock.mock import patch, MagicMock, call
 from ambari_agent.StackVersionsFileHandler import StackVersionsFileHandler
 from ambari_agent.CustomServiceOrchestrator import CustomServiceOrchestrator
 from ambari_agent.PythonExecutor import PythonExecutor
-from ambari_agent.CommandStatusDict import CommandStatusDict
 from ambari_agent.ActualConfigHandler import ActualConfigHandler
 from ambari_agent.RecoveryManager import RecoveryManager
-from ambari_agent.FileCache import FileCache
 from ambari_commons import OSCheck
 from only_for_platform import not_for_platform, os_distro_value, PLATFORM_WINDOWS, PLATFORM_LINUX
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b5406c59/ambari-agent/src/test/python/ambari_agent/TestAmbariConfig.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestAmbariConfig.py b/ambari-agent/src/test/python/ambari_agent/TestAmbariConfig.py
new file mode 100644
index 0000000..78f29fe
--- /dev/null
+++ b/ambari-agent/src/test/python/ambari_agent/TestAmbariConfig.py
@@ -0,0 +1,47 @@
+#!/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.
+'''
+
+from unittest import TestCase
+from ambari_agent.AmbariConfig import AmbariConfig
+import sys
+
+import logging
+
+class TestAmbariConfig(TestCase):
+  def setUp(self):
+    # save original open() method for later use
+    self.original_open = open
+
+  def tearDown(self):
+    sys.stdout = sys.__stdout__
+
+  logger = logging.getLogger()
+
+  def test_ambari_config_get(self):
+    config = AmbariConfig()
+    #default
+    self.assertEqual(config.get("security", "keysdir"), "/tmp/ambari-agent")
+    #non-default
+    config.set("security", "keysdir", "/tmp/non-default-path")
+    self.assertEqual(config.get("security", "keysdir"), "/tmp/non-default-path")
+    #whitespace handling
+    config.set("security", "keysdir", " /tmp/non-stripped")
+    self.assertEqual(config.get("security", "keysdir"), "/tmp/non-stripped")
+


Mime
View raw message