Throw specific InvalidVIFTypeError on attach_nic

When a invalid vif_type was given, we used to throw a generic
exception. This patch introduces a new specific exception
InvalidVIFTypeError.

Change-Id: I225e1ccb6fead59b26a011b0ad02b28983751f87
This commit is contained in:
Andreas Scheuring 2018-01-24 10:07:31 +01:00
parent d0b5290a8f
commit 07055fe19e
3 changed files with 9 additions and 2 deletions

View File

@ -267,7 +267,7 @@ class VmPartitionInstanceTestCase(TestCase):
vif.type = "non_dpm_vswitch"
self.assertRaises(
Exception,
exceptions.InvalidVIFTypeError,
self.partition_inst.attach_nic, vif)
@mock.patch.object(vm.PartitionInstance, 'attach_nic')

View File

@ -26,6 +26,13 @@ class MaxAmountOfInstancePortsExceededError(NovaException):
.format(max_ports=MAX_NICS_PER_PARTITION)
class InvalidVIFTypeError(NovaException):
msg_fmt = _("The vif type %(type)s is not supported by nova-dpm. The "
"only supported type is 'dpm_vswitch'. Please "
"configure the networking-dpm agent to only use OSA or "
"hipersockets adapters.")
class BootOsSpecificParametersPropertyExceededError(NovaException):
"""The boot-os-specific-parameters property would exceed the allowed max"""
msg_fmt = _("Exceeded the maximum len for the partitions "

View File

@ -236,7 +236,7 @@ class PartitionInstance(object):
# Only dpm_vswitch attachments are supported for now
if vif_obj.type != "dpm_vswitch":
raise Exception
raise exceptions.InvalidVIFTypeError(type=vif_obj.type)
dpm_nic_dict = self._get_nic_properties_dict(vif_obj)
LOG.debug("Creating NIC with properties: %s", dpm_nic_dict)