summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
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/utils.py
parentf85e4ec079283f4217415b4fd6a37ced189bc49a (diff)
downloadnova-ab1977af316eef5375c7aaefdf364548b4fb5289.tar.gz
nova-ab1977af316eef5375c7aaefdf364548b4fb5289.tar.xz
nova-ab1977af316eef5375c7aaefdf364548b4fb5289.zip
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/utils.py')
-rw-r--r--nova/utils.py37
1 files changed, 0 insertions, 37 deletions
diff --git a/nova/utils.py b/nova/utils.py
index 9067488d5..41d18b3cb 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -21,7 +21,6 @@
import contextlib
import datetime
-import errno
import functools
import hashlib
import inspect
@@ -439,18 +438,6 @@ def to_bytes(text, default=0):
return default
-def delete_if_exists(pathname):
- """delete a file, but ignore file not found error."""
-
- try:
- os.unlink(pathname)
- except OSError as e:
- if e.errno == errno.ENOENT:
- return
- else:
- raise
-
-
def get_from_path(items, path):
"""Returns a list of items matching the specified path.
@@ -733,18 +720,6 @@ def timefunc(func):
return inner
-@contextlib.contextmanager
-def remove_path_on_error(path):
- """Protect code that wants to operate on PATH atomically.
- Any exception will cause PATH to be removed.
- """
- try:
- yield
- except Exception:
- with excutils.save_and_reraise_exception():
- delete_if_exists(path)
-
-
def make_dev_path(dev, partition=None, base='/dev'):
"""Return a path to a particular device.
@@ -803,18 +778,6 @@ def read_cached_file(filename, cache_info, reload_func=None):
return cache_info['data']
-def file_open(*args, **kwargs):
- """Open file
-
- see built-in file() documentation for more details
-
- Note: The reason this is kept in a separate module is to easily
- be able to provide a stub module that doesn't alter system
- state at all (for unit tests)
- """
- return file(*args, **kwargs)
-
-
def hash_file(file_like_object):
"""Generate a hash for the contents of a file."""
checksum = hashlib.sha1()