Merge "Fix DeprecationWarning when using BaseException.message"
This commit is contained in:
commit
bffdec0f0f
|
@ -12,6 +12,9 @@
|
|||
|
||||
import os
|
||||
|
||||
import mock
|
||||
from oslo_concurrency import processutils
|
||||
|
||||
from nova.tests.unit.virt.libvirt.volume import test_volume
|
||||
from nova import utils
|
||||
from nova.virt.libvirt import utils as libvirt_utils
|
||||
|
@ -94,6 +97,20 @@ class LibvirtGlusterfsVolumeDriverTestCase(
|
|||
('umount', export_mnt_base)]
|
||||
self.assertEqual(self.executes, expected_commands)
|
||||
|
||||
@mock.patch.object(glusterfs.utils, 'execute')
|
||||
@mock.patch.object(glusterfs.LOG, 'debug')
|
||||
@mock.patch.object(glusterfs.LOG, 'exception')
|
||||
def test_libvirt_glusterfs_driver_umount_error(self, mock_LOG_exception,
|
||||
mock_LOG_debug, mock_utils_exe):
|
||||
export_string = '192.168.1.1:/volume-00001'
|
||||
connection_info = {'data': {'export': export_string,
|
||||
'name': self.name}}
|
||||
libvirt_driver = glusterfs.LibvirtGlusterfsVolumeDriver(self.fake_conn)
|
||||
mock_utils_exe.side_effect = processutils.ProcessExecutionError(
|
||||
None, None, None, 'umount', 'umount: target is busy.')
|
||||
libvirt_driver.disconnect_volume(connection_info, "vde")
|
||||
self.assertTrue(mock_LOG_debug.called)
|
||||
|
||||
def test_libvirt_glusterfs_driver_with_opts(self):
|
||||
mnt_base = '/mnt'
|
||||
self.flags(glusterfs_mount_point_base=mnt_base, group='libvirt')
|
||||
|
|
|
@ -112,8 +112,8 @@ class QuobyteTestCase(test.NoDBTestCase):
|
|||
utils.get_hash_str(quobyte_volume))
|
||||
|
||||
def exec_side_effect(*cmd, **kwargs):
|
||||
exerror = processutils.ProcessExecutionError()
|
||||
exerror.message = "Device or resource busy"
|
||||
exerror = processutils.ProcessExecutionError(
|
||||
"Device or resource busy")
|
||||
raise exerror
|
||||
mock_execute.side_effect = exec_side_effect
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
@ -85,7 +87,7 @@ class LibvirtGlusterfsVolumeDriver(fs.LibvirtBaseFileSystemVolumeDriver):
|
|||
utils.execute('umount', mount_path, run_as_root=True)
|
||||
except processutils.ProcessExecutionError as exc:
|
||||
export = connection_info['data']['export']
|
||||
if 'target is busy' in exc.message:
|
||||
if 'target is busy' in six.text_type(exc):
|
||||
LOG.debug("The GlusterFS share %s is still in use.", export)
|
||||
else:
|
||||
LOG.exception(_LE("Couldn't unmount the GlusterFS share %s"),
|
||||
|
@ -115,7 +117,7 @@ class LibvirtGlusterfsVolumeDriver(fs.LibvirtBaseFileSystemVolumeDriver):
|
|||
try:
|
||||
utils.execute(*gluster_cmd, run_as_root=True)
|
||||
except processutils.ProcessExecutionError as exc:
|
||||
if ensure and 'already mounted' in exc.message:
|
||||
if ensure and 'already mounted' in six.text_type(exc):
|
||||
LOG.warn(_LW("%s is already mounted"), glusterfs_share)
|
||||
else:
|
||||
raise
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import six
|
||||
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
@ -68,8 +70,8 @@ class LibvirtNFSVolumeDriver(fs.LibvirtBaseFileSystemVolumeDriver):
|
|||
utils.execute('umount', mount_path, run_as_root=True)
|
||||
except processutils.ProcessExecutionError as exc:
|
||||
export = connection_info['data']['export']
|
||||
if ('device is busy' in exc.message or
|
||||
'target is busy' in exc.message):
|
||||
if ('device is busy' in six.text_type(exc) or
|
||||
'target is busy' in six.text_type(exc)):
|
||||
LOG.debug("The NFS share %s is still in use.", export)
|
||||
else:
|
||||
LOG.exception(_LE("Couldn't unmount the NFS share %s"), export)
|
||||
|
@ -99,7 +101,7 @@ class LibvirtNFSVolumeDriver(fs.LibvirtBaseFileSystemVolumeDriver):
|
|||
try:
|
||||
utils.execute(*nfs_cmd, run_as_root=True)
|
||||
except processutils.ProcessExecutionError as exc:
|
||||
if ensure and 'already mounted' in exc.message:
|
||||
if ensure and 'already mounted' in six.text_type(exc):
|
||||
LOG.warn(_LW("%s is already mounted"), nfs_share)
|
||||
else:
|
||||
raise
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
import errno
|
||||
import os
|
||||
import six
|
||||
|
||||
from oslo_concurrency import processutils
|
||||
from oslo_config import cfg
|
||||
|
@ -71,7 +72,7 @@ def umount_volume(mnt_base):
|
|||
try:
|
||||
utils.execute('umount.quobyte', mnt_base)
|
||||
except processutils.ProcessExecutionError as exc:
|
||||
if 'Device or resource busy' in exc.message:
|
||||
if 'Device or resource busy' in six.text_type(exc):
|
||||
LOG.error(_LE("The Quobyte volume at %s is still in use."),
|
||||
mnt_base)
|
||||
else:
|
||||
|
|
|
@ -60,7 +60,7 @@ def mount_share(mount_path, export_path,
|
|||
try:
|
||||
utils.execute(*mount_cmd, run_as_root=True)
|
||||
except processutils.ProcessExecutionError as exc:
|
||||
if 'Device or resource busy' in exc.message:
|
||||
if 'Device or resource busy' in six.text_type(exc):
|
||||
LOG.warn(_LW("%s is already mounted"), export_path)
|
||||
else:
|
||||
raise
|
||||
|
@ -76,7 +76,7 @@ def unmount_share(mount_path, export_path):
|
|||
utils.execute('umount', mount_path, run_as_root=True,
|
||||
attempts=3, delay_on_retry=True)
|
||||
except processutils.ProcessExecutionError as exc:
|
||||
if 'target is busy' in exc.message:
|
||||
if 'target is busy' in six.text_type(exc):
|
||||
LOG.debug("The share %s is still in use.", export_path)
|
||||
else:
|
||||
LOG.exception(_LE("Couldn't unmount the share %s"),
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
# under the License.
|
||||
|
||||
import functools
|
||||
import six
|
||||
import sys
|
||||
|
||||
from oslo_config import cfg
|
||||
|
@ -44,7 +45,7 @@ class GlanceStore(object):
|
|||
def retry_cb(context, instance, exc=None):
|
||||
if exc:
|
||||
exc_info = sys.exc_info()
|
||||
LOG.debug(exc.message, exc_info=exc_info)
|
||||
LOG.debug(six.text_type(exc), exc_info=exc_info)
|
||||
compute_utils.add_instance_fault_from_exc(
|
||||
context, instance, exc, exc_info)
|
||||
|
||||
|
|
Loading…
Reference in New Issue