本文整理匯總了Python中charmhelpers.contrib.storage.linux.loopback.ensure_loopback_device方法的典型用法代碼示例。如果您正苦於以下問題:Python loopback.ensure_loopback_device方法的具體用法?Python loopback.ensure_loopback_device怎麽用?Python loopback.ensure_loopback_device使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類charmhelpers.contrib.storage.linux.loopback
的用法示例。
在下文中一共展示了loopback.ensure_loopback_device方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ensure_block_device
# 需要導入模塊: from charmhelpers.contrib.storage.linux import loopback [as 別名]
# 或者: from charmhelpers.contrib.storage.linux.loopback import ensure_loopback_device [as 別名]
def ensure_block_device(block_device):
'''
Confirm block_device, create as loopback if necessary.
:param block_device: str: Full path of block device to ensure.
:returns: str: Full path of ensured block device.
'''
_none = ['None', 'none', None]
if (block_device in _none):
error_out('prepare_storage(): Missing required input: block_device=%s.'
% block_device)
if block_device.startswith('/dev/'):
bdev = block_device
elif block_device.startswith('/'):
_bd = block_device.split('|')
if len(_bd) == 2:
bdev, size = _bd
else:
bdev = block_device
size = DEFAULT_LOOPBACK_SIZE
bdev = ensure_loopback_device(bdev, size)
else:
bdev = '/dev/%s' % block_device
if not is_block_device(bdev):
error_out('Failed to locate valid block device at %s' % bdev)
return bdev