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

Python n1kv_db_v2.add_network_binding函数代码示例

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

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



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

示例1: test_add_vxlan_trunk_binding

    def test_add_vxlan_trunk_binding(self):
        with self.network() as network1:
            with self.network() as network2:
                TEST_NETWORK_ID = network1['network']['id']

                self.assertRaises(c_exc.NetworkBindingNotFound,
                                  n1kv_db_v2.get_network_binding,
                                  self.session,
                                  TEST_NETWORK_ID)
                TEST_NETWORK_ID2 = network2['network']['id']
                self.assertRaises(c_exc.NetworkBindingNotFound,
                                  n1kv_db_v2.get_network_binding,
                                  self.session,
                                  TEST_NETWORK_ID2)
                p_v = _create_test_network_profile_if_not_there(
                    self.session, TEST_NETWORK_PROFILE_VXLAN_TRUNK)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID2,
                    c_const.NETWORK_TYPE_OVERLAY,
                    None, 5100, '224.10.10.10', p_v.id, None)
                p = _create_test_network_profile_if_not_there(
                    self.session,
                    TEST_NETWORK_PROFILE_VXLAN_TRUNK)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID, c_const.NETWORK_TYPE_TRUNK,
                    None, 0, '0.0.0.0', p.id,
                    [(TEST_NETWORK_ID2, 5)])
                binding = n1kv_db_v2.get_network_binding(
                    self.session, TEST_NETWORK_ID)
                self.assertIsNotNone(binding)
                self.assertEqual(binding.network_id, TEST_NETWORK_ID)
                self.assertEqual(binding.network_type,
                                 c_const.NETWORK_TYPE_TRUNK)
                self.assertIsNone(binding.physical_network)
                self.assertEqual(binding.segmentation_id, 0)
                t_binding = (n1kv_db_v2.get_trunk_network_binding(
                             self.session, TEST_NETWORK_ID,
                             (TEST_NETWORK_ID2, '5')))
                self.assertIsNotNone(t_binding)
                self.assertEqual(t_binding.trunk_segment_id, TEST_NETWORK_ID)
                self.assertEqual(t_binding.segment_id, TEST_NETWORK_ID2)
                self.assertEqual(t_binding.dot1qtag, '5')
                t_members = (n1kv_db_v2.get_trunk_members(
                    self.session, TEST_NETWORK_ID))
                self.assertEqual(t_members,
                                 [(TEST_NETWORK_ID2, '5')])
                self.assertTrue(n1kv_db_v2.is_trunk_member(
                    self.session, TEST_NETWORK_ID2))
                n1kv_db_v2.del_trunk_segment_binding(
                    self.session, TEST_NETWORK_ID,
                    [(TEST_NETWORK_ID2, '5')])
                t_members = (n1kv_db_v2.get_multi_segment_members(
                    self.session, TEST_NETWORK_ID))
                self.assertEqual(t_members, [])
开发者ID:COSHPC,项目名称:neutron,代码行数:54,代码来源:test_n1kv_db.py


示例2: test_add_vlan_trunk_binding

    def test_add_vlan_trunk_binding(self):
        with self.network() as network1:
            with self.network() as network2:
                TEST_NETWORK_ID = network1['network']['id']

                self.assertRaises(c_exc.NetworkBindingNotFound,
                                  n1kv_db_v2.get_network_binding,
                                  self.session,
                                  TEST_NETWORK_ID)
                TEST_NETWORK_ID2 = network2['network']['id']
                self.assertRaises(c_exc.NetworkBindingNotFound,
                                  n1kv_db_v2.get_network_binding,
                                  self.session,
                                  TEST_NETWORK_ID2)
                p_v = _create_test_network_profile_if_not_there(self.session)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID2, 'vlan',
                    PHYS_NET, 1234, '0.0.0.0', p_v.id, None)
                p = _create_test_network_profile_if_not_there(
                    self.session,
                    TEST_NETWORK_PROFILE_VLAN_TRUNK)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID, 'trunk',
                    None, 0, '0.0.0.0', p.id, [(TEST_NETWORK_ID2, 0)])
                binding = n1kv_db_v2.get_network_binding(
                    self.session, TEST_NETWORK_ID)
                self.assertIsNotNone(binding)
                self.assertEqual(binding.network_id, TEST_NETWORK_ID)
                self.assertEqual(binding.network_type, 'trunk')
                self.assertEqual(binding.physical_network, PHYS_NET)
                self.assertEqual(binding.segmentation_id, 0)
                t_binding = (n1kv_db_v2.get_trunk_network_binding(
                             self.session, TEST_NETWORK_ID,
                             (TEST_NETWORK_ID2, 0)))
                self.assertIsNotNone(t_binding)
                self.assertEqual(t_binding.trunk_segment_id, TEST_NETWORK_ID)
                self.assertEqual(t_binding.segment_id, TEST_NETWORK_ID2)
                self.assertEqual(t_binding.dot1qtag, '0')
                t_members = (n1kv_db_v2.get_trunk_members(
                    self.session, TEST_NETWORK_ID))
                self.assertEqual(t_members,
                                 [(TEST_NETWORK_ID2, '0')])
                self.assertTrue(n1kv_db_v2.is_trunk_member(
                                self.session, TEST_NETWORK_ID2))
                n1kv_db_v2.del_trunk_segment_binding(
                    self.session, TEST_NETWORK_ID,
                    [(TEST_NETWORK_ID2, '0')])
                t_members = (n1kv_db_v2.get_multi_segment_members(
                    self.session, TEST_NETWORK_ID))
                self.assertEqual(t_members, [])
