AMBARI-10155: Merge HDPWIN OOZIE package scripts to common services (jluniya)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7be96532 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7be96532 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7be96532 Branch: refs/heads/trunk Commit: 7be96532bbda54f15f2f759cecb375841302197a Parents: b8e6923 Author: Jayush Luniya <[email protected]> Authored: Tue Mar 31 14:15:34 2015 -0700 Committer: Jayush Luniya <[email protected]> Committed: Tue Mar 31 14:15:34 2015 -0700 ---------------------------------------------------------------------- .../scripts/check_oozie_server_status.py | 38 ++++ .../OOZIE/4.0.0.2.0/package/scripts/oozie.py | 39 ++++ .../4.0.0.2.0/package/scripts/oozie_server.py | 23 +- .../4.0.0.2.0/package/scripts/oozie_service.py | 14 ++ .../OOZIE/4.0.0.2.0/package/scripts/params.py | 197 +---------------- .../4.0.0.2.0/package/scripts/params_linux.py | 214 +++++++++++++++++++ .../4.0.0.2.0/package/scripts/params_windows.py | 33 +++ .../4.0.0.2.0/package/scripts/service_check.py | 64 ++++-- .../4.0.0.2.0/package/scripts/status_params.py | 21 +- .../2.1/services/OOZIE/package/scripts/oozie.py | 43 ---- .../OOZIE/package/scripts/oozie_client.py | 40 ---- .../OOZIE/package/scripts/oozie_server.py | 68 ------ .../services/OOZIE/package/scripts/params.py | 34 --- .../OOZIE/package/scripts/service_check.py | 32 --- .../OOZIE/package/scripts/service_mapping.py | 21 -- .../stacks/2.0.6/OOZIE/test_oozie_client.py | 1 + .../stacks/2.0.6/OOZIE/test_oozie_server.py | 2 +- .../stacks/2.0.6/OOZIE/test_service_check.py | 1 + 18 files changed, 414 insertions(+), 471 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/check_oozie_server_status.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/check_oozie_server_status.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/check_oozie_server_status.py new file mode 100644 index 0000000..7c69779 --- /dev/null +++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/check_oozie_server_status.py @@ -0,0 +1,38 @@ +""" +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 ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl +from ambari_commons import OSConst + + +@OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY) +def check_oozie_server_status(): + import status_params + from resource_management.libraries.functions.windows_service_utils import check_windows_service_status + + check_windows_service_status(status_params.oozie_server_win_service_name) + + +@OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT) +def check_oozie_server_status(): + import status_params + from resource_management.libraries.functions.check_process_status import check_process_status + + check_process_status(status_params.pid_file) + http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py index 1cf0e9d..76e01ff 100644 --- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py +++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie.py @@ -29,9 +29,48 @@ from resource_management.libraries.functions import format from resource_management.libraries.functions import compare_versions from resource_management.libraries.resources.xml_config import XmlConfig from resource_management.core.resources.packaging import Package +from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl +from ambari_commons import OSConst +from ambari_commons.inet_utils import download_file +@OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY) +def oozie(is_server=False): + import params + + XmlConfig("oozie-site.xml", + conf_dir=params.oozie_conf_dir, + configurations=params.config['configurations']['oozie-site'], + owner=params.oozie_user, + mode='f', + configuration_attributes=params.config['configuration_attributes']['oozie-site'] + ) + + File(os.path.join(params.oozie_conf_dir, "oozie-env.cmd"), + owner=params.oozie_user, + content=InlineTemplate(params.oozie_env_cmd_template) + ) + + Directory(params.oozie_tmp_dir, + owner=params.oozie_user, + recursive = True, + ) + download_file(os.path.join(params.config['hostLevelParams']['jdk_location'], "sqljdbc4.jar"), + os.path.join(params.oozie_root, "extra_libs", "sqljdbc4.jar") + ) + webapps_sqljdbc_path = os.path.join(params.oozie_home, "oozie-server", "webapps", "oozie", "WEB-INF", "lib", "sqljdbc4.jar") + if os.path.isfile(webapps_sqljdbc_path): + download_file(os.path.join(params.config['hostLevelParams']['jdk_location'], "sqljdbc4.jar"), + webapps_sqljdbc_path + ) + download_file(os.path.join(params.config['hostLevelParams']['jdk_location'], "sqljdbc4.jar"), + os.path.join(params.oozie_home, "share", "lib", "oozie", "sqljdbc4.jar") + ) + download_file(os.path.join(params.config['hostLevelParams']['jdk_location'], "sqljdbc4.jar"), + os.path.join(params.oozie_home, "temp", "WEB-INF", "lib", "sqljdbc4.jar") + ) # TODO: see if see can remove this +@OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT) def oozie(is_server=False): import params http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_server.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_server.py index e047027..0bf084e 100644 --- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_server.py +++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_server.py @@ -24,7 +24,6 @@ from resource_management.core import Logger from resource_management.core.resources.system import Execute from resource_management.libraries.functions import format from resource_management.libraries.script import Script -from resource_management.libraries.functions import check_process_status from resource_management.libraries.functions import compare_versions from resource_management.libraries.functions import format_hdp_stack_version from resource_management.libraries.functions.security_commons import build_expectations @@ -32,27 +31,25 @@ from resource_management.libraries.functions.security_commons import cached_kini from resource_management.libraries.functions.security_commons import get_params_from_filesystem from resource_management.libraries.functions.security_commons import validate_security_config_properties from resource_management.libraries.functions.security_commons import FILE_TYPE_XML +from ambari_commons import OSConst +from ambari_commons.os_family_impl import OsFamilyImpl from oozie import oozie from oozie_service import oozie_service +from check_oozie_server_status import check_oozie_server_status class OozieServer(Script): - def get_stack_to_component(self): - return {"HDP": "oozie-server"} - def install(self, env): self.install_packages(env) - def configure(self, env): import params env.set_params(params) oozie(is_server=True) - def start(self, env, rolling_restart=False): import params env.set_params(params) @@ -61,7 +58,6 @@ class OozieServer(Script): oozie_service(action='start', rolling_restart=rolling_restart) - def stop(self, env, rolling_restart=False): import params env.set_params(params) @@ -71,11 +67,16 @@ class OozieServer(Script): def status(self, env): import status_params env.set_params(status_params) - check_process_status(status_params.pid_file) + check_oozie_server_status() - def security_status(self, env): +@OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT) +class OozieServerDefault(OozieServer): + def get_stack_to_component(self): + return {"HDP": "oozie-server"} + + def security_status(self, env): import status_params env.set_params(status_params) @@ -138,7 +139,6 @@ class OozieServer(Script): else: self.put_structured_out({"securityState": "UNSECURED"}) - def pre_rolling_restart(self, env): """ Performs the tasks surrounding the Oozie startup when a rolling upgrade @@ -165,6 +165,9 @@ class OozieServer(Script): oozie_server_upgrade.prepare_libext_directory() oozie_server_upgrade.upgrade_oozie() +@OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY) +class OozieServerWindows(OozieServer): + pass if __name__ == "__main__": OozieServer().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py index 1715f82..34ac6e5 100644 --- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py +++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/oozie_service.py @@ -19,7 +19,21 @@ limitations under the License. """ import os from resource_management import * +from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl +from ambari_commons import OSConst +@OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY) +def oozie_service(action='start', rolling_restart=False): + import params + + if action == 'start': + cmd = format("cmd /C \"cd /d {oozie_tmp_dir} && {oozie_home}\\bin\\ooziedb.cmd create -sqlfile oozie.sql -run\"") + Execute(cmd, user=params.oozie_user, ignore_failures=True) + Service(params.oozie_server_win_service_name, action="start") + elif action == 'stop': + Service(params.oozie_server_win_service_name, action="stop") + +@OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT) def oozie_service(action = 'start', rolling_restart=False): """ Starts or stops the Oozie service http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params.py index e788eb2..a10c1d4 100644 --- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params.py +++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params.py @@ -17,198 +17,9 @@ See the License for the specific language governing permissions and limitations under the License. """ +from ambari_commons import OSCheck -from ambari_commons.constants import AMBARI_SUDO_BINARY -from resource_management import * -from resource_management.core import System -from resource_management.libraries import Script -from resource_management.libraries.functions import default -from resource_management.libraries.functions import get_kinit_path -from resource_management.libraries.functions import get_port_from_url -from resource_management.libraries.functions import format -from resource_management.libraries.functions.version import format_hdp_stack_version -from resource_management.libraries.functions.version import compare_versions -from resource_management.libraries.resources import HdfsDirectory - -import status_params -import itertools -import os - -# server configurations -config = Script.get_config() -tmp_dir = Script.get_tmp_dir() -sudo = AMBARI_SUDO_BINARY - -hostname = config["hostname"] - -# New Cluster Stack Version that is defined during the RESTART of a Rolling Upgrade -version = default("/commandParams/version", None) -stack_name = default("/hostLevelParams/stack_name", None) -upgrade_direction = default("/commandParams/upgrade_direction", None) - -stack_version_unformatted = str(config['hostLevelParams']['stack_version']) -hdp_stack_version = format_hdp_stack_version(stack_version_unformatted) - -#hadoop params -if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0: - # start out assuming client libraries - hadoop_bin_dir = "/usr/hdp/current/hadoop-client/bin" - hadoop_lib_home = "/usr/hdp/current/hadoop-client/lib" - - # if this is a server action, then use the server binaries; smoke tests - # use the client binaries - server_role_dir_mapping = { 'OOZIE_SERVER' : 'oozie-server', - 'OOZIE_SERVICE_CHECK' : 'oozie-client' } - - command_role = default("/role", "") - if command_role not in server_role_dir_mapping: - command_role = 'OOZIE_SERVICE_CHECK' - - oozie_root = server_role_dir_mapping[command_role] - - # using the correct oozie root dir, format the correct location - oozie_lib_dir = format("/usr/hdp/current/{oozie_root}") - oozie_setup_sh = format("/usr/hdp/current/{oozie_root}/bin/oozie-setup.sh") - oozie_webapps_dir = format("/usr/hdp/current/{oozie_root}/oozie-server/webapps") - oozie_webapps_conf_dir = format("/usr/hdp/current/{oozie_root}/oozie-server/conf") - oozie_libext_dir = format("/usr/hdp/current/{oozie_root}/libext") - oozie_libext_customer_dir = format("/usr/hdp/current/{oozie_root}/libext-customer") - oozie_server_dir = format("/usr/hdp/current/{oozie_root}/oozie-server") - oozie_shared_lib = format("/usr/hdp/current/{oozie_root}/share") - oozie_home = format("/usr/hdp/current/{oozie_root}") - oozie_bin_dir = format("/usr/hdp/current/{oozie_root}/bin") - falcon_home = '/usr/hdp/current/falcon-client' +if OSCheck.is_windows_family(): + from params_windows import * else: - hadoop_bin_dir = "/usr/bin" - hadoop_lib_home = "/usr/lib/hadoop/lib" - oozie_lib_dir = "/var/lib/oozie" - oozie_setup_sh = "/usr/lib/oozie/bin/oozie-setup.sh" - oozie_webapps_dir = "/var/lib/oozie/oozie-server/webapps/" - oozie_webapps_conf_dir = "/var/lib/oozie/oozie-server/conf" - oozie_libext_dir = "/usr/lib/oozie/libext" - oozie_server_dir = "/var/lib/oozie/oozie-server" - oozie_shared_lib = "/usr/lib/oozie/share" - oozie_home = "/usr/lib/oozie" - oozie_bin_dir = "/usr/bin" - falcon_home = '/usr/lib/falcon' - -execute_path = oozie_bin_dir + os.pathsep + hadoop_bin_dir - -hadoop_conf_dir = "/etc/hadoop/conf" -conf_dir = "/etc/oozie/conf" -hive_conf_dir = "/etc/oozie/conf/action-conf/hive" -oozie_user = config['configurations']['oozie-env']['oozie_user'] -smokeuser = config['configurations']['cluster-env']['smokeuser'] -smokeuser_principal = config['configurations']['cluster-env']['smokeuser_principal_name'] -user_group = config['configurations']['cluster-env']['user_group'] -jdk_location = config['hostLevelParams']['jdk_location'] -check_db_connection_jar_name = "DBConnectionVerification.jar" -check_db_connection_jar = format("/usr/lib/ambari-agent/{check_db_connection_jar_name}") -oozie_tmp_dir = "/var/tmp/oozie" -oozie_hdfs_user_dir = format("/user/{oozie_user}") -oozie_pid_dir = status_params.oozie_pid_dir -pid_file = status_params.pid_file -hadoop_jar_location = "/usr/lib/hadoop/" -java_share_dir = "/usr/share/java" -# for HDP1 it's "/usr/share/HDP-oozie/ext.zip" -ext_js_file = "ext-2.2.zip" -ext_js_path = format("/usr/share/HDP-oozie/{ext_js_file}") -security_enabled = config['configurations']['cluster-env']['security_enabled'] -oozie_heapsize = config['configurations']['oozie-env']['oozie_heapsize'] -oozie_permsize = config['configurations']['oozie-env']['oozie_permsize'] - -kinit_path_local = get_kinit_path() -oozie_service_keytab = config['configurations']['oozie-site']['oozie.service.HadoopAccessorService.keytab.file'] -oozie_principal = config['configurations']['oozie-site']['oozie.service.HadoopAccessorService.kerberos.principal'] -http_principal = config['configurations']['oozie-site']['oozie.authentication.kerberos.principal'] -oozie_site = config['configurations']['oozie-site'] -if security_enabled and hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') < 0: - #older versions of oozie have problems when using _HOST in principal - oozie_site = dict(config['configurations']['oozie-site']) - oozie_site['oozie.service.HadoopAccessorService.kerberos.principal'] = \ - oozie_principal.replace('_HOST', hostname) - oozie_site['oozie.authentication.kerberos.principal'] = \ - http_principal.replace('_HOST', hostname) - -smokeuser_keytab = config['configurations']['cluster-env']['smokeuser_keytab'] -oozie_keytab = default("/configurations/oozie-env/oozie_keytab", oozie_service_keytab) -oozie_env_sh_template = config['configurations']['oozie-env']['content'] - -oracle_driver_jar_name = "ojdbc6.jar" - -java_home = config['hostLevelParams']['java_home'] -java_version = int(config['hostLevelParams']['java_version']) -oozie_metastore_user_name = config['configurations']['oozie-site']['oozie.service.JPAService.jdbc.username'] -oozie_metastore_user_passwd = default("/configurations/oozie-site/oozie.service.JPAService.jdbc.password","") -oozie_jdbc_connection_url = default("/configurations/oozie-site/oozie.service.JPAService.jdbc.url", "") -oozie_log_dir = config['configurations']['oozie-env']['oozie_log_dir'] -oozie_data_dir = config['configurations']['oozie-env']['oozie_data_dir'] -oozie_server_port = get_port_from_url(config['configurations']['oozie-site']['oozie.base.url']) -oozie_server_admin_port = config['configurations']['oozie-env']['oozie_admin_port'] -fs_root = config['configurations']['core-site']['fs.defaultFS'] - -if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.0') >= 0 and compare_versions(hdp_stack_version, '2.2') < 0: - put_shared_lib_to_hdfs_cmd = format("hadoop --config {hadoop_conf_dir} dfs -put {oozie_shared_lib} {oozie_hdfs_user_dir}") -# for newer -else: - put_shared_lib_to_hdfs_cmd = format("{oozie_setup_sh} sharelib create -fs {fs_root} -locallib {oozie_shared_lib}") - -jdbc_driver_name = default("/configurations/oozie-site/oozie.service.JPAService.jdbc.driver", "") - -if jdbc_driver_name == "com.microsoft.sqlserver.jdbc.SQLServerDriver": - jdbc_driver_jar = "sqljdbc4.jar" - jdbc_symlink_name = "mssql-jdbc-driver.jar" -elif jdbc_driver_name == "com.mysql.jdbc.Driver": - jdbc_driver_jar = "mysql-connector-java.jar" - jdbc_symlink_name = "mysql-jdbc-driver.jar" -elif jdbc_driver_name == "org.postgresql.Driver": - jdbc_driver_jar = format("{oozie_home}/libserver/postgresql-9.0-801.jdbc4.jar") #oozie using it's own postgres jdbc - jdbc_symlink_name = "postgres-jdbc-driver.jar" -elif jdbc_driver_name == "oracle.jdbc.driver.OracleDriver": - jdbc_driver_jar = "ojdbc.jar" - jdbc_symlink_name = "oracle-jdbc-driver.jar" -else: - jdbc_driver_jar = "" - jdbc_symlink_name = "" - -driver_curl_source = format("{jdk_location}/{jdbc_symlink_name}") -driver_curl_target = format("{java_share_dir}/{jdbc_driver_jar}") -downloaded_custom_connector = format("{tmp_dir}/{jdbc_driver_jar}") -if jdbc_driver_name == "org.postgresql.Driver": - target = jdbc_driver_jar -else: - target = format("{oozie_libext_dir}/{jdbc_driver_jar}") - - -ambari_server_hostname = config['clusterHostInfo']['ambari_server_host'][0] -falcon_host = default("/clusterHostInfo/falcon_server_hosts", []) -has_falcon_host = not len(falcon_host) == 0 - -#oozie-log4j.properties -if (('oozie-log4j' in config['configurations']) and ('content' in config['configurations']['oozie-log4j'])): - log4j_props = config['configurations']['oozie-log4j']['content'] -else: - log4j_props = None - -oozie_hdfs_user_mode = 0775 -hdfs_user_keytab = config['configurations']['hadoop-env']['hdfs_user_keytab'] -hdfs_user = config['configurations']['hadoop-env']['hdfs_user'] -hdfs_principal_name = config['configurations']['hadoop-env']['hdfs_principal_name'] -import functools -#create partial functions with common arguments for every HdfsDirectory call -#to create hdfs directory we need to call params.HdfsDirectory in code -HdfsDirectory = functools.partial( - HdfsDirectory, - conf_dir=hadoop_conf_dir, - hdfs_user=hdfs_user, - security_enabled = security_enabled, - keytab = hdfs_user_keytab, - kinit_path_local = kinit_path_local, - bin_dir = hadoop_bin_dir -) - -# The logic for LZO also exists in HDFS' params.py -io_compression_codecs = default("/configurations/core-site/io.compression.codecs", None) -lzo_enabled = io_compression_codecs is not None and "com.hadoop.compression.lzo" in io_compression_codecs.lower() - -all_lzo_packages = get_lzo_packages(stack_version_unformatted) \ No newline at end of file + from params_linux import * http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py new file mode 100644 index 0000000..c9ae569 --- /dev/null +++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_linux.py @@ -0,0 +1,214 @@ +#!/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 ambari_commons.constants import AMBARI_SUDO_BINARY +from resource_management import * +from resource_management.core import System +from resource_management.libraries import Script +from resource_management.libraries.functions import default +from resource_management.libraries.functions import get_kinit_path +from resource_management.libraries.functions import get_port_from_url +from resource_management.libraries.functions import format +from resource_management.libraries.functions.version import format_hdp_stack_version +from resource_management.libraries.functions.version import compare_versions +from resource_management.libraries.resources import HdfsDirectory + +import status_params +import itertools +import os + +# server configurations +config = Script.get_config() +tmp_dir = Script.get_tmp_dir() +sudo = AMBARI_SUDO_BINARY + +hostname = config["hostname"] + +# New Cluster Stack Version that is defined during the RESTART of a Rolling Upgrade +version = default("/commandParams/version", None) +stack_name = default("/hostLevelParams/stack_name", None) +upgrade_direction = default("/commandParams/upgrade_direction", None) + +stack_version_unformatted = str(config['hostLevelParams']['stack_version']) +hdp_stack_version = format_hdp_stack_version(stack_version_unformatted) + +#hadoop params +if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') >= 0: + # start out assuming client libraries + hadoop_bin_dir = "/usr/hdp/current/hadoop-client/bin" + hadoop_lib_home = "/usr/hdp/current/hadoop-client/lib" + + # if this is a server action, then use the server binaries; smoke tests + # use the client binaries + server_role_dir_mapping = { 'OOZIE_SERVER' : 'oozie-server', + 'OOZIE_SERVICE_CHECK' : 'oozie-client' } + + command_role = default("/role", "") + if command_role not in server_role_dir_mapping: + command_role = 'OOZIE_SERVICE_CHECK' + + oozie_root = server_role_dir_mapping[command_role] + + # using the correct oozie root dir, format the correct location + oozie_lib_dir = format("/usr/hdp/current/{oozie_root}") + oozie_setup_sh = format("/usr/hdp/current/{oozie_root}/bin/oozie-setup.sh") + oozie_webapps_dir = format("/usr/hdp/current/{oozie_root}/oozie-server/webapps") + oozie_webapps_conf_dir = format("/usr/hdp/current/{oozie_root}/oozie-server/conf") + oozie_libext_dir = format("/usr/hdp/current/{oozie_root}/libext") + oozie_libext_customer_dir = format("/usr/hdp/current/{oozie_root}/libext-customer") + oozie_server_dir = format("/usr/hdp/current/{oozie_root}/oozie-server") + oozie_shared_lib = format("/usr/hdp/current/{oozie_root}/share") + oozie_home = format("/usr/hdp/current/{oozie_root}") + oozie_bin_dir = format("/usr/hdp/current/{oozie_root}/bin") + falcon_home = '/usr/hdp/current/falcon-client' +else: + hadoop_bin_dir = "/usr/bin" + hadoop_lib_home = "/usr/lib/hadoop/lib" + oozie_lib_dir = "/var/lib/oozie" + oozie_setup_sh = "/usr/lib/oozie/bin/oozie-setup.sh" + oozie_webapps_dir = "/var/lib/oozie/oozie-server/webapps/" + oozie_webapps_conf_dir = "/var/lib/oozie/oozie-server/conf" + oozie_libext_dir = "/usr/lib/oozie/libext" + oozie_server_dir = "/var/lib/oozie/oozie-server" + oozie_shared_lib = "/usr/lib/oozie/share" + oozie_home = "/usr/lib/oozie" + oozie_bin_dir = "/usr/bin" + falcon_home = '/usr/lib/falcon' + +execute_path = oozie_bin_dir + os.pathsep + hadoop_bin_dir + +hadoop_conf_dir = "/etc/hadoop/conf" +conf_dir = "/etc/oozie/conf" +hive_conf_dir = "/etc/oozie/conf/action-conf/hive" +oozie_user = config['configurations']['oozie-env']['oozie_user'] +smokeuser = config['configurations']['cluster-env']['smokeuser'] +smokeuser_principal = config['configurations']['cluster-env']['smokeuser_principal_name'] +user_group = config['configurations']['cluster-env']['user_group'] +jdk_location = config['hostLevelParams']['jdk_location'] +check_db_connection_jar_name = "DBConnectionVerification.jar" +check_db_connection_jar = format("/usr/lib/ambari-agent/{check_db_connection_jar_name}") +oozie_tmp_dir = "/var/tmp/oozie" +oozie_hdfs_user_dir = format("/user/{oozie_user}") +oozie_pid_dir = status_params.oozie_pid_dir +pid_file = status_params.pid_file +hadoop_jar_location = "/usr/lib/hadoop/" +java_share_dir = "/usr/share/java" +# for HDP1 it's "/usr/share/HDP-oozie/ext.zip" +ext_js_file = "ext-2.2.zip" +ext_js_path = format("/usr/share/HDP-oozie/{ext_js_file}") +security_enabled = config['configurations']['cluster-env']['security_enabled'] +oozie_heapsize = config['configurations']['oozie-env']['oozie_heapsize'] +oozie_permsize = config['configurations']['oozie-env']['oozie_permsize'] + +kinit_path_local = get_kinit_path() +oozie_service_keytab = config['configurations']['oozie-site']['oozie.service.HadoopAccessorService.keytab.file'] +oozie_principal = config['configurations']['oozie-site']['oozie.service.HadoopAccessorService.kerberos.principal'] +http_principal = config['configurations']['oozie-site']['oozie.authentication.kerberos.principal'] +oozie_site = config['configurations']['oozie-site'] +if security_enabled and hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.2') < 0: + #older versions of oozie have problems when using _HOST in principal + oozie_site = dict(config['configurations']['oozie-site']) + oozie_site['oozie.service.HadoopAccessorService.kerberos.principal'] = \ + oozie_principal.replace('_HOST', hostname) + oozie_site['oozie.authentication.kerberos.principal'] = \ + http_principal.replace('_HOST', hostname) + +smokeuser_keytab = config['configurations']['cluster-env']['smokeuser_keytab'] +oozie_keytab = default("/configurations/oozie-env/oozie_keytab", oozie_service_keytab) +oozie_env_sh_template = config['configurations']['oozie-env']['content'] + +oracle_driver_jar_name = "ojdbc6.jar" + +java_home = config['hostLevelParams']['java_home'] +java_version = int(config['hostLevelParams']['java_version']) +oozie_metastore_user_name = config['configurations']['oozie-site']['oozie.service.JPAService.jdbc.username'] +oozie_metastore_user_passwd = default("/configurations/oozie-site/oozie.service.JPAService.jdbc.password","") +oozie_jdbc_connection_url = default("/configurations/oozie-site/oozie.service.JPAService.jdbc.url", "") +oozie_log_dir = config['configurations']['oozie-env']['oozie_log_dir'] +oozie_data_dir = config['configurations']['oozie-env']['oozie_data_dir'] +oozie_server_port = get_port_from_url(config['configurations']['oozie-site']['oozie.base.url']) +oozie_server_admin_port = config['configurations']['oozie-env']['oozie_admin_port'] +fs_root = config['configurations']['core-site']['fs.defaultFS'] + +if hdp_stack_version != "" and compare_versions(hdp_stack_version, '2.0') >= 0 and compare_versions(hdp_stack_version, '2.2') < 0: + put_shared_lib_to_hdfs_cmd = format("hadoop --config {hadoop_conf_dir} dfs -put {oozie_shared_lib} {oozie_hdfs_user_dir}") +# for newer +else: + put_shared_lib_to_hdfs_cmd = format("{oozie_setup_sh} sharelib create -fs {fs_root} -locallib {oozie_shared_lib}") + +jdbc_driver_name = default("/configurations/oozie-site/oozie.service.JPAService.jdbc.driver", "") + +if jdbc_driver_name == "com.microsoft.sqlserver.jdbc.SQLServerDriver": + jdbc_driver_jar = "sqljdbc4.jar" + jdbc_symlink_name = "mssql-jdbc-driver.jar" +elif jdbc_driver_name == "com.mysql.jdbc.Driver": + jdbc_driver_jar = "mysql-connector-java.jar" + jdbc_symlink_name = "mysql-jdbc-driver.jar" +elif jdbc_driver_name == "org.postgresql.Driver": + jdbc_driver_jar = format("{oozie_home}/libserver/postgresql-9.0-801.jdbc4.jar") #oozie using it's own postgres jdbc + jdbc_symlink_name = "postgres-jdbc-driver.jar" +elif jdbc_driver_name == "oracle.jdbc.driver.OracleDriver": + jdbc_driver_jar = "ojdbc.jar" + jdbc_symlink_name = "oracle-jdbc-driver.jar" +else: + jdbc_driver_jar = "" + jdbc_symlink_name = "" + +driver_curl_source = format("{jdk_location}/{jdbc_symlink_name}") +driver_curl_target = format("{java_share_dir}/{jdbc_driver_jar}") +downloaded_custom_connector = format("{tmp_dir}/{jdbc_driver_jar}") +if jdbc_driver_name == "org.postgresql.Driver": + target = jdbc_driver_jar +else: + target = format("{oozie_libext_dir}/{jdbc_driver_jar}") + + +ambari_server_hostname = config['clusterHostInfo']['ambari_server_host'][0] +falcon_host = default("/clusterHostInfo/falcon_server_hosts", []) +has_falcon_host = not len(falcon_host) == 0 + +#oozie-log4j.properties +if (('oozie-log4j' in config['configurations']) and ('content' in config['configurations']['oozie-log4j'])): + log4j_props = config['configurations']['oozie-log4j']['content'] +else: + log4j_props = None + +oozie_hdfs_user_mode = 0775 +hdfs_user_keytab = config['configurations']['hadoop-env']['hdfs_user_keytab'] +hdfs_user = config['configurations']['hadoop-env']['hdfs_user'] +hdfs_principal_name = config['configurations']['hadoop-env']['hdfs_principal_name'] +import functools +#create partial functions with common arguments for every HdfsDirectory call +#to create hdfs directory we need to call params.HdfsDirectory in code +HdfsDirectory = functools.partial( + HdfsDirectory, + conf_dir=hadoop_conf_dir, + hdfs_user=hdfs_user, + security_enabled = security_enabled, + keytab = hdfs_user_keytab, + kinit_path_local = kinit_path_local, + bin_dir = hadoop_bin_dir +) + +# The logic for LZO also exists in HDFS' params.py +io_compression_codecs = default("/configurations/core-site/io.compression.codecs", None) +lzo_enabled = io_compression_codecs is not None and "com.hadoop.compression.lzo" in io_compression_codecs.lower() + +all_lzo_packages = get_lzo_packages(stack_version_unformatted) http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_windows.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_windows.py new file mode 100644 index 0000000..9d6b062 --- /dev/null +++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/params_windows.py @@ -0,0 +1,33 @@ +""" +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 resource_management.libraries.script.script import Script +import os +from status_params import * + +config = Script.get_config() + +hdp_root = os.path.abspath(os.path.join(os.environ["HADOOP_HOME"], "..")) +oozie_root = os.environ['OOZIE_ROOT'] +oozie_home = os.environ['OOZIE_HOME'] +oozie_conf_dir = os.path.join(oozie_home,'conf') +oozie_user = "hadoop" +oozie_tmp_dir = "c:\\hadoop\\temp\\oozie" + +oozie_env_cmd_template = config['configurations']['oozie-env']['content'] http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/service_check.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/service_check.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/service_check.py index de68ca5..d589452 100644 --- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/service_check.py +++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/service_check.py @@ -23,41 +23,63 @@ from resource_management.core.source import StaticFile from resource_management.core.system import System from resource_management.libraries.functions import format from resource_management.libraries.script import Script +from ambari_commons.os_family_impl import OsFamilyImpl +from ambari_commons import OSConst +import os + class OozieServiceCheck(Script): + pass + +@OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT) +class OozieServiceCheckDefault(OozieServiceCheck): + def service_check(self, env): import params env.set_params(params) - + # on HDP1 this file is different smoke_test_file_name = 'oozieSmoke2.sh' - oozie_smoke_shell_file( smoke_test_file_name) + OozieServiceCheckDefault.oozie_smoke_shell_file(smoke_test_file_name) + + @staticmethod + def oozie_smoke_shell_file(file_name): + import params + File(format("{tmp_dir}/{file_name}"), + content=StaticFile(file_name), + mode=0755 + ) -def oozie_smoke_shell_file(file_name): - import params + os_family = System.get_instance().os_family - File( format("{tmp_dir}/{file_name}"), - content = StaticFile(file_name), - mode = 0755 - ) + if params.security_enabled: + sh_cmd = format( + "{tmp_dir}/{file_name} {os_family} {oozie_lib_dir} {conf_dir} {oozie_bin_dir} {hadoop_conf_dir} {hadoop_bin_dir} {smokeuser} {security_enabled} {smokeuser_keytab} {kinit_path_local} {smokeuser_principal}") + else: + sh_cmd = format( + "{tmp_dir}/{file_name} {os_family} {oozie_lib_dir} {conf_dir} {oozie_bin_dir} {hadoop_conf_dir} {hadoop_bin_dir} {smokeuser} {security_enabled}") - os_family = System.get_instance().os_family + Execute(format("{tmp_dir}/{file_name}"), + command=sh_cmd, + path=params.execute_path, + tries=3, + try_sleep=5, + logoutput=True + ) - if params.security_enabled: - sh_cmd = format("{tmp_dir}/{file_name} {os_family} {oozie_lib_dir} {conf_dir} {oozie_bin_dir} {hadoop_conf_dir} {hadoop_bin_dir} {smokeuser} {security_enabled} {smokeuser_keytab} {kinit_path_local} {smokeuser_principal}") - else: - sh_cmd = format("{tmp_dir}/{file_name} {os_family} {oozie_lib_dir} {conf_dir} {oozie_bin_dir} {hadoop_conf_dir} {hadoop_bin_dir} {smokeuser} {security_enabled}") +@OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY) +class OozieServiceCheckWindows(OozieServiceCheck): + + def service_check(self, env): + import params + + env.set_params(params) + smoke_cmd = os.path.join(params.hdp_root, "Run-SmokeTests.cmd") + service = "OOZIE" + Execute(format("cmd /C {smoke_cmd} {service}"), logoutput=True) - Execute( format("{tmp_dir}/{file_name}"), - command = sh_cmd, - path = params.execute_path, - tries = 3, - try_sleep = 5, - logoutput = True - ) - if __name__ == "__main__": OozieServiceCheck().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/status_params.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/status_params.py b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/status_params.py index 13e1edf..5ae57fe 100644 --- a/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/status_params.py +++ b/ambari-server/src/main/resources/common-services/OOZIE/4.0.0.2.0/package/scripts/status_params.py @@ -19,15 +19,20 @@ limitations under the License. """ from resource_management import * +from ambari_commons import OSCheck config = Script.get_config() -oozie_pid_dir = config['configurations']['oozie-env']['oozie_pid_dir'] -pid_file = format("{oozie_pid_dir}/oozie.pid") +if OSCheck.is_windows_family(): + # windows service mapping + oozie_server_win_service_name = "oozieservice" +else: + oozie_pid_dir = config['configurations']['oozie-env']['oozie_pid_dir'] + pid_file = format("{oozie_pid_dir}/oozie.pid") -security_enabled = config['configurations']['cluster-env']['security_enabled'] -kinit_path_local = functions.get_kinit_path() -conf_dir = "/etc/oozie/conf" -tmp_dir = Script.get_tmp_dir() -oozie_user = config['configurations']['oozie-env']['oozie_user'] -hostname = config["hostname"] + security_enabled = config['configurations']['cluster-env']['security_enabled'] + kinit_path_local = functions.get_kinit_path() + conf_dir = "/etc/oozie/conf" + tmp_dir = Script.get_tmp_dir() + oozie_user = config['configurations']['oozie-env']['oozie_user'] + hostname = config["hostname"] http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/oozie.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/oozie.py b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/oozie.py deleted file mode 100644 index 25530e3..0000000 --- a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/oozie.py +++ /dev/null @@ -1,43 +0,0 @@ -""" -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. - -Ambari Agent - -""" - -from resource_management import * -import os - -def oozie(): - import params - XmlConfig("oozie-site.xml", - conf_dir = params.oozie_conf_dir, - configurations = params.config['configurations']['oozie-site'], - owner = params.oozie_user, - mode = 'f', - configuration_attributes=params.config['configuration_attributes']['oozie-site'] - ) - - File(os.path.join(params.oozie_conf_dir, "oozie-env.cmd"), - owner=params.oozie_user, - content=InlineTemplate(params.oozie_env_cmd_template) - ) - - Directory( params.oozie_tmp_dir, - owner = params.oozie_user, - recursive = True, - ) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/oozie_client.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/oozie_client.py b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/oozie_client.py deleted file mode 100644 index 164c940..0000000 --- a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/oozie_client.py +++ /dev/null @@ -1,40 +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. - -""" - -from resource_management import * -from oozie import oozie - -class OozieClient(Script): - def install(self, env): - # client checks env var to determine if it is installed - if not os.environ.has_key("OOZIE_HOME"): - self.install_packages(env) - self.configure(env) - - def configure(self, env): - import params - env.set_params(params) - oozie() - - def status(self, env): - raise ClientComponentHasNoStatus() - -if __name__ == "__main__": - OozieClient().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/oozie_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/oozie_server.py b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/oozie_server.py deleted file mode 100644 index 0f7c790..0000000 --- a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/oozie_server.py +++ /dev/null @@ -1,68 +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. - -""" - -import sys -import service_mapping -from resource_management import * -from oozie import oozie -from ambari_commons.inet_utils import force_download_file - -class OozieServer(Script): - def install(self, env): - import params - if not check_windows_service_exists(service_mapping.oozie_server_win_service_name): - self.install_packages(env) - force_download_file(os.path.join(params.config['hostLevelParams']['jdk_location'], "sqljdbc4.jar"), - os.path.join(params.oozie_root, "extra_libs", "sqljdbc4.jar") - ) - webapps_sqljdbc_path = os.path.join(params.oozie_home, "oozie-server", "webapps", "oozie", "WEB-INF", "lib", "sqljdbc4.jar") - if os.path.isfile(webapps_sqljdbc_path): - force_download_file(os.path.join(params.config['hostLevelParams']['jdk_location'], "sqljdbc4.jar"), - webapps_sqljdbc_path - ) - force_download_file(os.path.join(params.config['hostLevelParams']['jdk_location'], "sqljdbc4.jar"), - os.path.join(params.oozie_home, "share", "lib", "oozie", "sqljdbc4.jar") - ) - force_download_file(os.path.join(params.config['hostLevelParams']['jdk_location'], "sqljdbc4.jar"), - os.path.join(params.oozie_home, "temp", "WEB-INF", "lib", "sqljdbc4.jar") - ) - - def configure(self, env): - oozie() - - def start(self, env): - import params - env.set_params(params) - self.configure(env) - cmd = format("cmd /C \"cd /d {oozie_tmp_dir} && {oozie_home}\\bin\\ooziedb.cmd create -sqlfile oozie.sql -run\"") - Execute( cmd, user = params.oozie_user, ignore_failures = True ) - Service(service_mapping.oozie_server_win_service_name, action="start") - - def stop(self, env): - import params - env.set_params(params) - Service(service_mapping.oozie_server_win_service_name, action="stop") - - def status(self, env): - import params - check_windows_service_status(service_mapping.oozie_server_win_service_name) - -if __name__ == "__main__": - OozieServer().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/params.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/params.py b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/params.py deleted file mode 100644 index 16c6a1e..0000000 --- a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/params.py +++ /dev/null @@ -1,34 +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. - -""" - -from resource_management import * -import os - -# server configurations -config = Script.get_config() - -hdp_root = os.path.abspath(os.path.join(os.environ["HADOOP_HOME"], "..")) -oozie_root = os.environ['OOZIE_ROOT'] -oozie_home = os.environ['OOZIE_HOME'] -oozie_conf_dir = os.path.join(oozie_home,'conf') -oozie_user = "hadoop" -oozie_tmp_dir = "c:\\hadoop\\temp\\oozie" - -oozie_env_cmd_template = config['configurations']['oozie-env']['content'] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/service_check.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/service_check.py b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/service_check.py deleted file mode 100644 index 3867819..0000000 --- a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/service_check.py +++ /dev/null @@ -1,32 +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. - -""" - -from resource_management import * - -class OozieServiceCheck(Script): - def service_check(self, env): - import params - env.set_params(params) - smoke_cmd = os.path.join(params.hdp_root,"Run-SmokeTests.cmd") - service = "OOZIE" - Execute(format("cmd /C {smoke_cmd} {service}"), logoutput=True) - -if __name__ == "__main__": - OozieServiceCheck().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/service_mapping.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/service_mapping.py b/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/service_mapping.py deleted file mode 100644 index b71b25c..0000000 --- a/ambari-server/src/main/resources/stacks/HDPWIN/2.1/services/OOZIE/package/scripts/service_mapping.py +++ /dev/null @@ -1,21 +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. - -""" - -oozie_server_win_service_name = "oozieservice" \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py index f02b55b..342e353 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py +++ b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py @@ -21,6 +21,7 @@ from mock.mock import MagicMock, call, patch from stacks.utils.RMFTestCase import * import json +@patch("platform.linux_distribution", new = MagicMock(return_value="Linux")) class TestOozieClient(RMFTestCase): COMMON_SERVICES_PACKAGE_DIR = "OOZIE/4.0.0.2.0/package" STACK_VERSION = "2.0.6" http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py index 8200060..06480b7 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py +++ b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_server.py @@ -23,7 +23,7 @@ from stacks.utils.RMFTestCase import * from resource_management.core import shell from resource_management.core.exceptions import Fail - +@patch("platform.linux_distribution", new = MagicMock(return_value="Linux")) class TestOozieServer(RMFTestCase): COMMON_SERVICES_PACKAGE_DIR = "OOZIE/4.0.0.2.0/package" STACK_VERSION = "2.0.6" http://git-wip-us.apache.org/repos/asf/ambari/blob/7be96532/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_service_check.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_service_check.py b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_service_check.py index 58af10b..bcd5ad9 100644 --- a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_service_check.py +++ b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_service_check.py @@ -21,6 +21,7 @@ from stacks.utils.RMFTestCase import * import resource_management.libraries.functions from mock.mock import MagicMock, call, patch +@patch("platform.linux_distribution", new = MagicMock(return_value="Linux")) class TestServiceCheck(RMFTestCase): COMMON_SERVICES_PACKAGE_DIR = "OOZIE/4.0.0.2.0/package" STACK_VERSION = "2.0.6"
