Fix inventory parsing so that FQDN can be parsed without throwing ssh

port parsing errors
Fixes problesm introduced by 948d019fef
Adds testcases to defend
This commit is contained in:
John Barker
2013-12-18 21:33:05 +00:00
parent 3f81c3c416
commit 4bf9f714d0
3 changed files with 28 additions and 4 deletions

View File

@@ -89,10 +89,10 @@ class InventoryParser(object):
# 0. A hostname that contains a range pesudo-code and a port
# 1. A hostname that contains just a port
if hostname.count(":") > 1:
# probably an IPv6 addresss, so check for the format
# XXX:XXX::XXX.port, otherwise we'll just assume no
# port is set
if hostname.find(".") != -1:
# Possible an IPv6 address, or maybe a host line with multiple ranges
# IPv6 with Port XXX:XXX::XXX.port
# FQDN foo.example.com
if hostname.count(".") == 1:
(hostname, port) = hostname.rsplit(".", 1)
elif (hostname.find("[") != -1 and
hostname.find("]") != -1 and