开发者ID:PFZheng,项目名称:neutron,代码行数:50,代码来源:test_n1kv_db.py


示例3: test_create_vxlan_trunk_network

    def test_create_vxlan_trunk_network(self):
        with self.network() as network:
            TEST_NETWORK_ID = network["network"]["id"]

            self.assertRaises(
                c_exc.NetworkBindingNotFound, n1kv_db_v2.get_network_binding, self.session, TEST_NETWORK_ID
            )

            p = _create_test_network_profile_if_not_there(self.session, TEST_NETWORK_PROFILE_VXLAN_TRUNK)
            n1kv_db_v2.add_network_binding(self.session, TEST_NETWORK_ID, "trunk", None, 0, "0.0.0.0", p.id, None)
            binding = n1kv_db_v2.get_network_binding(self.session, TEST_NETWORK_ID)
            self.assertIsNotNone(binding)
            self.assertEqual(binding.network_id, TEST_NETWORK_ID)
            self.assertEqual(binding.network_type, "trunk")
            self.assertIsNone(binding.physical_network)
            self.assertEqual(binding.segmentation_id, 0)
开发者ID:gjholler,项目名称:neutron,代码行数:16,代码来源:test_n1kv_db.py


示例4: test_add_network_binding

    def test_add_network_binding(self):
        with self.network() as network:
            TEST_NETWORK_ID = network["network"]["id"]

            self.assertRaises(
                c_exc.NetworkBindingNotFound, n1kv_db_v2.get_network_binding, self.session, TEST_NETWORK_ID
            )

            p = _create_test_network_profile_if_not_there(self.session)
            n1kv_db_v2.add_network_binding(self.session, TEST_NETWORK_ID, "vlan", PHYS_NET, 1234, "0.0.0.0", p.id, None)
            binding = n1kv_db_v2.get_network_binding(self.session, TEST_NETWORK_ID)
            self.assertIsNotNone(binding)
            self.assertEqual(binding.network_id, TEST_NETWORK_ID)
            self.assertEqual(binding.network_type, "vlan")
            self.assertEqual(binding.physical_network, PHYS_NET)
            self.assertEqual(binding.segmentation_id, 1234)
开发者ID:gjholler,项目名称:neutron,代码行数:16,代码来源:test_n1kv_db.py


