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

Python n1kv_db_v2.create_network_profile函数代码示例

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

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



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

示例1: _make_test_profile

    def _make_test_profile(self,
                           name='default_network_profile',
                           segment_type=c_const.NETWORK_TYPE_VLAN,
                           segment_range='386-400'):
        """
        Create a profile record for testing purposes.

        :param name: string representing the name of the network profile to
                     create. Default argument value chosen to correspond to the
                     default name specified in config.py file.
        :param segment_type: string representing the type of network segment.
        :param segment_range: string representing the segment range for network
                              profile.
        """
        db_session = db.get_session()
        profile = {'name': name,
                   'segment_type': segment_type,
                   'tenant_id': self.tenant_id,
                   'segment_range': segment_range}
        if segment_type == c_const.NETWORK_TYPE_OVERLAY:
            profile['sub_type'] = 'unicast'
            profile['multicast_ip_range'] = '0.0.0.0'
            net_p = n1kv_db_v2.create_network_profile(db_session, profile)
            n1kv_db_v2.sync_vxlan_allocations(db_session, net_p)
        elif segment_type == c_const.NETWORK_TYPE_VLAN:
            profile['physical_network'] = PHYS_NET
            net_p = n1kv_db_v2.create_network_profile(db_session, profile)
            n1kv_db_v2.sync_vlan_allocations(db_session, net_p)
        return net_p
开发者ID:AsherBond,项目名称:quantum,代码行数:29,代码来源:test_n1kv_plugin.py


示例2: test_get_network_profiles

 def test_get_network_profiles(self):
     test_profiles = [{'name': 'test_profile1',
                       'segment_type': 'vlan',
                       'physical_network': 'phys1',
                       'segment_range': '200-210'},
                      {'name': 'test_profile2',
                       'segment_type': 'vlan',
                       'physical_network': 'phys1',
                       'segment_range': '211-220'},
                      {'name': 'test_profile3',
                       'segment_type': 'vlan',
                       'physical_network': 'phys1',
                       'segment_range': '221-230'},
                      {'name': 'test_profile4',
                       'segment_type': 'vlan',
                       'physical_network': 'phys1',
                       'segment_range': '231-240'},
                      {'name': 'test_profile5',
                       'segment_type': 'vlan',
                       'physical_network': 'phys1',
                       'segment_range': '241-250'},
                      {'name': 'test_profile6',
                       'segment_type': 'vlan',
                       'physical_network': 'phys1',
                       'segment_range': '251-260'},
                      {'name': 'test_profile7',
                       'segment_type': 'vlan',
                       'physical_network': 'phys1',
                       'segment_range': '261-270'}]
     [n1kv_db_v2.create_network_profile(self.session, p)
      for p in test_profiles]
     # TODO(abhraut): Fix this test to work with real tenant_td
     profiles = n1kv_db_v2._get_network_profiles(db_session=self.session)
     self.assertEqual(len(test_profiles), len(list(profiles)))
开发者ID:PFZheng,项目名称:neutron,代码行数:34,代码来源:test_n1kv_db.py


示例3: test_get_network_profile

 def test_get_network_profile(self):
     profile = n1kv_db_v2.create_network_profile(self.session,
                                                 TEST_NETWORK_PROFILE)
     got_profile = n1kv_db_v2.get_network_profile(self.session, profile.id)
     self.assertEqual(profile.id, got_profile.id)
     self.assertEqual(profile.name, got_profile.name)
     n1kv_db_v2.delete_network_profile(self.session, profile.id)
开发者ID:PFZheng,项目名称:neutron,代码行数:7,代码来源:test_n1kv_db.py


示例4: test_create_network_profile_overlap

    def test_create_network_profile_overlap(self):
        _db_profile = n1kv_db_v2.create_network_profile(self.session,
                                                        TEST_NETWORK_PROFILE_2)
        ctx = context.get_admin_context()
        TEST_NETWORK_PROFILE_2['name'] = 'net-profile-min-overlap'
        TEST_NETWORK_PROFILE_2['segment_range'] = SEGMENT_RANGE_MIN_OVERLAP
        test_net_profile = {'network_profile': TEST_NETWORK_PROFILE_2}
        self.assertRaises(n_exc.InvalidInput,
                          self.create_network_profile,
                          ctx,
                          test_net_profile)

        TEST_NETWORK_PROFILE_2['name'] = 'net-profile-max-overlap'
        TEST_NETWORK_PROFILE_2['segment_range'] = SEGMENT_RANGE_MAX_OVERLAP
        test_net_profile = {'network_profile': TEST_NETWORK_PROFILE_2}
        self.assertRaises(n_exc.InvalidInput,
                          self.create_network_profile,
                          ctx,
                          test_net_profile)

        TEST_NETWORK_PROFILE_2['name'] = 'net-profile-overlap'
        TEST_NETWORK_PROFILE_2['segment_range'] = SEGMENT_RANGE_OVERLAP
        test_net_profile = {'network_profile': TEST_NETWORK_PROFILE_2}
        self.assertRaises(n_exc.InvalidInput,
                          self.create_network_profile,
                          ctx,
                          test_net_profile)
        n1kv_db_v2.delete_network_profile(self.session, _db_profile.id)
