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


Python logger.warn函数代码示例

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


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

示例1: _get_node_uids_for_plugin_tasks

    def _get_node_uids_for_plugin_tasks(self, plugin):
        # TODO(aroma): remove concatenation of tasks when unified way of
        # processing will be introduced for deployment tasks and existing
        # plugin tasks
        tasks_to_process = plugin.tasks + plugin.deployment_tasks

        roles = []
        for task in tasks_to_process:
            # plugin tasks may store information about node
            # role not only in `role` key but also in `groups`
            task_role = task.get('role', task.get('groups'))
            if task_role == consts.TASK_ROLES.all:
                # just return all nodes
                return self.role_resolver.resolve(consts.TASK_ROLES.all)
            elif task_role == consts.TASK_ROLES.master:
                # NOTE(aroma): pre-deployment tasks should not be executed on
                # master node because in some cases it leads to errors due to
                # commands need to be run are not compatible with master node
                # OS (CentOS). E.g. of such situation - create repository
                # executes `apt-get update` which fails on CentOS
                continue
            elif isinstance(task_role, list):
                roles.extend(task_role)
            # if task has 'skipped' status it is allowed that 'roles' and
            # 'groups' are not be specified
            elif task['type'] != consts.ORCHESTRATOR_TASK_TYPES.skipped:
                logger.warn(
                    'Wrong roles format in task %s: either '
                    '`roles` or `groups` must be specified and contain '
                    'a list of roles or "*"',
                    task)

        return self.role_resolver.resolve(roles)
开发者ID:dnikishov,项目名称:fuel-web,代码行数:33,代码来源:plugins_serializers.py

