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

Python db.is_network_provisioned函数代码示例

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

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



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

示例1: test_create_and_delete_network

    def test_create_and_delete_network(self):
        tenant_id = 'ten-1'
        network_id = 'net1-id'
        segmentation_id = 1001

        network_context = self._get_network_context(tenant_id,
                                                    network_id,
                                                    segmentation_id)
        self.drv.create_network_precommit(network_context)
        net_provisioned = db.is_network_provisioned(tenant_id, network_id)
        self.assertTrue(net_provisioned, 'The network should be created')

        expected_num_nets = 1
        num_nets_provisioned = db.num_nets_provisioned(tenant_id)
        self.assertEqual(expected_num_nets, num_nets_provisioned,
                         'There should be %d nets, not %d' %
                         (expected_num_nets, num_nets_provisioned))

        #Now test the delete network
        self.drv.delete_network_precommit(network_context)
        net_provisioned = db.is_network_provisioned(tenant_id, network_id)
        self.assertFalse(net_provisioned, 'The network should be created')

        expected_num_nets = 0
        num_nets_provisioned = db.num_nets_provisioned(tenant_id)
        self.assertEqual(expected_num_nets, num_nets_provisioned,
                         'There should be %d nets, not %d' %
                         (expected_num_nets, num_nets_provisioned))
开发者ID:CiscoSystems,项目名称:neutron,代码行数:28,代码来源:test_arista_mechanism_driver.py


示例2: update_network_postcommit

    def update_network_postcommit(self, context):
        """At the moment we only support network name change

        If network name is changed, a new network create request is
        sent to the Arista Hardware.
        """
        new_network = context.current
        orig_network = context.original
        if new_network['name'] != orig_network['name']:
            network_id = new_network['id']
            network_name = new_network['name']
            tenant_id = new_network['tenant_id']
            vlan_id = new_network['provider:segmentation_id']
            with self.eos_sync_lock:
                if db.is_network_provisioned(tenant_id, network_id):
                    try:
                        network_dict = {
                            'network_id': network_id,
                            'segmentation_id': vlan_id,
                            'network_name': network_name}
                        self.rpc.create_network(tenant_id, network_dict)
                    except arista_exc.AristaRpcError:
                        LOG.info(EOS_UNREACHABLE_MSG)
                        raise ml2_exc.MechanismDriverError()
                else:
                    msg = _('Network %s is not updated as it is not found in'
                            'Arista DB') % network_id
                    LOG.info(msg)
开发者ID:amoid,项目名称:neutron,代码行数:28,代码来源:mechanism_arista.py


示例3: create_port_precommit

    def create_port_precommit(self, context):
        """Remember the infromation about a VM and its ports

        A VM information, along with the physical host information
        is saved.
        """
        port = context.current
        device_id = port['device_id']
        device_owner = port['device_owner']
        host = context.host

        # device_id and device_owner are set on VM boot
        is_vm_boot = device_id and device_owner
        if host and is_vm_boot:
            port_id = port['id']
            network_id = port['network_id']
            tenant_id = port['tenant_id']
            if not tenant_id:
                tenant_id = context._plugin_context.tenant_id
            with self.eos_sync_lock:
                if not db.is_network_provisioned(tenant_id, network_id):
                    # Ignore this request if network is not provisioned
                    return
                db.remember_tenant(tenant_id)
                db.remember_vm(device_id, host, port_id,
                               network_id, tenant_id)
开发者ID:prathyu1,项目名称:kulcloud-neutron,代码行数:26,代码来源:mechanism_arista.py


示例4: test_network_is_removed

    def test_network_is_removed(self):
        tenant_id = 'test'
        network_id = '123'

        db.remember_network(tenant_id, network_id, '123')
        db.forget_network(tenant_id, network_id)
        net_provisioned = db.is_network_provisioned(tenant_id, network_id)
        self.assertFalse(net_provisioned, 'The network should be deleted')
开发者ID:CiscoSystems,项目名称:neutron,代码行数:8,代码来源:test_arista_mechanism_driver.py


示例5: test_network_is_remembered

    def test_network_is_remembered(self):
        tenant_id = "test"
        network_id = "123"
        segmentation_id = 456

        db.remember_network(tenant_id, network_id, segmentation_id)
        net_provisioned = db.is_network_provisioned(tenant_id, network_id)
        self.assertTrue(net_provisioned, "Network must be provisioned")
