Merge "Network: interface attach and detach raised confusing exception"
This commit is contained in:
@@ -4524,7 +4524,8 @@ class ComputeManager(manager.Manager):
|
||||
if len(network_info) != 1:
|
||||
LOG.error(_('allocate_port_for_instance returned %(ports)s ports')
|
||||
% dict(ports=len(network_info)))
|
||||
raise exception.InterfaceAttachFailed(instance=instance)
|
||||
raise exception.InterfaceAttachFailed(
|
||||
instance_uuid=instance.uuid)
|
||||
image_ref = instance.get('image_ref')
|
||||
image_meta = compute_utils.get_image_metadata(
|
||||
context, self.image_api, image_ref, instance)
|
||||
|
||||
@@ -1306,11 +1306,13 @@ class ConfigDriveUnknownFormat(NovaException):
|
||||
|
||||
|
||||
class InterfaceAttachFailed(Invalid):
|
||||
msg_fmt = _("Failed to attach network adapter device to %(instance)s")
|
||||
msg_fmt = _("Failed to attach network adapter device to "
|
||||
"%(instance_uuid)s")
|
||||
|
||||
|
||||
class InterfaceDetachFailed(Invalid):
|
||||
msg_fmt = _("Failed to detach network adapter device from %(instance)s")
|
||||
msg_fmt = _("Failed to detach network adapter device from "
|
||||
"%(instance_uuid)s")
|
||||
|
||||
|
||||
class InstanceUserDataTooLarge(NovaException):
|
||||
|
||||
@@ -962,7 +962,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
||||
f_instance = objects.Instance._from_db_object(self.context,
|
||||
objects.Instance(),
|
||||
db_instance)
|
||||
e = exception.InterfaceAttachFailed(instance=f_instance)
|
||||
e = exception.InterfaceAttachFailed(instance_uuid=f_instance.uuid)
|
||||
|
||||
@mock.patch.object(compute_utils, 'add_instance_fault_from_exc')
|
||||
@mock.patch.object(self.compute.network_api,
|
||||
|
||||
@@ -248,14 +248,16 @@ class FakeDriver(driver.ComputeDriver):
|
||||
|
||||
def attach_interface(self, instance, image_meta, vif):
|
||||
if vif['id'] in self._interfaces:
|
||||
raise exception.InterfaceAttachFailed('duplicate')
|
||||
raise exception.InterfaceAttachFailed(
|
||||
instance_uuid=instance['uuid'])
|
||||
self._interfaces[vif['id']] = vif
|
||||
|
||||
def detach_interface(self, instance, vif):
|
||||
try:
|
||||
del self._interfaces[vif['id']]
|
||||
except KeyError:
|
||||
raise exception.InterfaceDetachFailed('not attached')
|
||||
raise exception.InterfaceDetachFailed(
|
||||
instance_uuid=instance['uuid'])
|
||||
|
||||
def get_info(self, instance):
|
||||
if instance['name'] not in self.instances:
|
||||
|
||||
@@ -1442,7 +1442,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
LOG.error(_LE('attaching network adapter failed.'),
|
||||
instance=instance)
|
||||
self.vif_driver.unplug(instance, vif)
|
||||
raise exception.InterfaceAttachFailed(instance)
|
||||
raise exception.InterfaceAttachFailed(
|
||||
instance_uuid=instance['uuid'])
|
||||
|
||||
def detach_interface(self, instance, vif):
|
||||
virt_dom = self._lookup_by_name(instance['name'])
|
||||
@@ -1466,7 +1467,8 @@ class LibvirtDriver(driver.ComputeDriver):
|
||||
else:
|
||||
LOG.error(_LE('detaching network adapter failed.'),
|
||||
instance=instance)
|
||||
raise exception.InterfaceDetachFailed(instance)
|
||||
raise exception.InterfaceDetachFailed(
|
||||
instance_uuid=instance['uuid'])
|
||||
|
||||
def _create_snapshot_metadata(self, base, instance, img_fmt, snp_name):
|
||||
metadata = {'is_public': False,
|
||||
|
||||
@@ -1554,7 +1554,7 @@ class VMwareVMOps(object):
|
||||
' %s'),
|
||||
e, instance=instance)
|
||||
raise exception.InterfaceAttachFailed(
|
||||
instance=instance['uuid'])
|
||||
instance_uuid=instance['uuid'])
|
||||
LOG.debug("Reconfigured VM to attach interface", instance=instance)
|
||||
|
||||
def detach_interface(self, instance, vif):
|
||||
@@ -1594,7 +1594,7 @@ class VMwareVMOps(object):
|
||||
'%s'),
|
||||
e, instance=instance)
|
||||
raise exception.InterfaceDetachFailed(
|
||||
instance=instance['uuid'])
|
||||
instance_uuid=instance['uuid'])
|
||||
LOG.debug("Reconfigured VM to detach interface", instance=instance)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user