bootstrap-vz/bootstrapvz/common/tasks/partitioning.py

50 lines
1.2 KiB
Python
Raw Normal View History

from base import Task
from common import phases
import filesystem
import host
import volume
class AddRequiredCommands(Task):
description = 'Adding commands required for partitioning the volume'
phase = phases.preparation
successors = [host.CheckExternalCommands]
@classmethod
def run(cls, info):
from base.fs.partitionmaps.none import NoPartitions
if not isinstance(info.volume.partition_map, NoPartitions):
info.host_dependencies['parted'] = 'parted'
info.host_dependencies['kpartx'] = 'kpartx'
class PartitionVolume(Task):
description = 'Partitioning the volume'
phase = phases.volume_preparation
@classmethod
def run(cls, info):
2013-10-05 20:41:05 +02:00
info.volume.partition_map.create(info.volume)
class MapPartitions(Task):
description = 'Mapping volume partitions'
phase = phases.volume_preparation
predecessors = [PartitionVolume]
successors = [filesystem.Format]
@classmethod
def run(cls, info):
2013-10-05 20:41:05 +02:00
info.volume.partition_map.map(info.volume)
class UnmapPartitions(Task):
description = 'Removing volume partitions mapping'
phase = phases.volume_unmounting
predecessors = [filesystem.UnmountRoot]
successors = [volume.Detach]
@classmethod
def run(cls, info):
2013-10-05 20:41:05 +02:00
info.volume.partition_map.unmap(info.volume)