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


Python api.publisher_id函数代码示例

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


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

示例1: remove_router_interface

    def remove_router_interface(self, context, router_id, interface_info):
        if not interface_info:
            msg = _("Either subnet_id or port_id must be specified")
            raise n_exc.BadRequest(resource='router', msg=msg)
        port_id = interface_info.get('port_id')
        subnet_id = interface_info.get('subnet_id')
        device_owner = self._get_device_owner(context, router_id)
        if port_id:
            port, subnet = self._remove_interface_by_port(context, router_id,
                                                          port_id, subnet_id,
                                                          device_owner)
        elif subnet_id:
            port, subnet = self._remove_interface_by_subnet(
                context, router_id, subnet_id, device_owner)

        self.l3_rpc_notifier.routers_updated(
            context, [router_id], 'remove_router_interface')
        info = {'id': router_id,
                'tenant_id': port['tenant_id'],
                'port_id': port['id'],
                'subnet_id': subnet['id']}
        notifier_api.notify(context,
                            notifier_api.publisher_id('network'),
                            'router.interface.delete',
                            notifier_api.CONF.default_notification_level,
                            {'router_interface': info})
        return info
开发者ID:KumarAcharya,项目名称:neutron,代码行数:27,代码来源:l3_db.py

示例2: test_allocation_notification

 def test_allocation_notification(self):
     subnet = dict(
         id=1,
         first_ip=0,
         last_ip=255,
         cidr="0.0.0.0/24",
         ip_version=4,
         next_auto_assign_ip=0,
         network=dict(ip_policy=None),
         ip_policy=None,
     )
     address = dict(address=0, created_at="123", subnet_id=1, address_readable="0.0.0.0", used_by_tenant_id=1)
     with self._stubs(address, subnets=[(subnet, 1)], addresses=[None, None]) as notify:
         self.ipam.allocate_ip_address(self.context, 0, 0, 0, version=4)
         notify.assert_called_once_with(
             self.context,
             notifier_api.publisher_id("network"),
             "ip_block.address.create",
             notifier_api.CONF.default_notification_level,
             dict(
                 ip_block_id=address["subnet_id"],
                 ip_address="0.0.0.0",
                 device_ids=[],
                 created_at=address["created_at"],
                 used_by_tenant_id=1,
             ),
         )
开发者ID:blamarvt,项目名称:quark,代码行数:27,代码来源:test_ipam.py

示例3: test_deallocation_notification

 def test_deallocation_notification(self):
     address = dict(
         address=0,
         created_at="123",
         subnet_id=1,
         address_readable="0.0.0.0",
         used_by_tenant_id=1,
         ports=[dict(device_id="foo")],
     )
     port = dict(ip_addresses=[address])
     with self._stubs(dict(), deleted_at="456") as notify:
         self.ipam.deallocate_ip_address(self.context, port)
         notify.assert_called_once_with(
             self.context,
             notifier_api.publisher_id("network"),
             "ip_block.address.delete",
             notifier_api.CONF.default_notification_level,
             dict(
                 ip_block_id=address["subnet_id"],
                 ip_address="0.0.0.0",
                 device_ids=["foo"],
                 created_at=address["created_at"],
                 deleted_at="456",
                 used_by_tenant_id=1,
             ),
         )
开发者ID:blamarvt,项目名称:quark,代码行数:26,代码来源:test_ipam.py

示例4: allocate_ip_address

    def allocate_ip_address(self, context, net_id, port_id, reuse_after,
                            version=None, ip_address=None):
        elevated = context.elevated()
        if ip_address:
            ip_address = netaddr.IPAddress(ip_address)

        new_addresses = []
        realloc_ips = self.attempt_to_reallocate_ip(context, net_id,
                                                    port_id, reuse_after,
                                                    version=None,
                                                    ip_address=None)
        if self.is_strategy_satisfied(realloc_ips):
            return realloc_ips
        new_addresses.extend(realloc_ips)
        with context.session.begin(subtransactions=True):
            subnets = self._choose_available_subnet(
                elevated, net_id, version, ip_address=ip_address,
                reallocated_ips=realloc_ips)
            for subnet in subnets:
                ip_policy_rules = models.IPPolicy.get_ip_policy_rule_set(
                    subnet)
                # Creating this IP for the first time
                next_ip = None
                if ip_address:
                    next_ip = ip_address
                    address = db_api.ip_address_find(
                        elevated, network_id=net_id, ip_address=next_ip,
                        used_by_tenant_id=elevated.tenant_id, scope=db_api.ONE)
                    if address:
                        raise exceptions.IpAddressGenerationFailure(
                            net_id=net_id)
                else:
                    next_ip = self._iterate_until_available_ip(
                        elevated, subnet, net_id, ip_policy_rules)

                context.session.add(subnet)
                address = db_api.ip_address_create(
                    elevated, address=next_ip, subnet_id=subnet["id"],
                    version=subnet["ip_version"], network_id=net_id)
                address["deallocated"] = 0
                new_addresses.append(address)

        for addr in new_addresses:
            payload = dict(used_by_tenant_id=addr["used_by_tenant_id"],
                           ip_block_id=addr["subnet_id"],
                           ip_address=addr["address_readable"],
                           device_ids=[p["device_id"] for p in addr["ports"]],
                           created_at=addr["created_at"])
            notifier_api.notify(context,
                                notifier_api.publisher_id("network"),
                                "ip_block.address.create",
                                notifier_api.CONF.default_notification_level,
                                payload)
        return new_addresses