示例5: test_add_multi_segment_binding

    def test_add_multi_segment_binding(self):
        with self.network() as network:
            TEST_NETWORK_ID = network['network']['id']

            self.assertRaises(c_exc.NetworkBindingNotFound,
                              n1kv_db_v2.get_network_binding,
                              self.session,
                              TEST_NETWORK_ID)

            p = _create_test_network_profile_if_not_there(
                self.session,
                TEST_NETWORK_PROFILE_MULTI_SEGMENT)
            n1kv_db_v2.add_network_binding(
                self.session, TEST_NETWORK_ID,
                c_const.NETWORK_TYPE_MULTI_SEGMENT,
                None, 0, '0.0.0.0', p.id,
                [(TEST_NETWORK_ID2, TEST_NETWORK_ID3)])
            binding = n1kv_db_v2.get_network_binding(
                self.session, TEST_NETWORK_ID)
            self.assertIsNotNone(binding)
            self.assertEqual(binding.network_id, TEST_NETWORK_ID)
            self.assertEqual(binding.network_type,
                             c_const.NETWORK_TYPE_MULTI_SEGMENT)
            self.assertIsNone(binding.physical_network)
            self.assertEqual(binding.segmentation_id, 0)
            ms_binding = (n1kv_db_v2.get_multi_segment_network_binding(
                          self.session, TEST_NETWORK_ID,
                          (TEST_NETWORK_ID2, TEST_NETWORK_ID3)))
            self.assertIsNotNone(ms_binding)
            self.assertEqual(ms_binding.multi_segment_id, TEST_NETWORK_ID)
            self.assertEqual(ms_binding.segment1_id, TEST_NETWORK_ID2)
            self.assertEqual(ms_binding.segment2_id, TEST_NETWORK_ID3)
            ms_members = (n1kv_db_v2.get_multi_segment_members(
                          self.session, TEST_NETWORK_ID))
            self.assertEqual(ms_members,
                             [(TEST_NETWORK_ID2, TEST_NETWORK_ID3)])
            self.assertTrue(n1kv_db_v2.is_multi_segment_member(
                            self.session, TEST_NETWORK_ID2))
            self.assertTrue(n1kv_db_v2.is_multi_segment_member(
                            self.session, TEST_NETWORK_ID3))
            n1kv_db_v2.del_multi_segment_binding(
                self.session, TEST_NETWORK_ID,
                [(TEST_NETWORK_ID2, TEST_NETWORK_ID3)])
            ms_members = (n1kv_db_v2.get_multi_segment_members(
                          self.session, TEST_NETWORK_ID))
            self.assertEqual(ms_members, [])
开发者ID:COSHPC,项目名称:neutron,代码行数:46,代码来源:test_n1kv_db.py


示例6: test_add_network_binding

    def test_add_network_binding(self):
        with self.network() as network:
            TEST_NETWORK_ID = network['network']['id']

            self.assertRaises(c_exc.NetworkBindingNotFound,
                              n1kv_db_v2.get_network_binding,
                              self.session,
                              TEST_NETWORK_ID)

            p = _create_test_network_profile_if_not_there(self.session)
            n1kv_db_v2.add_network_binding(
                self.session, TEST_NETWORK_ID, c_const.NETWORK_TYPE_VLAN,
                PHYS_NET, 1234, '0.0.0.0', p.id, None)
            binding = n1kv_db_v2.get_network_binding(
                self.session, TEST_NETWORK_ID)
            self.assertIsNotNone(binding)
            self.assertEqual(binding.network_id, TEST_NETWORK_ID)
            self.assertEqual(binding.network_type, c_const.NETWORK_TYPE_VLAN)
            self.assertEqual(binding.physical_network, PHYS_NET)
            self.assertEqual(binding.segmentation_id, 1234)
开发者ID:COSHPC,项目名称:neutron,代码行数:20,代码来源:test_n1kv_db.py


示例7: test_create_multi_segment_network

    def test_create_multi_segment_network(self):
        with self.network() as network:
            TEST_NETWORK_ID = network['network']['id']

            self.assertRaises(c_exc.NetworkBindingNotFound,
                              n1kv_db_v2.get_network_binding,
                              self.session,
                              TEST_NETWORK_ID)

            p = _create_test_network_profile_if_not_there(
                self.session,
                TEST_NETWORK_PROFILE_MULTI_SEGMENT)
            n1kv_db_v2.add_network_binding(
                self.session, TEST_NETWORK_ID, 'multi-segment',
                None, 0, '0.0.0.0', p.id, None)
            binding = n1kv_db_v2.get_network_binding(
                self.session, TEST_NETWORK_ID)
            self.assertIsNotNone(binding)
            self.assertEqual(binding.network_id, TEST_NETWORK_ID)
            self.assertEqual(binding.network_type, 'multi-segment')
            self.assertIsNone(binding.physical_network)
            self.assertEqual(binding.segmentation_id, 0)
开发者ID:PFZheng,项目名称:neutron,代码行数:22,代码来源:test_n1kv_db.py


