diff options
author | spisarski <s.pisarski@cablelabs.com> | 2018-03-09 14:42:34 -0700 |
---|---|---|
committer | spisarski <s.pisarski@cablelabs.com> | 2018-03-12 08:28:45 -0600 |
commit | 9e9e09590cce321f55996c1a31370ffdf28251b0 (patch) | |
tree | a0e031d0365604f4a299ad8f748fe10d09a75a8a /snaps/openstack/utils/launch_utils.py | |
parent | fb0ab37c323717ca10ac3f3bda24ae390635495e (diff) |
Closing keystone sessions after done with them.
By not closing all of the keystone sessions being created when
running all of the tests, this may be the root cause to the IOError
occasionally being observed:
IOError: [Errno 24] Too many open files
JIRA: SNAPS-285
Change-Id: I7fc7ab0c6cdd02f1ae32bb3ae4f121cb465d5693
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/utils/launch_utils.py')
-rw-r--r-- | snaps/openstack/utils/launch_utils.py | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/snaps/openstack/utils/launch_utils.py b/snaps/openstack/utils/launch_utils.py index 1899ef6..fd78bd2 100644 --- a/snaps/openstack/utils/launch_utils.py +++ b/snaps/openstack/utils/launch_utils.py @@ -48,7 +48,7 @@ from snaps.openstack.create_user import OpenStackUser from snaps.openstack.create_volume import OpenStackVolume from snaps.openstack.create_volume_type import OpenStackVolumeType from snaps.openstack.os_credentials import OSCreds, ProxySettings -from snaps.openstack.utils import deploy_utils, neutron_utils +from snaps.openstack.utils import deploy_utils, neutron_utils, keystone_utils from snaps.provisioning import ansible_utils logger = logging.getLogger('lanuch_utils') @@ -713,18 +713,22 @@ def __get_router_variable_value(var_config_values, routers_dict, os_creds): if router_creator: if 'external_fixed_ip' == var_config_values.get('attr'): - neutron = neutron_utils.neutron_client(os_creds) - ext_nets = neutron_utils.get_external_networks(neutron) - - subnet_name = var_config_values.get('subnet_name') - - for ext_net in ext_nets: - for subnet in ext_net.subnets: - if subnet_name == subnet.name: - router = router_creator.get_router() - for fixed_ips in router.external_fixed_ips: - if subnet.id == fixed_ips['subnet_id']: - return fixed_ips['ip_address'] + session = keystone_utils.keystone_session(os_creds) + neutron = neutron_utils.neutron_client(os_creds, session) + try: + ext_nets = neutron_utils.get_external_networks(neutron) + + subnet_name = var_config_values.get('subnet_name') + + for ext_net in ext_nets: + for subnet in ext_net.subnets: + if subnet_name == subnet.name: + router = router_creator.get_router() + for fixed_ips in router.external_fixed_ips: + if subnet.id == fixed_ips['subnet_id']: + return fixed_ips['ip_address'] + finally: + keystone_utils.close_session(session) def __get_vm_port_variable_value(var_config_values, vm_dict): |