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

Python api.port_list函数代码示例

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

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



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

示例1: _verify_show_network_details

    def _verify_show_network_details(self):
            # Verification - get raw result from db
            nw = db.network_list(self.tenant_id)[0]
            network = {'id': nw.uuid,
                       'name': nw.name,
                       'op-status': nw.op_status}
            port_list = db.port_list(nw.uuid)
            if not port_list:
                network['ports'] = [{'id': '<none>',
                                     'state': '<none>',
                                     'attachment': {'id': '<none>'}}]
            else:
                network['ports'] = []
                for port in port_list:
                    network['ports'].append({'id': port.uuid,
                                             'state': port.state,
                                             'attachment': {'id':
                                                            port.interface_id
                                                            or '<none>'}})

            # Fill CLI template
            output = cli.prepare_output('show_net_detail',
                                        self.tenant_id,
                                        dict(network=network),
                                        self.version)
            # Verify!
            # Must add newline at the end to match effect of print call
            self.assertEquals(self.fake_stdout.make_string(), output + '\n')
开发者ID:AnyBucket,项目名称:OpenStack-Install-and-Understand-Guide,代码行数:28,代码来源:test_cli.py


示例2: delete_network

    def delete_network(self, tenant_id, net_id):
        """
        Deletes the network with the specified network identifier
        belonging to the specified tenant.

        :returns: a sequence of mappings with the following signature:
                    {'net-id': uuid that uniquely identifies the
                                 particular quantum network
                    }
        :raises: exception.NetworkInUse
        :raises: exception.NetworkNotFound
        """
        LOG.debug("QuantumRestProxy: delete_network() called")
        net = self.get_network(tenant_id, net_id)
        for port in db.port_list(net_id):
            if port['interface_id']:
                raise exc.NetworkInUse(net_id=net_id)

        # Delete from DB
        db.network_destroy(net_id)

        # delete from network ctrl. Remote error on delete is ignored
        try:
            resource = '/tenants/%s/networks/%s' % (tenant_id, net_id)
            ret = self.servers.delete(resource)
            if not self.servers.action_success(ret):
                raise RemoteRestError(ret[2])
        except RemoteRestError as e:
            LOG.error(
                'QuantumRestProxy: Unable to update remote network: %s' %
                e.message)

        # return deleted network
        return net
开发者ID:mobilipia,项目名称:quantum-restproxy,代码行数:34,代码来源:plugins.py


示例3: delete_network

    def delete_network(self, tenant_id, net_id):
        """
        Deletes the network with the specified network identifier
        belonging to the specified tenant.
        """
        LOG.debug("LinuxBridgePlugin.delete_network() called")
        net = db.network_get(net_id)
        if net:
            ports_on_net = db.port_list(net_id)
            if len(ports_on_net) > 0:
                for port in ports_on_net:
                    if port[const.INTERFACEID]:
                        raise exc.NetworkInUse(net_id=net_id)
                for port in ports_on_net:
                    self.delete_port(tenant_id, net_id, port[const.UUID])

            net_dict = cutil.make_net_dict(net[const.UUID],
                                           net[const.NETWORKNAME],
                                           [], net[const.OPSTATUS])
            try:
                self._release_vlan_for_tenant(tenant_id, net_id)
                cdb.remove_vlan_binding(net_id)
            except Exception as excp:
                LOG.warning("Exception: %s" % excp)
                db.network_update(net_id, tenant_id, {const.OPSTATUS:
                                                      OperationalStatus.DOWN})
            db.network_destroy(net_id)
            return net_dict
        # Network not found
        raise exc.NetworkNotFound(net_id=net_id)
开发者ID:CiscoSystems,项目名称:QL3Proto,代码行数:30,代码来源:LinuxBridgePlugin.py


