From dd9c27f999221001bae9faa03571645824d2a681 Mon Sep 17 00:00:00 2001 From: Stanislaw Pitucha Date: Thu, 28 Feb 2013 19:50:21 +0000 Subject: Delegate authentication to quantumclient Quantumclient can deal with authentication, getting the token and refreshing it when needed. There should be no need for nova to do those explicitly. Additionally nova can save some time not having to recreate the Client object on each request. Fix a couple of places that relied on the exceptions module being imported inside quantumv2. Part of blueprint fewer-networking-token-checks Fixed bug 1177579 Change-Id: I007cef1f0bd688036fa45d79792e6e350c145f05 --- nova/tests/network/test_quantumv2.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'nova/tests') diff --git a/nova/tests/network/test_quantumv2.py b/nova/tests/network/test_quantumv2.py index ec1e88d86..3a2b8a7c4 100644 --- a/nova/tests/network/test_quantumv2.py +++ b/nova/tests/network/test_quantumv2.py @@ -19,6 +19,8 @@ import uuid import mox from oslo.config import cfg +from quantumclient import client as quantum_client +from quantumclient.common import exceptions as quantum_exceptions from quantumclient.v2_0 import client from nova.compute import flavors @@ -102,6 +104,17 @@ class TestQuantumClient(test.TestCase): self.mox.ReplayAll() quantumv2.get_client(my_context) + def test_cached_admin_client(self): + self.mox.StubOutWithMock(quantum_client.HTTPClient, "authenticate") + + # should be called one time only + quantum_client.HTTPClient.authenticate() + self.mox.ReplayAll() + + admin1 = quantumv2.get_client(None, admin=True) + admin2 = quantumv2.get_client(None, admin=True) + self.assertIs(admin1, admin2) + def test_withouttoken_keystone_connection_error(self): self.flags(quantum_auth_strategy='keystone') self.flags(quantum_url='http://anyhost/') @@ -1223,7 +1236,7 @@ class TestQuantumv2(test.TestCase): def test_list_floating_ips_without_l3_support(self): api = quantumapi.API() - QuantumNotFound = quantumv2.exceptions.QuantumClientException( + QuantumNotFound = quantum_exceptions.QuantumClientException( status_code=404) self.moxed_client.list_floatingips( fixed_ip_address='1.1.1.1', port_id=1).AndRaise(QuantumNotFound) -- cgit