~junaidali/charms/trusty/plumgrid-gateway/analyst_opsvm

« back to all changes in this revision

Viewing changes to hooks/charmhelpers/contrib/storage/linux/utils.py

  • Committer: bbaqar at plumgrid
  • Date: 2016-04-25 09:21:09 UTC
  • mfrom: (26.1.2 plumgrid-gateway)
  • Revision ID: bbaqar@plumgrid.com-20160425092109-kweey25bx97pmj80
Merge: Liberty/Mitaka support

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 
44
44
    :param block_device: str: Full path of block device to clean.
45
45
    '''
 
46
    # https://github.com/ceph/ceph/commit/fdd7f8d83afa25c4e09aaedd90ab93f3b64a677b
46
47
    # sometimes sgdisk exits non-zero; this is OK, dd will clean up
47
 
    call(['sgdisk', '--zap-all', '--mbrtogpt',
48
 
          '--clear', block_device])
 
48
    call(['sgdisk', '--zap-all', '--', block_device])
 
49
    call(['sgdisk', '--clear', '--mbrtogpt', '--', block_device])
49
50
    dev_end = check_output(['blockdev', '--getsz',
50
51
                            block_device]).decode('UTF-8')
51
52
    gpt_end = int(dev_end.split()[0]) - 100
63
64
    :returns: boolean: True if the path represents a mounted device, False if
64
65
        it doesn't.
65
66
    '''
66
 
    is_partition = bool(re.search(r".*[0-9]+\b", device))
67
 
    out = check_output(['mount']).decode('UTF-8')
68
 
    if is_partition:
69
 
        return bool(re.search(device + r"\b", out))
70
 
    return bool(re.search(device + r"[0-9]*\b", out))
 
67
    try:
 
68
        out = check_output(['lsblk', '-P', device]).decode('UTF-8')
 
69
    except:
 
70
        return False
 
71
    return bool(re.search(r'MOUNTPOINT=".+"', out))