• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python log_utils.log函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: __init__

 def __init__(
     self,
     module_path,
     publisher_id=None,
     node_id=None,
     **kwargs
 ):
     self.module_path = modules.__path__[0] + "/" + module_path
     self.publisher_id = publisher_id or NS.publisher_id
     self.node_id = node_id or NS.node_context.node_id
     if not os.path.isfile(self.module_path):
         logger.log(
             "debug",
             self.publisher_id,
             {"message": "Module path: %s does not exist" %
                 self.module_path},
             node_id=self.node_id
         )
         raise AnsibleModuleNotFound(module_path=self.module_path)
     if kwargs == {}:
         logger.log(
             "debug",
             self.publisher_id,
             {"message": "Empty argument dictionary"},
             node_id=self.node_id
         )
         raise ValueError
     else:
         self.argument_dict = kwargs
         self.argument_dict['_ansible_selinux_special_fs'] = \
             ['nfs', 'vboxsf', 'fuse', 'ramfs']
开发者ID:Tendrl,项目名称:bridge_common,代码行数:31,代码来源:ansible_module_runner.py


示例2: __generate_executable_module

 def __generate_executable_module(self):
     modname = os.path.basename(self.module_path)
     modname = os.path.splitext(modname)[0]
     try:
         (module_data, module_style, shebang) = \
             module_common.modify_module(
                 modname,
                 self.module_path,
                 self.argument_dict,
                 None,
                 task_vars={}
             )
     except Exception as e:
         logger.log(
             "debug",
             self.publisher_id,
             {"message": "Could not generate ansible "
                         "executable data "
                         "for module  : %s. Error: %s" %
                         (self.module_path, str(e))},
             node_id=self.node_id
         )
         raise AnsibleExecutableGenerationFailed(
             module_path=self.module_path,
             err=str(e)
         )
     return module_data
开发者ID:Tendrl,项目名称:bridge_common,代码行数:27,代码来源:ansible_module_runner.py


示例3: rebalance_volume

    def rebalance_volume(self, volume_name, action, host=None,
                         force=None, fix_layout=None):
        args = {}
        if host:
            args.update({"host": host})
        if force:
            args.update({"force": force})
        if fix_layout and action == "start":
            action = "fix-layout"

        out, err, rc = rebalance_volume.rebalance_volume(
            volume_name,
            action,
            **args
        )
        if rc == 0:
            logger.log(
                "info",
                NS.publisher_id,
                {"message": "Rebalance %s on volume %s performed"
                 "successfully" % (action, volume_name)},
                integration_id=NS.tendrl_context.integration_id
            )
        else:
            logger.log(
                "debug",
                NS.publisher_id,
                {"message": "Rebalance %s failed for volume "
                 "%s. Details: %s" % (action, volume_name, out)},
                integration_id=NS.tendrl_context.integration_id
            )
            return False
        return True
开发者ID:Tendrl,项目名称:gluster_bridge,代码行数:33,代码来源:gdeploy.py


示例4: gluster_provision_bricks

 def gluster_provision_bricks(self, brick_dictionary, disk_type=None,
                              disk_count=None, stripe_count=None):
     out, err, rc = gluster_brick_provision.provision_disks(
         brick_dictionary,
         disk_type,
         disk_count,
         stripe_count
     )
     if rc == 0 and err == "":
         logger.log(
             "info",
             NS.publisher_id,
             {"message": "Bricks Provisioned successfully"},
             integration_id=NS.tendrl_context.integration_id
         )
     else:
         logger.log(
             "info",
             NS.publisher_id,
             {"message": "Bricks Provisioning Failed. Error %s" % (
                 str(out))},
             integration_id=NS.tendrl_context.integration_id
         )
         return False
     return True
开发者ID:Tendrl,项目名称:gluster_bridge,代码行数:25,代码来源:gdeploy.py


