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
06e0e1f7
Commit
06e0e1f7
authored
Jun 20, 2014
by
James Cammarata
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ajsalminen-lvg_dm_names' into devel
parents
94963290
8e0148f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
4 deletions
+16
-4
library/system/lvg
+16
-4
No files found.
library/system/lvg
View file @
06e0e1f7
...
...
@@ -67,7 +67,7 @@ EXAMPLES = '''
# Create a volume group on top of /dev/sda1 with physical extent size = 32MB.
- lvg: vg=vg.services pvs=/dev/sda1 pesize=32
# Create or resize a volume group on top of /dev/sdb1 and /dev/sdc5.
# Create or resize a volume group on top of /dev/sdb1 and /dev/sdc5.
# If, for example, we already have VG vg.services on top of /dev/sdb1,
# this VG will be extended by /dev/sdc5. Or if vg.services was created on
# top of /dev/sda5, we first extend it with /dev/sdb1 and /dev/sdc5,
...
...
@@ -89,10 +89,22 @@ def parse_vgs(data):
})
return
vgs
def
parse_pvs
(
data
):
def
find_mapper_device_name
(
module
,
dm_device
):
dmsetup_cmd
=
module
.
get_bin_path
(
'dmsetup'
,
True
)
mapper_prefix
=
'/dev/mapper/'
rc
,
dm_name
,
err
=
module
.
run_command
(
"
%
s info -C --noheadings -o name
%
s"
%
(
dmsetup_cmd
,
dm_device
))
if
rc
!=
0
:
module
.
fail_json
(
msg
=
"Failed executing dmsetup command."
,
rc
=
rc
,
err
=
err
)
mapper_device
=
mapper_prefix
+
dm_name
.
rstrip
()
return
mapper_device
def
parse_pvs
(
module
,
data
):
pvs
=
[]
dm_prefix
=
'/dev/dm-'
for
line
in
data
.
splitlines
():
parts
=
line
.
strip
()
.
split
(
';'
)
if
parts
[
0
]
.
startswith
(
dm_prefix
):
parts
[
0
]
=
find_mapper_device_name
(
module
,
parts
[
0
])
pvs
.
append
({
'name'
:
parts
[
0
],
'vg_name'
:
parts
[
1
],
...
...
@@ -125,7 +137,7 @@ def main():
module
.
fail_json
(
msg
=
"No physical volumes given."
)
if
state
==
'present'
:
### check given devices
for
test_dev
in
dev_list
:
...
...
@@ -139,7 +151,7 @@ def main():
module
.
fail_json
(
msg
=
"Failed executing pvs command."
,
rc
=
rc
,
err
=
err
)
### check pv for devices
pvs
=
parse_pvs
(
current_pvs
)
pvs
=
parse_pvs
(
module
,
current_pvs
)
used_pvs
=
[
pv
for
pv
in
pvs
if
pv
[
'name'
]
in
dev_list
and
pv
[
'vg_name'
]
and
pv
[
'vg_name'
]
!=
vg
]
if
used_pvs
:
module
.
fail_json
(
msg
=
"Device
%
s is already in
%
s volume group."
%
(
used_pvs
[
0
][
'name'
],
used_pvs
[
0
][
'vg_name'
]))
...
...
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