diff options
author | spisarski <s.pisarski@cablelabs.com> | 2017-05-04 12:43:53 -0600 |
---|---|---|
committer | spisarski <s.pisarski@cablelabs.com> | 2017-05-08 09:31:16 -0600 |
commit | d1c4675e5c35257b84cd69969c6e67575faf19db (patch) | |
tree | 63ff3b41ff445b8c192ec33c0aefb913a112b613 /snaps/openstack/utils/neutron_utils.py | |
parent | 40c96233ca4c27de1b3d8b53187c302ddd6208a2 (diff) |
Modified code to support both Python 2.7 and 3.x
* Tested on Python 2.7.10 and 3.4.4
* Updated installation documentation
JIRA: SNAPS-30
Change-Id: I94a37d218be8ea47bbbcfb560197737430fcb3ba
Signed-off-by: spisarski <s.pisarski@cablelabs.com>
Diffstat (limited to 'snaps/openstack/utils/neutron_utils.py')
-rw-r--r-- | snaps/openstack/utils/neutron_utils.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/snaps/openstack/utils/neutron_utils.py b/snaps/openstack/utils/neutron_utils.py index 6c92d2e..a65a42f 100644 --- a/snaps/openstack/utils/neutron_utils.py +++ b/snaps/openstack/utils/neutron_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Cable Television Laboratories, Inc. ("CableLabs") +# Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs") # and others. All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,7 +16,7 @@ import logging from neutronclient.common.exceptions import NotFound from neutronclient.neutron.client import Client -import keystone_utils +from snaps.openstack.utils import keystone_utils __author__ = 'spisarski' @@ -80,7 +80,7 @@ def get_network(neutron, network_name, project_id=None): net_filter['project_id'] = project_id networks = neutron.list_networks(**net_filter) - for network, netInsts in networks.iteritems(): + for network, netInsts in networks.items(): for inst in netInsts: if inst.get('name') == network_name: if project_id and inst.get('project_id') == project_id: @@ -98,7 +98,7 @@ def get_network_by_id(neutron, network_id): :return: """ networks = neutron.list_networks(**{'id': network_id}) - for network, netInsts in networks.iteritems(): + for network, netInsts in networks.items(): for inst in netInsts: if inst.get('id') == network_id: return {'network': inst} @@ -144,7 +144,7 @@ def get_subnet_by_name(neutron, subnet_name): :return: """ subnets = neutron.list_subnets(**{'name': subnet_name}) - for subnet, subnetInst in subnets.iteritems(): + for subnet, subnetInst in subnets.items(): for inst in subnetInst: if inst.get('name') == subnet_name: return {'subnet': inst} @@ -189,7 +189,7 @@ def get_router_by_name(neutron, router_name): :return: """ routers = neutron.list_routers(**{'name': router_name}) - for router, routerInst in routers.iteritems(): + for router, routerInst in routers.items(): for inst in routerInst: if inst.get('name') == router_name: return {'router': inst} @@ -228,10 +228,10 @@ def remove_interface_router(neutron, router, subnet=None, port=None): logger.info('Removing router interface from router named ' + router['router']['name']) neutron.remove_interface_router(router=router['router']['id'], body=__create_port_json_body(subnet, port)) except NotFound as e: - logger.warn('Could not remove router interface. NotFound - ' + e.message) + logger.warning('Could not remove router interface. NotFound - ' + str(e)) pass else: - logger.warn('Could not remove router interface, No router object') + logger.warning('Could not remove router interface, No router object') def __create_port_json_body(subnet=None, port=None): |