2014-03-23 23:12:07 +01:00
|
|
|
from bootstrapvz.base import Task
|
|
|
|
from bootstrapvz.common import phases
|
2013-09-15 13:19:45 +02:00
|
|
|
import filesystem
|
2014-02-23 22:03:13 +01:00
|
|
|
import host
|
2013-09-15 13:19:45 +02:00
|
|
|
import volume
|
|
|
|
|
|
|
|
|
2014-02-23 22:03:13 +01:00
|
|
|
class AddRequiredCommands(Task):
|
2016-06-04 11:35:59 +02:00
|
|
|
description = 'Adding commands required for partitioning the volume'
|
|
|
|
phase = phases.preparation
|
|
|
|
successors = [host.CheckExternalCommands]
|
2014-02-23 22:03:13 +01:00
|
|
|
|
2016-06-04 11:35:59 +02:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
|
|
|
from bootstrapvz.base.fs.partitionmaps.none import NoPartitions
|
|
|
|
if not isinstance(info.volume.partition_map, NoPartitions):
|
|
|
|
info.host_dependencies['parted'] = 'parted'
|
|
|
|
info.host_dependencies['kpartx'] = 'kpartx'
|
2014-02-23 22:03:13 +01:00
|
|
|
|
|
|
|
|
2013-09-15 13:19:45 +02:00
|
|
|
class PartitionVolume(Task):
|
2016-06-04 11:35:59 +02:00
|
|
|
description = 'Partitioning the volume'
|
|
|
|
phase = phases.volume_preparation
|
2013-09-15 13:19:45 +02:00
|
|
|
|
2016-06-04 11:35:59 +02:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
|
|
|
info.volume.partition_map.create(info.volume)
|
2013-09-15 13:19:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
class MapPartitions(Task):
|
2016-06-04 11:35:59 +02:00
|
|
|
description = 'Mapping volume partitions'
|
|
|
|
phase = phases.volume_preparation
|
|
|
|
predecessors = [PartitionVolume]
|
|
|
|
successors = [filesystem.Format]
|
2013-09-15 13:19:45 +02:00
|
|
|
|
2016-06-04 11:35:59 +02:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
|
|
|
info.volume.partition_map.map(info.volume)
|
2013-09-15 13:19:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
class UnmapPartitions(Task):
|
2016-06-04 11:35:59 +02:00
|
|
|
description = 'Removing volume partitions mapping'
|
|
|
|
phase = phases.volume_unmounting
|
|
|
|
predecessors = [filesystem.UnmountRoot]
|
|
|
|
successors = [volume.Detach]
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
|
|
|
info.volume.partition_map.unmap(info.volume)
|