filter ipaddr: add custom delimiter option to ip4_hex(); fix format (#26862)

pull/35103/head
kokel 7 years ago committed by Nathaniel Case
parent 529404adc4
commit 66f654cb64

@ -982,10 +982,10 @@ def _need_netaddr(f_name, *args, **kwargs):
'installed on the ansible controller' % f_name)
def ip4_hex(arg):
def ip4_hex(arg, delimiter=''):
''' Convert an IPv4 address to Hexadecimal notation '''
numbers = list(map(int, arg.split('.')))
return '{:02x}{:02x}{:02x}{:02x}'.format(*numbers)
return '{0:02x}{sep}{1:02x}{sep}{2:02x}{sep}{3:02x}'.format(*numbers, sep=delimiter)
# ---- Ansible filters ----

Loading…
Cancel
Save