1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

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

This commit is contained in:
kokel 2018-01-17 18:49:49 +01:00 committed by Nathaniel Case
parent 529404adc4
commit 66f654cb64

View file

@ -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 ----