本文整理汇总了Python中ci.tests.general.general.General.unmount_partition方法的典型用法代码示例。如果您正苦于以下问题:Python General.unmount_partition方法的具体用法?Python General.unmount_partition怎么用?Python General.unmount_partition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ci.tests.general.general.General
的用法示例。
在下文中一共展示了General.unmount_partition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: unpartition_disk
# 需要导入模块: from ci.tests.general.general import General [as 别名]
# 或者: from ci.tests.general.general.General import unmount_partition [as 别名]
def unpartition_disk(disk, partitions=None, wait=True):
"""
Return disk to RAW state
:param disk: Disk DAL object
:param partitions: Partitions DAL object list
:return: None
"""
if partitions is None:
partitions = disk.partitions
else:
for partition in partitions:
if partition not in disk.partitions:
raise RuntimeError('Partition {0} does not belong to disk {1}'.format(partition.mountpoint, disk.name))
if len(disk.partitions) == 0:
return
root_client = SSHClient(disk.storagerouter, username='root')
for partition in partitions:
General.unmount_partition(root_client, partition)
root_client.run(['parted', '-s', '/dev/' + disk.name, 'mklabel', 'gpt'])
GeneralStorageRouter.sync_with_reality(disk.storagerouter)
counter = 0
timeout = 60
while counter < timeout:
time.sleep(1)
disk = GeneralDisk.get_disk(guid=disk.guid)
if len(disk.partitions) == 0:
break
counter += 1
if counter == timeout:
raise RuntimeError('Removing partitions failed for disk:\n {0} '.format(disk.name))