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_security_group.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_security_group.py')
-rw-r--r-- | snaps/openstack/create_security_group.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/snaps/openstack/create_security_group.py b/snaps/openstack/create_security_group.py index 57f7284..4e98e82 100644 --- a/snaps/openstack/create_security_group.py +++ b/snaps/openstack/create_security_group.py @@ -37,8 +37,8 @@ class OpenStackSecurityGroup: """ self.__os_creds = os_creds self.sec_grp_settings = sec_grp_settings - self.__neutron = neutron_utils.neutron_client(os_creds) - self.__keystone = keystone_utils.keystone_client(os_creds) + self.__neutron = None + self.__keystone = None # Attributes instantiated on create() self.__security_group = None @@ -52,6 +52,9 @@ class OpenStackSecurityGroup: :param cleanup: Denotes whether or not this is being called for cleanup or not :return: the OpenStack security group object """ + self.__neutron = neutron_utils.neutron_client(self.__os_creds) + self.__keystone = keystone_utils.keystone_client(self.__os_creds) + logger.info('Creating security group %s...' % self.sec_grp_settings.name) self.__security_group = neutron_utils.get_security_group(self.__neutron, self.sec_grp_settings.name) |