summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorZhongyue Luo <zhongyue.nah@intel.com>2013-06-10 14:43:41 +0800
committerZhongyue Luo <zhongyue.nah@intel.com>2013-06-11 13:28:29 +0900
commitab1977af316eef5375c7aaefdf364548b4fb5289 (patch)
treeabdded324a0220e9b17b78e5dc5c18c94b1f2b2d /nova/virt
parentf85e4ec079283f4217415b4fd6a37ced189bc49a (diff)
Replace functions in utils with oslo.fileutils
The following functions have moved to oslo. remove_path_on_error file_open delete_if_exists Replaced/removed overlapping functions with the ones in fileutils Change-Id: I41a19d76a777b6f899843bb0cc0582630accbd5c
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/configdrive.py2
-rwxr-xr-xnova/virt/images.py7
-rwxr-xr-xnova/virt/libvirt/driver.py2
-rwxr-xr-xnova/virt/libvirt/imagebackend.py8
4 files changed, 10 insertions, 9 deletions
diff --git a/nova/virt/configdrive.py b/nova/virt/configdrive.py
index 57e5155c8..173dd457b 100644
--- a/nova/virt/configdrive.py
+++ b/nova/virt/configdrive.py
@@ -169,7 +169,7 @@ class ConfigDriveBuilder(object):
def cleanup(self):
if self.imagefile:
- utils.delete_if_exists(self.imagefile)
+ fileutils.delete_if_exists(self.imagefile)
try:
shutil.rmtree(self.tempdir)
diff --git a/nova/virt/images.py b/nova/virt/images.py
index b40f566a6..08d275bc6 100755
--- a/nova/virt/images.py
+++ b/nova/virt/images.py
@@ -28,6 +28,7 @@ from oslo.config import cfg
from nova import exception
from nova.image import glance
+from nova.openstack.common import fileutils
from nova.openstack.common import log as logging
from nova import utils
@@ -197,7 +198,7 @@ def fetch(context, image_href, path, _user_id, _project_id):
# checked before we got here.
(image_service, image_id) = glance.get_remote_image_service(context,
image_href)
- with utils.remove_path_on_error(path):
+ with fileutils.remove_path_on_error(path):
with open(path, "wb") as image_file:
image_service.download(context, image_id, image_file)
@@ -206,7 +207,7 @@ def fetch_to_raw(context, image_href, path, user_id, project_id):
path_tmp = "%s.part" % path
fetch(context, image_href, path_tmp, user_id, project_id)
- with utils.remove_path_on_error(path_tmp):
+ with fileutils.remove_path_on_error(path_tmp):
data = qemu_img_info(path_tmp)
fmt = data.file_format
@@ -223,7 +224,7 @@ def fetch_to_raw(context, image_href, path, user_id, project_id):
if fmt != "raw" and CONF.force_raw_images:
staged = "%s.converted" % path
LOG.debug("%s was %s, converting to raw" % (image_href, fmt))
- with utils.remove_path_on_error(staged):
+ with fileutils.remove_path_on_error(staged):
convert_image(path_tmp, staged, 'raw')
os.unlink(path_tmp)
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index c0cec7a43..135791f3d 100755
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -2932,7 +2932,7 @@ class LibvirtDriver(driver.ComputeDriver):
return os.path.exists(data['filename'])
def check_instance_shared_storage_cleanup(self, ctxt, data):
- utils.delete_if_exists(data["filename"])
+ fileutils.delete_if_exists(data["filename"])
def check_can_live_migrate_destination(self, ctxt, instance_ref,
src_compute_info, dst_compute_info,
diff --git a/nova/virt/libvirt/imagebackend.py b/nova/virt/libvirt/imagebackend.py
index 844d9dfde..c564d2d24 100755
--- a/nova/virt/libvirt/imagebackend.py
+++ b/nova/virt/libvirt/imagebackend.py
@@ -166,7 +166,7 @@ class Image(object):
if can_fallocate is None:
_out, err = utils.trycmd('fallocate', '-n', '-l', '1',
self.path + '.fallocate_test')
- utils.delete_if_exists(self.path + '.fallocate_test')
+ fileutils.delete_if_exists(self.path + '.fallocate_test')
can_fallocate = not err
self.__class__.can_fallocate = can_fallocate
if not can_fallocate:
@@ -215,7 +215,7 @@ class Raw(Image):
else:
prepare_template(target=base, *args, **kwargs)
if not os.path.exists(self.path):
- with utils.remove_path_on_error(self.path):
+ with fileutils.remove_path_on_error(self.path):
copy_raw_image(base, self.path, size)
self.correct_format()
@@ -273,7 +273,7 @@ class Qcow2(Image):
# Create the legacy backing file if necessary.
if legacy_backing_size:
if not os.path.exists(legacy_base):
- with utils.remove_path_on_error(legacy_base):
+ with fileutils.remove_path_on_error(legacy_base):
libvirt_utils.copy_image(base, legacy_base)
disk.extend(legacy_base, legacy_backing_size)
@@ -285,7 +285,7 @@ class Qcow2(Image):
(base, size))
raise exception.InstanceTypeDiskTooSmall()
if not os.path.exists(self.path):
- with utils.remove_path_on_error(self.path):
+ with fileutils.remove_path_on_error(self.path):
copy_qcow2_image(base, self.path, size)
def snapshot_create(self):