From 9651c889f1b966dc2733daf7eabbb5e62268654d Mon Sep 17 00:00:00 2001 From: Cédric Ollivier Date: Sun, 29 Apr 2018 18:38:48 +0200 Subject: Fix NoneType in create_router.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It lets Neutron handle str or unicode instead of returning None. It reverts the first proposal [1] which raises side effects [2]. [1] https://gerrit.opnfv.org/gerrit/#/c/56171/ [2] https://build.opnfv.org/ci/view/functest/job/functest-compass-baremetal-daily-master/126/console Change-Id: I1b45c7d6118321dd67343f31253f154abae73655 Signed-off-by: Cédric Ollivier --- snaps/openstack/create_router.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'snaps') diff --git a/snaps/openstack/create_router.py b/snaps/openstack/create_router.py index 441b21a..0b93359 100644 --- a/snaps/openstack/create_router.py +++ b/snaps/openstack/create_router.py @@ -14,8 +14,6 @@ # limitations under the License. import logging -import six - from neutronclient.common.exceptions import NotFound, Unauthorized from snaps.config.router import RouterConfig @@ -151,10 +149,6 @@ class OpenStackRouter(OpenStackNetworkObject): :param sub_config: :return: """ - if isinstance(sub_config, six.text_type): - return neutron_utils.get_subnet_by_name( - self._neutron, self._keystone, - subnet_name=sub_config) if isinstance(sub_config, dict): sub_dict = sub_config['subnet'] network = neutron_utils.get_network( @@ -165,6 +159,10 @@ class OpenStackRouter(OpenStackNetworkObject): return neutron_utils.get_subnet( self._neutron, network, subnet_name=sub_dict['subnet_name']) + else: + return neutron_utils.get_subnet_by_name( + self._neutron, self._keystone, + subnet_name=sub_config) def clean(self): """ -- cgit 1.2.3-korg