Merge "VMAX Driver - Fix for invalid device id length"
This commit is contained in:
commit
e0fa774511
@ -19,6 +19,8 @@ import datetime
|
||||
import platform
|
||||
import time
|
||||
|
||||
from ddt import data
|
||||
from ddt import ddt
|
||||
import mock
|
||||
import requests
|
||||
import six
|
||||
@ -49,6 +51,7 @@ from cinder.volume import utils as volume_utils
|
||||
from cinder.volume import volume_types
|
||||
from cinder.zonemanager import utils as fczm_utils
|
||||
|
||||
|
||||
CINDER_EMC_CONFIG_DIR = '/etc/cinder/'
|
||||
|
||||
|
||||
@ -1260,6 +1263,7 @@ class FakeConfiguration(object):
|
||||
pass
|
||||
|
||||
|
||||
@ddt
|
||||
class VMAXUtilsTest(test.TestCase):
|
||||
def setUp(self):
|
||||
self.data = VMAXCommonData()
|
||||
@ -1413,6 +1417,23 @@ class VMAXUtilsTest(test.TestCase):
|
||||
self.utils.get_array_and_device_id,
|
||||
volume, external_ref)
|
||||
|
||||
@data({u'source-name': u'000001'}, {u'source-name': u'00028A'})
|
||||
def test_get_array_and_device_id_invalid_long_id(self, external_ref):
|
||||
volume = deepcopy(self.data.test_volume)
|
||||
# Test for device id more than 5 digits
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.utils.get_array_and_device_id,
|
||||
volume, external_ref)
|
||||
|
||||
@data({u'source-name': u'01'}, {u'source-name': u'028A'},
|
||||
{u'source-name': u'0001'})
|
||||
def test_get_array_and_device_id_invalid_short_id(self, external_ref):
|
||||
volume = deepcopy(self.data.test_volume)
|
||||
# Test for device id less than 5 digits
|
||||
self.assertRaises(exception.VolumeBackendAPIException,
|
||||
self.utils.get_array_and_device_id,
|
||||
volume, external_ref)
|
||||
|
||||
def test_get_pg_short_name(self):
|
||||
pg_under_12_chars = 'pg_11_chars'
|
||||
pg1 = self.utils.get_pg_short_name(pg_under_12_chars)
|
||||
|
@ -338,6 +338,13 @@ class VMAXUtils(object):
|
||||
array = host_list[(len(host_list) - 1)]
|
||||
|
||||
if device_id:
|
||||
if len(device_id) != 5:
|
||||
error_message = (_("Device ID: %(device_id)s is invalid. "
|
||||
"Device ID should be exactly 5 digits.") %
|
||||
{'device_id': device_id})
|
||||
LOG.error(error_message)
|
||||
raise exception.VolumeBackendAPIException(
|
||||
message=error_message)
|
||||
LOG.debug("Get device ID of existing volume - device ID: "
|
||||
"%(device_id)s, Array: %(array)s.",
|
||||
{'device_id': device_id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user