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


Python log.is_debug函数代码示例

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


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

示例1: setup

    def setup(self):
        """This method is called before the task start."""
        try:
            for user in self.context['users']:
                osclient = osclients.Clients(user['credential'])
                keystone = osclient.keystone()
                creds = keystone.ec2.list(user['id'])
                if not creds:
                    creds = keystone.ec2.create(user['id'], user['tenant_id'])
                else:
                    creds = creds[0]
                url = keystone.service_catalog.url_for(service_type='ec2')
                user['ec2args'] = {
                    'region': 'RegionOne',
                    'url': url,
                    'access': creds.access,
                    'secret': creds.secret
                }

            if self.net_wrapper.SERVICE_IMPL == consts.Service.NEUTRON:
                for user, tenant_id in rutils.iterate_per_tenants(
                        self.context["users"]):
                    body = {"quota": {"router": -1, "floatingip": -1}}
                    self.net_wrapper.client.update_quota(tenant_id, body)
                    network = self.net_wrapper.create_network(
                        tenant_id, add_router=True, subnets_num=1)
                    self.context["tenants"][tenant_id]["network"] = network

        except Exception as e:
            msg = "Can't prepare ec2 client: %s" % e.message
            if logging.is_debug():
                LOG.exception(msg)
            else:
                LOG.warning(msg)
开发者ID:hayderimran7,项目名称:ec2-api,代码行数:34,代码来源:context_plugin_ec2_creds.py

示例2: _run_scenario_once

def _run_scenario_once(args):
    iteration, cls, method_name, context, kwargs = args

    LOG.info("Task %(task)s | ITER: %(iteration)s START" %
             {"task": context["task"]["uuid"], "iteration": iteration})

    context["iteration"] = iteration
    scenario = cls(
        context=context,
        admin_clients=osclients.Clients(context["admin"]["endpoint"]),
        clients=osclients.Clients(context["user"]["endpoint"]))

    error = []
    scenario_output = {"errors": "", "data": {}}
    try:
        with rutils.Timer() as timer:
            scenario_output = getattr(scenario,
                                      method_name)(**kwargs) or scenario_output
    except Exception as e:
        error = utils.format_exc(e)
        if logging.is_debug():
            LOG.exception(e)
    finally:
        status = "Error %s: %s" % tuple(error[0:2]) if error else "OK"
        LOG.info("Task %(task)s | ITER: %(iteration)s END: %(status)s" %
                 {"task": context["task"]["uuid"], "iteration": iteration,
                  "status": status})

        return {"duration": timer.duration() - scenario.idle_duration(),
                "timestamp": timer.timestamp(),
                "idle_duration": scenario.idle_duration(),
                "error": error,
                "scenario_output": scenario_output,
                "atomic_actions": scenario.atomic_actions()}
开发者ID:aarefiev22,项目名称:rally,代码行数:34,代码来源:base.py

示例3: _consumer

def _consumer(consume, queue, is_published):
    """Infinity worker that consumes tasks from queue.

    This finishes it's work only in case if is_published.isSet().

    :param consume: method that consumes an object removed from the queue
    :param queue: deque object to popleft() objects from
    :param is_published: threading.Event that is used to stop the consumer
                         when the queue is empty
    """
    cache = {}
    while True:
        if not queue:
            if is_published.isSet():
                break
            time.sleep(0.1)
            continue
        else:
            try:
                args = queue.popleft()
            except IndexError:
                # consumed by other thread
                continue
        try:
            consume(cache, args)
        except Exception as e:
            LOG.warning(_("Failed to consume a task from the queue: %s") % e)
            if logging.is_debug():
                LOG.exception(e)
开发者ID:NeCTAR-RC,项目名称:rally,代码行数:29,代码来源:broker.py

示例4: create

    def create(cls, config, name):
        """Create a deployment.

        :param config: a dict with deployment configuration
        :param name: a str represents a name of the deployment
        :returns: Deployment object
        """

        try:
            deployment = objects.Deployment(name=name, config=config)
        except exceptions.DeploymentNameExists as e:
            if logging.is_debug():
                LOG.exception(e)
            raise

        deployer = deploy_engine.Engine.get_engine(
            deployment["config"]["type"], deployment)
        try:
            deployer.validate()
        except jsonschema.ValidationError:
            LOG.error(_("Deployment %s: Schema validation error.") %
                      deployment["uuid"])
            deployment.update_status(consts.DeployStatus.DEPLOY_FAILED)
            raise

        with deployer:
            endpoints = deployer.make_deploy()
            deployment.update_endpoints(endpoints)
            return deployment
开发者ID:radar92,项目名称:rally,代码行数:29,代码来源:api.py

示例5: _consumer

