The steps to remove a Neutron network are similar to the set of steps we followed to create the network.
Ensure that you have a suitable client available for using Neutron. If you are using the accompanying Vagrant environment, you can use the controller
node. This has the python-neutronclient
package that provides the neutron
command-line client.
If you created this node with Vagrant, you can execute the following command:
vagrant ssh controller
Ensure you have the following credentials set (adjust the path to your certificates and key file to match your environment if not using the Vagrant environment):
export OS_TENANT_NAME=cookbook export OS_USERNAME=admin export OS_PASSWORD=openstack export OS_AUTH_URL=https://192.168.100.200:5000/v2.0/ export OS_NO_CACHE=1 export OS_KEY=/vagrant/cakey.pem export OS_CACERT=/vagrant/ca.pem
To delete a Neutron network for a particular tenant, follow these steps:
neutron net-list
You will get the following output:
neutron subnet-list
You will get the following output:
neutron port-list
You will get the following output:
nova list
You will get the following output:
You can see that we have a cookbook_network_1
instance on the network that we want to delete.
nova delete test1
ROUTER_ID=$(neutron router-list | awk '/ cookbook_router_1 / {print $2}') SUBNET_ID=$(neutron subnet-list | awk '/ cookbook_subnet_1 / {print $2}') neutron router-interface-delete ${ROUTER_ID} ${SUBNET_ID}
neutron subnet-delete cookbook_subnet_1
neutron net-delete cookbook_network_1
In the preceding steps, we performed a series of steps to remove a network. This involves first removing any (virtual) devices attached to this network such as instances and routers, removing the subnet that has been attached to that network, and removing the underlying network itself. Let's see the net list:
neutron net-list
neutron subnet-list
neutron port-list
neutron router-interface-delete ROUTER_ID SUBNET_ID
neutron subnet-delete NAME_OF_SUBNET
neutron subnet-delete NAME_OF_NETWORK