开发者ID:PFZheng,项目名称:neutron,代码行数:28,代码来源:test_n1kv_db.py


示例5: _fake_add_dummy_profile_for_test

def _fake_add_dummy_profile_for_test(self, obj):
    """
    Replacement for a function in the N1KV neutron plugin module.

    Since VSM is not available at the time of tests, we have no
    policy profiles. Hence we inject a dummy policy/network profile into the
    port/network object.
    """
    dummy_profile_name = "dummy_profile"
    dummy_tenant_id = "test-tenant"
    db_session = db.get_session()
    if 'port' in obj:
        dummy_profile_id = "00000000-1111-1111-1111-000000000000"
        self._add_policy_profile(dummy_profile_name,
                                 dummy_profile_id,
                                 dummy_tenant_id)
        obj['port'][n1kv_profile.PROFILE_ID] = dummy_profile_id
    elif 'network' in obj:
        profile = {'name': 'dummy_profile',
                   'segment_type': 'vlan',
                   'physical_network': 'phsy1',
                   'segment_range': '3968-4047'}
        self.network_vlan_ranges = {profile[
            'physical_network']: [(3968, 4047)]}
        n1kv_db_v2.sync_vlan_allocations(db_session, self.network_vlan_ranges)
        np = n1kv_db_v2.create_network_profile(db_session, profile)
        obj['network'][n1kv_profile.PROFILE_ID] = np.id
开发者ID:CampHarmony,项目名称:neutron,代码行数:27,代码来源:test_n1kv_plugin.py


示例6: test_vxlan_pool

    def test_vxlan_pool(self):
        vxlan_ids = set()
        profile = n1kv_db_v2.create_network_profile(self.session,
                                                    TEST_NETWORK_PROFILE_VXLAN)
        for x in xrange(VXLAN_MIN, VXLAN_MAX + 1):
            vxlan = n1kv_db_v2.reserve_vxlan(self.session, profile)
            vxlan_id = vxlan[2]
            self.assertThat(vxlan_id, matchers.GreaterThan(VXLAN_MIN - 1))
            self.assertThat(vxlan_id, matchers.LessThan(VXLAN_MAX + 1))
            vxlan_ids.add(vxlan_id)

        self.assertRaises(q_exc.NoNetworkAvailable,
                          n1kv_db_v2.reserve_vxlan,
                          self.session,
                          profile)
        n1kv_db_v2.release_vxlan(self.session, vxlan_ids.pop(), VXLAN_RANGES)
        vxlan = n1kv_db_v2.reserve_vxlan(self.session, profile)
        vxlan_id = vxlan[2]
        self.assertThat(vxlan_id, matchers.GreaterThan(VXLAN_MIN - 1))
        self.assertThat(vxlan_id, matchers.LessThan(VXLAN_MAX + 1))
        vxlan_ids.add(vxlan_id)

        for vxlan_id in vxlan_ids:
            n1kv_db_v2.release_vxlan(self.session, vxlan_id, VXLAN_RANGES)
        n1kv_db_v2.delete_network_profile(self.session, profile.id)
开发者ID:ChengZuo,项目名称:neutron,代码行数:25,代码来源:test_n1kv_db.py


示例7: _create_test_network_profile_if_not_there

def _create_test_network_profile_if_not_there(session,
                                              profile=TEST_NETWORK_PROFILE):
    try:
        _profile = session.query(n1kv_models_v2.NetworkProfile).filter_by(
            name=profile['name']).one()
    except s_exc.NoResultFound:
        _profile = n1kv_db_v2.create_network_profile(session, profile)
    return _profile
开发者ID:PFZheng,项目名称:neutron,代码行数:8,代码来源:test_n1kv_db.py


