本文整理汇总了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