def _consumer(consume, queue, is_published):
    """Infinity worker that consumes tasks from queue.

    This finishes it's work only in case if is_published.isSet().

    :param consume: method that consumes an object removed from the queue
    :param queue: deque object to popleft() objects from
    :param is_published: threading.Event that is used to stop the consumer
                         when the queue is empty
    """
    cache = {}
    while True:
        if queue:
            try:
                consume(cache, queue.popleft())
            except IndexError:
                # NOTE(boris-42): queue is accessed from multiple threads so
                #                 it's quite possible to have 2 queue accessing
                #                 at the same point queue with only 1 element
                pass
            except Exception as e:
                LOG.warning(_("Failed to consume a task from the queue: "
                              "%s") % e)
                if logging.is_debug():
                    LOG.exception(e)
        elif is_published.isSet():
            break
        else:
            time.sleep(0.1)
开发者ID:esikachev,项目名称:rally,代码行数:29,代码来源:broker.py

示例6: _delete_single_resource

    def _delete_single_resource(self, resource):
        """Safe resource deletion with retries and timeouts.

        Send request to delete resource, in case of failures repeat it few
        times. After that pull status of resource until it's deleted.

        Writes in LOG warning with UUID of resource that wasn't deleted

        :param resource: instance of resource manager initiated with resource
                         that should be deleted.
        """

        msg_kw = {
            "uuid": resource.id(),
            "service": resource._service,
            "resource": resource._resource
        }

        LOG.debug("Deleting %(service)s %(resource)s object %(uuid)s" %
                  msg_kw)

        try:
            rutils.retry(resource._max_attempts, resource.delete)
        except Exception as e:
            msg_kw["reason"] = e
            LOG.warning(
                _("Resource deletion failed, max retries exceeded for "
                  "%(service)s.%(resource)s: %(uuid)s. Reason: %(reason)s")
                % msg_kw)
            if logging.is_debug():
                LOG.exception(e)
        else:
            started = time.time()
            failures_count = 0
            while time.time() - started < resource._timeout:
                try:
                    if resource.is_deleted():
                        return
                except Exception as e:
                    LOG.warning(
                        _("Seems like %s.%s.is_deleted(self) method is broken "
                          "It shouldn't raise any exceptions.")
                        % (resource.__module__, type(resource).__name__))
                    LOG.exception(e)

                    # NOTE(boris-42): Avoid LOG spamming in case of bad
                    #                 is_deleted() method
                    failures_count += 1
                    if failures_count > resource._max_attempts:
                        break

                finally:
                    time.sleep(resource._interval)

            LOG.warning(_("Resource deletion failed, timeout occurred for "
                          "%(service)s.%(resource)s: %(uuid)s.")
                        % msg_kw)
开发者ID:rvbaz,项目名称:rally,代码行数:57,代码来源:manager.py

示例7: load_plugins

def load_plugins(dir_or_file):
    if os.path.isdir(dir_or_file):
        directory = dir_or_file
        LOG.info(_("Loading plugins from directories %s/*") %
                 directory.rstrip("/"))

        to_load = []
        for root, dirs, files in os.walk(directory, followlinks=True):
            to_load.extend((plugin[:-3], root)
                           for plugin in files if plugin.endswith(".py"))
        for plugin, directory in to_load:
            if directory not in sys.path:
                sys.path.append(directory)

            fullpath = os.path.join(directory, plugin)
            try:
                fp, pathname, descr = imp.find_module(plugin, [directory])
                imp.load_module(plugin, fp, pathname, descr)
                fp.close()
                LOG.info(_("\t Loaded module with plugins: %s.py") % fullpath)
            except Exception as e:
                LOG.warning(
                    "\t Failed to load module with plugins %(path)s.py: %(e)s"
                    % {"path": fullpath, "e": e})
                if logging.is_debug():
                    LOG.exception(e)
    elif os.path.isfile(dir_or_file):
        plugin_file = dir_or_file
        LOG.info(_("Loading plugins from file %s") % plugin_file)
        if plugin_file not in sys.path:
            sys.path.append(plugin_file)
        try:
            plugin_name = os.path.splitext(plugin_file.split("/")[-1])[0]
            imp.load_source(plugin_name, plugin_file)
            LOG.info(_("\t Loaded module with plugins: %s.py") % plugin_name)
        except Exception as e:
            LOG.warning(_(
                "\t Failed to load module with plugins %(path)s: %(e)s")
                % {"path": plugin_file, "e": e})
            if logging.is_debug():
                LOG.exception(e)
开发者ID:group-policy,项目名称:rally,代码行数:41,代码来源:discover.py

示例8: cleanup

 def cleanup(self):
     """This method is called after the task finish."""
     try:
         nova = osclients.Clients(self.context["admin"]["endpoint"]).nova()
         nova.flavors.delete(self.context["flavor"]["id"])
         LOG.debug("Flavor '%s' deleted" % self.context["flavor"]["id"])
     except Exception as e:
         msg = "Can't delete flavor: %s" % e.message
         if logging.is_debug():
             LOG.exception(msg)
         else:
             LOG.warning(msg)
开发者ID:sckevmit,项目名称:rally,代码行数:12,代码来源:context_plugin.py

示例9: _publisher

