http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/alerts/check_supervisor_process_win.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/alerts/check_supervisor_process_win.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/alerts/check_supervisor_process_win.py deleted file mode 100644 index a698415..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/alerts/check_supervisor_process_win.py +++ /dev/null @@ -1,50 +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.libraries.functions import check_windows_service_status - - -RESULT_CODE_OK = 'OK' -RESULT_CODE_CRITICAL = 'CRITICAL' -RESULT_CODE_UNKNOWN = 'UNKNOWN' - - -def get_tokens(): - """ - Returns a tuple of tokens in the format {{site/property}} that will be used - to build the dictionary passed into execute - """ - return () - -def execute(configurations={}, parameters={}, host_name=None): - """ - Returns a tuple containing the result code and a pre-formatted result label - - Keyword arguments: - configurations (dictionary): a mapping of configuration key to value - parameters (dictionary): a mapping of script parameter key to value - host_name (string): the name of this host where the alert is running - """ - - try: - check_windows_service_status("supervisor") - return (RESULT_CODE_OK, ["Supervisor is running"]) - except: - return (RESULT_CODE_CRITICAL, ["Supervisor is stopped"])
http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/files/wordCount.jar ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/files/wordCount.jar b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/files/wordCount.jar deleted file mode 100644 index aed64be..0000000 Binary files a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/files/wordCount.jar and /dev/null differ http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/drpc_server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/drpc_server.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/drpc_server.py deleted file mode 100644 index b156578..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/drpc_server.py +++ /dev/null @@ -1,139 +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 -from resource_management.libraries.functions import check_process_status -from resource_management.libraries.script import Script -from resource_management.libraries.functions import conf_select -from resource_management.libraries.functions import stack_select -from resource_management.libraries.functions import format -from resource_management.core.resources.system import Execute -from resource_management.libraries.functions.stack_features import check_stack_feature -from resource_management.libraries.functions import StackFeature -from storm import storm -from service import service -from service_check import ServiceCheck -from resource_management.libraries.functions.security_commons import build_expectations, \ - cached_kinit_executor, get_params_from_filesystem, validate_security_config_properties, \ - FILE_TYPE_JAAS_CONF - -class DrpcServer(Script): - - def get_component_name(self): - return "storm-client" - - def install(self, env): - self.install_packages(env) - self.configure(env) - - def configure(self, env): - import params - env.set_params(params) - - storm() - - def pre_upgrade_restart(self, env, upgrade_type=None): - import params - env.set_params(params) - - if params.version and check_stack_feature(StackFeature.ROLLING_UPGRADE, params.version): - conf_select.select(params.stack_name, "storm", params.version) - stack_select.select("storm-client", params.version) - - def start(self, env, upgrade_type=None): - import params - env.set_params(params) - self.configure(env) - - service("drpc", action="start") - - def stop(self, env, upgrade_type=None): - import params - env.set_params(params) - - service("drpc", action="stop") - - def status(self, env): - import status_params - env.set_params(status_params) - check_process_status(status_params.pid_drpc) - - def security_status(self, env): - import status_params - - env.set_params(status_params) - - if status_params.security_enabled: - # Expect the following files to be available in status_params.config_dir: - # storm_jaas.conf - - try: - props_value_check = None - props_empty_check = ['StormServer/keyTab', 'StormServer/principal'] - props_read_check = ['StormServer/keyTab'] - storm_env_expectations = build_expectations('storm_jaas', props_value_check, props_empty_check, - props_read_check) - - storm_expectations = {} - storm_expectations.update(storm_env_expectations) - - security_params = get_params_from_filesystem(status_params.conf_dir, - {'storm_jaas.conf': FILE_TYPE_JAAS_CONF}) - - result_issues = validate_security_config_properties(security_params, storm_expectations) - if not result_issues: # If all validations passed successfully - # Double check the dict before calling execute - if ( 'storm_jaas' not in security_params - or 'StormServer' not in security_params['storm_jaas'] - or 'keyTab' not in security_params['storm_jaas']['StormServer'] - or 'principal' not in security_params['storm_jaas']['StormServer']): - self.put_structured_out({"securityState": "ERROR"}) - self.put_structured_out({"securityIssuesFound": "Keytab file or principal are not set property."}) - return - - cached_kinit_executor(status_params.kinit_path_local, - status_params.storm_user, - security_params['storm_jaas']['StormServer']['keyTab'], - security_params['storm_jaas']['StormServer']['principal'], - status_params.hostname, - status_params.tmp_dir) - self.put_structured_out({"securityState": "SECURED_KERBEROS"}) - else: - issues = [] - for cf in result_issues: - issues.append("Configuration file %s did not pass the validation. Reason: %s" % (cf, result_issues[cf])) - self.put_structured_out({"securityIssuesFound": ". ".join(issues)}) - self.put_structured_out({"securityState": "UNSECURED"}) - except Exception as e: - self.put_structured_out({"securityState": "ERROR"}) - self.put_structured_out({"securityStateErrorInfo": str(e)}) - else: - self.put_structured_out({"securityState": "UNSECURED"}) - - def get_log_folder(self): - import params - return params.log_dir - - def get_user(self): - import params - return params.storm_user - -if __name__ == "__main__": - DrpcServer().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus.py deleted file mode 100644 index b2148a5..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus.py +++ /dev/null @@ -1,157 +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 -from resource_management.libraries.functions import check_process_status -from resource_management.libraries.script import Script -from resource_management.libraries.functions import format -from resource_management.libraries.functions import conf_select -from resource_management.libraries.functions import stack_select -from resource_management.core.resources.system import Execute -from resource_management.libraries.functions.stack_features import check_stack_feature -from resource_management.libraries.functions import StackFeature -from storm import storm -from service import service -from resource_management.libraries.functions.security_commons import build_expectations, \ - cached_kinit_executor, get_params_from_filesystem, validate_security_config_properties, \ - FILE_TYPE_JAAS_CONF -from setup_ranger_storm import setup_ranger_storm -from ambari_commons import OSConst -from ambari_commons.os_family_impl import OsFamilyImpl -from resource_management.core.resources.service import Service - -class Nimbus(Script): - def get_component_name(self): - return "storm-nimbus" - - def install(self, env): - self.install_packages(env) - self.configure(env) - - def configure(self, env): - import params - env.set_params(params) - storm("nimbus") - - -@OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT) -class NimbusDefault(Nimbus): - - def pre_upgrade_restart(self, env, upgrade_type=None): - import params - env.set_params(params) - if params.version and check_stack_feature(StackFeature.ROLLING_UPGRADE, params.version): - conf_select.select(params.stack_name, "storm", params.version) - stack_select.select("storm-client", params.version) - stack_select.select("storm-nimbus", params.version) - - - def start(self, env, upgrade_type=None): - import params - env.set_params(params) - self.configure(env) - setup_ranger_storm(upgrade_type=upgrade_type) - service("nimbus", action="start") - - - def stop(self, env, upgrade_type=None): - import params - env.set_params(params) - service("nimbus", action="stop") - - - def status(self, env): - import status_params - env.set_params(status_params) - check_process_status(status_params.pid_nimbus) - - - def security_status(self, env): - import status_params - env.set_params(status_params) - if status_params.security_enabled: - # Expect the following files to be available in status_params.config_dir: - # storm_jaas.conf - try: - props_value_check = None - props_empty_check = ['StormServer/keyTab', 'StormServer/principal'] - props_read_check = ['StormServer/keyTab'] - storm_env_expectations = build_expectations('storm_jaas', props_value_check, props_empty_check, props_read_check) - storm_expectations = {} - storm_expectations.update(storm_env_expectations) - security_params = get_params_from_filesystem(status_params.conf_dir, {'storm_jaas.conf': FILE_TYPE_JAAS_CONF}) - result_issues = validate_security_config_properties(security_params, storm_expectations) - if not result_issues: # If all validations passed successfully - # Double check the dict before calling execute - if ( 'storm_jaas' not in security_params - or 'StormServer' not in security_params['storm_jaas'] - or 'keyTab' not in security_params['storm_jaas']['StormServer'] - or 'principal' not in security_params['storm_jaas']['StormServer']): - self.put_structured_out({"securityState": "ERROR"}) - self.put_structured_out({"securityIssuesFound": "Keytab file or principal are not set property."}) - return - - cached_kinit_executor(status_params.kinit_path_local, - status_params.storm_user, - security_params['storm_jaas']['StormServer']['keyTab'], - security_params['storm_jaas']['StormServer']['principal'], - status_params.hostname, - status_params.tmp_dir) - self.put_structured_out({"securityState": "SECURED_KERBEROS"}) - else: - issues = [] - for cf in result_issues: - issues.append("Configuration file %s did not pass the validation. Reason: %s" % (cf, result_issues[cf])) - self.put_structured_out({"securityIssuesFound": ". ".join(issues)}) - self.put_structured_out({"securityState": "UNSECURED"}) - except Exception as e: - self.put_structured_out({"securityState": "ERROR"}) - self.put_structured_out({"securityStateErrorInfo": str(e)}) - else: - self.put_structured_out({"securityState": "UNSECURED"}) - - def get_log_folder(self): - import params - return params.log_dir - - def get_user(self): - import params - return params.storm_user - -@OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY) -class NimbusWindows(Nimbus): - def start(self, env): - import status_params - env.set_params(status_params) - Service(status_params.nimbus_win_service_name, action="start") - - def stop(self, env): - import status_params - env.set_params(status_params) - Service(status_params.nimbus_win_service_name, action="stop") - - def status(self, env): - import status_params - from resource_management.libraries.functions.windows_service_utils import check_windows_service_status - env.set_params(status_params) - check_windows_service_status(status_params.nimbus_win_service_name) - -if __name__ == "__main__": - Nimbus().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus_prod.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus_prod.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus_prod.py deleted file mode 100644 index 39bda4d..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/nimbus_prod.py +++ /dev/null @@ -1,81 +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 -from resource_management.libraries.script import Script -from storm import storm -from supervisord_service import supervisord_service, supervisord_check_status -from resource_management.libraries.functions import conf_select -from resource_management.libraries.functions import stack_select -from resource_management.libraries.functions import format -from resource_management.core.resources.system import Execute -from resource_management.libraries.functions.stack_features import check_stack_feature -from resource_management.libraries.functions import StackFeature - -class Nimbus(Script): - - def get_component_name(self): - return "storm-nimbus" - - def install(self, env): - self.install_packages(env) - self.configure(env) - - def configure(self, env): - import params - env.set_params(params) - - storm() - - def pre_upgrade_restart(self, env, upgrade_type=None): - import params - env.set_params(params) - - if params.version and check_stack_feature(StackFeature.ROLLING_UPGRADE, params.version): - conf_select.select(params.stack_name, "storm", params.version) - stack_select.select("storm-client", params.version) - stack_select.select("storm-nimbus", params.version) - - def start(self, env, upgrade_type=None): - import params - env.set_params(params) - self.configure(env) - - supervisord_service("nimbus", action="start") - - def stop(self, env, upgrade_type=None): - import params - env.set_params(params) - - supervisord_service("nimbus", action="stop") - - def status(self, env): - supervisord_check_status("nimbus") - - def get_log_folder(self): - import params - return params.log_dir - - def get_user(self): - import params - return params.storm_user - -if __name__ == "__main__": - Nimbus().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/pacemaker.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/pacemaker.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/pacemaker.py deleted file mode 100644 index 2ea02e8..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/pacemaker.py +++ /dev/null @@ -1,138 +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 -from resource_management.libraries.functions import check_process_status -from resource_management.libraries.script import Script -from resource_management.libraries.functions import conf_select -from resource_management.libraries.functions import stack_select -from resource_management.libraries.functions import format -from resource_management.core.resources.system import Execute -from resource_management.libraries.functions.stack_features import check_stack_feature -from resource_management.libraries.functions import StackFeature -from storm import storm -from service import service -from service_check import ServiceCheck -from resource_management.libraries.functions.security_commons import build_expectations, \ - cached_kinit_executor, get_params_from_filesystem, validate_security_config_properties, \ - FILE_TYPE_JAAS_CONF - -class PaceMaker(Script): - - def get_component_name(self): - return "storm-client" - - def install(self, env): - self.install_packages(env) - self.configure(env) - - def configure(self, env): - import params - env.set_params(params) - storm() - - def pre_upgrade_restart(self, env, upgrade_type=None): - import params - env.set_params(params) - - if params.version and check_stack_feature(StackFeature.ROLLING_UPGRADE, params.version): - conf_select.select(params.stack_name, "storm", params.version) - stack_select.select("storm-client", params.version) - - def start(self, env, upgrade_type=None): - import params - env.set_params(params) - self.configure(env) - - service("pacemaker", action="start") - - def stop(self, env, upgrade_type=None): - import params - env.set_params(params) - - service("pacemaker", action="stop") - - def status(self, env): - import status_params - env.set_params(status_params) - check_process_status(status_params.pid_pacemaker) - - def security_status(self, env): - import status_params - - env.set_params(status_params) - - if status_params.security_enabled: - # Expect the following files to be available in status_params.config_dir: - # storm_jaas.conf - - try: - props_value_check = None - props_empty_check = ['StormServer/keyTab', 'StormServer/principal'] - props_read_check = ['StormServer/keyTab'] - storm_env_expectations = build_expectations('storm_jaas', props_value_check, props_empty_check, - props_read_check) - - storm_expectations = {} - storm_expectations.update(storm_env_expectations) - - security_params = get_params_from_filesystem(status_params.conf_dir, - {'storm_jaas.conf': FILE_TYPE_JAAS_CONF}) - - result_issues = validate_security_config_properties(security_params, storm_expectations) - if not result_issues: # If all validations passed successfully - # Double check the dict before calling execute - if ( 'storm_jaas' not in security_params - or 'StormServer' not in security_params['storm_jaas'] - or 'keyTab' not in security_params['storm_jaas']['StormServer'] - or 'principal' not in security_params['storm_jaas']['StormServer']): - self.put_structured_out({"securityState": "ERROR"}) - self.put_structured_out({"securityIssuesFound": "Keytab file or principal are not set property."}) - return - - cached_kinit_executor(status_params.kinit_path_local, - status_params.storm_user, - security_params['storm_jaas']['StormServer']['keyTab'], - security_params['storm_jaas']['StormServer']['principal'], - status_params.hostname, - status_params.tmp_dir) - self.put_structured_out({"securityState": "SECURED_KERBEROS"}) - else: - issues = [] - for cf in result_issues: - issues.append("Configuration file %s did not pass the validation. Reason: %s" % (cf, result_issues[cf])) - self.put_structured_out({"securityIssuesFound": ". ".join(issues)}) - self.put_structured_out({"securityState": "UNSECURED"}) - except Exception as e: - self.put_structured_out({"securityState": "ERROR"}) - self.put_structured_out({"securityStateErrorInfo": str(e)}) - else: - self.put_structured_out({"securityState": "UNSECURED"}) - - def get_log_folder(self): - import params - return params.log_dir - - def get_user(self): - import params - return params.storm_user - -if __name__ == "__main__": - PaceMaker().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params.py deleted file mode 100644 index f10a3f3..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params.py +++ /dev/null @@ -1,29 +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 ambari_commons import OSCheck -from resource_management.libraries.functions.default import default - -if OSCheck.is_windows_family(): - from params_windows import * -else: - from params_linux import * - -host_sys_prepped = default("/hostLevelParams/host_sys_prepped", False) -retryAble = default("/commandParams/command_retry_enabled", False) http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params_linux.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params_linux.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params_linux.py deleted file mode 100644 index d715a25..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params_linux.py +++ /dev/null @@ -1,351 +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 os -import re -import ambari_simplejson as json # simplejson is much faster comparing to Python 2.6 json module and has the same functions set. - -import status_params - -from ambari_commons.constants import AMBARI_SUDO_BINARY -from resource_management.libraries.functions.constants import Direction -from resource_management.libraries.functions import format -from resource_management.libraries.functions.version import format_stack_version -from resource_management.libraries.functions.default import default -from resource_management.libraries.functions.get_bare_principal import get_bare_principal -from resource_management.libraries.script import Script -from resource_management.libraries.resources.hdfs_resource import HdfsResource -from resource_management.libraries.functions import stack_select -from resource_management.libraries.functions import conf_select -from resource_management.libraries.functions import get_kinit_path -from resource_management.libraries.functions.get_not_managed_resources import get_not_managed_resources -from resource_management.libraries.functions.stack_features import check_stack_feature -from resource_management.libraries.functions import StackFeature -from resource_management.libraries.functions.expect import expect - -# server configurations -config = Script.get_config() -tmp_dir = Script.get_tmp_dir() -stack_root = status_params.stack_root -sudo = AMBARI_SUDO_BINARY - -cluster_name = config['clusterName'] - -stack_name = status_params.stack_name -upgrade_direction = default("/commandParams/upgrade_direction", Direction.UPGRADE) -version = default("/commandParams/version", None) - -agent_stack_retry_on_unavailability = config['hostLevelParams']['agent_stack_retry_on_unavailability'] -agent_stack_retry_count = expect("/hostLevelParams/agent_stack_retry_count", int) - -storm_component_home_dir = status_params.storm_component_home_dir -conf_dir = status_params.conf_dir - -stack_version_unformatted = status_params.stack_version_unformatted -stack_version_formatted = status_params.stack_version_formatted -stack_supports_ru = stack_version_formatted and check_stack_feature(StackFeature.ROLLING_UPGRADE, stack_version_formatted) -stack_supports_storm_kerberos = stack_version_formatted and check_stack_feature(StackFeature.STORM_KERBEROS, stack_version_formatted) -stack_supports_storm_ams = stack_version_formatted and check_stack_feature(StackFeature.STORM_AMS, stack_version_formatted) -stack_supports_ranger_kerberos = stack_version_formatted and check_stack_feature(StackFeature.RANGER_KERBEROS_SUPPORT, stack_version_formatted) - -# default hadoop params -rest_lib_dir = "/usr/lib/storm/contrib/storm-rest" -storm_bin_dir = "/usr/bin" -storm_lib_dir = "/usr/lib/storm/lib/" - -# hadoop parameters for 2.2+ -if stack_supports_ru: - rest_lib_dir = format("{storm_component_home_dir}/contrib/storm-rest") - storm_bin_dir = format("{storm_component_home_dir}/bin") - storm_lib_dir = format("{storm_component_home_dir}/lib") - log4j_dir = format("{storm_component_home_dir}/log4j2") - -storm_user = config['configurations']['storm-env']['storm_user'] -log_dir = config['configurations']['storm-env']['storm_log_dir'] -pid_dir = status_params.pid_dir -local_dir = config['configurations']['storm-site']['storm.local.dir'] -user_group = config['configurations']['cluster-env']['user_group'] -java64_home = config['hostLevelParams']['java_home'] -jps_binary = format("{java64_home}/bin/jps") -nimbus_port = config['configurations']['storm-site']['nimbus.thrift.port'] -storm_zookeeper_root_dir = default('/configurations/storm-site/storm.zookeeper.root', None) -storm_zookeeper_servers = config['configurations']['storm-site']['storm.zookeeper.servers'] -storm_zookeeper_port = config['configurations']['storm-site']['storm.zookeeper.port'] -storm_logs_supported = config['configurations']['storm-env']['storm_logs_supported'] - -# nimbus.seeds is supported in HDP 2.3.0.0 and higher -nimbus_seeds_supported = default('/configurations/storm-env/nimbus_seeds_supported', False) -nimbus_host = default('/configurations/storm-site/nimbus.host', None) -nimbus_seeds = default('/configurations/storm-site/nimbus.seeds', None) -default_topology_max_replication_wait_time_sec = default('/configurations/storm-site/topology.max.replication.wait.time.sec.default', -1) -nimbus_hosts = default("/clusterHostInfo/nimbus_hosts", []) -default_topology_min_replication_count = default('/configurations/storm-site/topology.min.replication.count.default', 1) - -#Calculate topology.max.replication.wait.time.sec and topology.min.replication.count -if len(nimbus_hosts) > 1: - # for HA Nimbus - actual_topology_max_replication_wait_time_sec = -1 - actual_topology_min_replication_count = len(nimbus_hosts) / 2 + 1 -else: - # for non-HA Nimbus - actual_topology_max_replication_wait_time_sec = default_topology_max_replication_wait_time_sec - actual_topology_min_replication_count = default_topology_min_replication_count - -if 'topology.max.replication.wait.time.sec.default' in config['configurations']['storm-site']: - del config['configurations']['storm-site']['topology.max.replication.wait.time.sec.default'] -if 'topology.min.replication.count.default' in config['configurations']['storm-site']: - del config['configurations']['storm-site']['topology.min.replication.count.default'] - -rest_api_port = "8745" -rest_api_admin_port = "8746" -rest_api_conf_file = format("{conf_dir}/config.yaml") -storm_env_sh_template = config['configurations']['storm-env']['content'] -jmxremote_port = config['configurations']['storm-env']['jmxremote_port'] - -if 'ganglia_server_host' in config['clusterHostInfo'] and len(config['clusterHostInfo']['ganglia_server_host'])>0: - ganglia_installed = True - ganglia_server = config['clusterHostInfo']['ganglia_server_host'][0] - ganglia_report_interval = 60 -else: - ganglia_installed = False - -security_enabled = config['configurations']['cluster-env']['security_enabled'] - -storm_ui_host = default("/clusterHostInfo/storm_ui_server_hosts", []) - -storm_user_nofile_limit = default('/configurations/storm-env/storm_user_nofile_limit', 128000) -storm_user_nproc_limit = default('/configurations/storm-env/storm_user_noproc_limit', 65536) - -if security_enabled: - _hostname_lowercase = config['hostname'].lower() - _storm_principal_name = config['configurations']['storm-env']['storm_principal_name'] - storm_jaas_principal = _storm_principal_name.replace('_HOST',_hostname_lowercase) - storm_keytab_path = config['configurations']['storm-env']['storm_keytab'] - - if stack_supports_storm_kerberos: - storm_ui_keytab_path = config['configurations']['storm-env']['storm_ui_keytab'] - _storm_ui_jaas_principal_name = config['configurations']['storm-env']['storm_ui_principal_name'] - storm_ui_jaas_principal = _storm_ui_jaas_principal_name.replace('_HOST',_hostname_lowercase) - storm_bare_jaas_principal = get_bare_principal(_storm_principal_name) - _nimbus_principal_name = config['configurations']['storm-env']['nimbus_principal_name'] - nimbus_jaas_principal = _nimbus_principal_name.replace('_HOST', _hostname_lowercase) - nimbus_bare_jaas_principal = get_bare_principal(_nimbus_principal_name) - nimbus_keytab_path = config['configurations']['storm-env']['nimbus_keytab'] - -kafka_bare_jaas_principal = None -if stack_supports_storm_kerberos: - if security_enabled: - storm_thrift_transport = config['configurations']['storm-site']['_storm.thrift.secure.transport'] - # generate KafkaClient jaas config if kafka is kerberoized - _kafka_principal_name = default("/configurations/kafka-env/kafka_principal_name", None) - kafka_bare_jaas_principal = get_bare_principal(_kafka_principal_name) - else: - storm_thrift_transport = config['configurations']['storm-site']['_storm.thrift.nonsecure.transport'] - -ams_collector_hosts = default("/clusterHostInfo/metrics_collector_hosts", []) -has_metric_collector = not len(ams_collector_hosts) == 0 -if has_metric_collector: - if 'cluster-env' in config['configurations'] and \ - 'metrics_collector_vip_host' in config['configurations']['cluster-env']: - metric_collector_host = config['configurations']['cluster-env']['metrics_collector_vip_host'] - else: - metric_collector_host = ams_collector_hosts[0] - if 'cluster-env' in config['configurations'] and \ - 'metrics_collector_vip_port' in config['configurations']['cluster-env']: - metric_collector_port = config['configurations']['cluster-env']['metrics_collector_vip_port'] - else: - metric_collector_web_address = default("/configurations/ams-site/timeline.metrics.service.webapp.address", "localhost:6188") - if metric_collector_web_address.find(':') != -1: - metric_collector_port = metric_collector_web_address.split(':')[1] - else: - metric_collector_port = '6188' - - metric_collector_report_interval = 60 - metric_collector_app_id = "nimbus" - if default("/configurations/ams-site/timeline.metrics.service.http.policy", "HTTP_ONLY") == "HTTPS_ONLY": - metric_collector_protocol = 'https' - else: - metric_collector_protocol = 'http' - metric_truststore_path= default("/configurations/ams-ssl-client/ssl.client.truststore.location", "") - metric_truststore_type= default("/configurations/ams-ssl-client/ssl.client.truststore.type", "") - metric_truststore_password= default("/configurations/ams-ssl-client/ssl.client.truststore.password", "") - pass -metrics_report_interval = default("/configurations/ams-site/timeline.metrics.sink.report.interval", 60) -metrics_collection_period = default("/configurations/ams-site/timeline.metrics.sink.collection.period", 10) -metric_collector_sink_jar = "/usr/lib/storm/lib/ambari-metrics-storm-sink*.jar" - -jar_jvm_opts = '' - -# Atlas related params -atlas_hosts = default('/clusterHostInfo/atlas_server_hosts', []) -has_atlas = len(atlas_hosts) > 0 -atlas_plugin_package = "atlas-metadata*-hive-plugin" -atlas_ubuntu_plugin_package = "atlas-metadata.*-hive-plugin" - -if has_atlas: - atlas_home_dir = os.environ['METADATA_HOME_DIR'] if 'METADATA_HOME_DIR' in os.environ else stack_root + '/current/atlas-server' - atlas_conf_dir = os.environ['METADATA_CONF'] if 'METADATA_CONF' in os.environ else '/etc/atlas/conf' - jar_jvm_opts = '-Datlas.conf=' + atlas_conf_dir - -# ranger host -stack_supports_ranger_audit_db = stack_version_formatted and check_stack_feature(StackFeature.RANGER_AUDIT_DB_SUPPORT, stack_version_formatted) -ranger_admin_hosts = default("/clusterHostInfo/ranger_admin_hosts", []) -has_ranger_admin = not len(ranger_admin_hosts) == 0 -xml_configurations_supported = config['configurations']['ranger-env']['xml_configurations_supported'] -ambari_server_hostname = config['clusterHostInfo']['ambari_server_host'][0] - -#ranger storm properties -policymgr_mgr_url = config['configurations']['admin-properties']['policymgr_external_url'] -xa_audit_db_name = config['configurations']['admin-properties']['audit_db_name'] -xa_audit_db_user = config['configurations']['admin-properties']['audit_db_user'] -xa_db_host = config['configurations']['admin-properties']['db_host'] -repo_name = str(config['clusterName']) + '_storm' - -common_name_for_certificate = config['configurations']['ranger-storm-plugin-properties']['common.name.for.certificate'] - -storm_ui_port = config['configurations']['storm-site']['ui.port'] - -repo_config_username = config['configurations']['ranger-storm-plugin-properties']['REPOSITORY_CONFIG_USERNAME'] -ranger_env = config['configurations']['ranger-env'] -ranger_plugin_properties = config['configurations']['ranger-storm-plugin-properties'] -policy_user = config['configurations']['ranger-storm-plugin-properties']['policy_user'] -storm_cluster_log4j_content = config['configurations']['storm-cluster-log4j']['content'] -storm_worker_log4j_content = config['configurations']['storm-worker-log4j']['content'] - -# some commands may need to supply the JAAS location when running as storm -storm_jaas_file = format("{conf_dir}/storm_jaas.conf") - -# 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_storm = (config['configurations']['ranger-storm-plugin-properties']['ranger-storm-plugin-enabled'].lower() == 'yes') - xa_audit_db_password = unicode(config['configurations']['admin-properties']['audit_db_password']) if stack_supports_ranger_audit_db else None - repo_config_password = unicode(config['configurations']['ranger-storm-plugin-properties']['REPOSITORY_CONFIG_PASSWORD']) - xa_audit_db_flavor = (config['configurations']['admin-properties']['DB_FLAVOR']).lower() - - if stack_supports_ranger_audit_db: - if xa_audit_db_flavor == 'mysql': - jdbc_jar_name = default("/hostLevelParams/custom_mysql_jdbc_name", None) - audit_jdbc_url = format('jdbc:mysql://{xa_db_host}/{xa_audit_db_name}') - jdbc_driver = "com.mysql.jdbc.Driver" - elif xa_audit_db_flavor == 'oracle': - jdbc_jar_name = default("/hostLevelParams/custom_oracle_jdbc_name", None) - colon_count = xa_db_host.count(':') - if colon_count == 2 or colon_count == 0: - audit_jdbc_url = format('jdbc:oracle:thin:@{xa_db_host}') - else: - audit_jdbc_url = format('jdbc:oracle:thin:@//{xa_db_host}') - jdbc_driver = "oracle.jdbc.OracleDriver" - elif xa_audit_db_flavor == 'postgres': - jdbc_jar_name = default("/hostLevelParams/custom_postgres_jdbc_name", None) - audit_jdbc_url = format('jdbc:postgresql://{xa_db_host}/{xa_audit_db_name}') - jdbc_driver = "org.postgresql.Driver" - elif xa_audit_db_flavor == 'mssql': - jdbc_jar_name = default("/hostLevelParams/custom_mssql_jdbc_name", None) - audit_jdbc_url = format('jdbc:sqlserver://{xa_db_host};databaseName={xa_audit_db_name}') - jdbc_driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver" - elif xa_audit_db_flavor == 'sqla': - jdbc_jar_name = default("/hostLevelParams/custom_sqlanywhere_jdbc_name", None) - audit_jdbc_url = format('jdbc:sqlanywhere:database={xa_audit_db_name};host={xa_db_host}') - jdbc_driver = "sap.jdbc4.sqlanywhere.IDriver" - - downloaded_custom_connector = format("{tmp_dir}/{jdbc_jar_name}") if stack_supports_ranger_audit_db else None - driver_curl_source = format("{jdk_location}/{jdbc_jar_name}") if stack_supports_ranger_audit_db else None - driver_curl_target = format("{storm_component_home_dir}/lib/{jdbc_jar_name}") if stack_supports_ranger_audit_db else None - sql_connector_jar = '' - - storm_ranger_plugin_config = { - 'username': repo_config_username, - 'password': repo_config_password, - 'nimbus.url': 'http://' + storm_ui_host[0].lower() + ':' + str(storm_ui_port), - 'commonNameForCertificate': common_name_for_certificate - } - - storm_ranger_plugin_repo = { - 'isActive': 'true', - 'config': json.dumps(storm_ranger_plugin_config), - 'description': 'storm repo', - 'name': repo_name, - 'repositoryType': 'storm', - 'assetType': '6' - } - - if stack_supports_ranger_kerberos and security_enabled: - storm_ranger_plugin_config['policy.download.auth.users'] = storm_user - storm_ranger_plugin_config['tag.download.auth.users'] = storm_user - - storm_ranger_plugin_repo = { - 'isEnabled': 'true', - 'configs': storm_ranger_plugin_config, - 'description': 'storm repo', - 'name': repo_name, - 'type': 'storm' - } - - if stack_supports_ranger_kerberos and security_enabled and 'storm-nimbus' in status_params.component_directory.lower(): - ranger_storm_principal = nimbus_jaas_principal - ranger_storm_keytab = nimbus_keytab_path - elif stack_supports_ranger_kerberos and security_enabled and 'storm-client' in status_params.component_directory.lower(): - ranger_storm_principal = storm_ui_jaas_principal - ranger_storm_keytab = storm_ui_keytab_path - - xa_audit_db_is_enabled = False - ranger_audit_solr_urls = config['configurations']['ranger-admin-site']['ranger.audit.solr.urls'] - if xml_configurations_supported and stack_supports_ranger_audit_db: - xa_audit_db_is_enabled = config['configurations']['ranger-storm-audit']['xasecure.audit.destination.db'] - xa_audit_hdfs_is_enabled = config['configurations']['ranger-storm-audit']['xasecure.audit.destination.hdfs'] if xml_configurations_supported else None - ssl_keystore_password = unicode(config['configurations']['ranger-storm-policymgr-ssl']['xasecure.policymgr.clientssl.keystore.password']) if xml_configurations_supported else None - ssl_truststore_password = unicode(config['configurations']['ranger-storm-policymgr-ssl']['xasecure.policymgr.clientssl.truststore.password']) if xml_configurations_supported else None - credential_file = format('/etc/ranger/{repo_name}/cred.jceks') if xml_configurations_supported else None - - #For SQLA explicitly disable audit to DB for Ranger - if xa_audit_db_flavor == 'sqla': - xa_audit_db_is_enabled = False - -namenode_hosts = default("/clusterHostInfo/namenode_host", []) -has_namenode = not len(namenode_hosts) == 0 - -hdfs_user = config['configurations']['hadoop-env']['hdfs_user'] if has_namenode else None -hdfs_user_keytab = config['configurations']['hadoop-env']['hdfs_user_keytab'] if has_namenode else None -hdfs_principal_name = config['configurations']['hadoop-env']['hdfs_principal_name'] if has_namenode else None -hdfs_site = config['configurations']['hdfs-site'] if has_namenode else None -default_fs = config['configurations']['core-site']['fs.defaultFS'] if has_namenode else None -hadoop_bin_dir = stack_select.get_hadoop_dir("bin") if has_namenode else None -hadoop_conf_dir = conf_select.get_hadoop_conf_dir() if has_namenode else None -kinit_path_local = get_kinit_path(default('/configurations/kerberos-env/executable_search_paths', None)) - -import functools -#create partial functions with common arguments for every HdfsResource call -#to create/delete hdfs directory/file/copyfromlocal we need to call params.HdfsResource in code -HdfsResource = functools.partial( - HdfsResource, - user=hdfs_user, - hdfs_resource_ignore_file = "/var/lib/ambari-agent/data/.hdfs_resource_ignore", - security_enabled = security_enabled, - keytab = hdfs_user_keytab, - kinit_path_local = kinit_path_local, - hadoop_bin_dir = hadoop_bin_dir, - hadoop_conf_dir = hadoop_conf_dir, - principal_name = hdfs_principal_name, - hdfs_site = hdfs_site, - default_fs = default_fs, - immutable_paths = get_not_managed_resources() -) http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params_windows.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params_windows.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params_windows.py deleted file mode 100644 index 88e6246..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/params_windows.py +++ /dev/null @@ -1,60 +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 status_params import * -from resource_management.libraries.functions.default import default - -# server configurations -config = Script.get_config() - -stack_is_hdp23_or_further = Script.is_stack_greater_or_equal("2.3") - -stack_root = os.path.abspath(os.path.join(os.environ["HADOOP_HOME"],"..")) -conf_dir = os.environ["STORM_CONF_DIR"] -hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"] -storm_user = hadoop_user - -security_enabled = config['configurations']['cluster-env']['security_enabled'] -default_topology_max_replication_wait_time_sec = default('/configurations/storm-site/topology.max.replication.wait.time.sec.default', -1) -nimbus_hosts = default("/clusterHostInfo/nimbus_hosts", []) -default_topology_min_replication_count = default('/configurations/storm-site/topology.min.replication.count.default', 1) - -#Calculate topology.max.replication.wait.time.sec and topology.min.replication.count -if len(nimbus_hosts) > 1: - # for HA Nimbus - actual_topology_max_replication_wait_time_sec = -1 - actual_topology_min_replication_count = len(nimbus_hosts) / 2 + 1 -else: - # for non-HA Nimbus - actual_topology_max_replication_wait_time_sec = default_topology_max_replication_wait_time_sec - actual_topology_min_replication_count = default_topology_min_replication_count - -if stack_is_hdp23_or_further: - if security_enabled: - storm_thrift_transport = config['configurations']['storm-site']['_storm.thrift.secure.transport'] - else: - storm_thrift_transport = config['configurations']['storm-site']['_storm.thrift.nonsecure.transport'] - -service_map = { - "nimbus" : nimbus_win_service_name, - "supervisor" : supervisor_win_service_name, - "ui" : ui_win_service_name -} http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/rest_api.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/rest_api.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/rest_api.py deleted file mode 100644 index 26fdb27..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/rest_api.py +++ /dev/null @@ -1,81 +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 -from resource_management.libraries.functions import check_process_status -from resource_management.libraries.script import Script -from resource_management.libraries.functions import conf_select -from resource_management.libraries.functions import stack_select -from resource_management.libraries.functions import format -from resource_management.core.resources.system import Execute - -from storm import storm -from service import service -from service_check import ServiceCheck - - -class StormRestApi(Script): - """ - Storm REST API. - It was available in HDP 2.0 and 2.1. - In HDP 2.2, it was removed since the functionality was moved to Storm UI Server. - """ - - def get_component_name(self): - return "storm-client" - - def install(self, env): - self.install_packages(env) - self.configure(env) - - def configure(self, env): - import params - env.set_params(params) - - storm() - - def start(self, env, upgrade_type=None): - import params - env.set_params(params) - self.configure(env) - - service("rest_api", action="start") - - def stop(self, env, upgrade_type=None): - import params - env.set_params(params) - - service("rest_api", action="stop") - - def status(self, env): - import status_params - env.set_params(status_params) - check_process_status(status_params.pid_rest_api) - - def get_log_folder(self): - import params - return params.log_dir - - def get_user(self): - import params - return params.storm_user - -if __name__ == "__main__": - StormRestApi().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service.py deleted file mode 100644 index 6da159a..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service.py +++ /dev/null @@ -1,97 +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 os - -from resource_management.core.resources import Execute -from resource_management.core.resources import File -from resource_management.core.shell import as_user -from resource_management.libraries.functions.format import format -from resource_management.libraries.functions import get_user_call_output -from resource_management.libraries.functions.show_logs import show_logs -import time - - -def service(name, action = 'start'): - import params - import status_params - - pid_file = status_params.pid_files[name] - no_op_test = as_user(format( - "ls {pid_file} >/dev/null 2>&1 && ps -p `cat {pid_file}` >/dev/null 2>&1"), user=params.storm_user) - tries_count = 12 - - if name == 'ui': - process_grep = "storm.ui.core$" - elif name == "rest_api": - process_grep = format("{rest_lib_dir}/storm-rest-.*\.jar$") - else: - process_grep = format("storm.daemon.{name}$") - - find_proc = format("{jps_binary} -l | grep {process_grep}") - write_pid = format("{find_proc} | awk {{'print $1'}} > {pid_file}") - crt_pid_cmd = format("{find_proc} && {write_pid}") - storm_env = format( - "source {conf_dir}/storm-env.sh ; export PATH=$JAVA_HOME/bin:$PATH") - - if action == "start": - if name == "rest_api": - process_cmd = format( - "{storm_env} ; java -jar {rest_lib_dir}/`ls {rest_lib_dir} | grep -wE storm-rest-[0-9.-]+\.jar` server") - cmd = format( - "{process_cmd} {rest_api_conf_file} > {log_dir}/restapi.log 2>&1") - else: - cmd = format("{storm_env} ; storm {name} > {log_dir}/{name}.out 2>&1") - - Execute(cmd, - not_if = no_op_test, - user = params.storm_user, - wait_for_finish = False, - path = params.storm_bin_dir) - - try: - Execute(crt_pid_cmd, - user = params.storm_user, - logoutput = True, - tries = tries_count, - try_sleep = 10, - path = params.storm_bin_dir) - except: - show_logs(params.log_dir, params.storm_user) - raise - - elif action == "stop": - process_dont_exist = format("! ({no_op_test})") - if os.path.exists(pid_file): - pid = get_user_call_output.get_user_call_output(format("! test -f {pid_file} || cat {pid_file}"), user=params.storm_user)[1] - - # if multiple processes are running (for example user can start logviewer from console) - # there can be more than one id - pid = pid.replace("\n", " ") - - Execute(format("{sudo} kill {pid}"), - not_if = process_dont_exist) - - Execute(format("{sudo} kill -9 {pid}"), - not_if = format( - "sleep 2; {process_dont_exist} || sleep 20; {process_dont_exist}"), - ignore_failures = True) - - File(pid_file, action = "delete") http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service_check.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service_check.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service_check.py deleted file mode 100644 index 80ea0f5..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/service_check.py +++ /dev/null @@ -1,79 +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 os - -from resource_management.libraries.functions.format import format -from resource_management.libraries.functions import get_unique_id_and_date -from resource_management.core.resources import File -from resource_management.core.resources import Execute -from resource_management.libraries.script import Script -from resource_management.core.source import StaticFile -from ambari_commons import OSCheck, OSConst -from ambari_commons.os_family_impl import OsFamilyImpl - -class ServiceCheck(Script): - pass - - -@OsFamilyImpl(os_family=OSConst.WINSRV_FAMILY) -class ServiceCheckWindows(ServiceCheck): - def service_check(self, env): - import params - env.set_params(params) - smoke_cmd = os.path.join(params.stack_root,"Run-SmokeTests.cmd") - service = "STORM" - Execute(format("cmd /C {smoke_cmd} {service}", smoke_cmd=smoke_cmd, service=service), user=params.storm_user, logoutput=True) - - -@OsFamilyImpl(os_family=OsFamilyImpl.DEFAULT) -class ServiceCheckDefault(ServiceCheck): - def service_check(self, env): - import params - env.set_params(params) - - unique = get_unique_id_and_date() - - File("/tmp/wordCount.jar", - content=StaticFile("wordCount.jar"), - owner=params.storm_user - ) - - cmd = "" - if params.nimbus_seeds_supported: - # Because this command is guaranteed to run on one of the hosts with storm client, there is no need - # to specify "-c nimbus.seeds={nimbus_seeds}" - cmd = format("storm jar /tmp/wordCount.jar storm.starter.WordCountTopology WordCount{unique}") - elif params.nimbus_host is not None: - cmd = format("storm jar /tmp/wordCount.jar storm.starter.WordCountTopology WordCount{unique} -c nimbus.host={nimbus_host}") - - Execute(cmd, - logoutput=True, - path=params.storm_bin_dir, - user=params.storm_user - ) - - Execute(format("storm kill WordCount{unique}"), - path=params.storm_bin_dir, - user=params.storm_user - ) - -if __name__ == "__main__": - ServiceCheck().execute() http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/setup_atlas_storm.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/setup_atlas_storm.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/setup_atlas_storm.py deleted file mode 100644 index 6c3e91f..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/setup_atlas_storm.py +++ /dev/null @@ -1,45 +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.core.resources.packaging import Package -from resource_management.core.resources.system import Link -from ambari_commons import OSCheck - -import os - -def setup_atlas_storm(): - import params - - if params.has_atlas: - - if not params.host_sys_prepped: - Package(params.atlas_ubuntu_plugin_package if OSCheck.is_ubuntu_family() else params.atlas_plugin_package, - retry_on_repo_unavailability=params.agent_stack_retry_on_unavailability, retry_count=params.agent_stack_retry_count) - - atlas_storm_hook_dir = os.path.join(params.atlas_home_dir, "hook", "storm") - if os.path.exists(atlas_storm_hook_dir): - storm_extlib_dir = os.path.join(params.storm_component_home_dir, "extlib") - if os.path.exists(storm_extlib_dir): - src_files = os.listdir(atlas_storm_hook_dir) - for file_name in src_files: - atlas_storm_hook_file_name = os.path.join(atlas_storm_hook_dir, file_name) - storm_lib_file_name = os.path.join(storm_extlib_dir, file_name) - if (os.path.isfile(atlas_storm_hook_file_name)): - Link(storm_lib_file_name, to = atlas_storm_hook_file_name) http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/setup_ranger_storm.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/setup_ranger_storm.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/setup_ranger_storm.py deleted file mode 100644 index ba4c777..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/setup_ranger_storm.py +++ /dev/null @@ -1,101 +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.core.logger import Logger - -def setup_ranger_storm(upgrade_type=None): - """ - :param upgrade_type: Upgrade Type such as "rolling" or "nonrolling" - """ - import params - if params.has_ranger_admin and params.security_enabled: - - stack_version = None - if upgrade_type is not None: - stack_version = params.version - - if params.retryAble: - Logger.info("Storm: Setup ranger: command retry enables thus retrying if ranger admin is down !") - else: - Logger.info("Storm: Setup ranger: command retry not enabled thus skipping if ranger admin is down !") - - if params.xml_configurations_supported and params.enable_ranger_storm and params.xa_audit_hdfs_is_enabled: - if params.has_namenode: - params.HdfsResource("/ranger/audit", - type="directory", - action="create_on_execute", - owner=params.hdfs_user, - group=params.hdfs_user, - mode=0755, - recursive_chmod=True - ) - params.HdfsResource("/ranger/audit/storm", - type="directory", - action="create_on_execute", - owner=params.storm_user, - group=params.storm_user, - mode=0700, - recursive_chmod=True - ) - params.HdfsResource(None, action="execute") - - if params.xml_configurations_supported: - api_version=None - if params.stack_supports_ranger_kerberos and params.security_enabled: - Logger.info('setting stack_version as v2') - api_version='v2' - from resource_management.libraries.functions.setup_ranger_plugin_xml import setup_ranger_plugin - setup_ranger_plugin('storm-nimbus', 'storm', - params.downloaded_custom_connector, params.driver_curl_source, - params.driver_curl_target, params.java64_home, - params.repo_name, params.storm_ranger_plugin_repo, - params.ranger_env, params.ranger_plugin_properties, - params.policy_user, params.policymgr_mgr_url, - params.enable_ranger_storm, conf_dict=params.conf_dir, - component_user=params.storm_user, component_group=params.user_group, cache_service_list=['storm'], - plugin_audit_properties=params.config['configurations']['ranger-storm-audit'], plugin_audit_attributes=params.config['configuration_attributes']['ranger-storm-audit'], - plugin_security_properties=params.config['configurations']['ranger-storm-security'], plugin_security_attributes=params.config['configuration_attributes']['ranger-storm-security'], - plugin_policymgr_ssl_properties=params.config['configurations']['ranger-storm-policymgr-ssl'], plugin_policymgr_ssl_attributes=params.config['configuration_attributes']['ranger-storm-policymgr-ssl'], - component_list=['storm-client', 'storm-nimbus'], audit_db_is_enabled=params.xa_audit_db_is_enabled, - credential_file=params.credential_file, xa_audit_db_password=params.xa_audit_db_password, - ssl_truststore_password=params.ssl_truststore_password, ssl_keystore_password=params.ssl_keystore_password, - stack_version_override = stack_version, skip_if_rangeradmin_down= not params.retryAble,api_version=api_version, - is_security_enabled = params.security_enabled, - is_stack_supports_ranger_kerberos = params.stack_supports_ranger_kerberos, - component_user_principal=params.ranger_storm_principal if params.security_enabled else None, - component_user_keytab=params.ranger_storm_keytab if params.security_enabled else None) - else: - from resource_management.libraries.functions.setup_ranger_plugin import setup_ranger_plugin - setup_ranger_plugin('storm-nimbus', 'storm', - params.downloaded_custom_connector, params.driver_curl_source, - params.driver_curl_target, params.java64_home, - params.repo_name, params.storm_ranger_plugin_repo, - params.ranger_env, params.ranger_plugin_properties, - params.policy_user, params.policymgr_mgr_url, - params.enable_ranger_storm, conf_dict=params.conf_dir, - component_user=params.storm_user, component_group=params.user_group, cache_service_list=['storm'], - plugin_audit_properties=params.config['configurations']['ranger-storm-audit'], plugin_audit_attributes=params.config['configuration_attributes']['ranger-storm-audit'], - plugin_security_properties=params.config['configurations']['ranger-storm-security'], plugin_security_attributes=params.config['configuration_attributes']['ranger-storm-security'], - plugin_policymgr_ssl_properties=params.config['configurations']['ranger-storm-policymgr-ssl'], plugin_policymgr_ssl_attributes=params.config['configuration_attributes']['ranger-storm-policymgr-ssl'], - component_list=['storm-client', 'storm-nimbus'], audit_db_is_enabled=params.xa_audit_db_is_enabled, - credential_file=params.credential_file, xa_audit_db_password=params.xa_audit_db_password, - ssl_truststore_password=params.ssl_truststore_password, ssl_keystore_password=params.ssl_keystore_password, - stack_version_override = stack_version, skip_if_rangeradmin_down= not params.retryAble) - else: - Logger.info('Ranger admin not installed') http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/status_params.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/status_params.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/status_params.py deleted file mode 100644 index d84b095..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/status_params.py +++ /dev/null @@ -1,83 +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.libraries.script import Script -from resource_management.libraries.functions import get_kinit_path -from resource_management.libraries.functions import default, format -from resource_management.libraries.functions.version import format_stack_version -from resource_management.libraries.functions.stack_features import check_stack_feature -from resource_management.libraries.functions import StackFeature -from ambari_commons import OSCheck - -# a map of the Ambari role to the component name -# for use with <stack-root>/current/<component> -SERVER_ROLE_DIRECTORY_MAP = { - 'NIMBUS' : 'storm-nimbus', - 'SUPERVISOR' : 'storm-supervisor', - 'STORM_UI_SERVER' : 'storm-client', - 'DRPC_SERVER' : 'storm-client', - 'STORM_SERVICE_CHECK' : 'storm-client' -} - -component_directory = Script.get_component_from_role(SERVER_ROLE_DIRECTORY_MAP, "STORM_SERVICE_CHECK") - -config = Script.get_config() -stack_root = Script.get_stack_root() -stack_version_unformatted = str(config['hostLevelParams']['stack_version']) -stack_version_formatted = format_stack_version(stack_version_unformatted) - -if OSCheck.is_windows_family(): - nimbus_win_service_name = "nimbus" - supervisor_win_service_name = "supervisor" - ui_win_service_name = "ui" -else: - pid_dir = config['configurations']['storm-env']['storm_pid_dir'] - pid_nimbus = format("{pid_dir}/nimbus.pid") - pid_supervisor = format("{pid_dir}/supervisor.pid") - pid_drpc = format("{pid_dir}/drpc.pid") - pid_ui = format("{pid_dir}/ui.pid") - pid_logviewer = format("{pid_dir}/logviewer.pid") - pid_rest_api = format("{pid_dir}/restapi.pid") - - pid_files = { - "logviewer":pid_logviewer, - "ui": pid_ui, - "nimbus": pid_nimbus, - "supervisor": pid_supervisor, - "drpc": pid_drpc, - "rest_api": pid_rest_api - } - - # Security related/required params - hostname = config['hostname'] - security_enabled = config['configurations']['cluster-env']['security_enabled'] - kinit_path_local = get_kinit_path(default('/configurations/kerberos-env/executable_search_paths', None)) - tmp_dir = Script.get_tmp_dir() - - storm_component_home_dir = "/usr/lib/storm" - conf_dir = "/etc/storm/conf" - if stack_version_formatted and check_stack_feature(StackFeature.ROLLING_UPGRADE, stack_version_formatted): - storm_component_home_dir = format("{stack_root}/current/{component_directory}") - conf_dir = format("{stack_root}/current/{component_directory}/conf") - - storm_user = config['configurations']['storm-env']['storm_user'] - storm_ui_principal = default('/configurations/storm-env/storm_ui_principal_name', None) - storm_ui_keytab = default('/configurations/storm-env/storm_ui_keytab', None) - -stack_name = default("/hostLevelParams/stack_name", None) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/8e5eeb4d/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/storm.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/storm.py b/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/storm.py deleted file mode 100644 index 2d50767..0000000 --- a/ambari-server/src/main/resources/common-services/STORM/0.9.1.2.1/package/scripts/storm.py +++ /dev/null @@ -1,162 +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.core.exceptions import Fail -from resource_management.core.resources.service import ServiceConfig -from resource_management.core.resources.system import Directory, Execute, File, Link -from resource_management.core.source import InlineTemplate -from resource_management.libraries.resources.template_config import TemplateConfig -from resource_management.libraries.functions.format import format -from resource_management.libraries.script.script import Script -from resource_management.core.source import Template -from resource_management.libraries.functions.stack_features import check_stack_feature -from resource_management.libraries.functions import StackFeature -from storm_yaml_utils import yaml_config_template, yaml_config -from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl -from ambari_commons import OSConst -from setup_atlas_storm import setup_atlas_storm - -@OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY) -def storm(name=None): - import params - yaml_config("storm.yaml", - conf_dir=params.conf_dir, - configurations=params.config['configurations']['storm-site'], - owner=params.storm_user - ) - - if params.service_map.has_key(name): - service_name = params.service_map[name] - ServiceConfig(service_name, - action="change_user", - username = params.storm_user, - password = Script.get_password(params.storm_user)) - - -@OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT) -def storm(name=None): - import params - import os - - Directory(params.log_dir, - owner=params.storm_user, - group=params.user_group, - mode=0777, - create_parents = True - ) - - Directory([params.pid_dir, params.local_dir], - owner=params.storm_user, - group=params.user_group, - create_parents = True, - cd_access="a", - mode=0755, - ) - - Directory(params.conf_dir, - group=params.user_group, - create_parents = True, - cd_access="a", - ) - - File(format("{conf_dir}/config.yaml"), - content=Template("config.yaml.j2"), - owner=params.storm_user, - group=params.user_group - ) - - configurations = params.config['configurations']['storm-site'] - - File(format("{conf_dir}/storm.yaml"), - content=yaml_config_template(configurations), - owner=params.storm_user, - group=params.user_group - ) - - File(format("{conf_dir}/storm-env.sh"), - owner=params.storm_user, - content=InlineTemplate(params.storm_env_sh_template) - ) - - setup_atlas_storm() - - if params.has_metric_collector: - File(format("{conf_dir}/storm-metrics2.properties"), - owner=params.storm_user, - group=params.user_group, - content=Template("storm-metrics2.properties.j2") - ) - - # Remove symlinks. They can be there, if you doing upgrade from HDP < 2.2 to HDP >= 2.2 - Link(format("{storm_lib_dir}/ambari-metrics-storm-sink.jar"), - action="delete") - # On old HDP 2.1 versions, this symlink may also exist and break EU to newer versions - Link("/usr/lib/storm/lib/ambari-metrics-storm-sink.jar", action="delete") - - Execute(format("{sudo} ln -s {metric_collector_sink_jar} {storm_lib_dir}/ambari-metrics-storm-sink.jar"), - not_if=format("ls {storm_lib_dir}/ambari-metrics-storm-sink.jar"), - only_if=format("ls {metric_collector_sink_jar}") - ) - - if params.storm_logs_supported: - Directory(params.log4j_dir, - owner=params.storm_user, - group=params.user_group, - mode=0755, - create_parents = True - ) - - File(format("{log4j_dir}/cluster.xml"), - owner=params.storm_user, - content=InlineTemplate(params.storm_cluster_log4j_content) - ) - File(format("{log4j_dir}/worker.xml"), - owner=params.storm_user, - content=InlineTemplate(params.storm_worker_log4j_content) - ) - - if params.security_enabled: - TemplateConfig(format("{conf_dir}/storm_jaas.conf"), - owner=params.storm_user - ) - if params.stack_version_formatted and check_stack_feature(StackFeature.ROLLING_UPGRADE, params.stack_version_formatted): - TemplateConfig(format("{conf_dir}/client_jaas.conf"), - owner=params.storm_user - ) - minRuid = configurations['_storm.min.ruid'] if configurations.has_key('_storm.min.ruid') else '' - - min_user_ruid = int(minRuid) if minRuid.isdigit() else _find_real_user_min_uid() - - File(format("{conf_dir}/worker-launcher.cfg"), - content=Template("worker-launcher.cfg.j2", min_user_ruid = min_user_ruid), - owner='root', - group=params.user_group - ) - - -''' -Finds minimal real user UID -''' -def _find_real_user_min_uid(): - with open('/etc/login.defs') as f: - for line in f: - if line.strip().startswith('UID_MIN') and len(line.split()) == 2 and line.split()[1].isdigit(): - return int(line.split()[1]) - raise Fail("Unable to find UID_MIN in file /etc/login.defs. Expecting format e.g.: 'UID_MIN 500'")