From 17993724ed993a009c88122857a4e5322156cc95 Mon Sep 17 00:00:00 2001 From: Sergey Kraynev Date: Fri, 13 Feb 2015 03:51:03 -0500 Subject: [PATCH] Move assign_keypair method in base class Change-Id: I69b8db037991f88b38b293560532bf51c0a04378 --- heat_integrationtests/common/test.py | 8 ++++++++ .../functional/test_template_resource.py | 6 +----- heat_integrationtests/functional/test_validation.py | 6 +----- heat_integrationtests/scenario/test_server_cfn_init.py | 10 +--------- heat_integrationtests/scenario/test_volumes.py | 6 +----- 5 files changed, 12 insertions(+), 24 deletions(-) diff --git a/heat_integrationtests/common/test.py b/heat_integrationtests/common/test.py index 7b17d57f2..bfb12605e 100644 --- a/heat_integrationtests/common/test.py +++ b/heat_integrationtests/common/test.py @@ -200,6 +200,14 @@ class HeatIntegrationTest(testscenarios.WithScenarios, self.addCleanup(delete_keypair) return keypair + def assign_keypair(self): + if self.conf.keypair_name: + self.keypair = None + self.keypair_name = self.conf.keypair_name + else: + self.keypair = self.create_keypair() + self.keypair_name = self.keypair.id + @classmethod def _stack_rand_name(cls): return rand_name(cls.__name__) diff --git a/heat_integrationtests/functional/test_template_resource.py b/heat_integrationtests/functional/test_template_resource.py index 80dcdceb7..2e929b410 100644 --- a/heat_integrationtests/functional/test_template_resource.py +++ b/heat_integrationtests/functional/test_template_resource.py @@ -361,11 +361,7 @@ Resources: def setUp(self): super(TemplateResourceUpdateFailedTest, self).setUp() self.client = self.orchestration_client - if self.conf.keypair_name: - self.keypair_name = self.conf.keypair_name - else: - self.keypair = self.create_keypair() - self.keypair_name = self.keypair.id + self.assign_keypair() def test_update_on_failed_create(self): # create a stack with "server" dependent on "keypair", but diff --git a/heat_integrationtests/functional/test_validation.py b/heat_integrationtests/functional/test_validation.py index 52309cd1e..2d9669d00 100644 --- a/heat_integrationtests/functional/test_validation.py +++ b/heat_integrationtests/functional/test_validation.py @@ -29,11 +29,7 @@ class StackValidationTest(test.HeatIntegrationTest): if not self.conf.instance_type: raise self.skipException("No instance_type configured to test") - if self.conf.keypair_name: - self.keypair_name = self.conf.keypair_name - else: - self.keypair = self.create_keypair() - self.keypair_name = self.keypair.id + self.assign_keypair() def test_stack_validate_provider_references_parent_resource(self): template = ''' diff --git a/heat_integrationtests/scenario/test_server_cfn_init.py b/heat_integrationtests/scenario/test_server_cfn_init.py index 9d8512055..a98747c17 100644 --- a/heat_integrationtests/scenario/test_server_cfn_init.py +++ b/heat_integrationtests/scenario/test_server_cfn_init.py @@ -25,18 +25,11 @@ class CfnInitIntegrationTest(test.HeatIntegrationTest): super(CfnInitIntegrationTest, self).setUp() if not self.conf.image_ref: raise self.skipException("No image configured to test") + self.assign_keypair() self.client = self.orchestration_client self.template_name = 'test_server_cfn_init.yaml' self.sub_dir = 'templates' - def assign_keypair(self): - if self.conf.keypair_name: - self.keypair = None - self.keypair_name = self.conf.keypair_name - else: - self.keypair = self.create_keypair() - self.keypair_name = self.keypair.id - def launch_stack(self): net = self._get_default_network() parameters = { @@ -114,6 +107,5 @@ class CfnInitIntegrationTest(test.HeatIntegrationTest): raise e def test_server_cfn_init(self): - self.assign_keypair() sid = self.launch_stack() self.check_stack(sid) diff --git a/heat_integrationtests/scenario/test_volumes.py b/heat_integrationtests/scenario/test_volumes.py index 6a802975e..a60ffb08f 100644 --- a/heat_integrationtests/scenario/test_volumes.py +++ b/heat_integrationtests/scenario/test_volumes.py @@ -27,11 +27,7 @@ class VolumeBackupRestoreIntegrationTest(test.HeatIntegrationTest): def setUp(self): super(VolumeBackupRestoreIntegrationTest, self).setUp() self.client = self.orchestration_client - if self.conf.keypair_name: - self.keypair_name = self.conf.keypair_name - else: - self.keypair = self.create_keypair() - self.keypair_name = self.keypair.id + self.assign_keypair() self.volume_description = 'A test volume description 123' self.volume_size = self.conf.volume_size