示例8: test_add_vxlan_trunk_binding

    def test_add_vxlan_trunk_binding(self):
        with self.network() as network1:
            with self.network() as network2:
                TEST_NETWORK_ID = network1["network"]["id"]

                self.assertRaises(
                    c_exc.NetworkBindingNotFound, n1kv_db_v2.get_network_binding, self.session, TEST_NETWORK_ID
                )
                TEST_NETWORK_ID2 = network2["network"]["id"]
                self.assertRaises(
                    c_exc.NetworkBindingNotFound, n1kv_db_v2.get_network_binding, self.session, TEST_NETWORK_ID2
                )
                p_v = _create_test_network_profile_if_not_there(self.session, TEST_NETWORK_PROFILE_VXLAN_TRUNK)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID2, "overlay", None, 5100, "224.10.10.10", p_v.id, None
                )
                p = _create_test_network_profile_if_not_there(self.session, TEST_NETWORK_PROFILE_VXLAN_TRUNK)
                n1kv_db_v2.add_network_binding(
                    self.session, TEST_NETWORK_ID, "trunk", None, 0, "0.0.0.0", p.id, [(TEST_NETWORK_ID2, 5)]
                )
                binding = n1kv_db_v2.get_network_binding(self.session, TEST_NETWORK_ID)
                self.assertIsNotNone(binding)
                self.assertEqual(binding.network_id, TEST_NETWORK_ID)
                self.assertEqual(binding.network_type, "trunk")
                self.assertIsNone(binding.physical_network)
                self.assertEqual(binding.segmentation_id, 0)
                t_binding = n1kv_db_v2.get_trunk_network_binding(self.session, TEST_NETWORK_ID, (TEST_NETWORK_ID2, "5"))
                self.assertIsNotNone(t_binding)
                self.assertEqual(t_binding.trunk_segment_id, TEST_NETWORK_ID)
                self.assertEqual(t_binding.segment_id, TEST_NETWORK_ID2)
                self.assertEqual(t_binding.dot1qtag, "5")
                t_members = n1kv_db_v2.get_trunk_members(self.session, TEST_NETWORK_ID)
                self.assertEqual(t_members, [(TEST_NETWORK_ID2, "5")])
                self.assertTrue(n1kv_db_v2.is_trunk_member(self.session, TEST_NETWORK_ID2))
                n1kv_db_v2.del_trunk_segment_binding(self.session, TEST_NETWORK_ID, [(TEST_NETWORK_ID2, "5")])
                t_members = n1kv_db_v2.get_multi_segment_members(self.session, TEST_NETWORK_ID)
                self.assertEqual(t_members, [])
开发者ID:gjholler,项目名称:neutron,代码行数:37,代码来源:test_n1kv_db.py


示例9: create_network

    def create_network(self, context, network):
        """
        Create network based on network profile.

        :param context: neutron api request context
        :param network: network dictionary
        :returns: network object
        """
        (network_type, physical_network,
         segmentation_id) = self._process_provider_create(context,
                                                          network['network'])
        self._add_dummy_profile_only_if_testing(network)
        profile_id = self._process_network_profile(context, network['network'])
        LOG.debug(_('create network: profile_id=%s'), profile_id)
        session = context.session
        with session.begin(subtransactions=True):
            if not network_type:
                # tenant network
                (physical_network, network_type, segmentation_id,
                    multicast_ip) = n1kv_db_v2.alloc_network(session,
                                                             profile_id)
                LOG.debug(_('Physical_network %(phy_net)s, '
                            'seg_type %(net_type)s, '
                            'seg_id %(seg_id)s, '
                            'multicast_ip %(multicast_ip)s'),
                          {'phy_net': physical_network,
                           'net_type': network_type,
                           'seg_id': segmentation_id,
                           'multicast_ip': multicast_ip})
                if not segmentation_id:
                    raise q_exc.TenantNetworksDisabled()
            else:
                # provider network
                if network_type == c_const.NETWORK_TYPE_VLAN:
                    network_profile = self.get_network_profile(context,
                                                               profile_id)
                    seg_min, seg_max = self._get_segment_range(
                        network_profile['segment_range'])
                    if not seg_min <= segmentation_id <= seg_max:
                        raise cisco_exceptions.VlanIDOutsidePool
                    n1kv_db_v2.reserve_specific_vlan(session,
                                                     physical_network,
                                                     segmentation_id)
                    multicast_ip = "0.0.0.0"
            net = super(N1kvNeutronPluginV2, self).create_network(context,
                                                                  network)
            n1kv_db_v2.add_network_binding(session,
                                           net['id'],
                                           network_type,
                                           physical_network,
                                           segmentation_id,
                                           multicast_ip,
                                           profile_id)
            self._process_l3_create(context, net, network['network'])
            self._extend_network_dict_provider(context, net)
            self._extend_network_dict_profile(context, net)

        try:
            self._send_create_network_request(context, net)
        except(cisco_exceptions.VSMError,
               cisco_exceptions.VSMConnectionFailed):
            super(N1kvNeutronPluginV2, self).delete_network(context, net['id'])
        else:
            # note - exception will rollback entire transaction
            LOG.debug(_("Created network: %s"), net['id'])
            return net
开发者ID:abhirajbutala,项目名称:neutron,代码行数:66,代码来源:n1kv_neutron_plugin.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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