Skip to content

Commit

Permalink
Fix missing device bug in cinder_volume_group
Browse files Browse the repository at this point in the history
Turns out that hd doesn't like it if the device passed in as a
parameter doesn't exist. So, consolidate the is_luks and is_lvm_pm
logic into _is_device_type and add a leading conditional that checks
for the device path's existence.

(cherry picked from commit eca8c34)
  • Loading branch information
craigtracey authored and omgjlk committed Feb 18, 2015
1 parent cf5f93a commit 3cd1f0a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions library/cinder_volume_group
Expand Up @@ -38,15 +38,21 @@ import os
import re
import subprocess

def is_luks(device, module):
def _is_device_type(device, device_type, module):
if not os.path.exists(device):
return False
cmd = ['hd', '-n', '16384', device]
rc, out, err = module.run_command(cmd, check_rc=True)
return re.search('LUKS', out)
return re.search(device_type, out)


def is_luks(device, module):
return _is_device_type(device, 'LUKS', module)


def is_lvm_pv(device, module):
cmd = ['hd', '-n', '16384', device]
rc, out, err = module.run_command(cmd, check_rc=True)
return re.search('LVM2', out)
return _is_device_type(device, 'LMV2', module)


def vgexists(name, module):
cmd = ['vgs', name]
Expand Down

0 comments on commit 3cd1f0a

Please sign in to comment.