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


Python logger.Logger类代码示例

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


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

示例1: action_create

  def action_create(self):
    path = self.resource.path

    if os.path.isdir(path):
      raise Fail("Applying %s failed, directory with name %s exists" % (self.resource, path))

    dirname = os.path.dirname(path)
    if not os.path.isdir(dirname):
      raise Fail("Applying %s failed, parent directory %s doesn't exist" % (self.resource, dirname))

    write = False
    content = self._get_content()
    if not os.path.exists(path):
      write = True
      reason = "it doesn't exist"
    elif self.resource.replace:
      if content is not None:
        with open(path, "rb") as fp:
          old_content = fp.read()
        if content != old_content:
          write = True
          reason = "contents don't match"
          if self.resource.backup:
            self.resource.env.backup_file(path)

    if write:
      Logger.info("Writing %s because %s" % (self.resource, reason))
      with open(path, "wb") as fp:
        if content:
          fp.write(content)

    if self.resource.owner and self.resource.mode:
      _set_file_acl(self.resource.path, self.resource.owner, self.resource.mode)
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:33,代码来源:system.py

示例2: install

 def install(self, env):
     Logger.info("install mysql cluster management")
     import params
     env.set_params(params)
     # remove_mysql_cmd = "yum remove mysql -y"
     # Execute(remove_mysql_cmd,
     #         user='root'
     #         )
     remove_mysql_lib_cmd = "rpm -e --nodeps mysql-libs-5.1.71-1.el6.x86_64 >/dev/null 2>&1"
     Execute(remove_mysql_lib_cmd,
             user='root'
             )
     install_server_cmd = "yum -y install MySQL-Cluster-server-gpl-7.4.11-1.el6.x86_64"
     Execute(install_server_cmd,
             user='root'
             )
     # create mgm config dir
     Directory(params.mgm_config_path,
               owner='root',
               group='root',
               recursive=True
               )
     # create cluster config
     Logger.info('create config.ini in /var/lib/mysql-cluster')
     File(format("{mgm_config_path}/config.ini"),
          owner = 'root',
          group = 'root',
          mode = 0644,
          content=InlineTemplate(params.config_ini_template)
          )
     Execute('ndb_mgmd -f /var/lib/mysql-cluster/config.ini --initial  >/dev/null 2>&1', logoutput = True)
     # create pid file
     pid_cmd = "pgrep -o -f ^ndb_mgmd.* > {0}".format(params.mgm_pid_file)
     Execute(pid_cmd,
             logoutput=True)
开发者ID:qwurey,项目名称:ambari-mysql-cluster-plugin,代码行数:35,代码来源:management.py

示例3: install_package

 def install_package(self, name):
   if not self._check_existence(name):
     cmd = INSTALL_CMD % (name)
     Logger.info("Installing package %s ('%s')" % (name, cmd))
     shell.checked_call(cmd)
   else:
     Logger.info("Skipping installing existent package %s" % (name))
开发者ID:duxia,项目名称:ambari,代码行数:7,代码来源:yumrpm.py

示例4: remove_package

 def remove_package(self, name):
   if self._check_existence(name):
     cmd = REMOVE_CMD % (name)
     Logger.info("Removing package %s ('%s')" % (name, cmd))
     shell.checked_call(cmd)
   else:
     Logger.info("Skipping removing non-existent package %s" % (name))
开发者ID:duxia,项目名称:ambari,代码行数:7,代码来源:yumrpm.py

示例5: check_process

 def check_process(self, keyword):
   Logger.info("check process with: {0}".format(keyword))
   cmd = "ps aux | grep -E '" + keyword + "' | grep -v grep | cat"
   result = self.exe(cmd)
   if (result == ""):
     Logger.error("process {0} not exist".format(keyword))
     raise ComponentIsNotRunning()
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:7,代码来源:utils.py

