Skip to content

Commit

Permalink
ceph-disk: _dmcrypt_map uses command_with_stdin
Browse files Browse the repository at this point in the history
Instead of an inlined version of it.

Signed-off-by: Loic Dachary <[email protected]>
  • Loading branch information
ldachary committed Jul 14, 2017
1 parent dcfe057 commit 5e42bc7
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions src/ceph-disk/ceph_disk/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,27 +1307,15 @@ def _dmcrypt_map(
rawdev,
] + cryptsetup_parameters

def run(args, stdin):
LOG.info(" ".join(args))
process = subprocess.Popen(
args,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out, err = process.communicate(stdin)
LOG.debug(out)
LOG.error(err)
assert process.returncode == 0

try:
if luks:
if format_dev:
run(luksFormat_args, key)
run(luksOpen_args, key)
command_with_stdin(luksFormat_args, key)
command_with_stdin(luksOpen_args, key)
else:
# Plain mode has no format function, nor any validation
# that the key is correct.
run(create_args, key)
command_with_stdin(create_args, key)
# set proper ownership of mapped device
command_check_call(['chown', 'ceph:ceph', dev])
return dev
Expand Down

0 comments on commit 5e42bc7

Please sign in to comment.