From 5f442a5f5e5eac1f9de0984ea243eb7414bb5a22 Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Fri, 17 Jun 2011 18:26:31 +0400 Subject: [PATCH 1/3] Made hostname independent from ec2 id. Add generation of hostnames based on display name. --- nova/tests/test_compute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index b4ac2dbc..8af2665b 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -128,7 +128,7 @@ class ComputeTestCase(test.TestCase): instance_ref = models.Instance() instance_ref['id'] = 1 instance_ref['volumes'] = [vol1, vol2] - instance_ref['hostname'] = 'i-00000001' + instance_ref['hostname'] = 'hostname-1' instance_ref['host'] = 'dummy' return instance_ref From 98d60848b9ac61bae1079065537bece6bf367018 Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Wed, 29 Jun 2011 13:37:24 +0400 Subject: [PATCH 2/3] Add test for hostname generation. --- nova/tests/test_compute.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 8af2665b..11ae7403 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -160,6 +160,18 @@ class ComputeTestCase(test.TestCase): db.security_group_destroy(self.context, group['id']) db.instance_destroy(self.context, ref[0]['id']) + def test_default_hostname_generator(self): + cases = [(None, 'server_1'), ('Hello, Server!', 'hello_server'), + ('<}\x1fh\x10e\x08l\x02l\x05o\x12!{>', 'hello')] + for display_name, hostname in cases: + ref = self.compute_api.create(self.context, + instance_types.get_default_instance_type(), None, + display_name=display_name) + try: + self.assertEqual(ref[0]['hostname'], hostname) + finally: + db.instance_destroy(self.context, ref[0]['id']) + def test_destroy_instance_disassociates_security_groups(self): """Make sure destroying disassociates security groups""" group = self._create_group() From b60c626ee23bc7a99d62c167f7ba87fb9415364d Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Thu, 30 Jun 2011 15:43:18 +0400 Subject: [PATCH 3/3] PEP8 fix. --- nova/tests/test_compute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 11ae7403..a53d94d7 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -171,7 +171,7 @@ class ComputeTestCase(test.TestCase): self.assertEqual(ref[0]['hostname'], hostname) finally: db.instance_destroy(self.context, ref[0]['id']) - + def test_destroy_instance_disassociates_security_groups(self): """Make sure destroying disassociates security groups""" group = self._create_group()