示例5: delete_volume

    def delete_volume(self, volume_name, host=None, force=None,
                      format_bricks=None):
        args = {}
        if host:
            args.update({"host": host})
        if force:
            args.update({"force": force})

        out, err, rc = delete_volume.delete_volume(
            volume_name,
            **args
        )
        if rc == 0:
            logger.log(
                "info",
                NS.publisher_id,
                {"message": "gluster volume %s deleted successfully" %
                 volume_name},
                integration_id=NS.tendrl_context.integration_id
            )
        else:
            logger.log(
                "debug",
                NS.publisher_id,
                {"message": "Volume deletion failed for volume "
                 "%s. Details: %s" % (volume_name, out)},
                integration_id=NS.tendrl_context.integration_id
            )
            return False
        if format_bricks:
            pass
            # TODO(darshan) Call gdeploy action to clear brick
        return True
开发者ID:Tendrl,项目名称:gluster_bridge,代码行数:33,代码来源:gdeploy.py


示例6: stop_volume

    def stop_volume(self, volume_name, host=None, force=None):
        args = {}
        if host:
            args.update({"host": host})
        if force:
            args.update({"force": force})

        out, err, rc = stop_volume.stop_volume(
            volume_name,
            **args
        )
        if rc == 0:
            logger.log(
                "info",
                NS.publisher_id,
                {"message": "Volume %s stopped successfully" %
                 volume_name},
                integration_id=NS.tendrl_context.integration_id
            )
        else:
            logger.log(
                "debug",
                NS.publisher_id,
                {"message": "Volume stop failed for volume "
                 "%s. Details: %s" % (volume_name, out)},
                integration_id=NS.tendrl_context.integration_id
            )
            return False
        return True
开发者ID:Tendrl,项目名称:gluster_bridge,代码行数:29,代码来源:gdeploy.py


示例7: run

    def run(self):
        integration_id = self.parameters['TendrlContext.integration_id']
        logger.log(
            "info",
            NS.get("publisher_id", None),
            {
                "message": "Setting cluster %s is_managed to \"no\":" %
                           integration_id
            },
            job_id=self.parameters['job_id'],
            flow_id=self.parameters['flow_id']
        )
        try:
            _cluster = NS.tendrl.objects.Cluster(
                integration_id=integration_id
            ).load()
            _cluster.is_managed = "no"
            _cluster.save()
        except etcd.EtcdKeyNotFound:
            logger.log(
                "error",
                NS.get("publisher_id", None),
                {
                    "message": "Error setting cluster %s"
                    "is_managed  to \"no\":" % (
                        integration_id
                    )
                },
                job_id=self.parameters['job_id'],
                flow_id=self.parameters['flow_id']
            )
            return False

        return True
开发者ID:Tendrl,项目名称:bridge_common,代码行数:34,代码来源:__init__.py


示例8: run

    def run(self):
        if not self._setup_gluster_native_message_reciever():
            logger.log(
                "error",
                NS.publisher_id,
                {"message": "gluster native message reciever setup failed"}
            )
            return

        # Enable WSGI access logging via Paste
        app_logged = TransLogger(app)

        # Mount the WSGI callable object (app) on the root directory
        cherrypy.tree.graft(app_logged, '/')
        # Set the configuration of the web server
        cherrypy.config.update({
            'engine.autoreload_on': False,
            'log.screen': True,
            'server.socket_port': self.port,
            'server.socket_host': self.host,
            'log.access_file': '',
            'log.error_file': ''
        })
        # Start the CherryPy WSGI web server
        cherrypy.engine.start()
        cherrypy.engine.block()
开发者ID:Tendrl,项目名称:gluster_bridge,代码行数:26,代码来源:gluster_native_message_handler.py


示例9: __init__

    def __init__(self, ns_name="tendrl", ns_src="tendrl.commons"):
        super(TendrlNS, self).__init__()
        if not hasattr(__builtin__, "NS"):
            setattr(__builtin__, "NS", maps.NamedDict())
            setattr(NS, "_int", maps.NamedDict())
            NS._int.wreconnect = cs_utils.wreconnect
            NS._int.reconnect = cs_utils.reconnect
            NS._int.watchers = dict()
        '''
            Note: Log messages in this file have try-except blocks to run in
            the condition when the node_agent has not been started and name
            spaces are being created.
        '''
        logger.log("info", NS.get("publisher_id", None),
                   {'message': "Creating namespace.%s from source %s"
                    % (ns_name, ns_src)})
        self.ns_name = ns_name
        self.ns_src = ns_src

        self._create_ns()

        self.current_ns = self._get_ns()
        logger.log("info", NS.get("publisher_id", None),
                   {'message': "namespace.%s created!" % self.ns_name})
        self._register_subclasses_to_ns()

        self.setup_definitions()
        self._validate_ns_definitions()
        self.setup_common_objects()
