Comment 2 for bug 1215329

Revision history for this message
Swapnil Kulkarni (coolsvap-deactivatedaccount) wrote :

Updated volume_type_destroy method to throw exception for volume type delete with associated volumes.

Added method to retrieve volumes associated with type.

Following are the unit test results after changes

# cinder type-list
+--------------------------------------+----------+
| ID | Name |
+--------------------------------------+----------+
| 5933b988-f474-40d7-a525-9e03180eb1ba | LUKS |
| 5a0f9245-099b-463e-9643-c1630e9ea745 | dm-crypt |
| e4bf8b60-34a1-446b-b5c6-412ac6053034 | lvm |
+--------------------------------------+----------+

# cinder list
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| 821e43be-afa0-47fe-a301-bb0fb0397348 | available | newlvmvol | 1 | lvm | False | |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

# cinder type-delete e4bf8b60-34a1-446b-b5c6-412ac6053034
ERROR: Volume Type deletion is not allowed with volumes present with the type.

# cinder delete 821e43be-afa0-47fe-a301-bb0fb0397348
# cinder list
+----+--------+--------------+------+-------------+----------+-------------+
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+----+--------+--------------+------+-------------+----------+-------------+
+----+--------+--------------+------+-------------+----------+-------------+
# cinder type-delete e4bf8b60-34a1-446b-b5c6-412ac6053034
# cinder type-list
+--------------------------------------+----------+
| ID | Name |
+--------------------------------------+----------+
| 5933b988-f474-40d7-a525-9e03180eb1ba | LUKS |
| 5a0f9245-099b-463e-9643-c1630e9ea745 | dm-crypt |
+--------------------------------------+----------+