You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rl...@apache.org on 2018/04/09 17:22:09 UTC
[ambari] branch trunk updated: [AMBARI-23382] Ambari-server
sync-ldap: Sync event creation failed (#806)
This is an automated email from the ASF dual-hosted git repository.
rlevas pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/trunk by this push:
new 674807e [AMBARI-23382] Ambari-server sync-ldap: Sync event creation failed (#806)
674807e is described below
commit 674807e82eb1ee2187a28947f007d8afabf373c6
Author: David F. Quiroga <qu...@gmail.com>
AuthorDate: Mon Apr 9 10:22:05 2018 -0700
[AMBARI-23382] Ambari-server sync-ldap: Sync event creation failed (#806)
* Update serverUtils.py
* fix unit tests, add comments
---
ambari-server/src/main/python/ambari_server/serverUtils.py | 7 +++++--
ambari-server/src/test/python/TestAmbariServer.py | 3 ++-
ambari-server/src/test/python/TestServerUtils.py | 6 +++++-
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/ambari-server/src/main/python/ambari_server/serverUtils.py b/ambari-server/src/main/python/ambari_server/serverUtils.py
index 7a0d3e7..63d78c8 100644
--- a/ambari-server/src/main/python/ambari_server/serverUtils.py
+++ b/ambari-server/src/main/python/ambari_server/serverUtils.py
@@ -22,8 +22,8 @@ import base64
import os
import sys
import time
+import socket
import urllib2
-
from ambari_commons.exceptions import FatalException, NonFatalException
from ambari_commons.logging_utils import get_verbose
from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
@@ -119,8 +119,10 @@ def refresh_stack_hash(properties):
# Reads server protocol/port from configuration
# And returns something like
# http://127.0.0.1:8080/api/v1/
+# or if using ssl https://hostname.domain:8443/api/v1
#
def get_ambari_server_api_base(properties):
+ api_host = SERVER_API_HOST
api_protocol = SERVER_API_PROTOCOL
api_port = CLIENT_API_PORT
api_port_prop = properties.get_property(CLIENT_API_PORT_PROPERTY)
@@ -133,12 +135,13 @@ def get_ambari_server_api_base(properties):
api_ssl = api_ssl_prop.lower() == "true"
if api_ssl:
+ api_host = socket.getfqdn()
api_protocol = SERVER_API_SSL_PROTOCOL
api_port = DEFAULT_SSL_API_PORT
api_port_prop = properties.get_property(SSL_API_PORT)
if api_port_prop is not None:
api_port = api_port_prop
- return '{0}://{1}:{2!s}/api/v1/'.format(api_protocol, SERVER_API_HOST, api_port)
+ return '{0}://{1}:{2!s}/api/v1/'.format(api_protocol, api_host, api_port)
def get_ambari_admin_username_password_pair(options):
diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py
index cbcfff4..705b239 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -33,6 +33,7 @@ import operator
from ambari_commons import subprocess32
from optparse import OptionParser
import platform
+import socket
import re
import shutil
import signal
@@ -7814,7 +7815,7 @@ class TestAmbariServer(TestCase):
sync_ldap(options)
- url = '{0}://{1}:{2!s}{3}'.format('https', '127.0.0.1', '8443', '/api/v1/ldap_sync_events')
+ url = '{0}://{1}:{2!s}{3}'.format('https', socket.getfqdn(), '8443', '/api/v1/ldap_sync_events')
request = urlopen_mock.call_args_list[0][0][0]
self.assertEquals(url, str(request.get_full_url()))
diff --git a/ambari-server/src/test/python/TestServerUtils.py b/ambari-server/src/test/python/TestServerUtils.py
index 2f982cf..3da98e4 100644
--- a/ambari-server/src/test/python/TestServerUtils.py
+++ b/ambari-server/src/test/python/TestServerUtils.py
@@ -22,6 +22,7 @@ os.environ["ROOT"] = ""
from mock.mock import patch, MagicMock
from unittest import TestCase
import platform
+import socket
from ambari_commons import os_utils
os_utils.search_file = MagicMock(return_value="/tmp/ambari.properties")
@@ -58,13 +59,16 @@ class TestServerUtils(TestCase):
self.assertEquals(result, 'http://127.0.0.1:8033/api/v1/')
# Test case of using https protocol (and ssl port)
+ fqdn = socket.getfqdn()
+ self.assertTrue(len(fqdn)>0)
+
properties = FakeProperties({
SSL_API: "true",
SSL_API_PORT : "8443",
CLIENT_API_PORT_PROPERTY: None
})
result = get_ambari_server_api_base(properties)
- self.assertEquals(result, 'https://127.0.0.1:8443/api/v1/')
+ self.assertEquals(result, 'https://{0}:8443/api/v1/'.format(fqdn))
def test_get_ambari_admin_credentials_from_cli_options(self):
--
To stop receiving notification emails like this one, please contact
rlevas@apache.org.