ip_address does not need str() and parse_host_port handles ipv6 or ipv4

note:
@isbm requested ip_address objects stay ip_address. They implement __str__
so they should work without explicit str() conversion if necessary.
This commit is contained in:
Jeremy McMillan 2019-01-08 21:38:00 -06:00 committed by Pedro Algarvio
parent 7a6bc576d1
commit 3574698a70

View file

@ -259,8 +259,8 @@ def prep_ip_port(opts):
# Use given master IP if "ip_only" is set or if master_ip is an ipv6 address without
# a port specified. The is_ipv6 check returns False if brackets are used in the IP
# definition such as master: '[::1]:1234'.
if opts['master_uri_format'] == 'ip_only' or salt.utils.network.is_ipv6(opts['master']):
ret['master'] = str(ipaddress.ip_address(opts['master']))
if opts['master_uri_format'] == 'ip_only':
ret['master'] = ipaddress.ip_address(opts['master'])
else:
host, port = parse_host_port(opts['master'])
ret = {'master': host}