~wesley-wiedenmeier/curtin/fix-extended-clear-holders

« back to all changes in this revision

Viewing changes to curtin/block/clear_holders.py

  • Committer: Wesley Wiedenmeier
  • Date: 2016-08-11 00:08:46 UTC
  • Revision ID: wesley.wiedenmeier@gmail.com-20160811000846-w0mfwfovlzxt9hwt
In clear_holders.shutdown_bcache test if device to shut down is already shut
down before doing anything

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
    """
50
50
    Shut down bcache for specified bcache device
51
51
    """
 
52
    bcache_shutdown_message = ('shutdown_bcache running on {} has determined '
 
53
                               'that the device has already been shut down '
 
54
                               'during handling of another bcache dev. '
 
55
                               'skipping'.format(device))
 
56
    if not os.path.exists(device):
 
57
        LOG.info(bcache_shutdown_message)
 
58
        return
 
59
 
52
60
    bcache_sysfs = get_bcache_using_dev(device)
53
61
    if not os.path.exists(bcache_sysfs):
54
 
        # bcache not running or module not loaded, so nothing needs to be done
55
 
        LOG.info("shutdown_bcache did not find /sys/fs path for bcache dev: "
56
 
                 "'%s', so bcache has already been shut down. continuing",
57
 
                 device)
58
 
    else:
59
 
        LOG.debug('stopping bcache at: %s', bcache_sysfs)
60
 
        with open(os.path.join(bcache_sysfs, 'stop'), 'w') as file_pointer:
61
 
            file_pointer.write('1')
 
62
        LOG.info(bcache_shutdown_message)
 
63
        return
 
64
 
 
65
    LOG.debug('stopping bcache at: %s', bcache_sysfs)
 
66
    with open(os.path.join(bcache_sysfs, 'stop'), 'w') as file_pointer:
 
67
        file_pointer.write('1')
62
68
 
63
69
 
64
70
def shutdown_lvm(device):