官术网_书友最值得收藏!

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
    
主站蜘蛛池模板: 东丽区| 沙洋县| 高邑县| 彰化县| 南安市| 汤原县| 彰武县| 台州市| 望江县| 镇赉县| 宁海县| 北宁市| 沙湾县| 阜康市| 治多县| 武汉市| 佳木斯市| 响水县| 馆陶县| 蒙自县| 来安县| 永兴县| 抚顺市| 通海县| 神农架林区| 普陀区| 醴陵市| 乳源| 桦甸市| 县级市| 黔东| 丽水市| 许昌市| 合作市| 和龙市| 中江县| 鄂托克前旗| 祁连县| 澎湖县| 泽州县| 伊金霍洛旗|