You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2015/05/13 14:56:45 UTC
ambari git commit: AMBARI-10911 - [WinTP2] Knox service need to be
refactored due to service check failed
Repository: ambari
Updated Branches:
refs/heads/trunk 9c3e5dd22 -> f33e58389
AMBARI-10911 - [WinTP2] Knox service need to be refactored due to service check failed
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/f33e5838
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/f33e5838
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/f33e5838
Branch: refs/heads/trunk
Commit: f33e5838959eb1d28f06500c0314fd2d8b595fe2
Parents: 9c3e5dd
Author: Artem Baranchuk <ab...@hortonworks.con>
Authored: Tue May 5 00:04:45 2015 +0300
Committer: Artem Baranchuk <ab...@hortonworks.con>
Committed: Wed May 13 15:54:05 2015 +0300
----------------------------------------------------------------------
.../common-services/KNOX/0.5.0.2.2/metainfo.xml | 4 +-
.../KNOX/0.5.0.2.2/package/scripts/knox.py | 3 +-
.../0.5.0.2.2/package/scripts/knox_gateway.py | 111 +++++-------
.../KNOX/0.5.0.2.2/package/scripts/knox_ldap.py | 3 +-
.../KNOX/0.5.0.2.2/package/scripts/params.py | 178 +------------------
.../0.5.0.2.2/package/scripts/params_linux.py | 173 +++++++++++++++++-
.../0.5.0.2.2/package/scripts/params_windows.py | 11 ++
.../0.5.0.2.2/package/scripts/service_check.py | 100 +++++++----
.../package/scripts/service_mapping.py | 22 ---
.../0.5.0.2.2/package/scripts/status_params.py | 42 +++--
.../services/KNOX/configuration/knox-env.xml | 10 --
.../ranger-knox-plugin-properties.xml | 1 -
12 files changed, 317 insertions(+), 341 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/f33e5838/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/metainfo.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/metainfo.xml b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/metainfo.xml
index 5d32ce1..5d49298 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/metainfo.xml
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/metainfo.xml
@@ -39,7 +39,7 @@
<customCommand>
<name>STARTDEMOLDAP</name>
<commandScript>
- <script>scripts/demo_ldap.py</script>
+ <script>scripts/knox_gateway.py</script>
<scriptType>PYTHON</scriptType>
<timeout>600</timeout>
</commandScript>
@@ -47,7 +47,7 @@
<customCommand>
<name>STOPDEMOLDAP</name>
<commandScript>
- <script>scripts/demo_ldap.py</script>
+ <script>scripts/knox_gateway.py</script>
<scriptType>PYTHON</scriptType>
<timeout>600</timeout>
</commandScript>
http://git-wip-us.apache.org/repos/asf/ambari/blob/f33e5838/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py
index f3040ee..6caec01 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox.py
@@ -25,7 +25,6 @@ from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
@OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
def knox():
import params
- from service_mapping import knox_geteway_win_service_name
XmlConfig("gateway-site.xml",
conf_dir=params.knox_conf_dir,
@@ -35,7 +34,7 @@ def knox():
)
# Manually overriding service logon user & password set by the installation package
- ServiceConfig(knox_geteway_win_service_name,
+ ServiceConfig(params.knox_gateway_win_service_name,
action="change_user",
username = params.knox_user,
password = Script.get_password(params.knox_user))
http://git-wip-us.apache.org/repos/asf/ambari/blob/f33e5838/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py
index bc254c5..1e2060e 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_gateway.py
@@ -29,32 +29,15 @@ import os
from knox import knox
from knox_ldap import ldap
from setup_ranger_knox import setup_ranger_knox
-import service_mapping
from ambari_commons import OSConst
from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
-class KnoxGateway(Script):
-
- @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
- def get_stack_to_component(self):
- return {"HDP": "knox-server"}
-
- @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
- def install(self, env):
- self.install_packages(env)
- import params
- env.set_params(params)
-
- File(format('{knox_conf_dir}/topologies/sandbox.xml'),
- action = "delete",
- )
- @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
+class KnoxGateway(Script):
def install(self, env):
import params
env.set_params(params)
- if not check_windows_service_exists(service_mapping.knox_geteway_win_service_name):
- self.install_packages(env)
+ self.install_packages(env)
File(os.path.join(params.knox_conf_dir, 'topologies', 'sandbox.xml'),
action = "delete",
@@ -66,17 +49,58 @@ class KnoxGateway(Script):
knox()
ldap()
- @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
- def pre_rolling_restart(self, env):
+ def configureldap(self, env):
import params
env.set_params(params)
+ ldap()
+
+
+@OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY)
+class KnoxGatewayWindows(KnoxGateway):
+ def start(self, env):
+ import params
+ env.set_params(params)
+ self.configure(env)
+ # setup_ranger_knox(env)
+ Service(params.knox_gateway_win_service_name, action="start")
+
+ def stop(self, env):
+ import params
+ env.set_params(params)
+ Service(params.knox_gateway_win_service_name, action="stop")
+
+ def status(self, env):
+ import status_params
+ env.set_params(status_params)
+ check_windows_service_status(status_params.knox_gateway_win_service_name)
+
+ def startdemoldap(self, env):
+ import params
+ env.set_params(params)
+ self.configureldap(env)
+ Service(params.knox_ldap_win_service_name, action="start")
+
+ def stopdemoldap(self, env):
+ import params
+ env.set_params(params)
+ Service(params.knox_ldap_win_service_name, action="stop")
+
+
+
+@OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
+class KnoxGatewayDefault(KnoxGateway):
+ def get_stack_to_component(self):
+ return {"HDP": "knox-server"}
+
+ def pre_rolling_restart(self, env):
+ import params
+ env.set_params(params)
if params.version and compare_versions(format_hdp_stack_version(params.version), '2.2.0.0') >= 0:
upgrade.backup_data()
conf_select.select(params.stack_name, "knox", params.version)
Execute(format("hdp-select set knox-server {version}"))
- @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
def start(self, env, rolling_restart=False):
import params
env.set_params(params)
@@ -95,15 +119,6 @@ class KnoxGateway(Script):
not_if=no_op_test
)
- @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
- def start(self, env):
- import params
- env.set_params(params)
- self.configure(env)
- # setup_ranger_knox(env)
- Service(service_mapping.knox_geteway_win_service_name, action="start")
-
- @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
def stop(self, env, rolling_restart=False):
import params
env.set_params(params)
@@ -115,29 +130,11 @@ class KnoxGateway(Script):
)
Execute (format("rm -f {knox_pid_file}"))
- @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
- def stop(self, env):
- import params
- env.set_params(params)
- Service(service_mapping.knox_geteway_win_service_name, action="stop")
-
- @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
def status(self, env):
import status_params
env.set_params(status_params)
check_process_status(status_params.knox_pid_file)
- @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
- def status(self, env):
- import params
- check_windows_service_status(service_mapping.knox_geteway_win_service_name)
-
- def configureldap(self, env):
- import params
- env.set_params(params)
- ldap()
-
- @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
def startdemoldap(self, env):
import params
env.set_params(params)
@@ -150,14 +147,6 @@ class KnoxGateway(Script):
not_if=no_op_test
)
- @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
- def startdemoldap(self, env):
- import params
- env.set_params(params)
- self.configureldap(env)
- Service(service_mapping.knox_ldap_win_service_name, action="start")
-
- @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
def stopdemoldap(self, env):
import params
env.set_params(params)
@@ -169,16 +158,8 @@ class KnoxGateway(Script):
)
Execute (format("rm -f {ldap_pid_file}"))
- @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
- def stopdemoldap(self, env):
- import params
- env.set_params(params)
- Service(service_mapping.knox_ldap_win_service_name, action="stop")
-
- @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
def security_status(self, env):
import status_params
-
env.set_params(status_params)
if status_params.security_enabled:
http://git-wip-us.apache.org/repos/asf/ambari/blob/f33e5838/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_ldap.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_ldap.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_ldap.py
index c96605e..dee0154 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_ldap.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/knox_ldap.py
@@ -43,10 +43,9 @@ def _ldap_common():
@OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
def ldap():
import params
- from service_mapping import knox_ldap_win_service_name
# Manually overriding service logon user & password set by the installation package
- ServiceConfig(knox_ldap_win_service_name,
+ ServiceConfig(params.knox_ldap_win_service_name,
action="change_user",
username = params.knox_user,
password = Script.get_password(params.knox_user))
http://git-wip-us.apache.org/repos/asf/ambari/blob/f33e5838/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params.py
index d2a7983..8fe1028 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params.py
@@ -18,188 +18,12 @@ limitations under the License.
Ambari Agent
"""
-import status_params
-
from ambari_commons import OSCheck
-from resource_management.libraries.functions import format
-from resource_management.libraries.functions.version import format_hdp_stack_version
from resource_management.libraries.functions.default import default
-from resource_management.libraries.functions.get_port_from_url import get_port_from_url
-from resource_management.libraries.functions import get_kinit_path
-from resource_management.libraries.script.script import Script
if OSCheck.is_windows_family():
from params_windows import *
else:
from params_linux import *
-host_sys_prepped = default("/hostLevelParams/host_sys_prepped", False)
-
-config = Script.get_config()
-tmp_dir = Script.get_tmp_dir()
-
-stack_name = default("/hostLevelParams/stack_name", None)
-
-version = default("/commandParams/version", None)
-
-stack_version_unformatted = str(config['hostLevelParams']['stack_version'])
-hdp_stack_version = format_hdp_stack_version(stack_version_unformatted)
-
-namenode_hosts = default("/clusterHostInfo/namenode_host", None)
-if type(namenode_hosts) is list:
- namenode_host = namenode_hosts[0]
-else:
- namenode_host = namenode_hosts
-
-has_namenode = not namenode_host == None
-namenode_http_port = "50070"
-namenode_rpc_port = "8020"
-
-if has_namenode:
- if 'dfs.namenode.http-address' in config['configurations']['hdfs-site']:
- namenode_http_port = get_port_from_url(config['configurations']['hdfs-site']['dfs.namenode.http-address'])
- if 'dfs.namenode.rpc-address' in config['configurations']['hdfs-site']:
- namenode_rpc_port = get_port_from_url(config['configurations']['hdfs-site']['dfs.namenode.rpc-address'])
-
-rm_hosts = default("/clusterHostInfo/rm_host", None)
-if type(rm_hosts) is list:
- rm_host = rm_hosts[0]
-else:
- rm_host = rm_hosts
-has_rm = not rm_host == None
-
-jt_rpc_port = "8050"
-rm_port = "8080"
-
-if has_rm:
- if 'yarn.resourcemanager.address' in config['configurations']['yarn-site']:
- jt_rpc_port = get_port_from_url(config['configurations']['yarn-site']['yarn.resourcemanager.address'])
-
- if 'yarn.resourcemanager.webapp.address' in config['configurations']['yarn-site']:
- rm_port = get_port_from_url(config['configurations']['yarn-site']['yarn.resourcemanager.webapp.address'])
-
-hive_http_port = default('/configurations/hive-site/hive.server2.thrift.http.port', "10001")
-hive_http_path = default('/configurations/hive-site/hive.server2.thrift.http.path', "cliservice")
-hive_server_hosts = default("/clusterHostInfo/hive_server_host", None)
-if type(hive_server_hosts) is list:
- hive_server_host = hive_server_hosts[0]
-else:
- hive_server_host = hive_server_hosts
-
-templeton_port = default('/configurations/webhcat-site/templeton.port', "50111")
-webhcat_server_hosts = default("/clusterHostInfo/webhcat_server_host", None)
-if type(webhcat_server_hosts) is list:
- webhcat_server_host = webhcat_server_hosts[0]
-else:
- webhcat_server_host = webhcat_server_hosts
-
-hbase_master_port = default('/configurations/hbase-site/hbase.rest.port', "8080")
-hbase_master_hosts = default("/clusterHostInfo/hbase_master_hosts", None)
-if type(hbase_master_hosts) is list:
- hbase_master_host = hbase_master_hosts[0]
-else:
- hbase_master_host = hbase_master_hosts
-
-oozie_server_hosts = default("/clusterHostInfo/oozie_server", None)
-if type(oozie_server_hosts) is list:
- oozie_server_host = oozie_server_hosts[0]
-else:
- oozie_server_host = oozie_server_hosts
-
-has_oozie = not oozie_server_host == None
-oozie_server_port = "11000"
-
-if has_oozie:
- oozie_server_port = get_port_from_url(config['configurations']['oozie-site']['oozie.base.url'])
-
-# Knox managed properties
-knox_managed_pid_symlink= "/usr/hdp/current/knox-server/pids"
-
-# server configurations
-knox_pid_dir = status_params.knox_pid_dir
-knox_pid_file = status_params.knox_pid_file
-ldap_pid_file = status_params.ldap_pid_file
-knox_master_secret = config['configurations']['knox-env']['knox_master_secret']
-knox_host_name = config['clusterHostInfo']['knox_gateway_hosts'][0]
-knox_host_name_in_cluster = config['hostname']
-knox_host_port = config['configurations']['gateway-site']['gateway.port']
-topology_template = config['configurations']['topology']['content']
-gateway_log4j = config['configurations']['gateway-log4j']['content']
-ldap_log4j = config['configurations']['ldap-log4j']['content']
-users_ldif = config['configurations']['users-ldif']['content']
-java_home = config['hostLevelParams']['java_home']
-security_enabled = config['configurations']['cluster-env']['security_enabled']
-smokeuser = config['configurations']['cluster-env']['smokeuser']
-smokeuser_principal = config['configurations']['cluster-env']['smokeuser_principal_name']
-smoke_user_keytab = config['configurations']['cluster-env']['smokeuser_keytab']
-kinit_path_local = get_kinit_path(default('/configurations/kerberos-env/executable_search_paths', None))
-if security_enabled:
- knox_keytab_path = config['configurations']['knox-env']['knox_keytab_path']
- _hostname_lowercase = config['hostname'].lower()
- knox_principal_name = config['configurations']['knox-env']['knox_principal_name'].replace('_HOST',_hostname_lowercase)
-
-# ranger host
-ranger_admin_hosts = default("/clusterHostInfo/ranger_admin_hosts", [])
-has_ranger_admin = not len(ranger_admin_hosts) == 0
-
-ambari_server_hostname = config['clusterHostInfo']['ambari_server_host'][0]
-
-# ranger knox properties
-policymgr_mgr_url = config['configurations']['admin-properties']['policymgr_external_url']
-sql_connector_jar = config['configurations']['admin-properties']['SQL_CONNECTOR_JAR']
-xa_audit_db_flavor = config['configurations']['admin-properties']['DB_FLAVOR']
-xa_audit_db_name = config['configurations']['admin-properties']['audit_db_name']
-xa_audit_db_user = config['configurations']['admin-properties']['audit_db_user']
-xa_audit_db_password = config['configurations']['admin-properties']['audit_db_password']
-xa_db_host = config['configurations']['admin-properties']['db_host']
-repo_name = str(config['clusterName']) + '_knox'
-
-knox_home = config['configurations']['ranger-knox-plugin-properties']['KNOX_HOME']
-common_name_for_certificate = config['configurations']['ranger-knox-plugin-properties']['common.name.for.certificate']
-
-repo_config_username = config['configurations']['ranger-knox-plugin-properties']['REPOSITORY_CONFIG_USERNAME']
-repo_config_password = config['configurations']['ranger-knox-plugin-properties']['REPOSITORY_CONFIG_PASSWORD']
-
-ranger_env = config['configurations']['ranger-env']
-ranger_plugin_properties = config['configurations']['ranger-knox-plugin-properties']
-policy_user = config['configurations']['ranger-knox-plugin-properties']['policy_user']
-
-#For curl command in ranger plugin to get db connector
-jdk_location = config['hostLevelParams']['jdk_location']
-java_share_dir = '/usr/share/java'
-if has_ranger_admin:
- enable_ranger_knox = (config['configurations']['ranger-knox-plugin-properties']['ranger-knox-plugin-enabled'].lower() == 'yes')
-
- if xa_audit_db_flavor.lower() == 'mysql':
- jdbc_symlink_name = "mysql-jdbc-driver.jar"
- jdbc_jar_name = "mysql-connector-java.jar"
- elif xa_audit_db_flavor.lower() == 'oracle':
- jdbc_jar_name = "ojdbc6.jar"
- jdbc_symlink_name = "oracle-jdbc-driver.jar"
- elif xa_audit_db_flavor.lower() == 'postgres':
- jdbc_jar_name = "postgresql.jar"
- jdbc_symlink_name = "postgres-jdbc-driver.jar"
- elif xa_audit_db_flavor.lower() == 'sqlserver':
- jdbc_jar_name = "sqljdbc4.jar"
- jdbc_symlink_name = "mssql-jdbc-driver.jar"
-
- downloaded_custom_connector = format("{tmp_dir}/{jdbc_jar_name}")
-
- driver_curl_source = format("{jdk_location}/{jdbc_symlink_name}")
- driver_curl_target = format("{java_share_dir}/{jdbc_jar_name}")
-
- knox_ranger_plugin_config = {
- 'username': repo_config_username,
- 'password': repo_config_password,
- 'knox.url': format("https://{knox_host_name}:{knox_host_port}/gateway/admin/api/v1/topologies"),
- 'commonNameForCertificate': common_name_for_certificate
- }
-
- knox_ranger_plugin_repo = {
- 'isActive': 'true',
- 'config': json.dumps(knox_ranger_plugin_config),
- 'description': 'knox repo',
- 'name': repo_name,
- 'repositoryType': 'knox',
- 'assetType': '5',
- }
\ No newline at end of file
+host_sys_prepped = default("/hostLevelParams/host_sys_prepped", False)
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/f33e5838/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py
index 1347760..5dfc2d7 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_linux.py
@@ -15,21 +15,29 @@ 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.
+Ambari Agent
+
"""
+from resource_management import *
+import json
from resource_management.libraries.functions import format
from resource_management.libraries.functions.version import format_hdp_stack_version
from resource_management.libraries.functions.default import default
+from resource_management.libraries.functions.get_port_from_url import get_port_from_url
+from resource_management.libraries.functions import get_kinit_path
from resource_management.libraries.script.script import Script
+from status_params import *
# server configurations
config = Script.get_config()
+tmp_dir = Script.get_tmp_dir()
+stack_name = default("/hostLevelParams/stack_name", None)
+version = default("/commandParams/version", None)
+
knox_master_secret_path = '/var/lib/knox/data/security/master'
knox_cert_store_path = '/var/lib/knox/data/security/keystores/gateway.jks'
-
knox_user = default("/configurations/knox-env/knox_user", "knox")
-stack_version_unformatted = str(config['hostLevelParams']['stack_version'])
-hdp_stack_version = format_hdp_stack_version(stack_version_unformatted)
# default parameters
knox_bin = '/usr/bin/gateway'
@@ -50,3 +58,162 @@ mode = 0644
# server configurations
knox_data_dir = '/var/lib/knox/data'
knox_logs_dir = '/var/log/knox'
+
+stack_version_unformatted = str(config['hostLevelParams']['stack_version'])
+hdp_stack_version = format_hdp_stack_version(stack_version_unformatted)
+
+namenode_hosts = default("/clusterHostInfo/namenode_host", None)
+if type(namenode_hosts) is list:
+ namenode_host = namenode_hosts[0]
+else:
+ namenode_host = namenode_hosts
+
+has_namenode = not namenode_host == None
+namenode_http_port = "50070"
+namenode_rpc_port = "8020"
+
+if has_namenode:
+ if 'dfs.namenode.http-address' in config['configurations']['hdfs-site']:
+ namenode_http_port = get_port_from_url(config['configurations']['hdfs-site']['dfs.namenode.http-address'])
+ if 'dfs.namenode.rpc-address' in config['configurations']['hdfs-site']:
+ namenode_rpc_port = get_port_from_url(config['configurations']['hdfs-site']['dfs.namenode.rpc-address'])
+
+rm_hosts = default("/clusterHostInfo/rm_host", None)
+if type(rm_hosts) is list:
+ rm_host = rm_hosts[0]
+else:
+ rm_host = rm_hosts
+has_rm = not rm_host == None
+
+jt_rpc_port = "8050"
+rm_port = "8080"
+
+if has_rm:
+ if 'yarn.resourcemanager.address' in config['configurations']['yarn-site']:
+ jt_rpc_port = get_port_from_url(config['configurations']['yarn-site']['yarn.resourcemanager.address'])
+
+ if 'yarn.resourcemanager.webapp.address' in config['configurations']['yarn-site']:
+ rm_port = get_port_from_url(config['configurations']['yarn-site']['yarn.resourcemanager.webapp.address'])
+
+hive_http_port = default('/configurations/hive-site/hive.server2.thrift.http.port', "10001")
+hive_http_path = default('/configurations/hive-site/hive.server2.thrift.http.path', "cliservice")
+hive_server_hosts = default("/clusterHostInfo/hive_server_host", None)
+if type(hive_server_hosts) is list:
+ hive_server_host = hive_server_hosts[0]
+else:
+ hive_server_host = hive_server_hosts
+
+templeton_port = default('/configurations/webhcat-site/templeton.port', "50111")
+webhcat_server_hosts = default("/clusterHostInfo/webhcat_server_host", None)
+if type(webhcat_server_hosts) is list:
+ webhcat_server_host = webhcat_server_hosts[0]
+else:
+ webhcat_server_host = webhcat_server_hosts
+
+hbase_master_port = default('/configurations/hbase-site/hbase.rest.port', "8080")
+hbase_master_hosts = default("/clusterHostInfo/hbase_master_hosts", None)
+if type(hbase_master_hosts) is list:
+ hbase_master_host = hbase_master_hosts[0]
+else:
+ hbase_master_host = hbase_master_hosts
+
+oozie_server_hosts = default("/clusterHostInfo/oozie_server", None)
+if type(oozie_server_hosts) is list:
+ oozie_server_host = oozie_server_hosts[0]
+else:
+ oozie_server_host = oozie_server_hosts
+
+has_oozie = not oozie_server_host == None
+oozie_server_port = "11000"
+
+if has_oozie:
+ oozie_server_port = get_port_from_url(config['configurations']['oozie-site']['oozie.base.url'])
+
+# Knox managed properties
+knox_managed_pid_symlink= "/usr/hdp/current/knox-server/pids"
+
+# server configurations
+knox_master_secret = config['configurations']['knox-env']['knox_master_secret']
+knox_host_name = config['clusterHostInfo']['knox_gateway_hosts'][0]
+knox_host_name_in_cluster = config['hostname']
+knox_host_port = config['configurations']['gateway-site']['gateway.port']
+topology_template = config['configurations']['topology']['content']
+gateway_log4j = config['configurations']['gateway-log4j']['content']
+ldap_log4j = config['configurations']['ldap-log4j']['content']
+users_ldif = config['configurations']['users-ldif']['content']
+java_home = config['hostLevelParams']['java_home']
+security_enabled = config['configurations']['cluster-env']['security_enabled']
+smokeuser = config['configurations']['cluster-env']['smokeuser']
+smokeuser_principal = config['configurations']['cluster-env']['smokeuser_principal_name']
+smoke_user_keytab = config['configurations']['cluster-env']['smokeuser_keytab']
+kinit_path_local = get_kinit_path(default('/configurations/kerberos-env/executable_search_paths', None))
+if security_enabled:
+ knox_keytab_path = config['configurations']['knox-env']['knox_keytab_path']
+ _hostname_lowercase = config['hostname'].lower()
+ knox_principal_name = config['configurations']['knox-env']['knox_principal_name'].replace('_HOST',_hostname_lowercase)
+
+# ranger host
+ranger_admin_hosts = default("/clusterHostInfo/ranger_admin_hosts", [])
+has_ranger_admin = not len(ranger_admin_hosts) == 0
+
+ambari_server_hostname = config['clusterHostInfo']['ambari_server_host'][0]
+
+# ranger knox properties
+policymgr_mgr_url = config['configurations']['admin-properties']['policymgr_external_url']
+sql_connector_jar = config['configurations']['admin-properties']['SQL_CONNECTOR_JAR']
+xa_audit_db_flavor = config['configurations']['admin-properties']['DB_FLAVOR']
+xa_audit_db_name = config['configurations']['admin-properties']['audit_db_name']
+xa_audit_db_user = config['configurations']['admin-properties']['audit_db_user']
+xa_audit_db_password = config['configurations']['admin-properties']['audit_db_password']
+xa_db_host = config['configurations']['admin-properties']['db_host']
+repo_name = str(config['clusterName']) + '_knox'
+
+knox_home = config['configurations']['ranger-knox-plugin-properties']['KNOX_HOME']
+common_name_for_certificate = config['configurations']['ranger-knox-plugin-properties']['common.name.for.certificate']
+
+repo_config_username = config['configurations']['ranger-knox-plugin-properties']['REPOSITORY_CONFIG_USERNAME']
+repo_config_password = config['configurations']['ranger-knox-plugin-properties']['REPOSITORY_CONFIG_PASSWORD']
+
+ranger_env = config['configurations']['ranger-env']
+ranger_plugin_properties = config['configurations']['ranger-knox-plugin-properties']
+policy_user = config['configurations']['ranger-knox-plugin-properties']['policy_user']
+
+#For curl command in ranger plugin to get db connector
+jdk_location = config['hostLevelParams']['jdk_location']
+java_share_dir = '/usr/share/java'
+if has_ranger_admin:
+ enable_ranger_knox = (config['configurations']['ranger-knox-plugin-properties']['ranger-knox-plugin-enabled'].lower() == 'yes')
+
+ if xa_audit_db_flavor.lower() == 'mysql':
+ jdbc_symlink_name = "mysql-jdbc-driver.jar"
+ jdbc_jar_name = "mysql-connector-java.jar"
+ elif xa_audit_db_flavor.lower() == 'oracle':
+ jdbc_jar_name = "ojdbc6.jar"
+ jdbc_symlink_name = "oracle-jdbc-driver.jar"
+ elif xa_audit_db_flavor.lower() == 'postgres':
+ jdbc_jar_name = "postgresql.jar"
+ jdbc_symlink_name = "postgres-jdbc-driver.jar"
+ elif xa_audit_db_flavor.lower() == 'sqlserver':
+ jdbc_jar_name = "sqljdbc4.jar"
+ jdbc_symlink_name = "mssql-jdbc-driver.jar"
+
+ downloaded_custom_connector = format("{tmp_dir}/{jdbc_jar_name}")
+
+ driver_curl_source = format("{jdk_location}/{jdbc_symlink_name}")
+ driver_curl_target = format("{java_share_dir}/{jdbc_jar_name}")
+
+ knox_ranger_plugin_config = {
+ 'username': repo_config_username,
+ 'password': repo_config_password,
+ 'knox.url': format("https://{knox_host_name}:{knox_host_port}/gateway/admin/api/v1/topologies"),
+ 'commonNameForCertificate': common_name_for_certificate
+ }
+
+ knox_ranger_plugin_repo = {
+ 'isActive': 'true',
+ 'config': json.dumps(knox_ranger_plugin_config),
+ 'description': 'knox repo',
+ 'name': repo_name,
+ 'repositoryType': 'knox',
+ 'assetType': '5',
+ }
http://git-wip-us.apache.org/repos/asf/ambari/blob/f33e5838/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py
index 652094a..8e89052 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/params_windows.py
@@ -20,6 +20,7 @@ limitations under the License.
from resource_management import *
import os
+from status_params import *
# server configurations
config = Script.get_config()
@@ -36,6 +37,16 @@ knox_data_dir = os.path.join(knox_home, 'data')
knox_master_secret_path = os.path.join(knox_data_dir, 'security', 'master')
knox_cert_store_path = os.path.join(knox_data_dir, 'security', 'keystores', 'gateway.jks')
+knox_host_port = config['configurations']['gateway-site']['gateway.port']
+knox_host_name = config['clusterHostInfo']['knox_gateway_hosts'][0]
+knox_host_name_in_cluster = config['hostname']
+knox_master_secret = config['configurations']['knox-env']['knox_master_secret']
+topology_template = config['configurations']['topology']['content']
+gateway_log4j = config['configurations']['gateway-log4j']['content']
+security_enabled = config['configurations']['cluster-env']['security_enabled']
+ldap_log4j = config['configurations']['ldap-log4j']['content']
+users_ldif = config['configurations']['users-ldif']['content']
+
hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"]
knox_user = hadoop_user
hdfs_user = hadoop_user
http://git-wip-us.apache.org/repos/asf/ambari/blob/f33e5838/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/service_check.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/service_check.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/service_check.py
index 498e259..5e9b89e 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/service_check.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/service_check.py
@@ -24,46 +24,70 @@ import os
from ambari_commons import OSConst
from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
+
class KnoxServiceCheck(Script):
+ def service_check(self, env):
+ pass
+
+
+@OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY)
+class KnoxServiceCheckWindows(KnoxServiceCheck):
+ def service_check(self, env):
+ import params
+ env.set_params(params)
+
+ temp_dir = os.path.join(os.path.dirname(params.knox_home), "temp")
+ validateKnoxFileName = "validateKnoxStatus.py"
+ validateKnoxFilePath = os.path.join(temp_dir, validateKnoxFileName)
+ python_executable = sys.executable
+ validateStatusCmd = "%s %s -p %s -n %s" % (python_executable, validateKnoxFilePath, params.knox_host_port, params.knox_host_name)
+
+ print "Test connectivity to knox server"
+
+ File(validateKnoxFilePath,
+ content=StaticFile(validateKnoxFileName)
+ )
+
+ Execute(validateStatusCmd,
+ tries=3,
+ try_sleep=5,
+ timeout=5,
+ logoutput=True
+ )
+
+
+@OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT)
+class KnoxServiceCheckDefault(KnoxServiceCheck):
+ def service_check(self, env):
+ import params
+ env.set_params(params)
+
+ validateKnoxFileName = "validateKnoxStatus.py"
+ validateKnoxFilePath = format("{tmp_dir}/{validateKnoxFileName}")
+ python_executable = sys.executable
+ validateStatusCmd = format("{python_executable} {validateKnoxFilePath} -p {knox_host_port} -n {knox_host_name}")
+ if params.security_enabled:
+ kinit_cmd = format("{kinit_path_local} -kt {smoke_user_keytab} {smokeuser_principal};")
+ smoke_cmd = format("{kinit_cmd} {validateStatusCmd}")
+ else:
+ smoke_cmd = validateStatusCmd
+
+ print "Test connectivity to knox server"
+
+ File(validateKnoxFilePath,
+ content=StaticFile(validateKnoxFileName),
+ mode=0755
+ )
+
+ Execute(smoke_cmd,
+ tries=3,
+ try_sleep=5,
+ path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
+ user=params.smokeuser,
+ timeout=5,
+ logoutput=True
+ )
- @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
- def service_check(self, env):
- import params
- env.set_params(params)
- smoke_cmd = os.path.join(params.hdp_root, "Run-SmokeTests.cmd")
- service = "KNOX"
- Execute(format("cmd /C {smoke_cmd} {service}"), logoutput=True, user=params.hdfs_user)
-
- @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
- def service_check(self, env):
- import params
- env.set_params(params)
-
- validateKnoxFileName = "validateKnoxStatus.py"
- validateKnoxFilePath = format("{tmp_dir}/{validateKnoxFileName}")
- python_executable = sys.executable
- validateStatusCmd = format("{python_executable} {validateKnoxFilePath} -p {knox_host_port} -n {knox_host_name}")
- if params.security_enabled:
- kinit_cmd = format("{kinit_path_local} -kt {smoke_user_keytab} {smokeuser_principal};")
- smoke_cmd = format("{kinit_cmd} {validateStatusCmd}")
- else:
- smoke_cmd = validateStatusCmd
-
- print "Test connectivity to knox server"
-
-
- File(validateKnoxFilePath,
- content=StaticFile(validateKnoxFileName),
- mode=0755
- )
- Execute(smoke_cmd,
- tries=3,
- try_sleep=5,
- path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
- user=params.smokeuser,
- timeout=5,
- logoutput=True
- )
if __name__ == "__main__":
KnoxServiceCheck().execute()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/f33e5838/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/service_mapping.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/service_mapping.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/service_mapping.py
deleted file mode 100644
index cf5ce2e..0000000
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/service_mapping.py
+++ /dev/null
@@ -1,22 +0,0 @@
-# !/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.
-
-"""
-
-knox_geteway_win_service_name = "gateway"
-knox_ldap_win_service_name = "ldap"
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/f33e5838/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/status_params.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/status_params.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/status_params.py
index bdf4b04..cf47b63 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/status_params.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/status_params.py
@@ -21,26 +21,30 @@ from resource_management.libraries.functions import format
from resource_management.libraries.functions.default import default
from resource_management.libraries.functions import get_kinit_path
from resource_management.libraries.script.script import Script
+from ambari_commons import OSCheck
config = Script.get_config()
-knox_conf_dir = '/etc/knox/conf'
-if Script.is_hdp_stack_greater_or_equal("2.2"):
- knox_conf_dir = '/usr/hdp/current/knox-server/conf'
-
-knox_pid_dir = config['configurations']['knox-env']['knox_pid_dir']
-knox_pid_file = format("{knox_pid_dir}/gateway.pid")
-ldap_pid_file = format("{knox_pid_dir}/ldap.pid")
-
-security_enabled = config['configurations']['cluster-env']['security_enabled']
-if security_enabled:
- knox_keytab_path = config['configurations']['knox-env']['knox_keytab_path']
- knox_principal_name = config['configurations']['knox-env']['knox_principal_name']
+if OSCheck.is_windows_family():
+ knox_gateway_win_service_name = "gateway"
+ knox_ldap_win_service_name = "ldap"
else:
- knox_keytab_path = None
- knox_principal_name = None
-
-hostname = config['hostname'].lower()
-knox_user = default("/configurations/knox-env/knox_user", "knox")
-kinit_path_local = get_kinit_path(default('/configurations/kerberos-env/executable_search_paths', None))
-temp_dir = Script.get_tmp_dir()
+ knox_conf_dir = '/etc/knox/conf'
+ if Script.is_hdp_stack_greater_or_equal("2.2"):
+ knox_conf_dir = '/usr/hdp/current/knox-server/conf'
+ knox_pid_dir = config['configurations']['knox-env']['knox_pid_dir']
+ knox_pid_file = format("{knox_pid_dir}/gateway.pid")
+ ldap_pid_file = format("{knox_pid_dir}/ldap.pid")
+
+ security_enabled = config['configurations']['cluster-env']['security_enabled']
+ if security_enabled:
+ knox_keytab_path = config['configurations']['knox-env']['knox_keytab_path']
+ knox_principal_name = config['configurations']['knox-env']['knox_principal_name']
+ else:
+ knox_keytab_path = None
+ knox_principal_name = None
+
+ hostname = config['hostname'].lower()
+ knox_user = default("/configurations/knox-env/knox_user", "knox")
+ kinit_path_local = get_kinit_path(default('/configurations/kerberos-env/executable_search_paths', None))
+ temp_dir = Script.get_tmp_dir()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ambari/blob/f33e5838/ambari-server/src/main/resources/stacks/HDPWIN/2.2/services/KNOX/configuration/knox-env.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDPWIN/2.2/services/KNOX/configuration/knox-env.xml b/ambari-server/src/main/resources/stacks/HDPWIN/2.2/services/KNOX/configuration/knox-env.xml
index feb8a00..c4d6dca 100644
--- a/ambari-server/src/main/resources/stacks/HDPWIN/2.2/services/KNOX/configuration/knox-env.xml
+++ b/ambari-server/src/main/resources/stacks/HDPWIN/2.2/services/KNOX/configuration/knox-env.xml
@@ -21,28 +21,18 @@
-->
<configuration supports_final="false">
- <!-- knox-env.sh -->
-
<property>
<name>knox_user</name>
- <value>knox</value>
- <property-type>USER</property-type>
<deleted>true</deleted>
- <description>Knox Username.</description>
</property>
<property>
<name>knox_group</name>
- <value>knox</value>
- <property-type>GROUP</property-type>
<deleted>true</deleted>
- <description>Knox Group.</description>
</property>
<property>
<name>knox_pid_dir</name>
- <value>/var/run/knox</value>
<deleted>true</deleted>
- <description>Knox PID dir.</description>
</property>
</configuration>
http://git-wip-us.apache.org/repos/asf/ambari/blob/f33e5838/ambari-server/src/main/resources/stacks/HDPWIN/2.2/services/KNOX/configuration/ranger-knox-plugin-properties.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDPWIN/2.2/services/KNOX/configuration/ranger-knox-plugin-properties.xml b/ambari-server/src/main/resources/stacks/HDPWIN/2.2/services/KNOX/configuration/ranger-knox-plugin-properties.xml
index 47c74c4..97da88f 100644
--- a/ambari-server/src/main/resources/stacks/HDPWIN/2.2/services/KNOX/configuration/ranger-knox-plugin-properties.xml
+++ b/ambari-server/src/main/resources/stacks/HDPWIN/2.2/services/KNOX/configuration/ranger-knox-plugin-properties.xml
@@ -23,7 +23,6 @@
<property>
<name>KNOX_HOME</name>
<value>c:\hadoop\knox</value>
- <description></description>
</property>
</configuration>
\ No newline at end of file