From 0502a2b35fb1a4424e7249cb9f39d7fc98bf37b5 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Mon, 20 Jun 2011 11:56:15 -0500 Subject: updated the exceptions around virtual interface creation, updated flatDHCP manager comment --- nova/db/sqlalchemy/api.py | 9 ++++++--- nova/exception.py | 4 ++++ nova/network/manager.py | 7 +++---- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index f86180b1f..3cb35b649 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -816,9 +816,12 @@ def virtual_interface_create(context, values): :param values: = dict containing column values """ - vif_ref = models.VirtualInterface() - vif_ref.update(values) - vif_ref.save() + try: + vif_ref = models.VirtualInterface() + vif_ref.update(values) + vif_ref.save() + except IntegrityError: + raise exception.VirtualInterfaceCreateException() return vif_ref diff --git a/nova/exception.py b/nova/exception.py index a4c1b2d30..8e67de965 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -118,6 +118,10 @@ class NovaException(Exception): return self._error_string +class VirtualInterfaceCreateException(NovaException): + message = _("Virtual Interface creation failed") + + class VirtualInterfaceMacAddressException(NovaException): message = _("5 attempts to create virtual interface" "with unique mac address failed") diff --git a/nova/network/manager.py b/nova/network/manager.py index 68818c6d7..f51738643 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -62,7 +62,6 @@ from nova import quota from nova import utils from nova import rpc from nova.network import api as network_api -from sqlalchemy.exc import IntegrityError import random @@ -452,7 +451,7 @@ class NetworkManager(manager.SchedulerDependentManager): try: self.db.virtual_interface_create(context, vif) break - except IntegrityError: + except exception.VirtualInterfaceCreateException: vif['address'] = self.generate_mac_address() else: self.db.virtual_interface_delete_by_instance(context, @@ -711,8 +710,8 @@ class FlatDHCPManager(FloatingIP, RPCAllocateFixedIP, NetworkManager): """Flat networking with dhcp. FlatDHCPManager will start up one dhcp server to give out addresses. - It never injects network settings into the guest. Otherwise it behaves - like FlatDHCPManager. + It never injects network settings into the guest. It also manages bridges. + Otherwise it behaves like FlatManager. """ -- cgit