示例8: test_get_network_profiles

 def test_get_network_profiles(self):
     test_profiles = [
         {"name": "test_profile1", "segment_type": "vlan", "physical_network": "phys1", "segment_range": "200-210"},
         {"name": "test_profile2", "segment_type": "vlan", "physical_network": "phys1", "segment_range": "211-220"},
         {"name": "test_profile3", "segment_type": "vlan", "physical_network": "phys1", "segment_range": "221-230"},
         {"name": "test_profile4", "segment_type": "vlan", "physical_network": "phys1", "segment_range": "231-240"},
         {"name": "test_profile5", "segment_type": "vlan", "physical_network": "phys1", "segment_range": "241-250"},
         {"name": "test_profile6", "segment_type": "vlan", "physical_network": "phys1", "segment_range": "251-260"},
         {"name": "test_profile7", "segment_type": "vlan", "physical_network": "phys1", "segment_range": "261-270"},
     ]
     [n1kv_db_v2.create_network_profile(self.session, p) for p in test_profiles]
     # TODO(abhraut): Fix this test to work with real tenant_td
     profiles = n1kv_db_v2._get_network_profiles(db_session=self.session)
     self.assertEqual(len(test_profiles), len(list(profiles)))
开发者ID:gjholler,项目名称:neutron,代码行数:14,代码来源:test_n1kv_db.py


示例9: test_create_network_profile

 def test_create_network_profile(self):
     _db_profile = n1kv_db_v2.create_network_profile(self.session, TEST_NETWORK_PROFILE)
     self.assertIsNotNone(_db_profile)
     db_profile = (
         self.session.query(n1kv_models_v2.NetworkProfile).filter_by(name=TEST_NETWORK_PROFILE["name"]).one()
     )
     self.assertIsNotNone(db_profile)
     self.assertEqual(_db_profile.id, db_profile.id)
     self.assertEqual(_db_profile.name, db_profile.name)
     self.assertEqual(_db_profile.segment_type, db_profile.segment_type)
     self.assertEqual(_db_profile.segment_range, db_profile.segment_range)
     self.assertEqual(_db_profile.multicast_ip_index, db_profile.multicast_ip_index)
     self.assertEqual(_db_profile.multicast_ip_range, db_profile.multicast_ip_range)
     n1kv_db_v2.delete_network_profile(self.session, _db_profile.id)
开发者ID:gjholler,项目名称:neutron,代码行数:14,代码来源:test_n1kv_db.py


示例10: test_delete_network_profile

    def test_delete_network_profile(self):
        try:
            profile = (
                self.session.query(n1kv_models_v2.NetworkProfile).filter_by(name=TEST_NETWORK_PROFILE["name"]).one()
            )
        except s_exc.NoResultFound:
            profile = n1kv_db_v2.create_network_profile(self.session, TEST_NETWORK_PROFILE)

        n1kv_db_v2.delete_network_profile(self.session, profile.id)
        try:
            self.session.query(n1kv_models_v2.NetworkProfile).filter_by(name=TEST_NETWORK_PROFILE["name"]).one()
        except s_exc.NoResultFound:
            pass
        else:
            self.fail("Network Profile (%s) was not deleted" % TEST_NETWORK_PROFILE["name"])
开发者ID:gjholler,项目名称:neutron,代码行数:15,代码来源:test_n1kv_db.py


示例11: _make_test_profile

    def _make_test_profile(self,
                           name='default_network_profile',
                           segment_range='386-400'):
        """
        Create a profile record for testing purposes.

        :param name: string representing the name of the network profile to
                     create. Default argument value chosen to correspond to the
                     default name specified in config.py file.
        :param segment_range: string representing the segment range for network
                              profile.
        """
        db_session = db.get_session()
        profile = {'name': name,
                   'segment_type': 'vlan',
                   'physical_network': PHYS_NET,
                   'tenant_id': self.tenant_id,
                   'segment_range': segment_range}
        net_p = n1kv_db_v2.create_network_profile(db_session, profile)
        n1kv_db_v2.sync_vlan_allocations(db_session, net_p)
        return net_p
开发者ID:aignatov,项目名称:neutron,代码行数:21,代码来源:test_n1kv_plugin.py


示例12: _make_test_profile

    def _make_test_profile(self, name="default_network_profile", segment_range="386-400"):
        """
        Create a profile record for testing purposes.

        :param name: string representing the name of the network profile to
                     create. Default argument value chosen to correspond to the
                     default name specified in config.py file.
        :param segment_range: string representing the segment range for network
                              profile.
        """
        db_session = db.get_session()
        profile = {
            "name": name,
            "segment_type": "vlan",
            "physical_network": PHYS_NET,
            "tenant_id": self.tenant_id,
            "segment_range": segment_range,
        }
        net_p = n1kv_db_v2.create_network_profile(db_session, profile)
        n1kv_db_v2.sync_vlan_allocations(db_session, net_p)
        return net_p
开发者ID:dreamhost,项目名称:quantum,代码行数:21,代码来源:test_n1kv_plugin.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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