Added missing raise statement when checking the config driver format
Closes-bug: #1275772
(cherry-picked from commit 378c28a8c0
)
Change-Id: I636525d0272511d4192c43d18c56e867fb7514d8
This commit is contained in:
parent
5aab5f03cd
commit
b57cc309bf
|
@ -415,7 +415,7 @@ class HyperVAPITestCase(test.NoDBTestCase):
|
|||
mox.IsA(str))
|
||||
m.WithSideEffects(self._add_ide_disk)
|
||||
|
||||
def _test_spawn_config_drive(self, use_cdrom):
|
||||
def _test_spawn_config_drive(self, use_cdrom, format_error=False):
|
||||
self.flags(force_config_drive=True)
|
||||
self.flags(config_drive_cdrom=use_cdrom, group='hyperv')
|
||||
self.flags(mkisofs_cmd='mkisofs.exe')
|
||||
|
@ -427,14 +427,25 @@ class HyperVAPITestCase(test.NoDBTestCase):
|
|||
expected_ide_disks = 2
|
||||
expected_ide_dvds = 0
|
||||
|
||||
self._test_spawn_instance(expected_ide_disks=expected_ide_disks,
|
||||
expected_ide_dvds=expected_ide_dvds,
|
||||
config_drive=True,
|
||||
use_cdrom=use_cdrom)
|
||||
if format_error:
|
||||
self.assertRaises(vmutils.UnsupportedConfigDriveFormatException,
|
||||
self._test_spawn_instance,
|
||||
with_exception=True,
|
||||
config_drive=True,
|
||||
use_cdrom=use_cdrom)
|
||||
else:
|
||||
self._test_spawn_instance(expected_ide_disks=expected_ide_disks,
|
||||
expected_ide_dvds=expected_ide_dvds,
|
||||
config_drive=True,
|
||||
use_cdrom=use_cdrom)
|
||||
|
||||
def test_spawn_config_drive(self):
|
||||
self._test_spawn_config_drive(False)
|
||||
|
||||
def test_spawn_config_drive_format_error(self):
|
||||
CONF.set_override('config_drive_format', 'wrong_format')
|
||||
self._test_spawn_config_drive(True, True)
|
||||
|
||||
def test_spawn_config_drive_cdrom(self):
|
||||
self._test_spawn_config_drive(True)
|
||||
|
||||
|
@ -1034,7 +1045,7 @@ class HyperVAPITestCase(test.NoDBTestCase):
|
|||
block_device_info,
|
||||
ephemeral_storage=ephemeral_storage)
|
||||
|
||||
if config_drive:
|
||||
if config_drive and not with_exception:
|
||||
self._setup_spawn_config_drive_mocks(use_cdrom)
|
||||
|
||||
# TODO(alexpilotti) Based on where the exception is thrown
|
||||
|
|
|
@ -274,8 +274,9 @@ class VMOps(object):
|
|||
|
||||
def _create_config_drive(self, instance, injected_files, admin_password):
|
||||
if CONF.config_drive_format != 'iso9660':
|
||||
vmutils.HyperVException(_('Invalid config_drive_format "%s"') %
|
||||
CONF.config_drive_format)
|
||||
raise vmutils.UnsupportedConfigDriveFormatException(
|
||||
_('Invalid config_drive_format "%s"') %
|
||||
CONF.config_drive_format)
|
||||
|
||||
LOG.info(_('Using config drive for instance: %s'), instance=instance)
|
||||
|
||||
|
|
|
@ -56,6 +56,11 @@ class HyperVAuthorizationException(HyperVException):
|
|||
super(HyperVException, self).__init__(message)
|
||||
|
||||
|
||||
class UnsupportedConfigDriveFormatException(HyperVException):
|
||||
def __init__(self, message=None):
|
||||
super(HyperVException, self).__init__(message)
|
||||
|
||||
|
||||
class VMUtils(object):
|
||||
|
||||
# These constants can be overridden by inherited classes
|
||||
|
|
Loading…
Reference in New Issue