def _publisher(publish, queue):
    """Calls a publish method that fills queue with jobs.

    :param publish: method that fills the queue
    :param queue: deque object to be filled by the publish() method
    """
    try:
        publish(queue)
    except Exception as e:
        LOG.warning(_("Failed to publish a task to the queue: %s") % e)
        if logging.is_debug():
            LOG.exception(e)
开发者ID:group-policy,项目名称:rally,代码行数:12,代码来源:broker.py

示例10: cleanup

 def cleanup(self):
     try:
         if self.net_wrapper.SERVICE_IMPL == consts.Service.NEUTRON:
             for user, tenant_id in rutils.iterate_per_tenants(
                     self.context["users"]):
                 network = self.context["tenants"][tenant_id]["network"]
                 self.net_wrapper.delete_network(network)
     except Exception as e:
         msg = "Can't cleanup ec2 client: %s" % e.message
         if logging.is_debug():
             LOG.exception(msg)
         else:
             LOG.warning(msg)
开发者ID:hayderimran7,项目名称:ec2-api,代码行数:13,代码来源:context_plugin_ec2_creds.py

示例11: nova

 def nova(self, version="2"):
     """Return nova client."""
     from novaclient import client as nova
     kc = self.keystone()
     compute_api_url = kc.service_catalog.url_for(
         service_type="compute",
         endpoint_type=self.endpoint.endpoint_type,
         region_name=self.endpoint.region_name)
     client = nova.Client(version,
                          auth_token=kc.auth_token,
                          http_log_debug=logging.is_debug(),
                          timeout=CONF.openstack_client_http_timeout,
                          insecure=self.endpoint.insecure,
                          cacert=self.endpoint.cacert,
                          **self._get_auth_info(password_key="api_key"))
     client.set_management_url(compute_api_url)
     return client
开发者ID:srhrkrishna,项目名称:rally,代码行数:17,代码来源:osclients.py

示例12: cinder

 def cinder(self, version="1"):
     """Return cinder client."""
     from cinderclient import client as cinder
     client = cinder.Client(version,
                            http_log_debug=logging.is_debug(),
                            timeout=CONF.openstack_client_http_timeout,
                            insecure=self.endpoint.insecure,
                            cacert=self.endpoint.cacert,
                            **self._get_auth_info(password_key="api_key"))
     kc = self.keystone()
     volume_api_url = kc.service_catalog.url_for(
         service_type="volume",
         endpoint_type=self.endpoint.endpoint_type,
         region_name=self.endpoint.region_name)
     client.client.management_url = volume_api_url
     client.client.auth_token = kc.auth_token
     return client
开发者ID:srhrkrishna,项目名称:rally,代码行数:17,代码来源:osclients.py

示例13: _publisher

def _publisher(publish, queue, is_published):
    """Calls a publish method that fills queue with jobs.

    After running publish method it sets is_published variable, that is used to
    stop workers (consumers).

    :param publish: method that fills the queue
    :param queue: deque object to be filled by the publish() method
    :param is_published: threading.Event that is used to stop consumers and
                         finish task
    """
    try:
        publish(queue)
    except Exception as e:
        LOG.warning(_("Failed to publish a task to the queue: %s") % e)
        if logging.is_debug():
            LOG.exception(e)
    finally:
        is_published.set()
开发者ID:NeCTAR-RC,项目名称:rally,代码行数:19,代码来源:broker.py

示例14: setup

 def setup(self):
     """This method is called before the task start."""
     try:
         # use rally.osclients to get necessary client instance
         nova = osclients.Clients(self.context["admin"]["endpoint"]).nova()
         # and than do what you need with this client
         self.context["flavor"] = nova.flavors.create(
             # context settings are stored in self.config
             name=self.config.get("flavor_name", "rally_test_flavor"),
             ram=self.config.get("ram", 1),
             vcpus=self.config.get("vcpus", 1),
             disk=self.config.get("disk", 1)).to_dict()
         LOG.debug("Flavor with id '%s'" % self.context["flavor"]["id"])
     except Exception as e:
         msg = "Can't create flavor: %s" % e.message
         if logging.is_debug():
             LOG.exception(msg)
         else:
             LOG.warning(msg)
开发者ID:sckevmit,项目名称:rally,代码行数:19,代码来源:context_plugin.py

示例15: manila

 def manila(self, version="1"):
     """Return manila client."""
     from manilaclient import client as manila
     manila_client = manila.Client(
         version,
         region_name=self.endpoint.region_name,
         http_log_debug=logging.is_debug(),
         timeout=CONF.openstack_client_http_timeout,
         insecure=self.endpoint.insecure,
         cacert=self.endpoint.cacert,
         **self._get_auth_info(password_key="api_key",
                               project_name_key="project_name"))
     kc = self.keystone()
     manila_client.client.management_url = kc.service_catalog.url_for(
         service_type="share",
         endpoint_type=self.endpoint.endpoint_type,
         region_name=self.endpoint.region_name)
     manila_client.client.auth_token = kc.auth_token
     return manila_client
开发者ID:srhrkrishna,项目名称:rally,代码行数:19,代码来源:osclients.py


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