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
ae9d264b
Commit
ae9d264b
authored
Aug 12, 2015
by
Brian Coca
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #11762 from amenonsen/9795-rebase
Add LVM facts to setup module
parents
829a88b9
f344ec46
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
lib/ansible/module_utils/facts.py
+32
-0
No files found.
lib/ansible/module_utils/facts.py
View file @
ae9d264b
...
...
@@ -724,6 +724,7 @@ class LinuxHardware(Hardware):
self
.
get_dmi_facts
()
self
.
get_device_facts
()
self
.
get_uptime_facts
()
self
.
get_lvm_facts
()
try
:
self
.
get_mount_facts
()
except
TimeoutError
:
...
...
@@ -1068,6 +1069,37 @@ class LinuxHardware(Hardware):
uptime_seconds_string
=
get_file_content
(
'/proc/uptime'
)
.
split
(
' '
)[
0
]
self
.
facts
[
'uptime_seconds'
]
=
int
(
float
(
uptime_seconds_string
))
def
get_lvm_facts
(
self
):
""" Get LVM Facts if running as root and lvm utils are available """
if
os
.
getuid
()
==
0
and
module
.
get_bin_path
(
'vgs'
):
lvm_util_options
=
'--noheadings --nosuffix --units g'
#vgs fields: VG #PV #LV #SN Attr VSize VFree
vgs
=
{}
rc
,
vg_lines
,
err
=
module
.
run_command
(
'vgs
%
s'
%
lvm_util_options
)
for
vg_line
in
vg_lines
.
splitlines
():
items
=
vg_line
.
split
()
vgs
[
items
[
0
]]
=
{
'size_g'
:
items
[
-
2
],
'free_g'
:
items
[
-
1
],
'num_lvs'
:
items
[
2
],
'num_pvs'
:
items
[
1
]}
#lvs fields:
#LV VG Attr LSize Pool Origin Data% Move Log Copy% Convert
lvs
=
{}
rc
,
lv_lines
,
err
=
module
.
run_command
(
'lvs
%
s'
%
lvm_util_options
)
for
lv_line
in
lv_lines
.
splitlines
():
items
=
lv_line
.
split
()
lvs
[
items
[
0
]]
=
{
'size_g'
:
items
[
3
],
'vg'
:
items
[
1
]}
self
.
facts
[
'lvm'
]
=
{
'lvs'
:
lvs
,
'vgs'
:
vgs
}
class
SunOSHardware
(
Hardware
):
"""
In addition to the generic memory and cpu facts, this also sets
...
...
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