当前位置: 首页>>代码示例>>Python>>正文


Python os_check.OSCheck类代码示例

本文整理汇总了Python中ambari_commons.os_check.OSCheck的典型用法代码示例。如果您正苦于以下问题:Python OSCheck类的具体用法?Python OSCheck怎么用?Python OSCheck使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OSCheck类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: actionexecute

  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!")
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:32,代码来源:update_repo.py

示例2: server_files

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
    )
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:27,代码来源:ganglia_server.py

示例3: install_repository

  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
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:30,代码来源:install_packages.py

示例4: install_packages

  def install_packages(self, env, exclude_packages=[]):
    """
    List of packages that are required< by service is received from the server
    as a command parameter. The method installs all packages
    from this list
    """
    config = self.get_config()
    try:
      package_list_str = config['hostLevelParams']['package_list']
      if isinstance(package_list_str, basestring) and len(package_list_str) > 0:
        package_list = json.loads(package_list_str)
        for package in package_list:
          if not package['name'] in exclude_packages:
            name = package['name']
            if OSCheck.is_windows_family():
              if name[-4:] == ".msi":
                #TODO all msis must be located in resource folder of server, change it to repo later
                Msi(name, http_source=os.path.join(config['hostLevelParams']['jdk_location']))
            else:
              Package(name)
    except KeyError:
      pass  # No reason to worry

    if OSCheck.is_windows_family():
      #TODO hacky install of windows msi, remove it or move to old(2.1) stack definition when component based install will be implemented
      install_windows_msi(os.path.join(config['hostLevelParams']['jdk_location'], "hdp.msi"),
                          config["hostLevelParams"]["agentCacheDir"], "hdp.msi", self.get_password("hadoop"),
                          str(config['hostLevelParams']['stack_version']))
      reload_windows_env()
    pass
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:30,代码来源:script.py

示例5: list_ambari_managed_repos

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
开发者ID:maduhu,项目名称:HDP2.5-ambari,代码行数:28,代码来源:list_ambari_managed_repos.py

示例6: get_serivice_params

 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'
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:8,代码来源:monitor_webserver.py

示例7: install_repos

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)
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:9,代码来源:repo_initialization.py

示例8: stop

 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')
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:10,代码来源:kerberos_server.py

示例9: get_base_packages_to_install

  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
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:12,代码来源:install_packages.py

示例10: _clear_package_manager_cache

  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)
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:14,代码来源:install_packages.py

示例11: launch_python_subprocess

  def launch_python_subprocess(self, command, tmpout, tmperr):
    """
    Creates subprocess with given parameters. This functionality was moved to separate method
    to make possible unit testing
    """
    close_fds = None if OSCheck.get_os_family() == OSConst.WINSRV_FAMILY else True
    command_env = dict(os.environ)
    if OSCheck.get_os_family() == OSConst.WINSRV_FAMILY:
      command_env["PYTHONPATH"] = os.pathsep.join(sys.path)
      for k, v in command_env.iteritems():
        command_env[k] = str(v)

    return subprocess.Popen(command,
      stdout=tmpout,
      stderr=tmperr, close_fds=close_fds, env=command_env, preexec_fn=self.preexec_fn)
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:15,代码来源:PythonExecutor.py

示例12: get_elastic_config_path

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
开发者ID:JonZeolla,项目名称:incubator-metron,代码行数:15,代码来源:elastic_commands.py

示例13: execute

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
  """

  if configurations is None:
    return (RESULT_CODE_UNKNOWN, ['There were no configurations supplied to the script.'])

  if not OOZIE_URL_KEY in configurations:
    return (RESULT_CODE_UNKNOWN, ['The Oozie URL is a required parameter.'])

  # use localhost on Windows, 0.0.0.0 on others; 0.0.0.0 means bind to all
  # interfaces, which doesn't work on Windows
  localhost_address = 'localhost' if OSCheck.get_os_family() == OSConst.WINSRV_FAMILY else '0.0.0.0'

  oozie_url = configurations[OOZIE_URL_KEY]
  oozie_url = oozie_url.replace(urlparse(oozie_url).hostname,localhost_address)

  try:
    command, env = get_check_command(oozie_url, host_name, configurations)
    # execute the command
    Execute(command, environment=env)

    return (RESULT_CODE_OK, ["Successful connection to {0}".format(oozie_url)])
  except KerberosPropertiesNotFound, ex:
    return (RESULT_CODE_UNKNOWN, [str(ex)])
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:31,代码来源:alert_check_oozie_server.py

示例14: actionexecute

  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'])
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:26,代码来源:ru_set_all.py

示例15: start

  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')
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:16,代码来源:kerberos_server.py


注:本文中的ambari_commons.os_check.OSCheck类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。