示例4: _validate_attachment

 def _validate_attachment(self, tenant_id, network_id, port_id,
                          remote_interface_id):
     for port in db.port_list(network_id):
         if port['interface_id'] == remote_interface_id:
             raise exc.AlreadyAttached(net_id=network_id,
                                       port_id=port_id,
                                       att_id=port['interface_id'],
                                       att_port_id=port['uuid'])
开发者ID:asomya,项目名称:quantum,代码行数:8,代码来源:SamplePlugin.py


示例5: get_all_ports

 def get_all_ports(self, tenant_id, net_id):
     ids = []
     ports = db.port_list(net_id)
     for p in ports:
         LOG.debug("Appending port: %s" % p.uuid)
         d = self._make_port_dict(str(p.uuid), p.state, p.network_id,
                                                 p.interface_id)
         ids.append(d)
     return ids
开发者ID:Oneiroi,项目名称:quantum,代码行数:9,代码来源:ovs_quantum_plugin.py


示例6: delete_network

    def delete_network(self, tenant_id, net_id):
        net = db.network_get(net_id)

        # Verify that no attachments are plugged into the network
        for port in db.port_list(net_id):
            if port.interface_id:
                raise q_exc.NetworkInUse(net_id=net_id)
        net = db.network_destroy(net_id)
        ovs_db.remove_vlan_binding(net_id)
        self.vmap.release(net_id)
        return self._make_net_dict(str(net.uuid), net.name, [])
开发者ID:Oneiroi,项目名称:quantum,代码行数:11,代码来源:ovs_quantum_plugin.py


示例7: delete_network

    def delete_network(self, tenant_id, net_id):
        db.validate_network_ownership(tenant_id, net_id)
        net = db.network_get(net_id)

        # Verify that no attachments are plugged into the network
        for port in db.port_list(net_id):
            if port.interface_id:
                raise q_exc.NetworkInUse(net_id=net_id)
        net = db.network_destroy(net_id)
        self.driver.delete_network(net)
        return self._make_net_dict(str(net.uuid), net.name, [], net.op_status)
开发者ID:codeoedoc,项目名称:quantum,代码行数:11,代码来源:ovs_quantum_plugin_base.py


示例8: _verify_list_ports

 def _verify_list_ports(self, network_id):
         # Verification - get raw result from db
         port_list = db.port_list(network_id)
         ports = [dict(id=port.uuid, state=port.state)
                  for port in port_list]
         # Fill CLI template
         output = cli.prepare_output('list_ports', self.tenant_id,
                                     dict(network_id=network_id,
                                          ports=ports))
         # Verify!
         # Must add newline at the end to match effect of print call
         self.assertEquals(self.fake_stdout.make_string(), output + '\n')
开发者ID:OpenStack-Kha,项目名称:python-quantumclient,代码行数:12,代码来源:test_cli.py


示例9: _verify_delete_port

 def _verify_delete_port(self, network_id, port_id):
         # Verification - get raw result from db
         port_list = db.port_list(network_id)
         if len(port_list) != 0:
             self.fail("DB should not contain any port")
         # Fill CLI template
         output = cli.prepare_output('delete_port', self.tenant_id,
                                     dict(network_id=network_id,
                                          port_id=port_id))
         # Verify!
         # Must add newline at the end to match effect of print call
         self.assertEquals(self.fake_stdout.make_string(), output + '\n')
开发者ID:OpenStack-Kha,项目名称:python-quantumclient,代码行数:12,代码来源:test_cli.py


示例10: get_all_ports

 def get_all_ports(self, tenant_id, net_id):
     """
     Retrieves all port identifiers belonging to the
     specified Virtual Network.
     """
     LOG.debug("FakePlugin.get_all_ports() called")
     port_ids = []
     ports = db.port_list(net_id)
     for x in ports:
         d = {'port-id': str(x.uuid)}
         port_ids.append(d)
     return port_ids
开发者ID:asomya,项目名称:quantum,代码行数:12,代码来源:SamplePlugin.py


