summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Lee <aaron.lee@rackspace.com>2012-02-29 17:07:39 -0600
committerAaron Lee <aaron.lee@rackspace.com>2012-02-29 17:53:16 -0600
commit29d021ba9063a9db16b29a327af9581b58a8e2f7 (patch)
tree75b401d1d7d4b1348aa828d1a17c09132f1b9f72
parent05958d176cd9438c2fd5028256260f9f9ae9ff20 (diff)
downloadnova-29d021ba9063a9db16b29a327af9581b58a8e2f7.tar.gz
nova-29d021ba9063a9db16b29a327af9581b58a8e2f7.tar.xz
nova-29d021ba9063a9db16b29a327af9581b58a8e2f7.zip
Fixes lp931801 and a key_error
The quantum manager should log the errors it receives from quantum, even when charging ahead with the deletes. update: pep8 and less some testing code update: checking log is called and consolidate error messages Change-Id: I8f533e8e54c5e4487614a61a73d9c8e2e756058d
-rw-r--r--nova/network/quantum/manager.py11
-rw-r--r--nova/tests/test_quantum.py30
2 files changed, 35 insertions, 6 deletions
diff --git a/nova/network/quantum/manager.py b/nova/network/quantum/manager.py
index d7370db32..da1bdda21 100644
--- a/nova/network/quantum/manager.py
+++ b/nova/network/quantum/manager.py
@@ -558,6 +558,7 @@ class QuantumManager(manager.FloatingIP, manager.FlatManager):
db.virtual_interface_delete(admin_context, vif['id'])
def deallocate_port(self, interface_id, net_id, q_tenant_id, instance_id):
+ port_id = None
try:
port_id = self.q_conn.get_port_by_attachment(q_tenant_id,
net_id, interface_id)
@@ -574,10 +575,8 @@ class QuantumManager(manager.FloatingIP, manager.FlatManager):
net_id, port_id)
except Exception:
# except anything so the rest of deallocate can succeed
-
- msg = _('port deallocation failed for instance: '
- '|%(instance_id)s|, port_id: |%(port_id)s|')
- LOG.critical(msg % locals())
+ LOG.exception(_('port deallocation failed for instance: '
+ '|%(instance_id)s|, port_id: |%(port_id)s|') % locals())
def deallocate_ip_address(self, context, net_id,
project_id, vif_ref, instance_id):
@@ -595,8 +594,8 @@ class QuantumManager(manager.FloatingIP, manager.FlatManager):
# except anything so the rest of deallocate can succeed
vif_uuid = vif_ref['uuid']
msg = _('ipam deallocation failed for instance: '
- '|%(instance_id)s|, vif_uuid: |%(vif_uuid)s|')
- LOG.critical(msg % locals())
+ '|%(instance_id)s|, vif_uuid: |%(vif_uuid)s|') % locals()
+ LOG.exception(msg)
return ipam_tenant_id
# TODO(bgh): At some point we should consider merging enable_dhcp() and
diff --git a/nova/tests/test_quantum.py b/nova/tests/test_quantum.py
index 3d40f9701..91b14fabd 100644
--- a/nova/tests/test_quantum.py
+++ b/nova/tests/test_quantum.py
@@ -15,6 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
+import mox
+
from nova import context
from nova import db
from nova.db.sqlalchemy import models
@@ -265,6 +267,21 @@ class QuantumDeallocationTestCase(QuantumNovaTestCase):
self.net_man.deallocate_port('interface_id', 'net_id', 'q_tenant_id',
'instance_id')
+ def test_deallocate_port_logs_error(self):
+ quantum = self.mox.CreateMock(
+ quantum_connection.QuantumClientConnection)
+ quantum.get_port_by_attachment('q_tenant_id', 'net_id',
+ 'interface_id').AndRaise(Exception)
+ self.net_man.q_conn = quantum
+
+ self.mox.StubOutWithMock(quantum_manager.LOG, 'exception')
+ quantum_manager.LOG.exception(mox.Regex(r'port deallocation failed'))
+
+ self.mox.ReplayAll()
+
+ self.net_man.deallocate_port('interface_id', 'net_id', 'q_tenant_id',
+ 'instance_id')
+
def test_deallocate_ip_address(self):
ipam = self.mox.CreateMock(melange_ipam_lib.QuantumMelangeIPAMLib)
ipam.get_tenant_id_by_net_id('context', 'net_id', {'uuid': 1},
@@ -274,6 +291,19 @@ class QuantumDeallocationTestCase(QuantumNovaTestCase):
self.net_man.deallocate_ip_address('context', 'net_id', 'project_id',
{'uuid': 1}, 'instance_id')
+ def test_deallocate_ip_address(self):
+ ipam = self.mox.CreateMock(melange_ipam_lib.QuantumMelangeIPAMLib)
+ ipam.get_tenant_id_by_net_id('context', 'net_id', {'uuid': 1},
+ 'project_id').AndRaise(Exception())
+ self.net_man.ipam = ipam
+
+ self.mox.StubOutWithMock(quantum_manager.LOG, 'exception')
+ quantum_manager.LOG.exception(mox.Regex(r'ipam deallocation failed'))
+
+ self.mox.ReplayAll()
+ self.net_man.deallocate_ip_address('context', 'net_id', 'project_id',
+ {'uuid': 1}, 'instance_id')
+
class QuantumManagerTestCase(QuantumNovaTestCase):
def test_create_and_delete_nets(self):