开发者ID:blamarvt,项目名称:quark,代码行数:54,代码来源:ipam.py

示例5: process_request

    def process_request(self, request):
        request.environ['HTTP_X_SERVICE_NAME'] = \
            self.service_name or request.host
        payload = {
            'request': self.environ_to_dict(request.environ),
        }

        api.notify(context.get_admin_context(),
                   api.publisher_id(os.path.basename(sys.argv[0])),
                   'http.request',
                   api.INFO,
                   payload)
开发者ID:50infivedays,项目名称:neutron,代码行数:12,代码来源:notifier.py

示例6: _notify_new_addresses

 def _notify_new_addresses(self, context, new_addresses):
     for addr in new_addresses:
         payload = dict(used_by_tenant_id=addr["used_by_tenant_id"],
                        ip_block_id=addr["subnet_id"],
                        ip_address=addr["address_readable"],
                        device_ids=[p["device_id"] for p in addr["ports"]],
                        created_at=addr["created_at"])
         notifier_api.notify(context,
                             notifier_api.publisher_id("network"),
                             "ip_block.address.create",
                             notifier_api.CONF.default_notification_level,
                             payload)
开发者ID:blamarvt,项目名称:quark-1,代码行数:12,代码来源:ipam.py

示例7: __init__

    def __init__(self, plugin, collection, resource, attr_info,
                 allow_bulk=False, member_actions=None, parent=None,
                 allow_pagination=False, allow_sorting=False):
        if member_actions is None:
            member_actions = []
        self._plugin = plugin
        self._collection = collection.replace('-', '_')
        self._resource = resource.replace('-', '_')
        self._attr_info = attr_info
        self._allow_bulk = allow_bulk
        self._allow_pagination = allow_pagination
        self._allow_sorting = allow_sorting
        self._native_bulk = self._is_native_bulk_supported()
        self._native_pagination = self._is_native_pagination_supported()
        self._native_sorting = self._is_native_sorting_supported()
        self._policy_attrs = [name for (name, info) in self._attr_info.items()
                              if info.get('required_by_policy')]
        self._publisher_id = notifier_api.publisher_id('network')
        # use plugin's dhcp notifier, if this is already instantiated
        agent_notifiers = getattr(plugin, 'agent_notifiers', {})
        self._dhcp_agent_notifier = (
            agent_notifiers.get(const.AGENT_TYPE_DHCP) or
            dhcp_rpc_agent_api.DhcpAgentNotifyAPI()
        )
        if cfg.CONF.notify_nova_on_port_data_changes:
            from neutron.notifiers import nova
            self._nova_notifier = nova.Notifier()
        self._member_actions = member_actions
        self._primary_key = self._get_primary_key()
        if self._allow_pagination and self._native_pagination:
            # Native pagination need native sorting support
            if not self._native_sorting:
                raise exceptions.Invalid(
                    _("Native pagination depend on native sorting")
                )
            if not self._allow_sorting:
                LOG.info(_("Allow sorting is enabled because native "
                           "pagination requires native sorting"))
                self._allow_sorting = True

        if parent:
            self._parent_id_name = '%s_id' % parent['member_name']
            parent_part = '_%s' % parent['member_name']
        else:
            self._parent_id_name = None
            parent_part = ''
        self._plugin_handlers = {
            self.LIST: 'get%s_%s' % (parent_part, self._collection),
            self.SHOW: 'get%s_%s' % (parent_part, self._resource)
        }
        for action in [self.CREATE, self.UPDATE, self.DELETE]:
            self._plugin_handlers[action] = '%s%s_%s' % (action, parent_part,
                                                         self._resource)
