Deleting a Neutron network

The steps to remove a Neutron network are similar to the set of steps we followed to create the network.

Getting ready

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

How to do it...

To delete a Neutron network for a particular tenant, follow these steps:

  1. List the networks with the following command:
    neutron net-list
    

    You will get the following output:

    How to do it...
  2. To list the subnets, issue the following command:
    neutron subnet-list
    

    You will get the following output:

    How to do it...
  3. To delete a network and subnets, ensure that there are no instances and services using the networks and subnets you are about to delete. To check which ports are connected to your network, query the port list in Neutron using the following command:
    neutron port-list
    

    You will get the following output:

    How to do it...
  4. You can also look at the running instances and the networks that they are attached to by issuing the following command:
    nova list
    

    You will get the following output:

    How to do it...

    You can see that we have a cookbook_network_1 instance on the network that we want to delete.

  5. You need to delete any instances that are running on this network, for example:
    nova delete test1
    
  6. Now that you have stopped the instances that you want to remove, you can remove any router interfaces attached to this network with the following commands:
    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}
    
  7. With the router interface removed, you can proceed to delete the subnet with the following command:
    neutron subnet-delete cookbook_subnet_1
    
  8. With the subnet removed, you can delete the network with the following command:
    neutron net-delete cookbook_network_1
    

How it works...

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:

  • To list a nework, use the following command:
    neutron net-list
    
  • To list a subnet, use the following command:
    neutron subnet-list 
    
  • The following command lists used Neutron Ports:
    neutron port-list
    
  • To remove a router interface from a subnet, use the following syntax:
    neutron router-interface-delete 
      ROUTER_ID 
      SUBNET_ID 
    
  • To remove a subnet, use the following syntax:
    neutron subnet-delete NAME_OF_SUBNET
    
  • To remove a network, use the following syntax:
    neutron subnet-delete NAME_OF_NETWORK
    
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset