From b40abd3145df4cb732b43261bb1608375eb3b0b7 Mon Sep 17 00:00:00 2001 From: John Tran Date: Wed, 8 Jun 2011 15:23:33 -0700 Subject: [PATCH 1/7] added a test for allocate_address & added error handling for api instead of returning 'UnknownError', will give information 'AllocateAddressError: NoMoreAddresses --- nova/tests/test_cloud.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index ba133c860..d6d90e873 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -115,6 +115,16 @@ class CloudTestCase(test.TestCase): public_ip=address) db.floating_ip_destroy(self.context, address) + def test_allocate_address(self): + address = "10.10.10.10" + allocate = self.cloud.allocate_address + db.floating_ip_create(self.context, + {'address': address, + 'host': self.network.host}) + self.assertEqual(allocate(self.context)['publicIp'], address) + db.floating_ip_destroy(self.context, address) + self.assertRaises(rpc.RemoteError, allocate, self.context) + def test_associate_disassociate_address(self): """Verifies associate runs cleanly without raising an exception""" address = "10.10.10.10" From 1a9620b4a4d5fe947f0e9f38fbfff2fa79c44531 Mon Sep 17 00:00:00 2001 From: John Tran Date: Wed, 8 Jun 2011 17:15:35 -0700 Subject: [PATCH 2/7] raises exception.NoFloatingIpsDefined instead of UnknownError --- nova/tests/test_cloud.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index d6d90e873..7cb13c919 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -123,7 +123,8 @@ class CloudTestCase(test.TestCase): 'host': self.network.host}) self.assertEqual(allocate(self.context)['publicIp'], address) db.floating_ip_destroy(self.context, address) - self.assertRaises(rpc.RemoteError, allocate, self.context) + self.assertRaises(exception.NoFloatingIpsDefined, allocate, + self.context) def test_associate_disassociate_address(self): """Verifies associate runs cleanly without raising an exception""" From 126a95c22dc3c27ad0e224f81e86a076beb1d955 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Thu, 9 Jun 2011 03:35:59 +0000 Subject: [PATCH 3/7] Support multiple glance-api servers --- nova/flags.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nova/flags.py b/nova/flags.py index d5090edba..51f0536e8 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -270,8 +270,10 @@ DEFINE_list('region_list', DEFINE_string('connection_type', 'libvirt', 'libvirt, xenapi or fake') DEFINE_string('aws_access_key_id', 'admin', 'AWS Access ID') DEFINE_string('aws_secret_access_key', 'admin', 'AWS Access Key') -DEFINE_integer('glance_port', 9292, 'glance port') -DEFINE_string('glance_host', '$my_ip', 'glance host') +# NOTE(sirp): my_ip interpolation doesn't work within nested structures +DEFINE_list('glance_api_servers', + [('127.0.0.1', 9292)], + 'list of glance servers available to nova') DEFINE_integer('s3_port', 3333, 's3 port') DEFINE_string('s3_host', '$my_ip', 's3 host (for infrastructure)') DEFINE_string('s3_dmz', '$my_ip', 's3 dmz ip (for instances)') From 2351f8f305679017602d4445f4131d109b53c907 Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Thu, 9 Jun 2011 21:36:20 +0000 Subject: [PATCH 4/7] Fixing code per review comments --- nova/flags.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/flags.py b/nova/flags.py index 545cf90fe..acfcf8d68 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -272,8 +272,8 @@ DEFINE_string('aws_access_key_id', 'admin', 'AWS Access ID') DEFINE_string('aws_secret_access_key', 'admin', 'AWS Access Key') # NOTE(sirp): my_ip interpolation doesn't work within nested structures DEFINE_list('glance_api_servers', - [('127.0.0.1', 9292)], - 'list of glance servers available to nova') + ['127.0.0.1:9292'], + 'list of glance api servers available to nova (host:port)') DEFINE_integer('s3_port', 3333, 's3 port') DEFINE_string('s3_host', '$my_ip', 's3 host (for infrastructure)') DEFINE_string('s3_dmz', '$my_ip', 's3 dmz ip (for instances)') From 95276b7c913379bc8a377a12f5e54cd12b9e2419 Mon Sep 17 00:00:00 2001 From: John Tran Date: Fri, 10 Jun 2011 10:24:24 -0700 Subject: [PATCH 5/7] style change --- nova/tests/test_cloud.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index 7cb13c919..c8313a5d3 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -123,7 +123,8 @@ class CloudTestCase(test.TestCase): 'host': self.network.host}) self.assertEqual(allocate(self.context)['publicIp'], address) db.floating_ip_destroy(self.context, address) - self.assertRaises(exception.NoFloatingIpsDefined, allocate, + self.assertRaises(exception.NoFloatingIpsDefined, + allocate, self.context) def test_associate_disassociate_address(self): From e520170fec412d0f5e79c771a5ff2babe3c47356 Mon Sep 17 00:00:00 2001 From: John Tran Date: Fri, 10 Jun 2011 11:10:58 -0700 Subject: [PATCH 6/7] added new exception more descriptive of not having available floating addresses avail for allocation --- nova/exception.py | 4 ++++ nova/tests/test_cloud.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/nova/exception.py b/nova/exception.py index 69b3e0359..1571dd032 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -376,6 +376,10 @@ class NoFloatingIpsDefinedForInstance(NoFloatingIpsDefined): message = _("Zero floating ips defined for instance %(instance_id)s.") +class NoMoreFloatingIps(NotFound): + message = _("Zero floating ips available.") + + class KeypairNotFound(NotFound): message = _("Keypair %(keypair_name)s not found for user %(user_id)s") diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index c8313a5d3..13046f861 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -123,7 +123,7 @@ class CloudTestCase(test.TestCase): 'host': self.network.host}) self.assertEqual(allocate(self.context)['publicIp'], address) db.floating_ip_destroy(self.context, address) - self.assertRaises(exception.NoFloatingIpsDefined, + self.assertRaises(exception.NoMoreFloatingIps, allocate, self.context)