Repository: ambari
Updated Branches:
  refs/heads/trunk 9067dfafb -> 51e6a82df


AMBARI-20536: Alerts Which Fallback To A Port In Absence of a URI Fail 
(Madhuvanthi Radhakrishnan via jluniya)


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

Branch: refs/heads/trunk
Commit: 51e6a82dfb47f4b1946aaa14391e5323ac69c99d
Parents: 9067dfa
Author: Jayush Luniya <[email protected]>
Authored: Mon Mar 27 10:56:20 2017 -0700
Committer: Jayush Luniya <[email protected]>
Committed: Mon Mar 27 10:56:20 2017 -0700

----------------------------------------------------------------------
 .../python/resource_management/TestLibraryFunctions.py    |  1 +
 .../libraries/functions/get_port_from_url.py              | 10 +++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/51e6a82d/ambari-agent/src/test/python/resource_management/TestLibraryFunctions.py
----------------------------------------------------------------------
diff --git 
a/ambari-agent/src/test/python/resource_management/TestLibraryFunctions.py 
b/ambari-agent/src/test/python/resource_management/TestLibraryFunctions.py
index 48e0aa0..1e635bf 100644
--- a/ambari-agent/src/test/python/resource_management/TestLibraryFunctions.py
+++ b/ambari-agent/src/test/python/resource_management/TestLibraryFunctions.py
@@ -31,5 +31,6 @@ class TestLibraryFunctions(TestCase):
     self.assertEqual("8080",get_port_from_url("host:8080/dots_in_url8888:"))
     
self.assertEqual("8080",get_port_from_url("protocol://host:8080/dots_in_url8888:"))
     self.assertEqual("8080",get_port_from_url("127.0.0.1:8080"))
+    self.assertEqual("8042",get_port_from_url("8042"))
     self.assertRaises(Fail, get_port_from_url, "http://host/no_port";)
     self.assertRaises(Fail, get_port_from_url, "127.0.0.1:808080")

http://git-wip-us.apache.org/repos/asf/ambari/blob/51e6a82d/ambari-common/src/main/python/resource_management/libraries/functions/get_port_from_url.py
----------------------------------------------------------------------
diff --git 
a/ambari-common/src/main/python/resource_management/libraries/functions/get_port_from_url.py
 
b/ambari-common/src/main/python/resource_management/libraries/functions/get_port_from_url.py
index 7ff2a14..199d4fe 100644
--- 
a/ambari-common/src/main/python/resource_management/libraries/functions/get_port_from_url.py
+++ 
b/ambari-common/src/main/python/resource_management/libraries/functions/get_port_from_url.py
@@ -30,11 +30,15 @@ def get_port_from_url(address):
   If address is UnknownConfiguration, UnknownConfiguration will be returned. 
   If no port was found, Fail will be raised.
   """
+  
+  if is_empty(address):
+    return address
+
+  if isinstance(address, (int, long)):
+    return address
+
   if address is None or address.strip() == "":
     return ""
-  address = address.strip()
-  if isinstance(address, (int, long)):
-    return address  
   
   port = re.findall(":([\d]{1,5})(?=/|$)", address)
   if port:

Reply via email to