本文整理汇总了Python中ambari_commons.os_check.OSCheck.is_redhat_family方法的典型用法代码示例。如果您正苦于以下问题:Python OSCheck.is_redhat_family方法的具体用法?Python OSCheck.is_redhat_family怎么用?Python OSCheck.is_redhat_family使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ambari_commons.os_check.OSCheck
的用法示例。
在下文中一共展示了OSCheck.is_redhat_family方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: actionexecute
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_redhat_family [as 别名]
def actionexecute(self, env):
config = Script.get_config()
version = default('/commandParams/version', None)
stack_name = default('/hostLevelParams/stack_name', "")
if not version:
raise Fail("Value is required for '/commandParams/version'")
# other os?
if OSCheck.is_redhat_family():
cmd = ('/usr/bin/yum', 'clean', 'all')
code, out = shell.call(cmd, sudo=True)
min_ver = format_hdp_stack_version("2.2")
real_ver = format_hdp_stack_version(version)
if stack_name == "HDP":
if compare_versions(real_ver, min_ver) >= 0:
cmd = ('hdp-select', 'set', 'all', version)
code, out = shell.call(cmd, sudo=True)
if compare_versions(real_ver, format_hdp_stack_version("2.3")) >= 0:
# backup the old and symlink /etc/[component]/conf to /usr/hdp/current/[component]
for k, v in conf_select.PACKAGE_DIRS.iteritems():
for dir_def in v:
link_config(dir_def['conf_dir'], dir_def['current_dir'])
示例2: install_repository
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_redhat_family [as 别名]
def install_repository(self, url_info, repository_version, append_to_file):
template = "repo_suse_rhel.j2" if OSCheck.is_redhat_family() or OSCheck.is_suse_family() else "repo_ubuntu.j2"
repo = {
'repoName': "{0}-{1}".format(url_info['name'], repository_version)
}
if not 'baseUrl' in url_info:
repo['baseurl'] = None
else:
repo['baseurl'] = url_info['baseUrl']
if not 'mirrorsList' in url_info:
repo['mirrorsList'] = None
else:
repo['mirrorsList'] = url_info['mirrorsList']
ubuntu_components = [url_info['name']] + self.UBUNTU_REPO_COMPONENTS_POSTFIX
file_name = self.REPO_FILE_NAME_PREFIX + repository_version
Repository(repo['repoName'],
action = "create",
base_url = repo['baseurl'],
mirror_list = repo['mirrorsList'],
repo_file_name = file_name,
repo_template = template,
append_to_file = append_to_file,
components = ubuntu_components, # ubuntu specific
)
return repo['repoName'], file_name
示例3: list_ambari_managed_repos
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_redhat_family [as 别名]
def list_ambari_managed_repos(stack_name):
"""
Lists all repositories that are present at host
"""
stack_name = stack_name.upper()
# TODO : get it dynamically from the server
repository_names = [stack_name, stack_name + "-UTILS" ]
if OSCheck.is_ubuntu_family():
repo_dir = '/etc/apt/sources.list.d/'
elif OSCheck.is_redhat_family(): # Centos/RHEL 5/6
repo_dir = '/etc/yum.repos.d/'
elif OSCheck.is_suse_family():
repo_dir = '/etc/zypp/repos.d/'
else:
raise Fail('Can not dermine repo dir')
repos = []
for name in repository_names:
# List all files that match pattern
files = glob.glob(os.path.join(repo_dir, name) + '*')
for f in files:
filename = os.path.basename(f)
# leave out extension
reponame = os.path.splitext(filename)[0]
repos.append(reponame)
# get uniq strings
seen = set()
uniq = [s for s in repos if not (s in seen or seen.add(s))]
return uniq
示例4: actionexecute
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_redhat_family [as 别名]
def actionexecute(self, env):
config = Script.get_config()
structured_output = {}
try:
repo_info_json = config['hostLevelParams']['repo_info']
repo_info_dict = json.loads(repo_info_json)
for item in repo_info_dict["repositories"]:
base_url = item["base_url"]
repo_name = item["repo_name"]
repo_id = item["repo_id"]
repo_rhel_suse = config['configurations']['cluster-env']['repo_suse_rhel_template']
repo_ubuntu = config['configurations']['cluster-env']['repo_ubuntu_template']
template = repo_rhel_suse if OSCheck.is_suse_family() or OSCheck.is_redhat_family() else repo_ubuntu
ubuntu_components = [repo_name] + self.UBUNTU_REPO_COMPONENTS_POSTFIX
Repository(repo_id,
action = "create",
base_url = base_url,
mirror_list = None,
repo_file_name = repo_name,
repo_template = template,
components = ubuntu_components, # ubuntu specific
)
structured_output["repo_update"] = {"exit_code" : 0, "message": format("Repository files successfully updated!")}
except Exception, exception:
Logger.logger.exception("ERROR: There was an unexpected error while updating repositories")
raise Fail("Failed to update repo files!")
示例5: install_repos
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_redhat_family [as 别名]
def install_repos():
import params
if params.host_sys_prepped:
return
template = params.repo_rhel_suse if OSCheck.is_suse_family() or OSCheck.is_redhat_family() else params.repo_ubuntu
_alter_repo("create", params.repo_info, template)
if params.service_repo_info:
_alter_repo("create", params.service_repo_info, template)
示例6: _clear_package_manager_cache
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_redhat_family [as 别名]
def _clear_package_manager_cache(self):
package_manager_cmd = ""
if OSCheck.is_redhat_family():
package_manager_cmd = ("/usr/bin/yum", "clean", "metadata")
if OSCheck.is_suse_family():
package_manager_cmd = ("/usr/bin/zypper", "-q", "-n", "clean")
if OSCheck.is_ubuntu_family():
return
Logger.debug("Clearing repo manager metadata")
Execute(package_manager_cmd, logoutput=False, sudo=True)
示例7: get_elastic_config_path
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_redhat_family [as 别名]
def get_elastic_config_path(default="/etc/default/elasticsearch"):
"""
Defines the path to the Elasticsearch environment file. This path will
differ based on the OS family.
:param default: The path used if the OS family is not recognized.
"""
path = default
if OSCheck.is_redhat_family():
path = "/etc/sysconfig/elasticsearch"
elif OSCheck.is_ubuntu_family():
path = "/etc/default/elasticsearch"
else:
Logger.error("Unexpected OS family; using default path={0}".format(path))
return path
示例8: install_packages
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_redhat_family [as 别名]
def install_packages(self, package_list):
"""
Actually install the packages using the package manager.
:param package_list: List of package names to install
:return: Returns 0 if no errors were found, and 1 otherwise.
"""
ret_code = 0
# Clear cache of package manager right before installation of the packages
self._clear_package_manager_cache()
# Install packages
packages_were_checked = False
try:
Package(self.get_base_packages_to_install())
packages_installed_before = []
allInstalledPackages(packages_installed_before)
packages_installed_before = [package[0] for package in packages_installed_before]
packages_were_checked = True
filtered_package_list = self.filter_package_list(package_list)
for package in filtered_package_list:
name = self.format_package_name(package['name'], self.repository_version)
Package(name,
use_repos=list(self.current_repo_files) if OSCheck.is_ubuntu_family() else self.current_repositories,
skip_repos=[self.REPO_FILE_NAME_PREFIX + "*"] if OSCheck.is_redhat_family() else [])
except Exception, err:
ret_code = 1
Logger.logger.exception("Package Manager failed to install packages. Error: {0}".format(str(err)))
# Remove already installed packages in case of fail
if packages_were_checked and packages_installed_before:
packages_installed_after = []
allInstalledPackages(packages_installed_after)
packages_installed_after = [package[0] for package in packages_installed_after]
packages_installed_before = set(packages_installed_before)
new_packages_installed = [package for package in packages_installed_after if package not in packages_installed_before]
if OSCheck.is_ubuntu_family():
package_version_string = self.repository_version.replace('.', '-')
else:
package_version_string = self.repository_version.replace('-', '_')
package_version_string = package_version_string.replace('.', '_')
for package in new_packages_installed:
if package_version_string and (package_version_string in package):
Package(package, action="remove")
示例9: get_lzo_packages
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_redhat_family [as 别名]
def get_lzo_packages(stack_version_unformatted):
lzo_packages = []
script_instance = Script.get_instance()
if OSCheck.is_suse_family() and int(OSCheck.get_os_major_version()) >= 12:
lzo_packages += ["liblzo2-2", "hadoop-lzo-native"]
elif OSCheck.is_redhat_family() or OSCheck.is_suse_family():
lzo_packages += ["lzo", "hadoop-lzo-native"]
elif OSCheck.is_ubuntu_family():
lzo_packages += ["liblzo2-2"]
if stack_version_unformatted and check_stack_feature(StackFeature.ROLLING_UPGRADE, stack_version_unformatted):
if OSCheck.is_ubuntu_family():
lzo_packages += [script_instance.format_package_name("hadooplzo-${stack_version}") ,
script_instance.format_package_name("hadooplzo-${stack_version}-native")]
else:
lzo_packages += [script_instance.format_package_name("hadooplzo_${stack_version}"),
script_instance.format_package_name("hadooplzo_${stack_version}-native")]
else:
lzo_packages += ["hadoop-lzo"]
return lzo_packages
示例10: calc_xmn_from_xms
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_redhat_family [as 别名]
regionserver_xmn_percent = config['configurations']['hbase-env']['hbase_regionserver_xmn_ratio']
regionserver_xmn_size = calc_xmn_from_xms(regionserver_heapsize, regionserver_xmn_percent, regionserver_xmn_max)
phoenix_hosts = default('/clusterHostInfo/phoenix_query_server_hosts', [])
phoenix_enabled = default('/configurations/hbase-env/phoenix_sql_enabled', False)
has_phoenix = len(phoenix_hosts) > 0
if not has_phoenix and not phoenix_enabled:
exclude_packages = ['phoenix*']
else:
exclude_packages = []
underscored_version = stack_version_unformatted.replace('.', '_')
dashed_version = stack_version_unformatted.replace('.', '-')
if OSCheck.is_redhat_family() or OSCheck.is_suse_family():
phoenix_package = format("phoenix_{underscored_version}_*")
elif OSCheck.is_ubuntu_family():
phoenix_package = format("phoenix-{dashed_version}-.*")
pid_dir = status_params.pid_dir
tmp_dir = config['configurations']['hbase-site']['hbase.tmp.dir']
local_dir = config['configurations']['hbase-site']['hbase.local.dir']
client_jaas_config_file = format("{hbase_conf_dir}/hbase_client_jaas.conf")
master_jaas_config_file = format("{hbase_conf_dir}/hbase_master_jaas.conf")
regionserver_jaas_config_file = format("{hbase_conf_dir}/hbase_regionserver_jaas.conf")
queryserver_jaas_config_file = format("{hbase_conf_dir}/hbase_queryserver_jaas.conf")
ganglia_server_hosts = default('/clusterHostInfo/ganglia_server_host', []) # is not passed when ganglia is not present
ganglia_server_host = '' if len(ganglia_server_hosts) == 0 else ganglia_server_hosts[0]
示例11: str
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_redhat_family [as 别名]
installed_packages, repos = self.execute_existing_repos_and_installed_packages_check(config)
structured_output[CHECK_INSTALLED_PACKAGES] = installed_packages
structured_output[CHECK_EXISTING_REPOS] = repos
except Exception, exception :
print "There was an unknown error while checking installed packages and existing repositories: " + str(exception)
structured_output[CHECK_INSTALLED_PACKAGES] = {"exit_code" : 1, "message": str(exception)}
structured_output[CHECK_EXISTING_REPOS] = {"exit_code" : 1, "message": str(exception)}
# Here we are checking transparent huge page if CHECK_TRANSPARENT_HUGE_PAGE is in check_execute_list
if CHECK_TRANSPARENT_HUGE_PAGE in check_execute_list:
try :
thp_regex = "\[(.+)\]"
file_name = None
if OSCheck.is_ubuntu_family():
file_name = THP_FILE_UBUNTU
elif OSCheck.is_redhat_family():
file_name = THP_FILE_REDHAT
if file_name and os.path.isfile(file_name):
with open(file_name) as f:
file_content = f.read()
structured_output[CHECK_TRANSPARENT_HUGE_PAGE] = {"exit_code" : 0, "message": str(re.search(thp_regex,
file_content).groups()[0])}
else:
structured_output[CHECK_TRANSPARENT_HUGE_PAGE] = {"exit_code" : 0, "message": ""}
except Exception, exception :
print "There was an unknown error while getting transparent huge page data: " + str(exception)
structured_output[CHECK_TRANSPARENT_HUGE_PAGE] = {"exit_code" : 1, "message": str(exception)}
# this is necessary for HostCleanup to know later what were the results.
self.reportFileHandler.writeHostChecksCustomActionsFile(structured_output)
示例12: actionexecute
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_redhat_family [as 别名]
def actionexecute(self, env):
num_errors = 0
# Parse parameters
config = Script.get_config()
repo_rhel_suse = config['configurations']['cluster-env']['repo_suse_rhel_template']
repo_ubuntu = config['configurations']['cluster-env']['repo_ubuntu_template']
template = repo_rhel_suse if OSCheck.is_redhat_family() or OSCheck.is_suse_family() else repo_ubuntu
# Handle a SIGTERM and SIGINT gracefully
signal.signal(signal.SIGTERM, self.abort_handler)
signal.signal(signal.SIGINT, self.abort_handler)
# Select dict that contains parameters
try:
self.repository_version = config['roleParams']['repository_version']
base_urls = json.loads(config['roleParams']['base_urls'])
package_list = json.loads(config['roleParams']['package_list'])
stack_id = config['roleParams']['stack_id']
except KeyError:
# Last try
self.repository_version = config['commandParams']['repository_version']
base_urls = json.loads(config['commandParams']['base_urls'])
package_list = json.loads(config['commandParams']['package_list'])
stack_id = config['commandParams']['stack_id']
stack_name = None
self.stack_root_folder = None
if stack_id and "-" in stack_id:
stack_split = stack_id.split("-")
if len(stack_split) == 2:
stack_name = stack_split[0].upper()
if stack_name in self.STACK_TO_ROOT_FOLDER:
self.stack_root_folder = self.STACK_TO_ROOT_FOLDER[stack_name]
if self.stack_root_folder is None:
raise Fail("Cannot determine the stack's root directory by parsing the stack_id property, {0}".format(str(stack_id)))
if self.repository_version is None:
raise Fail("Cannot determine the repository version to install")
self.repository_version = self.repository_version.strip()
# Install/update repositories
installed_repositories = []
self.current_repositories = []
self.current_repo_files = set()
# Enable base system repositories
# We don't need that for RHEL family, because we leave all repos enabled
# except disabled HDP* ones
if OSCheck.is_suse_family():
self.current_repositories.append('base')
elif OSCheck.is_ubuntu_family():
self.current_repo_files.add('base')
Logger.info("Will install packages for repository version {0}".format(self.repository_version))
try:
append_to_file = False
for url_info in base_urls:
repo_name, repo_file = self.install_repository(url_info, append_to_file, template)
self.current_repositories.append(repo_name)
self.current_repo_files.add(repo_file)
append_to_file = True
installed_repositories = list_ambari_managed_repos()
except Exception, err:
Logger.logger.exception("Cannot distribute repositories. Error: {0}".format(str(err)))
num_errors += 1