本文整理汇总了Python中ambari_commons.os_check.OSCheck.is_ubuntu_family方法的典型用法代码示例。如果您正苦于以下问题:Python OSCheck.is_ubuntu_family方法的具体用法?Python OSCheck.is_ubuntu_family怎么用?Python OSCheck.is_ubuntu_family使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ambari_commons.os_check.OSCheck
的用法示例。
在下文中一共展示了OSCheck.is_ubuntu_family方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_ambari_managed_repos
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_ubuntu_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
示例2: server_files
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_ubuntu_family [as 别名]
def server_files():
import params
rrd_py_path = params.rrd_py_path
Directory(rrd_py_path,
recursive=True
)
rrd_py_file_path = path.join(rrd_py_path, "rrd.py")
TemplateConfig(rrd_py_file_path,
owner="root",
group="root",
mode=0755
)
rrd_file_owner = params.gmetad_user
Directory(params.rrdcached_base_dir,
owner=rrd_file_owner,
group=rrd_file_owner,
mode=0755,
recursive=True
)
if OSCheck.is_suse_family() or OSCheck.is_ubuntu_family():
File( params.ganglia_apache_config_file,
content = Template("ganglia.conf.j2"),
mode = 0644
)
示例3: get_serivice_params
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_ubuntu_family [as 别名]
def get_serivice_params(self):
self.system = System.get_instance()
if OSCheck.is_suse_family() or OSCheck.is_ubuntu_family():
self.service_name = "apache2"
self.httpd_conf_dir = '/etc/apache2'
else:
self.service_name = "httpd"
self.httpd_conf_dir = '/etc/httpd/conf'
示例4: install_packages
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_ubuntu_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")
示例5: stop
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_ubuntu_family [as 别名]
def stop(self, env):
if OSCheck.is_suse_family():
Execute('rckadmind stop')
Execute('rckrb5kdc stop')
elif OSCheck.is_ubuntu_family():
Execute('service krb5-kdc stop')
Execute('service krb5-admin-server stop')
else:
Execute('service krb5kdc stop')
Execute('service kadmin stop')
示例6: get_base_packages_to_install
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_ubuntu_family [as 别名]
def get_base_packages_to_install(self):
"""
HACK: list packages which should be installed without disabling any repos. (This is planned to fix in Ambari-2.2)
"""
base_packages_to_install = ['fuse']
if OSCheck.is_suse_family() or OSCheck.is_ubuntu_family():
base_packages_to_install.append('libfuse2')
else:
base_packages_to_install.append('fuse-libs')
return base_packages_to_install
示例7: get_lzo_packages
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_ubuntu_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
示例8: _clear_package_manager_cache
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_ubuntu_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)
示例9: get_elastic_config_path
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_ubuntu_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
示例10: start
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_ubuntu_family [as 别名]
def start(self, env):
# Attempt to reconfigure the service before starting
self.configure(env)
# Create or update the administrator account
KerberosScript.create_or_update_administrator_identity()
if OSCheck.is_suse_family():
Execute('rckadmind start')
Execute('rckrb5kdc start')
elif OSCheck.is_ubuntu_family():
Execute('service krb5-kdc start')
Execute('service krb5-admin-server start')
else:
Execute('service krb5kdc start')
Execute('service kadmin start')
示例11: status
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_ubuntu_family [as 别名]
def status(self, env):
import params
if OSCheck.is_suse_family():
try:
Execute('checkproc `which krb5kdc`')
Execute('checkproc `which kadmind`')
except Fail as ex:
raise ComponentIsNotRunning()
elif OSCheck.is_ubuntu_family():
check_process_status(params.kdamin_pid_path)
check_process_status(params.krb5kdc_pid_path)
else:
check_process_status(params.kdamin_pid_path)
check_process_status(params.krb5kdc_pid_path)
示例12: turn_off_autostart
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_ubuntu_family [as 别名]
def turn_off_autostart(service):
if OSCheck.is_ubuntu_family():
Execute(('update-rc.d', service, 'disable'),
path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
sudo = True
)
Execute(('service', service, 'stop'),
sudo = True,
ignore_failures=True,
)
File(format('/etc/init/{service}.override'), # disable upstart job
content = 'manual',
)
else:
Execute(('chkconfig', service, 'off'),
path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
sudo = True,
)
示例13: get_kinit_path
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_ubuntu_family [as 别名]
# for create_hdfs_directory
security_enabled = config['configurations']['cluster-env']['security_enabled']
hdfs_user_keytab = config['configurations']['hadoop-env']['hdfs_user_keytab']
hdfs_user = config['configurations']['hadoop-env']['hdfs_user']
hdfs_principal_name = config['configurations']['hadoop-env'][
'hdfs_principal_name']
smokeuser_principal = config['configurations']['cluster-env'][
'smokeuser_principal_name']
kinit_path_local = get_kinit_path(
default('/configurations/kerberos-env/executable_search_paths', None))
hdfs_site = config['configurations']['hdfs-site']
default_fs = config['configurations']['core-site']['fs.defaultFS']
dfs_type = default("/commandParams/dfs_type", "")
# MYSQL
if OSCheck.is_ubuntu_family():
mysql_configname = '/etc/mysql/my.cnf'
else:
mysql_configname = '/etc/my.cnf'
daemon_name = status_params.daemon_name
# There will always be exactly one mysql_host
mysql_host = config['clusterHostInfo']['metron_enrichment_mysql_server_hosts'][
0]
mysql_port = config['configurations']['metron-env'][
'metron_enrichment_db_port']
mysql_adduser_path = tmp_dir + "/addMysqlUser.sh"
mysql_deluser_path = tmp_dir + "/removeMysqlUser.sh"
mysql_create_geoip_path = tmp_dir + "/createMysqlGeoIp.sh"
示例14: actionexecute
# 需要导入模块: from ambari_commons.os_check import OSCheck [as 别名]
# 或者: from ambari_commons.os_check.OSCheck import is_ubuntu_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