Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
ansible
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
ansible
Commits
616fda57
Commit
616fda57
authored
Feb 01, 2015
by
Toshio Kuratomi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First try at only failing if the filter is actually used.
parent
7e465541
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
21 deletions
+27
-21
lib/ansible/runner/filter_plugins/ipaddr.py
+27
-21
No files found.
lib/ansible/runner/filter_plugins/ipaddr.py
View file @
616fda57
...
...
@@ -19,8 +19,13 @@ from ansible import errors
try
:
import
netaddr
except
Exception
,
e
:
raise
errors
.
AnsibleFilterError
(
'python-netaddr package is not installed'
)
except
ImportError
:
# in this case, we'll make the filters return error messages (see bottom)
netaddr
=
None
else
:
class
mac_linux
(
netaddr
.
mac_unix
):
pass
mac_linux
.
word_fmt
=
'
%.2
x'
# ---- IP address and network filters ----
...
...
@@ -500,32 +505,33 @@ def hwaddr(value, query = '', alias = 'hwaddr'):
return
False
class
mac_linux
(
netaddr
.
mac_unix
):
pass
mac_linux
.
word_fmt
=
'
%.2
x'
def
macaddr
(
value
,
query
=
''
):
return
hwaddr
(
value
,
query
,
alias
=
'macaddr'
)
def
_need_netaddr
(
*
args
,
**
kwargs
):
raise
errors
.
AnsibleFilterError
(
'python-netaddr package is not installed'
)
# ---- Ansible filters ----
class
FilterModule
(
object
):
''' IP address and network manipulation filters '''
filter_map
=
{
# IP addresses and networks
'ipaddr'
:
ipaddr
,
'ipwrap'
:
ipwrap
,
'ipv4'
:
ipv4
,
'ipv6'
:
ipv6
,
'ipsubnet'
:
ipsubnet
,
# MAC / HW addresses
'hwaddr'
:
hwaddr
,
'macaddr'
:
macaddr
}
def
filters
(
self
):
return
{
# IP addresses and networks
'ipaddr'
:
ipaddr
,
'ipwrap'
:
ipwrap
,
'ipv4'
:
ipv4
,
'ipv6'
:
ipv6
,
'ipsubnet'
:
ipsubnet
,
# MAC / HW addresses
'hwaddr'
:
hwaddr
,
'macaddr'
:
macaddr
}
if
netaddr
:
return
self
.
filter_map
else
:
# Need to install python-netaddr for these filters to work
return
dict
((
f
,
_need_netaddr
)
for
f
in
self
.
filter_map
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment