diff options
author | spisarski <s.pisarski@cablelabs.com> | 2017-05-16 13:57:26 -0600 |
---|---|---|
committer | spisarski <s.pisarski@cablelabs.com> | 2017-05-16 13:57:26 -0600 |
commit | 6fd1af82cd7bf41274c4e1620006004b79628759 (patch) | |
tree | e60a9f18c777892f5fe3cb0a8b279cc99b847e20 /snaps/openstack/create_keypairs.py | |
parent | f57080bd2a6412c8fdc50c68111e780f6c36a360 (diff) |
Ensure creators' constructors cannot raise exceptions.
While creating unit tests for vPing that is using SNAPS, exceptions can
be raised when retrieving their respective OpenStack clients with
incorrect credentials. Moved client retrieval to the create() method
which one should expect exceptions to be raised.
JIRA: SNAPS-81
Change-Id: Id8e4279f60b97704b25a89c6312dcf2ebdc3f459
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/create_keypairs.py')
-rw-r--r-- | snaps/openstack/create_keypairs.py | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/snaps/openstack/create_keypairs.py b/snaps/openstack/create_keypairs.py index 6af40c6..250acec 100644 --- a/snaps/openstack/create_keypairs.py +++ b/snaps/openstack/create_keypairs.py @@ -35,6 +35,7 @@ class OpenStackKeypair: :param os_creds: The credentials to connect with OpenStack :param keypair_settings: The settings used to create a keypair """ + self.__nova = None self.__os_creds = os_creds self.keypair_settings = keypair_settings self.__nova = nova_utils.nova_client(os_creds) @@ -47,6 +48,8 @@ class OpenStackKeypair: Responsible for creating the keypair object. :param cleanup: Denotes whether or not this is being called for cleanup or not """ + self.__nova = nova_utils.nova_client(self.__os_creds) + logger.info('Creating keypair %s...' % self.keypair_settings.name) self.__keypair = nova_utils.get_keypair_by_name(self.__nova, self.keypair_settings.name) |