示例6: check_service_status

 def check_service_status(self, service, keyword):
   cmd = "service {0} status | grep -E '{1}'".format(service, keyword)
   Logger.info("run service check on {0} : ".format(service))
   (status, output) = commands.getstatusoutput(cmd)
   if (output == ""):
     Logger.error("service {0} not running".format(service))
     raise ComponentIsNotRunning() 
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:7,代码来源:utils.py

示例7: check_process_status

def check_process_status(pid_file):
  """
  Function checks whether process is running.
  Process is considered running, if pid file exists, and process with
  a pid, mentioned in pid file is running
  If process is not running, will throw ComponentIsNotRunning exception

  @param pid_file: path to service pid file
  """
  if not pid_file or not os.path.isfile(pid_file):
    raise ComponentIsNotRunning()
  
  try:
    pid = int(sudo.read_file(pid_file))
  except:
    Logger.debug("Pid file {0} does not exist".format(pid_file))
    raise ComponentIsNotRunning()

  code, out = shell.call(["ps","-p", str(pid)])
  
  if code:
    Logger.debug("Process with pid {0} is not running. Stale pid file"
              " at {1}".format(pid, pid_file))
    raise ComponentIsNotRunning()
  pass
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:25,代码来源:check_process_status.py

示例8: service_check

def service_check(cmd, user, label):
    """
    Executes a service check command that adheres to LSB-compliant
    return codes.  The return codes are interpreted as defined
    by the LSB.

    See http://refspecs.linuxbase.org/LSB_3.0.0/LSB-PDA/LSB-PDA/iniscrptact.html
    for more information.

    :param cmd: The service check command to execute.
    :param label: The name of the service.
    """
    Logger.info("Performing service check; cmd={0}, user={1}, label={2}".format(cmd, user, label))
    rc, out, err = get_user_call_output(cmd, user, is_checked_call=False)

    if len(err) > 0:
      Logger.error(err)

    if rc in [1, 2, 3]:
      # if return code in [1, 2, 3], then 'program is not running' or 'program is dead'
      Logger.info("{0} is not running".format(label))
      raise ComponentIsNotRunning()

    elif rc == 0:
      # if return code = 0, then 'program is running or service is OK'
      Logger.info("{0} is running".format(label))

    else:
      # else service state is unknown
      err_msg = "{0} service check failed; cmd '{1}' returned {2}".format(label, cmd, rc)
      Logger.error(err_msg)
      raise ExecutionFailed(err_msg, rc, out, err)
开发者ID:JonZeolla,项目名称:incubator-metron,代码行数:32,代码来源:common.py

示例9: _get_directory_mappings_during_upgrade

def _get_directory_mappings_during_upgrade():
  """
  Gets a dictionary of directory to archive name that represents the
  directories that need to be backed up and their output tarball archive targets
  :return:  the dictionary of directory to tarball mappings
  """
  import params

  # Must be performing an Upgrade
  if params.upgrade_direction is None or params.upgrade_direction != Direction.UPGRADE or \
          params.upgrade_from_version is None or params.upgrade_from_version == "":
    Logger.error("Function _get_directory_mappings_during_upgrade() can only be called during a Stack Upgrade in direction UPGRADE.")
    return {}

  # By default, use this for all stacks.
  knox_data_dir = '/var/lib/knox/data'

  if params.stack_name and params.stack_name.upper() == "HDP" and \
          compare_versions(format_hdp_stack_version(params.upgrade_from_version), "2.3.0.0") > 0:
    # Use the version that is being upgraded from.
    knox_data_dir = format('/usr/hdp/{upgrade_from_version}/knox/data')

  # the trailing "/" is important here so as to not include the "conf" folder itself
  directories = {knox_data_dir: BACKUP_DATA_ARCHIVE, params.knox_conf_dir + "/": BACKUP_CONF_ARCHIVE}

  Logger.info(format("Knox directories to backup:\n{directories}"))
  return directories
开发者ID:OpenPOWER-BigData,项目名称:HDP-ambari,代码行数:27,代码来源:upgrade.py

示例10: setup_solr_cloud