开发者ID:Tendrl,项目名称:bridge_common,代码行数:29,代码来源:__init__.py


示例10: alert_job_status

def alert_job_status(curr_value, msg, integration_id=None, cluster_name=None):
    alert = {}
    alert['source'] = NS.publisher_id
    alert['classification'] = 'cluster'
    alert['pid'] = os.getpid()
    alert['time_stamp'] = tendrl_now().isoformat()
    alert['alert_type'] = 'STATUS'
    severity = "INFO"
    if curr_value.lower() == "failed":
        severity = "WARNING"
    alert['severity'] = severity
    alert['resource'] = 'job_status'
    alert['current_value'] = curr_value
    alert['tags'] = dict(
        message=msg,
        integration_id=integration_id or
        NS.tendrl_context.integration_id,
        cluster_name=cluster_name or
        NS.tendrl_context.cluster_name,
        sds_name=NS.tendrl_context.sds_name,
        fqdn=NS.node_context.fqdn
    )
    alert['node_id'] = NS.node_context.node_id
    if not NS.node_context.node_id:
        return
    logger.log(
        "notice",
        "alerting",
        {'message': json.dumps(alert)}
    )
开发者ID:Tendrl,项目名称:bridge_common,代码行数:30,代码来源:alert_utils.py


示例11: update_cluster_alert_count

def update_cluster_alert_count():
    cluster_alert_count = 0
    severity = ["WARNING", "CRITICAL"]
    try:
        alert_counts = get_volume_alert_counts()
        alerts = NS.tendrl.objects.ClusterAlert(
            tags={'integration_id': NS.tendrl_context.integration_id}
        ).load_all()
        for alert in alerts:
            alert.tags = json.loads(alert.tags)
            if alert.severity in severity:
                cluster_alert_count += 1
                if alert.resource in NS.gluster.objects.VolumeAlertCounters(
                        )._defs['relationship'][alert.alert_type.lower()]:
                    vol_name = alert.tags.get('volume_name', None)
                    if vol_name and vol_name in alert_counts.keys():
                        alert_counts[vol_name]['alert_count'] += 1
        # Update cluster alert count
        NS.tendrl.objects.ClusterAlertCounters(
            integration_id=NS.tendrl_context.integration_id,
            alert_count=cluster_alert_count
        ).save()
        # Update volume alert count
        for volume, vol_dict in alert_counts.iteritems():
            NS.gluster.objects.VolumeAlertCounters(
                integration_id=NS.tendrl_context.integration_id,
                alert_count=vol_dict['alert_count'],
                volume_id=vol_dict['vol_id']
            ).save()
    except (etcd.EtcdException, AttributeError) as ex:
        logger.log(
            "debug",
            NS.publisher_id,
            {"message": "Unable to update alert count.err: %s" % ex}
        )
开发者ID:Tendrl,项目名称:gluster_bridge,代码行数:35,代码来源:__init__.py


示例12: run

    def run(self):
        logger.log(
            "debug",
            NS.publisher_id,
            {"message": "%s running" % self.__class__.__name__}
        )
        while not self._complete.is_set():
            _job_sync_interval = 5
            NS.node_context = NS.node_context.load()
            NS.tendrl_context = NS.tendrl_context.load()
            if "tendrl/monitor" not in NS.node_context.tags:
                if NS.tendrl_context.integration_id is None or \
                        NS.node_context.fqdn is None:
                    time.sleep(_job_sync_interval)
                    continue
            if "tendrl/monitor" in NS.node_context.tags:
                _job_sync_interval = 3

            time.sleep(_job_sync_interval)
            try:
                jobs = NS.tendrl.objects.Job().load_all()
            except etcd.EtcdKeyNotFound:
                continue

            for job in jobs:
                # Check job not already locked by some agent
                if job.locked_by or job.job_id in [None, '']:
                    continue

                _job_thread = threading.Thread(
                    target=process_job, args=(job.job_id,)
                )
                _job_thread.daemon = True
                _job_thread.start()
                _job_thread.join()
