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


Python db.add_network_segment函数代码示例

本文整理汇总了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;未经允许,请勿转载。