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

Python db.add_network_segment函数代码示例

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

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



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

示例1: _bind_segment_to_vif_type

    def _bind_segment_to_vif_type(self, context, agent=None):
        mappings = {}
        if agent:
            mappings = agent['configurations'].get('bridge_mappings', {})

        for res in self.resource_groups:
            if agent and res['ResourceGroupName'] not in mappings:
                continue
            if res['device_owner'] != context._port['device_owner']:
                continue

            network_id = context.network.current['id']
            dummy_segment = db.get_dynamic_segment(
                context.network._plugin_context.session,
                network_id, physical_network=res['ResourceGroupName'])
            LOG.debug("1st: dummy segment is %s", dummy_segment)
            if not dummy_segment:
                dummy_segment = {
                    api.PHYSICAL_NETWORK: res['ResourceGroupName'],
                    api.NETWORK_TYPE: plugin_const.TYPE_VLAN,
                    api.SEGMENTATION_ID: 0
                }
                db.add_network_segment(
                    context.network._plugin_context.session,
                    network_id, dummy_segment, is_dynamic=True)
            LOG.debug("2nd: dummy segment is %s", dummy_segment)
            context.set_binding(dummy_segment[api.ID],
                                self.vif_type,
                                {portbindings.CAP_PORT_FILTER: True,
                                 portbindings.OVS_HYBRID_PLUG: True})
            return True
        return False
开发者ID:sajeevm,项目名称:networking-nec,代码行数:32,代码来源:mech_necnwa.py


示例2: create_network

    def create_network(self, context, network):
        net_data = network['network']
        segments = self._process_provider_create(net_data)
        tenant_id = self._get_tenant_id_for_create(context, net_data)

        session = context.session
        with session.begin(subtransactions=True):
            self._ensure_default_security_group(context, tenant_id)
            result = super(Ml2Plugin, self).create_network(context, network)
            network_id = result['id']
            self._process_l3_create(context, result, net_data)
            # REVISIT(rkukura): Consider moving all segment management
            # to TypeManager.
            if segments:
                for segment in segments:
                    self.type_manager.reserve_provider_segment(session,
                                                               segment)
                    db.add_network_segment(session, network_id, segment)
            else:
                segment = self.type_manager.allocate_tenant_segment(session)
                db.add_network_segment(session, network_id, segment)
            self._extend_network_dict_provider(context, result)
            mech_context = driver_context.NetworkContext(self, context,
                                                         result)
            self.mechanism_manager.create_network_precommit(mech_context)

        try:
            self.mechanism_manager.create_network_postcommit(mech_context)
        except ml2_exc.MechanismDriverError:
            with excutils.save_and_reraise_exception():
                LOG.error(_("mechanism_manager.create_network_postcommit "
                            "failed, deleting network '%s'"), result['id'])
                self.delete_network(context, result['id'])
        return result
开发者ID:Doude,项目名称:neutron,代码行数:34,代码来源:plugin.py


示例3: _create_segments

    def _create_segments(self, segments, is_seg_dynamic=False, network_id="foo-network-id"):
        self._setup_neutron_network(network_id)
        for segment in segments:
            ml2_db.add_network_segment(self.ctx.session, network_id, segment, is_dynamic=is_seg_dynamic)

        net_segments = ml2_db.get_network_segments(self.ctx.session, network_id, filter_dynamic=is_seg_dynamic)

        for segment_index, segment in enumerate(segments):
            self.assertEqual(segment, net_segments[segment_index])

        return net_segments
开发者ID:qianqunyi,项目名称:neutron,代码行数:11,代码来源:test_db.py


示例4: allocate_dynamic_segment

    def allocate_dynamic_segment(self, session, network_id, segment):
        """Allocate a dynamic segment using a partial or full segment dict."""
        dynamic_segment = db.get_dynamic_segment(
            session, network_id, segment.get(api.PHYSICAL_NETWORK), segment.get(api.SEGMENTATION_ID)
        )

        if dynamic_segment:
            return dynamic_segment

        driver = self.drivers.get(segment.get(api.NETWORK_TYPE))
        dynamic_segment = driver.obj.reserve_provider_segment(session, segment)
        db.add_network_segment(session, network_id, dynamic_segment, is_dynamic=True)
        return dynamic_segment
