コード例 #1
0
    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)
コード例 #2
0
    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
コード例 #3
0
    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")
        db.validate_network_ownership(tenant_id, net_id)
        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)
コード例 #4
0
    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')
コード例 #5
0
ファイル: SamplePlugin.py プロジェクト: asomya/quantum
 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'])
コード例 #6
0
 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'])
コード例 #7
0
ファイル: ovs_quantum_plugin.py プロジェクト: Oneiroi/quantum
 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
コード例 #8
0
 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')
コード例 #9
0
ファイル: ovs_quantum_plugin.py プロジェクト: Oneiroi/quantum
    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, [])
コード例 #10
0
ファイル: ovs_quantum_plugin.py プロジェクト: emonty/quantum
    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, [], net.op_status)
コード例 #11
0
    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)
コード例 #12
0
    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)
コード例 #13
0
 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')
コード例 #14
0
ファイル: SamplePlugin.py プロジェクト: asomya/quantum
 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
コード例 #15
0
 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')
コード例 #16
0
 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')
コード例 #17
0
 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
コード例 #18
0
 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')
コード例 #19
0
 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')
コード例 #20
0
 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
コード例 #21
0
    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
コード例 #22
0
ファイル: database_stubs.py プロジェクト: soheilhy/quantum
 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 as exc:
         LOG.error("Failed to get all ports: %s", str(exc))
 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))
コード例 #24
0
    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")
        db.validate_network_ownership(tenant_id, 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
コード例 #25
0
ファイル: SamplePlugin.py プロジェクト: OpenStack-Kha/quantum
 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
コード例 #26
0
ファイル: SamplePlugin.py プロジェクト: hongbin/quantum
 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)
コード例 #27
0
ファイル: SamplePlugin.py プロジェクト: asomya/quantum
 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)
コード例 #28
0
    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}
コード例 #29
0
    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
コード例 #30
0
    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
コード例 #31
0
    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")
        db.validate_network_ownership(tenant_id, net_id)
        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
コード例 #32
0
 def get_all_ports(self, tenant_id, net_id, **kwargs):
     ids = []
     db.validate_network_ownership(tenant_id, net_id)
     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]
コード例 #33
0
 def get_all_ports(self, tenant_id, net_id):
     ids = []
     ports = db.port_list(net_id)
     return [{'port-id': str(p.uuid)} for p in ports]
コード例 #34
0
 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]
コード例 #35
0
ファイル: ovs_quantum_plugin.py プロジェクト: emonty/quantum
 def get_all_ports(self, tenant_id, net_id):
     ids = []
     ports = db.port_list(net_id)
     return [{'port-id': str(p.uuid)} for p in ports]
コード例 #36
0
 def get_all_ports(self, tenant_id, net_id, **kwargs):
     ids = []
     db.validate_network_ownership(tenant_id, net_id)
     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]