From e102cfcdc8b81de9fa80ccc00ec44059ac322944 Mon Sep 17 00:00:00 2001 From: Tim Briggs Date: Fri, 22 Apr 2016 11:41:39 -0700 Subject: [PATCH] Add better IPv6 addr match check when starting node --- calico_node/filesystem/startup.py | 29 ++++++++++++++++++++++------- calico_test/tests/st/utils/utils.py | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/calico_node/filesystem/startup.py b/calico_node/filesystem/startup.py index f99c8e23c..f4bea4fc9 100644 --- a/calico_node/filesystem/startup.py +++ b/calico_node/filesystem/startup.py @@ -1,3 +1,17 @@ +# Copyright 2016 Metaswitch Networks +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + import os import sys @@ -171,13 +185,14 @@ def warn_if_unknown_ip(ip, ip6): :param ip6: IPv6 address which should be present on the host. :return: None """ - if ip and ip not in get_host_ips(version=4, exclude=["docker0"]): - print "WARNING: Could not confirm that the provided IPv4 address is assigned" \ - " to this host." - - if ip6 and ip6 not in get_host_ips(version=6, exclude=["docker0"]): - print "WARNING: Could not confirm that the provided IPv6 address is assigned" \ - " to this host." + if ip and IPAddress(ip) not in get_host_ips(version=4, exclude=["docker0"]): + print "WARNING: Could not confirm that the provided IPv4 address is" \ + " assigned to this host." + + if ip6 and IPAddress(ip6) not in get_host_ips(version=6, + exclude=["docker0"]): + print "WARNING: Could not confirm that the provided IPv6 address is" \ + " assigned to this host." def warn_if_hostname_conflict(ip): diff --git a/calico_test/tests/st/utils/utils.py b/calico_test/tests/st/utils/utils.py index 59cfb626f..2d53da66c 100644 --- a/calico_test/tests/st/utils/utils.py +++ b/calico_test/tests/st/utils/utils.py @@ -56,7 +56,7 @@ def get_ip(v6=False): version = 6 if v6 else 4 ips = get_host_ips(version) if ips: - ip = ips[0] + ip = str(ips[0]) return ip