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 | +--------------------------------------+----------+
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 ------- ------- ------- ------- ----+-- ------- -+ ------- ------- ------- ------- ----+-- ------- -+ f474-40d7- a525-9e03180eb1 ba | LUKS | 099b-463e- 9643-c1630e9ea7 45 | dm-crypt | 34a1-446b- b5c6-412ac60530 34 | lvm | ------- ------- ------- ------- ----+-- ------- -+
+------
| ID | Name |
+------
| 5933b988-
| 5a0f9245-
| e4bf8b60-
+------
# cinder list ------- ------- ------- ------- ----+-- ------- --+---- ------- ---+--- ---+--- ------- ---+--- ------- +------ ------- + ------- ------- ------- ------- ----+-- ------- --+---- ------- ---+--- ---+--- ------- ---+--- ------- +------ ------- + afa0-47fe- a301-bb0fb03973 48 | available | newlvmvol | 1 | lvm | False | | ------- ------- ------- ------- ----+-- ------- --+---- ------- ---+--- ---+--- ------- ---+--- ------- +------ ------- +
+------
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+------
| 821e43be-
+------
# cinder type-delete e4bf8b60- 34a1-446b- b5c6-412ac60530 34
ERROR: Volume Type deletion is not allowed with volumes present with the type.
# cinder delete 821e43be- afa0-47fe- a301-bb0fb03973 48 ------- +------ ------- -+----- -+----- ------- -+----- -----+- ------- -----+ ------- +------ ------- -+----- -+----- ------- -+----- -----+- ------- -----+ ------- +------ ------- -+----- -+----- ------- -+----- -----+- ------- -----+ 34a1-446b- b5c6-412ac60530 34 ------- ------- ------- ------- ----+-- ------- -+ ------- ------- ------- ------- ----+-- ------- -+ f474-40d7- a525-9e03180eb1 ba | LUKS | 099b-463e- 9643-c1630e9ea7 45 | dm-crypt | ------- ------- ------- ------- ----+-- ------- -+
# cinder list
+----+-
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+----+-
+----+-
# cinder type-delete e4bf8b60-
# cinder type-list
+------
| ID | Name |
+------
| 5933b988-
| 5a0f9245-
+------