Adds support for converting a MAC address to an integer.
Example: --- - hosts: local tasks: - set_fact: mac_str="52:54:00:00:00:00" - set_fact: base_mac="{{ mac_str | macaddr('int') }}" - debug: msg="{{ (base_mac|int + 257) | macaddr('linux') }}" # 52:54:00:00:01:01
This commit is contained in:
parent
13f00f3073
commit
bd0066d621
1 changed files with 4 additions and 0 deletions
|
@ -228,6 +228,9 @@ def _bool_hwaddr_query(v):
|
||||||
if v:
|
if v:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def _int_hwaddr_query(v):
|
||||||
|
return int(v)
|
||||||
|
|
||||||
def _cisco_query(v):
|
def _cisco_query(v):
|
||||||
v.dialect = netaddr.mac_cisco
|
v.dialect = netaddr.mac_cisco
|
||||||
return str(v)
|
return str(v)
|
||||||
|
@ -637,6 +640,7 @@ def hwaddr(value, query = '', alias = 'hwaddr'):
|
||||||
'': _empty_hwaddr_query,
|
'': _empty_hwaddr_query,
|
||||||
'bare': _bare_query,
|
'bare': _bare_query,
|
||||||
'bool': _bool_hwaddr_query,
|
'bool': _bool_hwaddr_query,
|
||||||
|
'int': _int_hwaddr_query,
|
||||||
'cisco': _cisco_query,
|
'cisco': _cisco_query,
|
||||||
'eui48': _win_query,
|
'eui48': _win_query,
|
||||||
'linux': _linux_query,
|
'linux': _linux_query,
|
||||||
|
|
Loading…
Reference in a new issue