开发者ID:Tendrl,项目名称:bridge_common,代码行数:35,代码来源:__init__.py


示例13: _setup_gluster_native_message_reciever

    def _setup_gluster_native_message_reciever(self):
        service = svc.Service("glustereventsd")
        message, success = service.start()
        gluster_eventsd = svc_stat.ServiceStatus("glustereventsd")
        if not gluster_eventsd.status():
            if not success:
                logger.log(
                    "error",
                    NS.publisher_id,
                    {
                        "message": "glustereventsd could"
                        " not be started: %s" % message
                    }
                )
                return False

        url = "http://{0}:{1}{2}".format(self.host, str(self.port), self.path)
        cmd = cmd_utils.Command('gluster-eventsapi webhook-add %s' % url)
        out, err, rc = cmd.run()
        if rc != 0:
            severity = "debug" if "Webhook already exists" in err else "error"
            logger.log(
                severity,
                NS.publisher_id,
                {
                    "message": "could not add webhook"
                    " for glustereventsd. {0}: {1}".format(
                        severity,
                        err
                    )
                }
            )
        return True
开发者ID:Tendrl,项目名称:gluster_bridge,代码行数:33,代码来源:gluster_native_message_handler.py


示例14: test_log

def test_log():
    setattr(__builtin__, "NS", maps.NamedDict())
    NS.publisher_id = 1
    with mock.patch('tendrl.commons.event.Event.__init__',
                    mock.Mock(return_value=None)):
        with mock.patch('tendrl.commons.message.Message.__init__',
                        mock.Mock(return_value=None)):
            log_utils.log("info", "node_context", {"message": "test"})
    log_utils.log("error", None, {"message": "test"})
开发者ID:Tendrl,项目名称:bridge_common,代码行数:9,代码来源:test_log_utils.py


示例15: stop

    def stop(self):
        if not self._cleanup_gluster_native_message_reciever():
            logger.log(
                "error",
                NS.publisher_id,
                {"message": "gluster native message reciever cleanup failed"}
            )

        cherrypy.engine.exit()
开发者ID:Tendrl,项目名称:gluster_bridge,代码行数:9,代码来源:gluster_native_message_handler.py


示例16: reload_config

 def reload_config(signum, frame):
     logger.log(
         "debug",
         NS.publisher_id,
         {
             "message": "Signal handler: SIGHUP,"
             " reload service config"
         }
     )
     NS.gluster.ns.setup_common_objects()
开发者ID:Tendrl,项目名称:gluster_bridge,代码行数:10,代码来源:__init__.py


示例17: start

 def start(self):
     logger.log(
         "debug",
         NS.publisher_id,
         {"message": "%s starting" % self.__class__.__name__}
     )
     if self._message_handler_thread is not None:
         self._message_handler_thread.start()
     if self._sds_sync_thread is not None:
         self._sds_sync_thread.start()
     self._job_consumer_thread.start()
开发者ID:Tendrl,项目名称:bridge_common,代码行数:11,代码来源:__init__.py


示例18: shutdown

    def shutdown(signum, frame):
        logger.log(
            "debug",
            NS.publisher_id,
            {"message": "Signal handler: stopping"}
        )
        # Remove the node's name from gluster server tag
        try:
            gl_srvr_list = etcd_utils.read(
                "/indexes/tags/gluster/server"
            ).value
            gl_srvr_list = json.loads(gl_srvr_list)
            if NS.node_context.node_id in gl_srvr_list:
                gl_srvr_list.remove(NS.node_context.node_id)
            etcd_utils.write(
                "/indexes/tags/gluster/server",
                json.dumps(gl_srvr_list)
            )
            node_tags = NS.node_context.tags
            if 'provisioner/%s' % NS.tendrl_context.integration_id \
                in node_tags:
                etcd_utils.delete(
                    "/indexes/tags/provisioner/%s" %
                    NS.tendrl_context.integration_id,
                    recursive=True
                )
            int_srvr_list = etcd_utils.read(
                "/indexes/tags/tendrl/integration/gluster"
            ).value
            int_srvr_list = json.loads(int_srvr_list)
            if NS.node_context.node_id in int_srvr_list:
                int_srvr_list.remove(NS.node_context.node_id)
            etcd_utils.write(
                "/indexes/tags/tendrl/integration/gluster",
                json.dumps(int_srvr_list)
            )
        except etcd.EtcdKeyNotFound:
            logger.log(
                "debug",
                NS.publisher_id,
                {
                    "message": "Couldnt remove node from "
                    "gluster servers list tag."
                    "integration_id: %s, node_id: %s" %
                    (
                        NS.tendrl_context.integration_id,
                        NS.node_context.node_id
                    )
                }
            )
            pass

        complete.set()
        m.stop()
