~gnuoy/charms/trusty/odl-controller/amulet

« back to all changes in this revision

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

  • Committer: Liam Young
  • Date: 2015-11-03 17:23:59 UTC
  • Revision ID: liam.young@canonical.com-20151103172359-74a8n5a0mo05iv07
First stab at amulet

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
67
68
    out = check_output(['mount']).decode('UTF-8')
68
69
    if is_partition:
69
70
        return bool(re.search(device + r"\b", out))
70
 
    return bool(re.search(device + r"[0-9]+\b", out))
 
71
    return bool(re.search(device + r"[0-9]*\b", out))