1、查看要清理的镜像

root@node-32:~/images-old# openstack image list |grep w

| 708117f8-dda3-4f4e-aad5-65143497846c | d1_w2012r2               |

| 431668a0-c60e-45ba-a48f-58bb315d4ea2 | win2k8r2-v1              |

| 32e599e0-d622-4049-852c-0bcf3550260d | win2k8r2                 |

 

2、先删除快照镜像

root@node-32:~/images-old# openstack image delete 431668a0-c60e-45ba-a48f-58bb315d4ea2

 

3、删除镜像

root@node-32:~/images-old# openstack image delete 32e599e0-d622-4049-852c-0bcf3550260d

409 Conflict: Image 32e599e0-d622-4049-852c-0bcf3550260d could not be deleted because it is in use: The image cannot be deleted because it is in use through the backend store outside of Glance. (HTTP 409)

 

root@node-32:~/images-old# openstack image list |grep w

| 708117f8-dda3-4f4e-aad5-65143497846c | d1_w2012r2               |

| 32e599e0-d622-4049-852c-0bcf3550260d | win2k8r2                 |

 

root@node-32:~/images-old# openstack image show 32e599e0-d622-4049-852c-0bcf3550260d

+------------------+--------------------------------------+

| Field            | Value                                |

+------------------+--------------------------------------+

| checksum         | 9a46894b8e7b14ceb09041f92323590b     |

| container_format | bare                                 |

| created_at       | 2017-03-01T04:31:50.000000           |

| deleted          | False                                |

| disk_format      | raw                                  |

| id               | 32e599e0-d622-4049-852c-0bcf3550260d |

| is_public        | False                                |

| min_disk         | 0                                    |

| min_ram          | 0                                    |

| name             | win2k8r2                             |

| owner            | 74f3bf2affa8443bbcd77b51173bf0de     |

| properties       |                                      |

| protected        | False                                |

| size             | 21478375424                          |

| status           | active                               |

| updated_at       | 2018-08-21T03:21:27.000000           |

+------------------+--------------------------------------+

root@node-32:~/images-old# openstack image show 431668a0-c60e-45ba-a48f-58bb315d4ea2

+------------------+--------------------------------------+

| Field            | Value                                |

+------------------+--------------------------------------+

| checksum         | 674d99763d15a294931a65052e5bba58     |

| container_format | bare                                 |

| created_at       | 2017-03-01T05:00:39.000000           |

| deleted          | True                                 |

| deleted_at       | 2018-08-21T03:21:11.000000           |

| disk_format      | raw                                  |

| id               | 431668a0-c60e-45ba-a48f-58bb315d4ea2 |

| is_public        | True                                 |

| min_disk         | 21                                   |

| min_ram          | 0                                    |

| name             | win2k8r2-v1                          |

| owner            | 74f3bf2affa8443bbcd77b51173bf0de     |

| properties       |                                      |

| protected        | False                                |

| size             | 22548578304                          |

| status           | deleted                              |

| updated_at       | 2018-08-21T03:21:11.000000           |

+------------------+--------------------------------------+

4、查找占用的volume

root@node-32:~/images-old# rbd info images/32e599e0-d622-4049-852c-0bcf3550260d

rbd image '32e599e0-d622-4049-852c-0bcf3550260d':

    size 20483 MB in 2561 objects

    order 23 (8192 kB objects)

    block_name_prefix: rbd_data.19f73363162b6d4

    format: 2

    features: layering, striping

    flags:

    stripe unit: 8192 kB

    stripe count: 1

root@node-32:~/images-old# rbd snap ls images/32e599e0-d622-4049-852c-0bcf3550260d

SNAPID NAME     SIZE

  2834 snap 20483 MB

 

 

root@node-32:~/images-old# rbd info images/32e599e0-d622-4049-852c-0bcf3550260d@snap

rbd image '32e599e0-d622-4049-852c-0bcf3550260d':

    size 20483 MB in 2561 objects

    order 23 (8192 kB objects)

    block_name_prefix: rbd_data.19f73363162b6d4

    format: 2

    features: layering, striping

    flags:

    protected: True

    stripe unit: 8192 kB

    stripe count: 1

root@node-32:~/images-old# rbd info images/32e599e0-d622-4049-852c-0bcf3550260d    

rbd image '32e599e0-d622-4049-852c-0bcf3550260d':

    size 20483 MB in 2561 objects

    order 23 (8192 kB objects)

    block_name_prefix: rbd_data.19f73363162b6d4

    format: 2

    features: layering, striping

    flags:

    stripe unit: 8192 kB

    stripe count: 1

root@node-32:~/images-old# rbd children images/32e599e0-d622-4049-852c-0bcf3550260d@snap

volumes-sata/volume-5fe51793-b88b-4a30-bd5f-bcf9d03ae184

 

5、删除占用的卷

root@node-32:~/images-old# cinder list --all |grep 5fe51793-b88b-4a30-bd5f-bcf9d03ae184

| 5fe51793-b88b-4a30-bd5f-bcf9d03ae184 | 74f3bf2affa8443bbcd77b51173bf0de | available |        -         |                                      |  21  |     sata    |   true   |    False    |                                      |

root@node-32:~/images-old# cinder delete 5fe51793-b88b-4a30-bd5f-bcf9d03ae184

Request to delete volume 5fe51793-b88b-4a30-bd5f-bcf9d03ae184 has been accepted.

You have new mail in /var/mail/root

root@node-32:~/images-old# cinder list --all |grep 5fe51793-b88b-4a30-bd5f-bcf9d03ae184

| 5fe51793-b88b-4a30-bd5f-bcf9d03ae184 | 74f3bf2affa8443bbcd77b51173bf0de |  deleting |        -         |                                      |  21  |     sata    |   true   |    False    |                                      |

root@node-32:~/images-old# cinder list --all |grep 5fe51793-b88b-4a30-bd5f-bcf9d03ae184

 

6、删除镜像

root@node-32:~/images-old# rbd children images/32e599e0-d622-4049-852c-0bcf3550260d@snap

root@node-32:~/images-old# openstack image delete 32e599e0-d622-4049-852c-0bcf3550260d

 

root@node-32:~/images-old# openstack image list |grep w

| 708117f8-dda3-4f4e-aad5-65143497846c | d1_w2012r2               |