示例11: _verify_create_port

 def _verify_create_port(self, network_id):
         # Verification - get raw result from db
         port_list = db.port_list(network_id)
         if len(port_list) != 1:
             self.fail("No port created")
         port_id = port_list[0].uuid
         # Fill CLI template
         output = cli.prepare_output('create_port', self.tenant_id,
                                     dict(network_id=network_id,
                                          port_id=port_id))
         # Verify!
         # Must add newline at the end to match effect of print call
         self.assertEquals(self.fake_stdout.make_string(), output + '\n')
开发者ID:OpenStack-Kha,项目名称:python-quantumclient,代码行数:13,代码来源:test_cli.py


示例12: get_all_ports

 def get_all_ports(self, tenant_id, network_id):
     """
     Retrieves all port identifiers belonging to the
     specified Virtual Network.
     """
     LOG.debug("get_all_ports() called")
     # verify network_id
     self._get_network(tenant_id, network_id)
     ports = db.port_list(network_id)
     port_ids = []
     for x in ports:
         port_id = {'port-id': x.uuid}
         port_ids.append(port_id)
     return port_ids
开发者ID:yasuhito,项目名称:quantum-nec-of-plugin,代码行数:14,代码来源:nec_plugin.py


示例13: get_all_ports

    def get_all_ports(self, tenant_id, net_id, **kwargs):
        """
        Retrieves all port identifiers belonging to the
        specified Virtual Network.
        """
        LOG.debug("LinuxBridgePlugin.get_all_ports() called")
        network = db.network_get(net_id)
        ports_list = db.port_list(net_id)
        ports_on_net = []
        for port in ports_list:
            new_port = cutil.make_port_dict(port)
            ports_on_net.append(new_port)

        # This plugin does not perform filtering at the moment
        return ports_on_net
开发者ID:CiscoSystems,项目名称:QL3Proto,代码行数:15,代码来源:LinuxBridgePlugin.py


示例14: get_all_ports

 def get_all_ports(self, net_id):
     """Get all ports"""
     ports = []
     try:
         for port in db.port_list(net_id):
             LOG.debug("Getting port: %s", port.uuid)
             port_dict = {}
             port_dict["id"] = str(port.uuid)
             port_dict["net-id"] = str(port.network_id)
             port_dict["attachment"] = port.interface_id
             port_dict["state"] = port.state
             ports.append(port_dict)
         return ports
     except Exception, exc:
         LOG.error("Failed to get all ports: %s", str(exc))
开发者ID:AnyBucket,项目名称:OpenStack-Install-and-Understand-Guide,代码行数:15,代码来源:database_stubs.py


示例15: get_all_ports

 def get_all_ports(self, tenant_id, net_id, **kwargs):
     """
     Retrieves all port identifiers belonging to the
     specified Virtual Network.
     """
     LOG.debug("FakePlugin.get_all_ports() called")
     filter_opts = kwargs.get('filter_opts', None)
     if not filter_opts is None and len(filter_opts) > 0:
         LOG.debug("filtering options were passed to the plugin"
                   "but the Fake plugin does not support them")
     port_ids = []
     ports = db.port_list(net_id)
     for x in ports:
         d = {'port-id': str(x.uuid)}
         port_ids.append(d)
     return port_ids
开发者ID:CiscoSystems,项目名称:QL3Proto,代码行数:16,代码来源:SamplePlugin.py


示例16: delete_network

 def delete_network(self, tenant_id, net_id):
     """
     Deletes the network with the specified network identifier
     belonging to the specified tenant.
     """
     LOG.debug("FakePlugin.delete_network() called")
     net = self._get_network(tenant_id, net_id)
     # Verify that no attachments are plugged into the network
     if net:
         for port in db.port_list(net_id):
             if port['interface_id']:
                 raise exc.NetworkInUse(net_id=net_id)
         db.network_destroy(net_id)
         return net
     # Network not found
     raise exc.NetworkNotFound(net_id=net_id)
