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


Python api.port_list函数代码示例

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


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


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