开发者ID:ArifovicH,项目名称:neutron,代码行数:53,代码来源:base.py

示例8: _deallocate_ip_address

 def _deallocate_ip_address(self, context, address):
     address["deallocated"] = 1
     payload = dict(used_by_tenant_id=address["used_by_tenant_id"],
                    ip_block_id=address["subnet_id"],
                    ip_address=address["address_readable"],
                    device_ids=[p["device_id"] for p in address["ports"]],
                    created_at=address["created_at"],
                    deleted_at=timeutils.utcnow())
     notifier_api.notify(context,
                         notifier_api.publisher_id("network"),
                         "ip_block.address.delete",
                         notifier_api.CONF.default_notification_level,
                         payload)
开发者ID:blamarvt,项目名称:quark,代码行数:13,代码来源:ipam.py

示例9: test_create_subnet_notification

 def test_create_subnet_notification(self):
     s = dict(network_id=1, cidr="192.168.10.0/24",
              tenant_id=1, id=1, created_at="123")
     with self._stubs(s) as notify:
         self.plugin.create_subnet(self.context, dict(subnet=s))
         notify.assert_called_once_with(
             self.context,
             notifier_api.publisher_id("network"),
             "ip_block.create",
             notifier_api.CONF.default_notification_level,
             dict(tenant_id=s["tenant_id"],
                  ip_block_id=s["id"],
                  created_at=s["created_at"]))
开发者ID:mohanraj1311,项目名称:quark,代码行数:13,代码来源:test_subnets.py

示例10: remove_router_interface

    def remove_router_interface(self, context, router_id, interface_info):
        if not interface_info:
            msg = _("Either subnet_id or port_id must be specified")
            raise q_exc.BadRequest(resource="router", msg=msg)
        if "port_id" in interface_info:
            port_id = interface_info["port_id"]
            port_db = self._core_plugin._get_port(context, port_id)
            if not (port_db["device_owner"] == DEVICE_OWNER_ROUTER_INTF and port_db["device_id"] == router_id):
                raise l3.RouterInterfaceNotFound(router_id=router_id, port_id=port_id)
            if "subnet_id" in interface_info:
                port_subnet_id = port_db["fixed_ips"][0]["subnet_id"]
                if port_subnet_id != interface_info["subnet_id"]:
                    raise q_exc.SubnetMismatchForPort(port_id=port_id, subnet_id=interface_info["subnet_id"])
            subnet_id = port_db["fixed_ips"][0]["subnet_id"]
            subnet = self._core_plugin._get_subnet(context, subnet_id)
            self._confirm_router_interface_not_in_use(context, router_id, subnet_id)
            self._core_plugin.delete_port(context, port_db["id"], l3_port_check=False)
        elif "subnet_id" in interface_info:
            subnet_id = interface_info["subnet_id"]
            self._confirm_router_interface_not_in_use(context, router_id, subnet_id)

            subnet = self._core_plugin._get_subnet(context, subnet_id)
            found = False

            try:
                rport_qry = context.session.query(models_v2.Port)
                ports = rport_qry.filter_by(
                    device_id=router_id, device_owner=DEVICE_OWNER_ROUTER_INTF, network_id=subnet["network_id"]
                )

                for p in ports:
                    if p["fixed_ips"][0]["subnet_id"] == subnet_id:
                        port_id = p["id"]
                        self._core_plugin.delete_port(context, p["id"], l3_port_check=False)
                        found = True
                        break
            except exc.NoResultFound:
                pass

            if not found:
                raise l3.RouterInterfaceNotFoundForSubnet(router_id=router_id, subnet_id=subnet_id)
        self.l3_rpc_notifier.routers_updated(context, [router_id], "remove_router_interface")
        info = {"id": router_id, "tenant_id": subnet["tenant_id"], "port_id": port_id, "subnet_id": subnet_id}
        notifier_api.notify(
            context,
            notifier_api.publisher_id("network"),
            "router.interface.delete",
            notifier_api.CONF.default_notification_level,
            {"router.interface": info},
        )
        return info
开发者ID:Ahmed-Azri,项目名称:Cloud-Networking-SDN,代码行数:51,代码来源:l3_db.py