开发者ID:bigswitch,项目名称:neutron,代码行数:13,代码来源:managers.py


示例5: create_network_segments

 def create_network_segments(self, context, network, tenant_id):
     """Call type drivers to create network segments."""
     segments = self._process_provider_create(network)#验证参数以及创建网络segments
     session = context.session
     with session.begin(subtransactions=True):
         network_id = network['id']
         if segments:
             for segment in segments:
                 segment = self.reserve_provider_segment(
                     session, segment)
                 db.add_network_segment(session, network_id, segment)
         else:
             segment = self.allocate_tenant_segment(session)
             db.add_network_segment(session, network_id, segment)
开发者ID:xiongmeng1108,项目名称:gcloud7_neutron-2014.2.2,代码行数:14,代码来源:managers.py


示例6: create_network_segments

 def create_network_segments(self, context, network, tenant_id):
     """Call type drivers to create network segments."""
     segments = self._process_provider_create(network)
     session = context.session
     mtu = []
     with session.begin(subtransactions=True):
         network_id = network['id']
         if segments:
             for segment_index, segment in enumerate(segments):
                 segment = self.reserve_provider_segment(
                     session, segment)
                 db.add_network_segment(session, network_id,
                                        segment, segment_index)
                 if segment.get(api.MTU) > 0:
                     mtu.append(segment[api.MTU])
         else:
             segment = self.allocate_tenant_segment(session)
             db.add_network_segment(session, network_id, segment)
             if segment.get(api.MTU) > 0:
                 mtu.append(segment[api.MTU])
     network[api.MTU] = min(mtu) if mtu else 0
开发者ID:Stavitsky,项目名称:neutron,代码行数:21,代码来源:managers.py


示例7: create_network

    def create_network(self, context, network):
        attrs = network['network']
        segment = self._process_provider_create(context, attrs)
        tenant_id = self._get_tenant_id_for_create(context, attrs)

        session = context.session
        with session.begin(subtransactions=True):
            self._ensure_default_security_group(context, tenant_id)
            if segment:
                self.type_manager.reserve_provider_segment(session, segment)
            else:
                segment = self.type_manager.allocate_tenant_segment(session)
            result = super(Ml2Plugin, self).create_network(context, network)
            id = result['id']
            self._process_l3_create(context, result, attrs)
            # REVISIT(rkukura): Consider moving all segment management
            # to TypeManager.
            db.add_network_segment(session, id, segment)
            self._extend_network_dict_provider(context, result)

        return result
开发者ID:CiscoSystems,项目名称:quantum,代码行数:21,代码来源:plugin.py


示例8: _bind_segment_to_vif_type

 def _bind_segment_to_vif_type(self, context, physical_network):
     if self.multi_dc:
         return
     network_id = context.network.current['id']
     session = context.network._plugin_context.session
     dummy_segment = db.get_dynamic_segment(
         session, network_id, physical_network=physical_network)
     LOG.debug("1st: dummy segment is %s", dummy_segment)
     if not dummy_segment:
         dummy_segment = {
             api.PHYSICAL_NETWORK: physical_network,
             api.NETWORK_TYPE: plugin_const.TYPE_VLAN,
             api.SEGMENTATION_ID: 0
         }
         db.add_network_segment(
             session, network_id, dummy_segment, is_dynamic=True)
     LOG.debug("2nd: dummy segment is %s", dummy_segment)
     context.set_binding(dummy_segment[api.ID],
                         self.vif_type,
                         {portbindings.CAP_PORT_FILTER: True,
                          portbindings.OVS_HYBRID_PLUG: True})
开发者ID:nec-openstack,项目名称:networking-nec-nwa,代码行数:21,代码来源:mech_necnwa.py


示例9: _add_network_segment

 def _add_network_segment(self, session, network_id, segment, mtu,
                          segment_index=0):
     db.add_network_segment(session, network_id, segment, segment_index)
     if segment.get(api.MTU, 0) > 0:
         mtu.append(segment[api.MTU])
开发者ID:TonyChengTW,项目名称:OpenStack_Liberty_Control,代码行数:5,代码来源:managers.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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