diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-05-29 00:10:31 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-05-29 00:10:31 +0000 |
| commit | ea4c411bca55dc885c466b0068fde02fb289323d (patch) | |
| tree | 9a3a7b5ec8a8c1ded9de84f470a841d1e77547c5 | |
| parent | 7cecbc6c968296a3c93ec5016873b85d1168b286 (diff) | |
| parent | d5180f6e41d4b4107179cff678401295e7da931d (diff) | |
| download | nova-ea4c411bca55dc885c466b0068fde02fb289323d.tar.gz nova-ea4c411bca55dc885c466b0068fde02fb289323d.tar.xz nova-ea4c411bca55dc885c466b0068fde02fb289323d.zip | |
Merge "Test for remote directory creation before shutting down instance"
| -rwxr-xr-x | nova/virt/libvirt/driver.py | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 12bc03e66..7af7e4e2a 100755 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -3558,6 +3558,19 @@ class LibvirtDriver(driver.ComputeDriver): disk_info_text = self.get_instance_disk_info(instance['name']) disk_info = jsonutils.loads(disk_info_text) + # copy disks to destination + # rename instance dir to +_resize at first for using + # shared storage for instance dir (eg. NFS). + inst_base = libvirt_utils.get_instance_path(instance) + inst_base_resize = inst_base + "_resize" + shared_storage = self._is_storage_shared_with(dest, inst_base) + + # try to create the directory on the remote compute node + # if this fails we pass the exception up the stack so we can catch + # failures here earlier + if not shared_storage: + utils.execute('ssh', dest, 'mkdir', '-p', inst_base) + self.power_off(instance) block_device_mapping = driver.block_device_info_get_mapping( @@ -3569,20 +3582,14 @@ class LibvirtDriver(driver.ComputeDriver): connection_info, disk_dev) - # copy disks to destination - # rename instance dir to +_resize at first for using - # shared storage for instance dir (eg. NFS). - inst_base = libvirt_utils.get_instance_path(instance) - inst_base_resize = inst_base + "_resize" - - shared_storage = self._is_storage_shared_with(dest, inst_base) try: utils.execute('mv', inst_base, inst_base_resize) + # if we are migrating the instance with shared storage then + # create the directory. If it is a remote node the directory + # has already been created if shared_storage: dest = None utils.execute('mkdir', '-p', inst_base) - else: - utils.execute('ssh', dest, 'mkdir', '-p', inst_base) for info in disk_info: # assume inst_base == dirname(info['path']) img_path = info['path'] |