示例2: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized Task object.
        :http: * 202 (deployment stopping initiated)
               * 400 (can't stop deployment)
               * 404 (environment not found in db)
        """
        cluster = self.get_object_or_404(Cluster, cluster_id)

        try:
            logger.info(
                u"Trying to stop deployment "
                u"on environment '{0}'".format(
                    cluster_id
                )
            )
            task_manager = StopDeploymentTaskManager(
                cluster_id=cluster.id
            )
            task = task_manager.execute()
        except errors.StopAlreadyRunning as exc:
            err = web.conflict
            err.message = exc.message
            raise err
        except Exception as exc:
            logger.warn(u'Error during execution '
                        u'deployment stopping task: {0}'.format(str(exc)))
            raise web.badrequest(str(exc))

        raise web.webapi.HTTPError(
            status="202 Accepted",
            data=TaskHandler.render(task)
        )
开发者ID:tsipa,项目名称:fuel-web,代码行数:32,代码来源:cluster.py

示例3: _get_vlan_splinters_desc

    def _get_vlan_splinters_desc(cls, use_vlan_splinters, iface, cluster):
        iface_attrs = {}
        if use_vlan_splinters in ("disabled", "kernel_lt"):
            iface_attrs["vlan_splinters"] = "off"
            return iface_attrs
        iface_attrs["vlan_splinters"] = "auto"
        trunks = [0]

        if use_vlan_splinters == "hard":
            for ng in iface.assigned_networks_list:
                if (
                    ng.name == "private"
                    and cluster.network_config.segmentation_type == consts.NEUTRON_SEGMENT_TYPES.vlan
                ):
                    vlan_range = cluster.network_config.vlan_range
                    trunks.extend(xrange(*vlan_range))
                    trunks.append(vlan_range[1])
                else:
                    if ng.vlan_start in (0, None):
                        continue
                    trunks.append(ng.vlan_start)
        elif use_vlan_splinters == "soft":
            pass
        else:
            logger.warn("Invalid vlan_splinters value: %s", use_vlan_splinters)
            return {}

        iface_attrs["trunks"] = trunks

        return iface_attrs
开发者ID:ymkins,项目名称:fuel-web,代码行数:30,代码来源:neutron_serializers.py

示例4: PUT

    def PUT(self):
        """Executes update tasks for specified resources.

        :http: * 200 (OK)
               * 202 (Accepted)
               * 400 (Invalid data)
               * 404 (Object dependencies not found)
        """
        graph_type = web.input(graph_type=None).graph_type or None
        filters = self.checked_data(self.validator.validate_execute)

        cluster = self.get_object_or_404(
            objects.Cluster, filters['cluster_id'])

        # Execute upload task for nodes
        task_manager = self.task_manager(cluster_id=cluster.id)
        try:
            task = task_manager.execute(filters, graph_type=graph_type)
        except Exception as exc:
            logger.warn(
                u'Cannot execute %s task nodes: %s',
                self.task_manager.__name__, traceback.format_exc())
            raise self.http(400, six.text_type(exc))

        self.raise_task(task)
开发者ID:huyupeng,项目名称:fuel-web,代码行数:25,代码来源:openstack_config.py

示例5: PUT

    def PUT(self, cluster_id):
        cluster = self.get_object_or_404(
            Cluster,
            cluster_id,
            log_404=(
                "warning",
                "Error: there is no cluster "
                "with id '{0}' in DB.".format(cluster_id)))

        try:
            network_info = \
                NetworkConfigurationSerializer.serialize_for_cluster(
                    cluster
                )
            logger.info(
                u"Network info:\n{0}".format(
                    json.dumps(network_info, indent=4)
                )
            )
            task_manager = DeploymentTaskManager(
                cluster_id=cluster.id
            )
            task = task_manager.execute()
        except Exception as exc:
            logger.warn(u'ClusterChangesHandler: error while execution'
                        ' deploy task: {0}'.format(str(exc)))
            raise web.badrequest(str(exc))

        return TaskHandler.render(task)
开发者ID:mahak,项目名称:fuelweb,代码行数:29,代码来源:cluster.py

示例6: check_range_in_use_already

 def check_range_in_use_already(cidr_range):
     for n in used_nets:
         if cls.is_range_intersection(n, cidr_range):
             logger.warn("IP range {0} is in use already".format(
                 cidr_range))
             break
     used_nets.append(cidr_range)
开发者ID:naveenzhang,项目名称:fuel-web,代码行数:7,代码来源:manager.py

示例7: get_node_volumes

def get_node_volumes(node):
    """Helper for retrieving node volumes in correct order.
    If spaces don't defained for role, will be used
    partitioning for role `other`.
    """
    node_volumes = []

    role_volumes = node.cluster.release.volumes_metadata[
        'volumes_roles_mapping']
    roles = node.roles + node.pending_roles

    for role in roles:
        if not role_volumes.get(role):
            continue

        for volume in role_volumes[role]:
            if volume not in node_volumes:
                node_volumes.append(volume)

    # Use role other
    if not node_volumes:
        logger.warn('Cannot find volumes for node: %s assigning default '
                    'volumes' % (node.full_name))
        for volume in role_volumes['other']:
            node_volumes.append(volume)

    return node_volumes
开发者ID:mrasskazov,项目名称:fuelweb,代码行数:27,代码来源:manager.py

示例8: get_node_spaces

def get_node_spaces(node):
    """Helper for retrieving node volumes.
    If spaces don't defained for role, will be used
    partitioning for role `other`.
    Sets key `_allocate_size` which used only for internal calculation
    and not used in partitioning system.
    """
    node_spaces = []

    role_mapping = node.cluster.release.volumes_metadata[
        'volumes_roles_mapping']
    all_spaces = node.cluster.release.volumes_metadata['volumes']

    for role in node.all_roles:
        if not role_mapping.get(role):
            continue

        for volume in role_mapping[role]:
            space = find_space_by_id(all_spaces, volume['id'])
            if space not in node_spaces:
                space['_allocate_size'] = get_allocate_size(node, volume)
                node_spaces.append(space)

    # Use role `other`
    if not node_spaces:
        logger.warn('Cannot find volumes for node: %s assigning default '
                    'volumes' % (node.full_name))
        for volume in role_mapping['other']:
            space = find_space_by_id(all_spaces, volume['id'])
            space['_allocate_size'] = get_allocate_size(node, volume)
            node_spaces.append(space)

    return node_spaces
开发者ID:andrey-borisov,项目名称:fuel-web,代码行数:33,代码来源:manager.py

示例9: deployment_tasks

    def deployment_tasks(self, plugins, stage):
        plugin_tasks = []
        sorted_plugins = sorted(plugins, key=lambda p: p.plugin.name)

        for plugin in sorted_plugins:
            stage_tasks = filter(
                lambda t: t['stage'].startswith(stage), plugin.tasks)
            plugin_tasks.extend(self._set_tasks_defaults(plugin, stage_tasks))

        sorted_tasks = self._sort_by_stage_postfix(plugin_tasks)
        for task in sorted_tasks:
            make_task = None
            uids = self.role_resolver.resolve(task['role'])
            if not uids:
                continue

            if task['type'] == 'shell':
                make_task = templates.make_shell_task
            elif task['type'] == 'puppet':
                make_task = templates.make_puppet_task
            elif task['type'] == 'reboot':
                make_task = templates.make_reboot_task
            else:
                logger.warn('Task is skipped %s, because its type is '
                            'not supported', task)

            if make_task:
                yield self._serialize_task(make_task(uids, task), task)
开发者ID:ekorekin,项目名称:fuel-web,代码行数:28,代码来源:plugins_serializers.py

示例10: provision_resp

    def provision_resp(cls, **kwargs):
        logger.info(
            "RPC method provision_resp received: %s" %
            json.dumps(kwargs))

        task_uuid = kwargs.get('task_uuid')
        message = kwargs.get('error')
        status = kwargs.get('status')
        progress = kwargs.get('progress')
        nodes = kwargs.get('nodes', [])

        task = get_task_by_uuid(task_uuid)

        for node in nodes:
            uid = node.get('uid')
            node_db = db().query(Node).get(uid)

            if not node_db:
                logger.warn('Task with uid "{0}" not found'.format(uid))
                continue

            if node.get('status') == 'error':
                node_db.status = 'error'
                node_db.progress = 100
                node_db.error_type = 'provision'
                node_db.error_msg = node.get('error_msg', 'Unknown error')
            else:
                node_db.status = node.get('status')
                node_db.progress = node.get('progress')

        TaskHelper.update_task_status(task.uuid, status, progress, message)
开发者ID:adanin,项目名称:fuel-web,代码行数:31,代码来源:receiver.py

示例11: _get_vlan_splinters_desc

    def _get_vlan_splinters_desc(cls, use_vlan_splinters, iface,
                                 cluster):
        iface_attrs = {}
        if use_vlan_splinters in ('disabled', 'kernel_lt'):
            iface_attrs['vlan_splinters'] = 'off'
            return iface_attrs
        iface_attrs['vlan_splinters'] = 'auto'
        trunks = [0]

        if use_vlan_splinters == 'hard':
            for ng in iface.assigned_networks_list:
                if ng.name == 'private':
                    vlan_range = cluster.network_config.vlan_range
                    trunks.extend(xrange(*vlan_range))
                    trunks.append(vlan_range[1])
                else:
                    if ng.vlan_start in (0, None):
                        continue
                    trunks.append(ng.vlan_start)
        elif use_vlan_splinters == 'soft':
            pass
        else:
            logger.warn('Invalid vlan_splinters value: %s', use_vlan_splinters)
            return {}

        iface_attrs['trunks'] = trunks

        return iface_attrs
开发者ID:zbwzy,项目名称:nailgun,代码行数:28,代码来源:deployment_serializers.py

示例12: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized Task object.
        :http: * 200 (task successfully executed)
               * 404 (cluster not found in db)
               * 400 (failed to execute task)
        """
        cluster = self.get_object_or_404(
            Cluster,
            cluster_id,
            log_404=("warning", "Error: there is no cluster " "with id '{0}' in DB.".format(cluster_id)),
        )

        if cluster.net_provider == "nova_network":
            net_serializer = NovaNetworkConfigurationSerializer
        elif cluster.net_provider == "neutron":
            net_serializer = NeutronNetworkConfigurationSerializer

        try:
            network_info = net_serializer.serialize_for_cluster(cluster)
            logger.info(u"Network info:\n{0}".format(json.dumps(network_info, indent=4)))
            task_manager = ApplyChangesTaskManager(cluster_id=cluster.id)
            task = task_manager.execute()
        except Exception as exc:
            logger.warn(u"ClusterChangesHandler: error while execution" " deploy task: {0}".format(str(exc)))
            raise web.badrequest(str(exc))

        return TaskHandler.render(task)
开发者ID:pombredanne,项目名称:fuel-web,代码行数:27,代码来源:cluster.py

示例13: get_uids_for_tasks

def get_uids_for_tasks(nodes, tasks):
    """Return node uids where particular tasks should be executed

    :param nodes: list of Node db objects
    :param tasks: list of dicts
    :returns: list of strings
    """
    roles = []
    for task in tasks:
        # plugin tasks may store information about node
        # role not only in `role` key but also in `groups`
        task_role = task.get('role', task.get('groups'))
        if task_role == consts.ALL_ROLES:
            return get_uids_for_roles(nodes, consts.ALL_ROLES)
        elif task_role == consts.MASTER_ROLE:
            return [consts.MASTER_ROLE]
        elif isinstance(task_role, list):
            roles.extend(task_role)
        # if task has 'skipped' status it is allowed that 'roles' and
        # 'groups' are not be specified
        elif task['type'] != consts.ORCHESTRATOR_TASK_TYPES.skipped:
            logger.warn(
                'Wrong roles format in task %s: either '
                '`roles` or `groups` must be specified and contain '
                'a list of roles or "*"',
                task)
    return get_uids_for_roles(nodes, roles)
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:27,代码来源:tasks_serializer.py

示例14: provision_resp

    def provision_resp(cls, **kwargs):
        logger.info(
            "RPC method provision_resp received: %s" % jsonutils.dumps(kwargs))

        task_uuid = kwargs.get('task_uuid')
        message = kwargs.get('error')
        status = kwargs.get('status')
        progress = kwargs.get('progress')
        nodes = kwargs.get('nodes', [])

        task = objects.Task.get_by_uuid(
            task_uuid, fail_if_not_found=True, lock_for_update=True)

        # if task was failed on master node then we should
        # mark all cluster's nodes in error state
        master = next((n for n in nodes if n['uid'] == consts.MASTER_ROLE), {})

        # we should remove master node from the nodes since it requires
        # special handling and won't work with old code
        if master:
            nodes.remove(master)

        if master.get('status') == consts.TASK_STATUSES.error:
            status = consts.TASK_STATUSES.error
            progress = 100

        # lock nodes for updating
        q_nodes = objects.NodeCollection.filter_by_id_list(
            None, [n['uid'] for n in nodes])
        q_nodes = objects.NodeCollection.order_by(q_nodes, 'id')
        objects.NodeCollection.lock_for_update(q_nodes).all()

        for node in nodes:
            uid = node.get('uid')
            node_db = objects.Node.get_by_uid(node['uid'])

            if not node_db:
                logger.warn('Node with uid "{0}" not found'.format(uid))
                continue

            if node.get('status') == consts.TASK_STATUSES.error:
                node_db.status = consts.TASK_STATUSES.error
                node_db.progress = 100
                node_db.error_type = 'provision'
                node_db.error_msg = node.get('error_msg', 'Unknown error')
            else:
                node_db.status = node.get('status')
                node_db.progress = node.get('progress')

        db().flush()
        if nodes and not progress:
            progress = TaskHelper.recalculate_provisioning_task_progress(task)

        data = {'status': status, 'progress': progress, 'message': message}
        objects.Task.update(task, data)

        cls._update_action_log_entry(status, task.name, task_uuid, nodes)
开发者ID:nebril,项目名称:fuel-web,代码行数:57,代码来源:receiver.py

示例15: POST

 def POST(self):
     data = self.checked_data()
     # TODO: activate and save status
     task_manager = DownloadReleaseTaskManager(data['release_id'])
     try:
         task = task_manager.execute()
     except Exception as exc:
         logger.warn(u'DownloadReleaseHandler: error while execution'
                     ' deploy task: {0}'.format(exc.message))
         raise web.badrequest(exc.message)
     return TaskHandler.render(task)
开发者ID:ilyinon,项目名称:fuelweb,代码行数:11,代码来源:redhat.py


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