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
fc8d9377
Commit
fc8d9377
authored
Mar 14, 2013
by
Michael DeHaan
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2396 from johanwiren/obsd_facts
Added OpenBSD facts
parents
e3e649a9
61256a7e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
88 additions
and
0 deletions
+88
-0
library/setup
+88
-0
No files found.
library/setup
View file @
fc8d9377
...
...
@@ -619,6 +619,83 @@ class SunOSHardware(Hardware):
self
.
facts
[
'swap_allocated_mb'
]
=
allocated
/
1024
self
.
facts
[
'swap_reserved_mb'
]
=
reserved
/
1024
class
OpenBSDHardware
(
Hardware
):
"""
OpenBSD-specific subclass of Hardware. Defines memory, CPU and device facts:
- memfree_mb
- memtotal_mb
- swapfree_mb
- swaptotal_mb
- processor (a list)
- processor_cores
- processor_count
- processor_speed
- devices
"""
platform
=
'OpenBSD'
DMESG_BOOT
=
'/var/run/dmesg.boot'
def
__init__
(
self
):
Hardware
.
__init__
(
self
)
def
populate
(
self
):
self
.
sysctl
=
self
.
get_sysctl
()
self
.
get_memory_facts
()
self
.
get_processor_facts
()
self
.
get_device_facts
()
return
self
.
facts
def
get_sysctl
(
self
):
rc
,
out
,
err
=
module
.
run_command
([
"/sbin/sysctl"
,
"hw"
])
if
rc
!=
0
:
return
dict
()
sysctl
=
dict
()
for
line
in
out
.
splitlines
():
(
key
,
value
)
=
line
.
split
(
'='
)
sysctl
[
key
]
=
value
.
strip
()
return
sysctl
def
get_memory_facts
(
self
):
# Get free memory. vmstat output looks like:
# procs memory page disks traps cpu
# r b w avm fre flt re pi po fr sr wd0 fd0 int sys cs us sy id
# 0 0 0 47512 28160 51 0 0 0 0 0 1 0 116 89 17 0 1 99
rc
,
out
,
err
=
module
.
run_command
(
"/usr/bin/vmstat"
)
if
rc
==
0
:
self
.
facts
[
'memfree_mb'
]
=
long
(
out
.
splitlines
()[
-
1
]
.
split
()[
4
])
/
1024
self
.
facts
[
'memtotal_mb'
]
=
long
(
self
.
sysctl
[
'hw.usermem'
])
/
1024
/
1024
# Get swapctl info. swapctl output looks like:
# total: 69268 1K-blocks allocated, 0 used, 69268 available
# And for older OpenBSD:
# total: 69268k bytes allocated = 0k used, 69268k available
rc
,
out
,
err
=
module
.
run_command
(
"/sbin/swapctl -sk"
)
if
rc
==
0
:
data
=
out
.
split
()
self
.
facts
[
'swapfree_mb'
]
=
long
(
data
[
-
2
]
.
translate
(
None
,
"kmg"
))
/
1024
self
.
facts
[
'swaptotal_mb'
]
=
long
(
data
[
1
]
.
translate
(
None
,
"kmg"
))
/
1024
def
get_processor_facts
(
self
):
processor
=
[]
dmesg_boot
=
get_file_content
(
OpenBSDHardware
.
DMESG_BOOT
)
if
not
dmesg_boot
:
rc
,
dmesg_boot
,
err
=
module
.
run_command
(
"/sbin/dmesg"
)
i
=
0
for
line
in
dmesg_boot
.
splitlines
():
if
line
.
split
(
' '
,
1
)[
0
]
==
'cpu
%
i:'
%
i
:
processor
.
append
(
line
.
split
(
' '
,
1
)[
1
])
i
=
i
+
1
processor_count
=
i
self
.
facts
[
'processor'
]
=
processor
self
.
facts
[
'processor_count'
]
=
processor_count
# I found no way to figure out the number of Cores per CPU in OpenBSD
self
.
facts
[
'processor_cores'
]
=
'NA'
def
get_device_facts
(
self
):
devices
=
[]
devices
.
extend
(
self
.
sysctl
[
'hw.disknames'
]
.
split
(
','
))
self
.
facts
[
'devices'
]
=
devices
class
FreeBSDHardware
(
Hardware
):
"""
FreeBSD-specific subclass of Hardware. Defines memory and CPU facts:
...
...
@@ -1208,6 +1285,17 @@ class FreeBSDNetwork(GenericBsdIfconfigNetwork, Network):
"""
platform
=
'FreeBSD'
class
OpenBSDNetwork
(
GenericBsdIfconfigNetwork
,
Network
):
"""
This is the OpenBSD Network Class.
It uses the GenericBsdIfconfigNetwork.
"""
platform
=
'OpenBSD'
# Return macaddress instead of lladdr
def
parse_lladdr_line
(
self
,
words
,
current_if
,
ips
):
current_if
[
'macaddress'
]
=
words
[
1
]
class
Virtual
(
Facts
):
"""
This is a generic Virtual subclass of Facts. This should be further
...
...
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