Use 'device' instead of 'volume_path'

If device is not found at the first try,
exception VolumeDeviceNotFound will be thrown.
The exception VolumeDeviceNotFound expects the key 'device',
however, 'volume_path' is passed in. As a result,
KeyError: 'device' exception will be thrown.

See the following definition in exception.py:
class VolumeDeviceNotFound(CinderException):
    message = _('Volume device not found at %(device)s.')

This bug is introduced in https://review.openstack.org/#/c/213389

Change-Id: I64b37486631c31569fb037064c2ec0fee3bd855c
Closes-Bug: #1492936
This commit is contained in:
Peter Wang 2015-09-07 03:52:20 -04:00
parent 891cf03109
commit 0f3ec7c70a
2 changed files with 13 additions and 2 deletions

View File

@ -160,7 +160,7 @@ class LinuxSCSI(executor.Executor):
if not os.path.exists(volume_path):
LOG.debug("%(path)s doesn't exists yet.", {'path': volume_path})
raise exception.VolumeDeviceNotFound(
volume_path=volume_path)
device=volume_path)
else:
LOG.debug("%s has shown up.", volume_path)

View File

@ -14,6 +14,7 @@
import os
import os.path
import time
import mock
from oslo_log import log as logging
@ -129,12 +130,22 @@ class LinuxSCSITestCase(base.TestCase):
self.assertEqual(expected_path, found_path)
@mock.patch.object(os.path, 'exists', return_value=False)
def test_find_multipath_device_path_fail(self, exists_mock):
@mock.patch.object(time, 'sleep')
def test_find_multipath_device_path_fail(self, exists_mock, sleep_mock):
fake_wwn = '1234567890'
found_path = self.linuxscsi.find_multipath_device_path(fake_wwn)
expected_path = None
self.assertEqual(expected_path, found_path)
@mock.patch.object(os.path, 'exists', return_value=False)
@mock.patch.object(time, 'sleep')
def test_wait_for_path_not_found(self, exists_mock, sleep_mock):
path = "/dev/disk/by-id/dm-uuid-mpath-%s" % '1234567890'
self.assertRaisesRegexp(exception.VolumeDeviceNotFound,
r'Volume device not found at %s' % path,
self.linuxscsi.wait_for_path,
path)
@mock.patch.object(linuxscsi.LinuxSCSI, 'find_multipath_device')
@mock.patch.object(os.path, 'exists', return_value=True)
def test_remove_multipath_device(self, exists_mock, mock_multipath):