开发者ID:Tendrl,项目名称:gluster_bridge,代码行数:54,代码来源:__init__.py


示例19: emit_event

def emit_event(resource, curr_value, msg, instance,
               severity, alert_notify=False, tags={},
               integration_id=None, cluster_name=None,
               sds_name=None, node_id=None):
    alert = {}
    alert['source'] = NS.publisher_id
    alert['node_id'] = node_id
    alert['pid'] = os.getpid()
    alert['time_stamp'] = tendrl_now().isoformat()
    alert['alert_type'] = 'STATUS'
    alert['severity'] = severity
    alert['resource'] = resource
    alert['current_value'] = curr_value
    alert['tags'] = dict(
        plugin_instance=instance,
        message=msg,
        integration_id=integration_id or NS.tendrl_context.integration_id,
        cluster_name=cluster_name or NS.tendrl_context.cluster_name
    )
    if "entity_type" in tags:
        if tags["entity_type"] == BRICK_ENTITY:
            alert['node_id'] = tags.get(
                "node_id", NS.node_context.node_id
            )
            alert['tags']['fqdn'] = tags.get(
                "fqdn", NS.node_context.fqdn
            )
            alert['tags']['volume_name'] = tags.get(
                'volume_name', None
            )
        elif tags["entity_type"] == VOLUME_ENTITY:
            alert['tags']['volume_name'] = tags.get(
                'volume_name', None
            )
    payload = {'message': json.dumps(alert)}
    payload['alert_condition_state'] = severity
    payload['alert_condition_status'] = resource

    if alert_notify:
        payload['alert_notify'] = alert_notify

    if severity == "INFO":
        payload['alert_condition_unset'] = True
    else:
        payload['alert_condition_unset'] = False
    logger.log(
        "notice",
        "alerting",
        payload,
        integration_id=integration_id
    )
开发者ID:Tendrl,项目名称:bridge_common,代码行数:51,代码来源:event_utils.py


示例20: load_definition

 def load_definition(self):
     try:
         logger.log(
             "debug",
             NS.publisher_id,
             {"message": "Load definitions (.yml) for "
                         "namespace.%s."
                         "objects.%s.atoms.%s" %
                         (self._ns.ns_name, self.obj.__name__,
                          self.__class__.__name__)}
         )
     except KeyError:
         sys.stdout.write(
             "Load definitions (.yml) for "
             "namespace.%s.objects.%s."
             "atoms.%s \n" %
             (self._ns.ns_name, self.obj.__name__,
              self.__class__.__name__)
         )
     try:
         return self._ns.get_atom_definition(
             self.obj.__name__,
             self.__class__.__name__
         )
     except KeyError as ex:
         msg = "Could not find definitions (.yml) for" \
               "namespace.%s.objects.%s.atoms.%s" % \
               (
                   self._ns.ns_src,
                   self.obj.__name__,
                   self.__class__.__name__
               )
         try:
             Event(
                 ExceptionMessage(
                     priority="debug",
                     publisher=NS.publisher_id,
                     payload={"message": "Error", "exception": ex}
                 )
             )
         except KeyError:
             sys.stderr.write("Error: %s \n" % ex)
         try:
             logger.log(
                 "debug",
                 NS.publisher_id,
                 {"message": msg}
             )
         except KeyError:
             sys.stderr.write(msg + "\n")
         raise Exception(msg)
开发者ID:Tendrl,项目名称:bridge_common,代码行数:51,代码来源:__init__.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python tensor.tensor函数代码示例发布时间:2022-05-27
下一篇:
Python log.get_logger函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap