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


Python log_utils.log函数代码示例

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


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


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