summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-09-10 20:09:22 +0000
committerGerrit Code Review <review@openstack.org>2017-09-10 20:09:22 +0000
commit7195c63f80cc8e027e0514146bd73fbce9472027 (patch)
tree35bdb84d28f3cd81bac4490a5b83f1e7a120ea47
parentd35f26b25c5f8bdd489cbb92e0fe70acc51a4654 (diff)
parentf5fc74d658b877f20a20a1edc016edba66f493d2 (diff)
downloadnova-7195c63f80cc8e027e0514146bd73fbce9472027.tar.gz
Merge "Remove two testing stubs which aren't really needed."
-rw-r--r--nova/tests/unit/virt/libvirt/fake_libvirt_utils.py4
-rw-r--r--nova/tests/unit/virt/libvirt/storage/test_lvm.py3
-rw-r--r--nova/tests/unit/virt/libvirt/test_driver.py2
-rw-r--r--nova/tests/unit/virt/test_virt_drivers.py6
-rw-r--r--nova/virt/libvirt/driver.py4
-rw-r--r--nova/virt/libvirt/storage/lvm.py5
-rw-r--r--nova/virt/libvirt/utils.py20
7 files changed, 11 insertions, 33 deletions
diff --git a/nova/tests/unit/virt/libvirt/fake_libvirt_utils.py b/nova/tests/unit/virt/libvirt/fake_libvirt_utils.py
index 1dcbc2df30..0b56cbdc71 100644
--- a/nova/tests/unit/virt/libvirt/fake_libvirt_utils.py
+++ b/nova/tests/unit/virt/libvirt/fake_libvirt_utils.py
@@ -128,10 +128,6 @@ def logical_volume_info(path):
return {}
-def file_delete(path):
- return True
-
-
def get_fs_info(path):
return {'total': 128 * (1024 ** 3),
'used': 44 * (1024 ** 3),
diff --git a/nova/tests/unit/virt/libvirt/storage/test_lvm.py b/nova/tests/unit/virt/libvirt/storage/test_lvm.py
index bf62eaeda5..89c31a80c2 100644
--- a/nova/tests/unit/virt/libvirt/storage/test_lvm.py
+++ b/nova/tests/unit/virt/libvirt/storage/test_lvm.py
@@ -21,7 +21,6 @@ from nova import exception
from nova import test
from nova import utils
from nova.virt.libvirt.storage import lvm
-from nova.virt.libvirt import utils as libvirt_utils
CONF = cfg.CONF
@@ -52,7 +51,7 @@ class LvmTestCase(test.NoDBTestCase):
self.assertRaises(exception.VolumeBDMPathNotFound,
lvm.get_volume_size, '/dev/foo')
- @mock.patch.object(libvirt_utils, 'path_exists', return_value=True)
+ @mock.patch('os.path.exists', return_value=True)
@mock.patch.object(utils, 'execute',
side_effect=processutils.ProcessExecutionError(
stderr='blockdev: i am sad in other ways'))
diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py
index 7b3216f3d5..b9b05466b9 100644
--- a/nova/tests/unit/virt/libvirt/test_driver.py
+++ b/nova/tests/unit/virt/libvirt/test_driver.py
@@ -17392,7 +17392,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
mock.patch.object(libvirt_utils, 'write_to_file'),
mock.patch.object(drvr, '_destroy'),
mock.patch.object(drvr, '_create_domain'),
- mock.patch.object(libvirt_utils, 'file_delete'),
+ mock.patch.object(os, 'unlink'),
mock.patch.object(shutil, 'rmtree'),
mock.patch.object(os.path, "isdir",
side_effect=isdir_sideeffect),
diff --git a/nova/tests/unit/virt/test_virt_drivers.py b/nova/tests/unit/virt/test_virt_drivers.py
index a996950dad..0c41207ff3 100644
--- a/nova/tests/unit/virt/test_virt_drivers.py
+++ b/nova/tests/unit/virt/test_virt_drivers.py
@@ -336,12 +336,14 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
image_meta, '')
@catch_notimplementederror
- def test_unrescue_unrescued_instance(self):
+ @mock.patch('os.unlink')
+ def test_unrescue_unrescued_instance(self, mock_unlink):
instance_ref, network_info = self._get_running_instance()
self.connection.unrescue(instance_ref, network_info)
@catch_notimplementederror
- def test_unrescue_rescued_instance(self):
+ @mock.patch('os.unlink')
+ def test_unrescue_rescued_instance(self, mock_unlink):
image_meta = objects.ImageMeta.from_dict({})
instance_ref, network_info = self._get_running_instance()
self.connection.rescue(self.ctxt, instance_ref, network_info,
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py
index 7d89d29768..e5c55f0774 100644
--- a/nova/virt/libvirt/driver.py
+++ b/nova/virt/libvirt/driver.py
@@ -2760,13 +2760,13 @@ class LibvirtDriver(driver.ComputeDriver):
virt_dom = guest._domain
self._destroy(instance)
self._create_domain(xml, virt_dom)
- libvirt_utils.file_delete(unrescue_xml_path)
+ os.unlink(unrescue_xml_path)
rescue_files = os.path.join(instance_dir, "*.rescue")
for rescue_file in glob.iglob(rescue_files):
if os.path.isdir(rescue_file):
shutil.rmtree(rescue_file)
else:
- libvirt_utils.file_delete(rescue_file)
+ os.unlink(rescue_file)
# cleanup rescue volume
lvm.remove_volumes([lvmdisk for lvmdisk in self._lvm_disks(instance)
if lvmdisk.endswith('.rescue')])
diff --git a/nova/virt/libvirt/storage/lvm.py b/nova/virt/libvirt/storage/lvm.py
index 35d6463978..014aac6d06 100644
--- a/nova/virt/libvirt/storage/lvm.py
+++ b/nova/virt/libvirt/storage/lvm.py
@@ -19,6 +19,8 @@
# under the License.
#
+import os
+
from oslo_concurrency import processutils
from oslo_log import log as logging
from oslo_utils import units
@@ -28,7 +30,6 @@ import nova.conf
from nova import exception
from nova.i18n import _
from nova import utils
-from nova.virt.libvirt import utils as libvirt_utils
CONF = nova.conf.CONF
LOG = logging.getLogger(__name__)
@@ -157,7 +158,7 @@ def get_volume_size(path):
out, _err = utils.execute('blockdev', '--getsize64', path,
run_as_root=True)
except processutils.ProcessExecutionError:
- if not libvirt_utils.path_exists(path):
+ if not os.path.exists(path):
raise exception.VolumeBDMPathNotFound(path=path)
else:
raise
diff --git a/nova/virt/libvirt/utils.py b/nova/virt/libvirt/utils.py
index b334be3439..3865fa0f57 100644
--- a/nova/virt/libvirt/utils.py
+++ b/nova/virt/libvirt/utils.py
@@ -318,26 +318,6 @@ def file_open(*args, **kwargs):
return open(*args, **kwargs)
-def file_delete(path):
- """Delete (unlink) file
-
- 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 os.unlink(path)
-
-
-def path_exists(path):
- """Returns if path exists
-
- 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 os.path.exists(path)
-
-
def find_disk(guest):
"""Find root device path for instance