开发者ID:asomya,项目名称:quantum,代码行数:16,代码来源:SamplePlugin.py


示例17: delete_network

    def delete_network(self, tenant_id, network_id):
        """
        Deletes the network with the specified network identifier
        belonging to the specified tenant.
        """
        LOG.debug("delete_network() called")
        network = self._get_network(tenant_id, network_id)
        # Verify that the network has no port
        for port in db.port_list(network_id):
            if port:
                raise exc.NetworkInUse(network_id=network_id)

        ofn_tenant_id = self._get_ofn_tenant_id(tenant_id)
        ofn_network_id = self._get_ofn_network_id(network_id)
        self.ofn.ofn_delete_network(ofn_tenant_id, ofn_network_id)
        ndb.del_ofn_network(network_id)
        db.network_destroy(network_id)
        return {'net-id': network.uuid}
开发者ID:yasuhito,项目名称:quantum-nec-of-plugin,代码行数:18,代码来源:nec_plugin.py


示例18: get_all_ports

    def get_all_ports(self, tenant_id, net_id, **kwargs):
        """
        Retrieves all port identifiers belonging to the
        specified Virtual Network.
        :param tenant_id: unique identifier for the tenant for which this
            method is going to retrieve ports
        :param net_id: unique identifiers for the network whose ports are
            about to be retrieved
        :param **kwargs: options to be passed to the plugin. The following
            keywork based-options can be specified:
            filter_opts - options for filtering network list
        :returns: a list of mapping sequences with the following signature:
                     [ {'port-id': uuid representing a particular port
                                    on the specified quantum network
                       },
                       ....
                       {'port-id': uuid representing a particular port
                                     on the specified quantum network
                       }
                    ]
        :raises: exception.NetworkNotFound
        """
        LOG.debug("QuantumRestProxy: get_all_ports() called")
        db.validate_network_ownership(tenant_id, net_id)

        filter_fn = None
        filter_opts = kwargs.get('filter_opts', None)
        if filter_opts is not None and len(filter_opts) > 0:
            filter_fn = self.filter_port
            LOG.debug("QuantumRestProxy: filter_opts ignored: %s" %
                      filter_opts)

        port_ids = []
        ports = db.port_list(net_id)
        for port in ports:
            if filter_fn is not None and \
               filter_fn(filter_opts, port) is None:
                continue
            d = {
                'port-id': str(port.uuid),
            }
            port_ids.append(d)
        return port_ids
开发者ID:mobilipia,项目名称:quantum-restproxy,代码行数:43,代码来源:plugins.py


示例19: get_network_details

    def get_network_details(self, tenant_id, net_id):
        """
        retrieved a list of all the remote vifs that
        are attached to the network
        """
        LOG.debug("LinuxBridgePlugin.get_network_details() called")
        network = db.network_get(net_id)
        ports_list = db.port_list(net_id)
        ports_on_net = []
        for port in ports_list:
            new_port = cutil.make_port_dict(port)
            ports_on_net.append(new_port)

        new_network = cutil.make_net_dict(network[const.UUID],
                                          network[const.NETWORKNAME],
                                          ports_on_net,
                                          network[const.OPSTATUS])

        return new_network
开发者ID:CiscoSystems,项目名称:QL3Proto,代码行数:19,代码来源:LinuxBridgePlugin.py


示例20: get_all_ports

 def get_all_ports(self, tenant_id, net_id, **kwargs):
     ports = db.port_list(net_id)
     # This plugin does not perform filtering at the moment
     return [{'port-id': str(p.uuid)} for p in ports]
开发者ID:ykaneko,项目名称:quantum-backup,代码行数:4,代码来源:ovs_quantum_plugin_base.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python api.port_set_attachment函数代码示例发布时间:2022-05-26
下一篇:
Python api.port_get函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap