From 7598609e5b6092117deb80ba2cd6396215c90651 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Mon, 25 Jul 2016 17:41:33 +0100 Subject: [PATCH] If /var/lib/libvirt/qemu/save exists, move it to nova_libvirt_save_path In https://review.openstack.org/320624 the qemu save directory was set to be a link into the same directory where nova instances are kept in order to ensure that temporary files created in snapshots are stored in a location which is likely on shared storage or has plenty of space. The patch did not actually create the link if a folder existed there already, so this patch implements a move of the folder and a link to replace it. Closes-Bug: #1585325 Change-Id: I5224ac72b14ad027410f5d5c14d20870dd37b5cb --- tasks/nova_compute_kvm_install.yml | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/tasks/nova_compute_kvm_install.yml b/tasks/nova_compute_kvm_install.yml index 29dc5632..3a798fd7 100644 --- a/tasks/nova_compute_kvm_install.yml +++ b/tasks/nova_compute_kvm_install.yml @@ -13,28 +13,34 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Check if qemu save directory is a directory +- name: Check the state of the default qemu save directory stat: path: "/var/lib/libvirt/qemu/save" - register: qemu_savedir_stat + register: _qemu_save_dir -- name: Check if qemu save directory is empty +- name: Check if the qemu save directory is empty shell: 'ls -1A /var/lib/libvirt/qemu/save' - register: qemu_savedir_empty + register: _qemu_save_dir_contents + +- name: Move the existing save directory to nova_libvirt_save_path + command: "mv /var/lib/libvirt/qemu/save {{ nova_libvirt_save_path }}" + when: + - _qemu_save_dir.stat.isdir is defined + - _qemu_save_dir.stat.isdir | bool + - _qemu_save_dir_contents.stdout_lines | length == 0 + +- name: Create the new save directory + file: + path: "{{ nova_libvirt_save_path }}" + state: directory -# We force the link creation if our tests passed, this removes the directory as -# well - name: Symlink qemu save dir to nova_libvirt_save_path file: - path: "/var/lib/libvirt/qemu/save" + src: "{{ nova_libvirt_save_path }}" + dest: "/var/lib/libvirt/qemu/save" state: link owner: "{{ nova_qemu_user }}" group: "{{ nova_qemu_group }}" - src: "{{ nova_libvirt_save_path }}" - force: True - when: - - qemu_savedir_stat.stat.isdir - - qemu_savedir_empty.stdout_lines | length == 0 - name: Install pip packages pip: