删除net,层层迭代下去,要先删除port
neutron port-list | grep 183F | cut -d" " -f2 | xargs neutron port-delete
然后可以删除subnet
neutron subnet-list |grep 183F
neutron subnet-delete 28daaa58-4b04-4d02-8fc6-6030fd0138b3
然后删除net
neutron net-list | grep 183F
neutron net-delete b9698714-7a9a-4219-a6e8-4f111008c0de
[root@ncontroller ~]# nova list | grep 183F | cut -d" " -f2|xargs -i nova reset-state {} --active
Reset state for server d1e58945-0ec6-4493-aef2-38932942f4f9 succeeded; new state is active
用这个命令来使instance的状态变成active,因为误操作可能使其变成ERROR等状态。
cut -d后面接分隔字符,-f2是选择第二列,这样就取到了ID,xargs的-i选项说明有参数,参数用{}来表示,这样就把前面所列的ID一个一个传给了xargs后面的命令,nova reset-state
[root@ncontroller ~]# nova list | grep 183F
| d1e58945-0ec6-4493-aef2-38932942f4f9 | VNDB183F-0-0-10 | SHUTOFF | - | Shutdown | |
| 826c8323-240a-4e60-b222-0ff1c2f9e759 | VNDB183F-0-0-11 | ACTIVE | - | NOSTATE | |
SHUTOFF可能是由于openstack关机导致的,的需要到dashboard上start instance
把cinder停掉,从in-use状态到available状态
[root@ncontroller ~]# cinder list |grep 183F | cut -d" " -f2 | xargs cinder reset-state
进MySQL,use cinder
[root@ncontroller ~]# mysql -uroot -p123456
MariaDB [(none)]> use cinder
可以在外面用命令执行
[root@ncontroller ~]# cinder list |grep 183F|cut -d" " -f2|xargs -i mysql -uroot -p123456 -D cinder -e "UPDATE volumes SET attach_status='detached' WHERE id='{}';"
删除cinder
[root@ncontroller ~]# cinder list |grep 183F|cut -d" " -f2|xargs cinder delete