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
def test_ryu_driver(self): from ryu.app import client as client_mod from ryu.app import rest_nw_id as rest_nw_id_mod self.mox.StubOutClassWithMocks(client_mod, 'OFPClient') client_mock = client_mod.OFPClient(utils.FAKE_REST_ADDR) self.mox.StubOutWithMock(client_mock, 'update_network') self.mox.StubOutWithMock(client_mock, 'create_network') self.mox.StubOutWithMock(client_mock, 'delete_network') client_mock.update_network(rest_nw_id_mod.NW_ID_EXTERNAL) uuid0 = '01234567-89ab-cdef-0123-456789abcdef' def fake_uuid4(): return uuid0 self.stubs.Set(uuid, 'uuid4', fake_uuid4) uuid1 = '12345678-9abc-def0-1234-56789abcdef0' net1 = utils.Net(uuid1) client_mock.update_network(uuid0) client_mock.create_network(uuid1) client_mock.delete_network(uuid1) self.mox.ReplayAll() db.network_create('test', uuid0) from quantum.plugins.ryu import ryu_quantum_plugin ryu_driver = ryu_quantum_plugin.OFPRyuDriver(self.config) ryu_driver.create_network(net1) ryu_driver.delete_network(net1) self.mox.VerifyAll() db.network_destroy(uuid0)
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)
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)
def create_network(self, tenant_id, net_name, **kwargs): net = db.network_create(tenant_id, net_name, op_status=OperationalStatus.UP) try: vlan_id = self.vmap.acquire(str(net.uuid)) except NoFreeVLANException: db.network_destroy(net.uuid) raise LOG.debug("Created network: %s" % net) ovs_db.add_vlan_binding(vlan_id, str(net.uuid)) return self._make_net_dict(str(net.uuid), net.name, [], net.op_status)
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)
def create_network(self, tenant_id, net_name, **kwargs): """ Creates a new Virtual Network, and assigns it a symbolic name. :returns: a sequence of mappings with the following signature: {'net-id': uuid that uniquely identifies the particular quantum network, 'net-name': a human-readable name associated with network referenced by net-id } :raises: """ LOG.debug("QuantumRestProxy: create_network() called") # create in DB new_net = db.network_create(tenant_id, net_name) db.network_update(new_net.uuid, net_name, op_status=OperationalStatus.UP) net_id = str(new_net.uuid) # create on networl ctrl try: resource = '/tenants/%s/networks' % tenant_id data = { "network": { "id": net_id, "name": net_name, "gateway": self.nova.get_gateway(net_id), } } ret = self.servers.post(resource, data) if not self.servers.action_success(ret): raise RemoteRestError(ret[2]) except RemoteRestError as e: LOG.error( 'QuantumRestProxy: Unable to create remote network: %s' % e.message) db.network_destroy(net_id) raise # return created network return { 'net-id': net_id, 'net-name': net_name, }
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}
def delete_network(self, net_id): """Delete a network""" try: net = db.network_destroy(net_id) LOG.debug("Deleted network: %s" % net.uuid) net_dict = {} net_dict["net-id"] = str(net.uuid) return net_dict except Exception, exc: raise Exception("Failed to delete port: %s" % str(exc))
def delete_network(self, net_id): """Delete a network""" try: net = db.network_destroy(net_id) LOG.debug("Deleted network: %s", net.uuid) net_dict = {} net_dict["id"] = str(net.uuid) return net_dict except Exception, exc: LOG.error("Failed to delete network: %s", str(exc))
def delete_network(self, net_id): """Delete a network.""" try: net = db.network_destroy(net_id) LOG.debug("Deleted network: %s", net.uuid) net_dict = {} net_dict["id"] = str(net.uuid) return net_dict except Exception as exc: LOG.error("Failed to delete network: %s", str(exc))
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)
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, [])
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)