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

Python utils.create_port函数代码示例

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

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



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

示例1: _port_action

 def _port_action(self, plugin, context, port, action):
     """Perform port operations taking care of concurrency issues."""
     try:
         if action == 'create_port':
             return p_utils.create_port(plugin, context, port)
         elif action == 'update_port':
             return plugin.update_port(context, port['id'], port)
         else:
             msg = _('Unrecognized action')
             raise exceptions.Invalid(message=msg)
     except (db_exc.DBError,
             exceptions.NetworkNotFound,
             exceptions.SubnetNotFound,
             exceptions.IpAddressGenerationFailure) as e:
         with excutils.save_and_reraise_exception(reraise=False) as ctxt:
             if isinstance(e, exceptions.IpAddressGenerationFailure):
                 # Check if the subnet still exists and if it does not,
                 # this is the reason why the ip address generation failed.
                 # In any other unlikely event re-raise
                 try:
                     subnet_id = port['port']['fixed_ips'][0]['subnet_id']
                     plugin.get_subnet(context, subnet_id)
                 except exceptions.SubnetNotFound:
                     pass
                 else:
                     ctxt.reraise = True
             net_id = port['port']['network_id']
             LOG.warning(_LW("Action %(action)s for network %(net_id)s "
                             "could not complete successfully: %(reason)s"),
                         {"action": action, "net_id": net_id, 'reason': e})
开发者ID:biruce-openstack,项目名称:neutron,代码行数:30,代码来源:dhcp_rpc.py


示例2: _add_csnat_router_interface_port

    def _add_csnat_router_interface_port(
            self, context, router, network_id, subnet_id, do_pop=True):
        """Add SNAT interface to the specified router and subnet."""
        port_data = {'tenant_id': '',
                     'network_id': network_id,
                     'fixed_ips': [{'subnet_id': subnet_id}],
                     'device_id': router.id,
                     'device_owner': const.DEVICE_OWNER_ROUTER_SNAT,
                     'admin_state_up': True,
                     'name': ''}
        snat_port = p_utils.create_port(self._core_plugin, context,
                                        {'port': port_data})
        if not snat_port:
            msg = _("Unable to create the SNAT Interface Port")
            raise n_exc.BadRequest(resource='router', msg=msg)

        with context.session.begin(subtransactions=True):
            router_port = l3_db.RouterPort(
                port_id=snat_port['id'],
                router_id=router.id,
                port_type=const.DEVICE_OWNER_ROUTER_SNAT
            )
            context.session.add(router_port)

        if do_pop:
            return self._populate_mtu_and_subnets_for_ports(context,
                                                            [snat_port])
        return snat_port
开发者ID:andreitira,项目名称:neutron,代码行数:28,代码来源:l3_dvr_db.py


示例3: create_fip_agent_gw_port_if_not_exists

    def create_fip_agent_gw_port_if_not_exists(
        self, context, network_id, host):
        """Function to return the FIP Agent GW port.

        This function will create a FIP Agent GW port
        if required. If the port already exists, it
        will return the existing port and will not
        create a new one.
        """
        l3_agent_db = self._get_agent_by_type_and_host(
            context, l3_const.AGENT_TYPE_L3, host)
        if l3_agent_db:
            LOG.debug("Agent ID exists: %s", l3_agent_db['id'])
            f_port = self._get_agent_gw_ports_exist_for_network(
                context, network_id, host, l3_agent_db['id'])
            if not f_port:
                LOG.info(_LI('Agent Gateway port does not exist,'
                             ' so create one: %s'), f_port)
                port_data = {'tenant_id': '',
                             'network_id': network_id,
                             'device_id': l3_agent_db['id'],
                             'device_owner': l3_const.DEVICE_OWNER_AGENT_GW,
                             'binding:host_id': host,
                             'admin_state_up': True,
                             'name': ''}
                agent_port = p_utils.create_port(self._core_plugin, context,
                                                 {'port': port_data})
                if agent_port:
                    self._populate_subnets_for_ports(context, [agent_port])
                    return agent_port
                msg = _("Unable to create the Agent Gateway Port")
                raise n_exc.BadRequest(resource='router', msg=msg)
            else:
                self._populate_subnets_for_ports(context, [f_port])
                return f_port
开发者ID:glove747,项目名称:liberty-neutron,代码行数:35,代码来源:l3_dvr_db.py


示例4: add_ha_port

    def add_ha_port(self, context, router_id, network_id, tenant_id):
        # NOTE(kevinbenton): we have to block any ongoing transactions because
        # our exception handling will try to delete the port using the normal
        # core plugin API. If this function is called inside of a transaction
        # the exception will mangle the state, cause the delete call to fail,
        # and end up relying on the DB rollback to remove the port instead of
        # proper delete_port call.
        if context.session.is_active:
            raise RuntimeError(_('add_ha_port cannot be called inside of a '
                                 'transaction.'))
        args = {'tenant_id': '',
                'network_id': network_id,
                'admin_state_up': True,
                'device_id': router_id,
                'device_owner': constants.DEVICE_OWNER_ROUTER_HA_INTF,
                'name': constants.HA_PORT_NAME % tenant_id}
        port = p_utils.create_port(self._core_plugin, context,
                                 {'port': args})

        try:
            return self._create_ha_port_binding(context, port['id'], router_id)
        except Exception:
            with excutils.save_and_reraise_exception():
                self._core_plugin.delete_port(context, port['id'],
                                              l3_port_check=False)
开发者ID:dlundquist,项目名称:neutron,代码行数:25,代码来源:l3_hamode_db.py


示例5: add_ha_port

    def add_ha_port(self, context, router_id, network_id, tenant_id):
        args = {'tenant_id': '',
                'network_id': network_id,
                'admin_state_up': True,
                'device_id': router_id,
                'device_owner': constants.DEVICE_OWNER_ROUTER_HA_INTF,
                'name': constants.HA_PORT_NAME % tenant_id}
        port = p_utils.create_port(self._core_plugin, context,
                                 {'port': args})

        try:
            return self._create_ha_port_binding(context, port['id'], router_id)
        except Exception:
            with excutils.save_and_reraise_exception():
                self._core_plugin.delete_port(context, port['id'],
                                              l3_port_check=False)
开发者ID:glove747,项目名称:liberty-neutron,代码行数:16,代码来源:l3_hamode_db.py


示例6: add_ha_port

    def add_ha_port(self, context, router_id, network_id, tenant_id):
        args = {
            "tenant_id": "",
            "network_id": network_id,
            "admin_state_up": True,
            "device_id": router_id,
            "device_owner": constants.DEVICE_OWNER_ROUTER_HA_INTF,
            "name": constants.HA_PORT_NAME % tenant_id,
        }
        port = p_utils.create_port(self._core_plugin, context, {"port": args})

        try:
            return self._create_ha_port_binding(context, port["id"], router_id)
        except Exception:
            with excutils.save_and_reraise_exception():
                self._core_plugin.delete_port(context, port["id"], l3_port_check=False)
开发者ID:tal-nino,项目名称:neutron,代码行数:16,代码来源:l3_hamode_db.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.in_pending_status函数代码示例发布时间:2022-05-27
下一篇:
Python n1kv_db_v2.get_vlan_allocation函数代码示例发布时间: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