开发者ID:armando-migliaccio,项目名称:neutron-1,代码行数:8,代码来源:test_arista_mechanism_driver.py


示例6: test_network_is_remembered

    def test_network_is_remembered(self):
        tenant_id = 'test'
        network_id = '123'
        segmentation_id = 456

        db.remember_network(tenant_id, network_id, segmentation_id)
        net_provisioned = db.is_network_provisioned(tenant_id,
                                                    network_id)
        self.assertTrue(net_provisioned, 'Network must be provisioned')
开发者ID:CiscoSystems,项目名称:neutron,代码行数:9,代码来源:test_arista_mechanism_driver.py


示例7: delete_network_precommit

 def delete_network_precommit(self, context):
     """Delete the network infromation from the DB."""
     network = context.current
     network_id = network['id']
     tenant_id = network['tenant_id']
     with self.eos_sync_lock:
         if db.is_network_provisioned(tenant_id, network_id):
             db.forget_network(tenant_id, network_id)
         # if necessary, delete tenant as well.
         self.delete_tenant(tenant_id)
开发者ID:amoid,项目名称:neutron,代码行数:10,代码来源:mechanism_arista.py


示例8: update_port_postcommit

    def update_port_postcommit(self, context):
        """Update the name of a given port in EOS.

        At the moment we only support port name change
        Any other change to port is not supported at this time.
        """
        port = context.current
        orig_port = context.original
        if port['name'] == orig_port['name']:
            # nothing to do
            return

        device_id = port['device_id']
        device_owner = port['device_owner']
        host = context.host
        is_vm_boot = device_id and device_owner

        if host and is_vm_boot:
            port_id = port['id']
            port_name = port['name']
            network_id = port['network_id']
            tenant_id = port['tenant_id']
            with self.eos_sync_lock:
                hostname = self._host_name(host)
                segmentation_id = db.get_segmentation_id(tenant_id,
                                                         network_id)
                vm_provisioned = db.is_vm_provisioned(device_id,
                                                      host,
                                                      port_id,
                                                      network_id,
                                                      tenant_id)
                net_provisioned = db.is_network_provisioned(tenant_id,
                                                            network_id,
                                                            segmentation_id)
                if vm_provisioned and net_provisioned:
                    try:
                        self.rpc.plug_port_into_network(device_id,
                                                        hostname,
                                                        port_id,
                                                        network_id,
                                                        tenant_id,
                                                        port_name,
                                                        device_owner)
                    except arista_exc.AristaRpcError:
                        LOG.info(EOS_UNREACHABLE_MSG)
                        raise ml2_exc.MechanismDriverError()
                else:
                    msg = _('VM %s is not updated as it is not found in '
                            'Arista DB') % device_id
                    LOG.info(msg)
开发者ID:amoid,项目名称:neutron,代码行数:50,代码来源:mechanism_arista.py


示例9: _delete_port

    def _delete_port(self, port, host, tenant_id):
        """Deletes the port from EOS.

        param port: Port which is to be deleted
        param host: The host on which the port existed
        param tenant_id: The tenant to which the port belongs to. Some times
                         the tenant id in the port dict is not present (as in
                         the case of HA router).
        """
        device_id = port['device_id']
        port_id = port['id']
        network_id = port['network_id']
        device_owner = port['device_owner']

        try:
            if not db.is_network_provisioned(tenant_id, network_id):
                # If we do not have network associated with this, ignore it
                return
            hostname = self._host_name(host)
            if device_owner == n_const.DEVICE_OWNER_DHCP:
                self.rpc.unplug_dhcp_port_from_network(device_id,
                                                       hostname,
                                                       port_id,
                                                       network_id,
                                                       tenant_id)
            else:
                self.rpc.unplug_host_from_network(device_id,
                                                  hostname,
                                                  port_id,
                                                  network_id,
                                                  tenant_id)
            # if necessary, delete tenant as well.
            self.delete_tenant(tenant_id)
        except arista_exc.AristaRpcError:
            LOG.info(EOS_UNREACHABLE_MSG)
            raise ml2_exc.MechanismDriverError()
开发者ID:prathyu1,项目名称:kulcloud-neutron,代码行数:36,代码来源:mechanism_arista.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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