MNAIO: Clean up existing data when switching backing store
When switching from LVM to a file backing store, the existing pool cannot be undefined until any existing VM's and LV's are removed. This ensures that if this is the case, it will be cleaned up so that the switch is effortless. Change-Id: Ie1460b37593306044f0a63f445c3da1987362d34
This commit is contained in:
parent
782a884c55
commit
c556bea0d7
@ -261,6 +261,35 @@
|
||||
- (default_vm_disk_mode == "file" and _virt_pools.pools.default.format is defined) or
|
||||
(default_vm_disk_mode == "lvm" and _virt_pools.pools.default.format is not defined)
|
||||
block:
|
||||
- name: Stop running VMs
|
||||
virt:
|
||||
name: "{{ item }}"
|
||||
command: destroy
|
||||
failed_when: false
|
||||
with_items: "{{ _virt_pools.pools.default.volumes }}"
|
||||
|
||||
- name: Delete VM LVs
|
||||
lvol:
|
||||
vg: "{{ default_vm_disk_vg }}"
|
||||
lv: "{{ item }}"
|
||||
state: absent
|
||||
force: yes
|
||||
failed_when: false
|
||||
with_items: "{{ _virt_pools.pools.default.volumes }}"
|
||||
|
||||
- name: Delete VM Disk Images
|
||||
file:
|
||||
path: "{{ _virt_pools.pools.default.path | default('/data/images') }}/{{ item }}.img"
|
||||
state: absent
|
||||
with_items: "{{ _virt_pools.pools.default.volumes }}"
|
||||
|
||||
- name: Undefine the VMs
|
||||
virt:
|
||||
name: "{{ item }}"
|
||||
command: undefine
|
||||
failed_when: false
|
||||
with_items: "{{ _virt_pools.pools.default.volumes }}"
|
||||
|
||||
- name: Dismount the mount point if default_vm_disk_mode is 'lvm'
|
||||
mount:
|
||||
path: /data
|
||||
|
Loading…
x
Reference in New Issue
Block a user