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
4c661e2b
Commit
4c661e2b
authored
Feb 10, 2015
by
pdelared
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update facts.py
Added support for HPUX network fact
parent
38b0a6ae
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
lib/ansible/module_utils/facts.py
+51
-0
No files found.
lib/ansible/module_utils/facts.py
View file @
4c661e2b
...
...
@@ -2048,6 +2048,57 @@ class GenericBsdIfconfigNetwork(Network):
for
item
in
ifinfo
[
ip_type
][
0
]
.
keys
():
defaults
[
item
]
=
ifinfo
[
ip_type
][
0
][
item
]
class
HPUX
(
Network
):
"""
HP-UX-specifig subclass of Network. Defines networking facts:
- default_interface
- interfaces (a list of interface names)
- interface_<name> dictionary of ipv4 address information.
"""
platform
=
'HP-UX'
def
__init__
(
self
,
module
):
Network
.
__init__
(
self
,
module
)
def
populate
(
self
):
netstat_path
=
self
.
module
.
get_bin_path
(
'netstat'
)
if
netstat_path
is
None
:
return
self
.
facts
self
.
get_default_interfaces
()
interfaces
=
self
.
get_interfaces_info
()
self
.
facts
[
'interfaces'
]
=
interfaces
.
keys
()
for
iface
in
interfaces
:
self
.
facts
[
iface
]
=
interfaces
[
iface
]
return
self
.
facts
def
get_default_interfaces
(
self
):
rc
,
out
,
err
=
module
.
run_command
(
"/usr/bin/netstat -nr"
,
use_unsafe_shell
=
True
)
lines
=
out
.
split
(
'
\n
'
)
for
line
in
lines
:
words
=
line
.
split
()
if
len
(
words
)
>
1
:
if
words
[
0
]
==
'default'
:
self
.
facts
[
'default_interface'
]
=
words
[
4
]
self
.
facts
[
'default_gateway'
]
=
words
[
1
]
def
get_interfaces_info
(
self
):
interfaces
=
{}
rc
,
out
,
err
=
module
.
run_command
(
"/usr/bin/netstat -ni"
,
use_unsafe_shell
=
True
)
lines
=
out
.
split
(
'
\n
'
)
for
line
in
lines
:
words
=
line
.
split
()
for
i
in
range
(
len
(
words
)
-
1
):
if
words
[
i
][:
3
]
==
'lan'
:
device
=
words
[
i
]
interfaces
[
device
]
=
{
'device'
:
device
}
address
=
words
[
i
+
3
]
interfaces
[
device
][
'ipv4'
]
=
{
'address'
:
address
}
network
=
words
[
i
+
2
]
interfaces
[
device
][
'ipv4'
]
=
{
'network'
:
network
,
'interface'
:
device
,
'address'
:
address
}
return
interfaces
class
DarwinNetwork
(
GenericBsdIfconfigNetwork
,
Network
):
"""
This is the Mac OS X/Darwin Network Class.
...
...
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