def setup_solr_cloud():
    import params

    code, output = call(
            format(
                    '{zk_client_prefix} -cmd get {solr_cloud_zk_directory}{clusterstate_json}'
            ),
            env={'JAVA_HOME': params.java64_home},
            timeout=60
    )

    if not ("NoNodeException" in output):
        Logger.info(
                format(
                        "ZK node {solr_cloud_zk_directory}{clusterstate_json} already exists, skipping ..."
                )
        )
        return

    Execute(
            format(
                    '{zk_client_prefix} -cmd makepath {solr_cloud_zk_directory}'
            ),
            environment={'JAVA_HOME': params.java64_home},
            ignore_failures=True,
            user=params.solr_config_user
    )
开发者ID:hortonworks,项目名称:solr-stack,代码行数:27,代码来源:setup_solr_cloud.py

示例11: check_process

 def check_process(keyword):
   Logger.info("check process by: {0}".format(keyword))
   cmd = "ps aux | grep -E '" + keyword + "' | grep -v grep | cat"
   result = Toolkit.exe(cmd)
   if (result == ""):
     Logger.error("process checked by {0} not exist".format(keyword))
     raise ComponentIsNotRunning()
开发者ID:chinpeng,项目名称:ambari,代码行数:7,代码来源:toolkit.py

示例12: configure

    def configure(self, env, upgrade_type=None, config_dir=None):
        from params import params
        env.set_params(params)

        Logger.info("Running profiler configure")
        File(format("{metron_config_path}/profiler.properties"),
             content=Template("profiler.properties.j2"),
             owner=params.metron_user,
             group=params.metron_group
             )

        if not metron_service.is_zk_configured(params):
            metron_service.init_zk_config(params)
            metron_service.set_zk_configured(params)
        metron_service.refresh_configs(params)

        commands = ProfilerCommands(params)
        if not commands.is_hbase_configured():
            commands.create_hbase_tables()
        if params.security_enabled and not commands.is_hbase_acl_configured():
            commands.set_hbase_acls()
        if params.security_enabled and not commands.is_acl_configured():
            commands.init_kafka_acls()
            commands.set_acl_configured()

        Logger.info("Calling security setup")
        storm_security_setup(params)
        if not commands.is_configured():
            commands.set_configured()
开发者ID:JonZeolla,项目名称:incubator-metron,代码行数:29,代码来源:profiler_master.py

示例13: check_nifi_process_status

  def check_nifi_process_status(self, pid_file):
    """
    Function checks whether process is running.
    Process is considered running, if pid file exists, and process with
    a pid, mentioned in pid file is running
    If process is not running, will throw ComponentIsNotRunning exception

    @param pid_file: path to service pid file
    """
    if not pid_file or not os.path.isfile(pid_file):
        raise ComponentIsNotRunning()

    try:
        lines = [line.rstrip('\n') for line in open(pid_file)]
        pid = int(lines[2].split('=')[1]);
    except:
        Logger.warn("Pid file {0} does not exist".format(pid_file))
        raise ComponentIsNotRunning()

    code, out = shell.call(["ps","-p", str(pid)])

    if code:
        Logger.debug("Process with pid {0} is not running. Stale pid file"
                     " at {1}".format(pid, pid_file))
        raise ComponentIsNotRunning()
    pass
开发者ID:fanzhidongyzby,项目名称:ambari,代码行数:26,代码来源:nifi.py

示例14: stop

 def stop(self, env):
     Logger.info("stop sql node")
     import params
     env.set_params(params)
     Execute(params.stop_sql_node_cmd,
             user='root'
             )
开发者ID:qwurey,项目名称:ambari-mysql-cluster-plugin,代码行数:7,代码来源:sql_node.py

示例15: start

 def start(self, env):
     Logger.info("start sql node")
     import params
     env.set_params(params)
     Execute("mysqld_safe >/dev/null 2>&1 &",
             user='root'
             )
开发者ID:qwurey,项目名称:ambari-mysql-cluster-plugin,代码行数:7,代码来源:sql_node.py


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