示例11: test_delete_subnet_notification

 def test_delete_subnet_notification(self):
     now = time.strftime('%Y-%m-%d %H:%M:%S')
     later = time.strftime('%Y-%m-%d %H:%M:%S')
     s = dict(tenant_id=1, id=1, created_at=now)
     with self._stubs(s, deleted_at=later) as notify:
         self.plugin.delete_subnet(self.context, 1)
         notify.assert_called_once_with(
             self.context,
             notifier_api.publisher_id("network"),
             "ip_block.delete",
             notifier_api.CONF.default_notification_level,
             dict(tenant_id=s["tenant_id"],
                  created_at=s["created_at"],
                  ip_block_id=s["id"],
                  deleted_at=later))
开发者ID:mohanraj1311,项目名称:quark,代码行数:15,代码来源:test_subnets.py

示例12: main

def main():
    cfg.CONF(project='neutron')
    config.setup_logging(cfg.CONF)

    cxt = context.get_admin_context()
    plugin = manager.NeutronManager.get_plugin()
    for network in plugin.get_networks(cxt):
        notifier_api.notify(cxt,
                            notifier_api.publisher_id('network'),
                            'network.exists',
                            notifier_api.INFO,
                            {'network': network})
    for subnet in plugin.get_subnets(cxt):
        notifier_api.notify(cxt,
                            notifier_api.publisher_id('network'),
                            'subnet.exists',
                            notifier_api.INFO,
                            {'subnet': subnet})
    for port in plugin.get_ports(cxt):
        notifier_api.notify(cxt,
                            notifier_api.publisher_id('network'),
                            'port.exists',
                            notifier_api.INFO,
                            {'port': port})
    for router in plugin.get_routers(cxt):
        notifier_api.notify(cxt,
                            notifier_api.publisher_id('network'),
                            'router.exists',
                            notifier_api.INFO,
                            {'router': router})
    for floatingip in plugin.get_floatingips(cxt):
        notifier_api.notify(cxt,
                            notifier_api.publisher_id('network'),
                            'floatingip.exists',
                            notifier_api.INFO,
                            {'floatingip': floatingip})
开发者ID:50infivedays,项目名称:neutron,代码行数:36,代码来源:usage_audit.py

示例13: _metering_notification

    def _metering_notification(self):
        for label_id, info in self.metering_infos.items():
            data = {'label_id': label_id,
                    'tenant_id': self.label_tenant_id.get(label_id),
                    'pkts': info['pkts'],
                    'bytes': info['bytes'],
                    'time': info['time'],
                    'first_update': info['first_update'],
                    'last_update': info['last_update'],
                    'host': self.host}

            LOG.debug("Send metering report: %s" % data)
            notifier_api.notify(self.context,
                                notifier_api.publisher_id('metering'),
                                'l3.meter',
                                notifier_api.CONF.default_notification_level,
                                data)
            info['pkts'] = 0
            info['bytes'] = 0
            info['time'] = 0
开发者ID:uramanan,项目名称:neutron,代码行数:20,代码来源:metering_agent.py

示例14: process_response

    def process_response(self, request, response,
                         exception=None, traceback=None):
        payload = {
            'request': self.environ_to_dict(request.environ),
        }

        if response:
            payload['response'] = {
                'status': response.status,
                'headers': response.headers,
            }

        if exception:
            payload['exception'] = {
                'value': repr(exception),
                'traceback': tb.format_tb(traceback)
            }

        api.notify(context.get_admin_context(),
                   api.publisher_id(os.path.basename(sys.argv[0])),
                   'http.response',
                   api.INFO,
                   payload)
开发者ID:50infivedays,项目名称:neutron,代码行数:23,代码来源:notifier.py

示例15: add_router_interface

    def add_router_interface(self, context, router_id, interface_info):
        add_by_port, add_by_sub = self._validate_interface_info(interface_info)
        device_owner = self._get_device_owner(context, router_id)

        if add_by_port:
            port = self._add_interface_by_port(
                context, router_id, interface_info['port_id'], device_owner)
        elif add_by_sub:
            port = self._add_interface_by_subnet(
                context, router_id, interface_info['subnet_id'], device_owner)

        self.l3_rpc_notifier.routers_updated(
            context, [router_id], 'add_router_interface')
        info = {'id': router_id,
                'tenant_id': port['tenant_id'],
                'port_id': port['id'],
                'subnet_id': port['fixed_ips'][0]['subnet_id']}
        notifier_api.notify(context,
                            notifier_api.publisher_id('network'),
                            'router.interface.create',
                            notifier_api.CONF.default_notification_level,
                            {'router_interface': info})
        return info
开发者ID:KumarAcharya,项目名称:neutron,代码行数:23,代码来源:l3_db.py


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