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
935514cd
Commit
935514cd
authored
Mar 15, 2013
by
Jimmy Tang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added osrelease and osversion as well as changed the way sysctl is called on OSX
parent
fc8d9377
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
14 deletions
+27
-14
library/setup
+27
-14
No files found.
library/setup
View file @
935514cd
...
...
@@ -855,36 +855,49 @@ class AIX(Hardware):
class
Darwin
(
Hardware
):
"""
Darwin-specific subclass of Hardware. Defines memory and CPU facts:
- processor
- processor_cores
- memtotal_mb
- memfree_mb
- model
- osversion
- osrevision
"""
platform
=
'Darwin'
def
__init__
(
self
):
Hardware
.
__init__
(
self
)
Hardware
.
__init__
(
self
)
def
populate
(
self
):
self
.
sysctl
=
self
.
get_sysctl
()
self
.
get_mac_facts
()
self
.
get_cpu_facts
()
self
.
get_memory_facts
()
return
self
.
facts
def
get_sysctl
(
self
):
rc
,
out
,
err
=
module
.
run_command
([
"/usr/sbin/sysctl"
,
"hw"
,
"machdep"
,
"kern"
])
if
rc
!=
0
:
return
dict
()
sysctl
=
dict
()
for
line
in
out
.
splitlines
():
if
line
.
rstrip
(
"
\n
"
):
(
key
,
value
)
=
re
.
split
(
' = |: '
,
line
,
maxsplit
=
1
)
sysctl
[
key
]
=
value
.
strip
()
return
sysctl
def
get_mac_facts
(
self
):
self
.
facts
[
'model'
]
=
self
.
sysctl
[
'hw.model'
]
self
.
facts
[
'osversion'
]
=
self
.
sysctl
[
'kern.osversion'
]
self
.
facts
[
'osrevision'
]
=
self
.
sysctl
[
'kern.osrevision'
]
def
get_cpu_facts
(
self
):
self
.
facts
[
'processor'
]
=
[]
rc
,
out
,
err
=
module
.
run_command
(
"/usr/sbin/sysctl machdep.cpu.brand_string"
)
data
=
out
[:
-
1
]
.
split
(
': '
)
self
.
facts
[
'processor'
]
=
data
[
1
]
rc
,
out
,
err
=
module
.
run_command
(
"/usr/sbin/sysctl machdep.cpu.core_count"
)
data
=
out
[:
-
1
]
.
split
(
': '
)
self
.
facts
[
'processor_cores'
]
=
data
[
1
]
self
.
facts
[
'processor'
]
=
self
.
sysctl
[
'machdep.cpu.brand_string'
]
self
.
facts
[
'processor_cores'
]
=
self
.
sysctl
[
'machdep.cpu.core_count'
]
def
get_memory_facts
(
self
):
rc
,
out
,
err
=
module
.
run_command
(
"/usr/sbin/sysctl hw.memsize"
)
data
=
out
[:
-
1
]
.
split
(
': '
)
self
.
facts
[
'memtotal_mb'
]
=
int
(
data
[
1
])
/
1024
/
1024
rc
,
out
,
err
=
module
.
run_command
(
"/usr/sbin/sysctl hw.usermem"
)
data
=
out
[:
-
1
]
.
split
(
': '
)
self
.
facts
[
'memfree_mb'
]
=
int
(
data
[
1
])
/
1024
/
1024
self
.
facts
[
'memtotal_mb'
]
=
long
(
self
.
sysctl
[
'hw.memsize'
])
/
1024
/
1024
self
.
facts
[
'memfree_mb'
]
=
long
(
self
.
sysctl
[
'hw.usermem'
])
/
1024
/
1024
class
Network
(
Facts
):
"""
...
...
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