mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-10-10 09:09:50 +00:00
Partitioning fixes
This commit is contained in:
parent
c78866f103
commit
6ddd8809a3
8 changed files with 18 additions and 22 deletions
|
@ -70,7 +70,7 @@ class AbstractPartitionMap(FSMProxy):
|
|||
def _before_unmap(self, event):
|
||||
volume = event.volume
|
||||
for partition in self.partitions:
|
||||
if partition.is_blocking():
|
||||
if partition.is_state('mounted'):
|
||||
msg = 'The partition {partition} prevents the unmap procedure'.format(partition=partition)
|
||||
raise PartitionError(msg)
|
||||
log_check_call(['/sbin/kpartx', '-d', volume.device_path])
|
||||
|
|
|
@ -7,14 +7,15 @@ from common.tools import log_check_call
|
|||
class GPTPartitionMap(AbstractPartitionMap):
|
||||
|
||||
def __init__(self, data):
|
||||
self.boot = None
|
||||
self.swap = None
|
||||
self.partitions = []
|
||||
if 'boot' in data:
|
||||
self.boot = GPTPartition(data['boot']['size'], data['boot']['filesystem'], 'boot', None)
|
||||
self.partitions.append(self.boot)
|
||||
self.root = GPTPartition(data['root']['size'], data['root']['filesystem'], 'root', self.boot)
|
||||
self.partitions.append(self.root)
|
||||
if 'swap' in data:
|
||||
self.swap = GPTSwapPartition(data['swap']['size'], self.root)
|
||||
self.partitions = filter(lambda p: p is not None, [self.boot, self.root, self.swap])
|
||||
self.partitions.append(self.swap)
|
||||
|
||||
super(GPTPartitionMap, self).__init__()
|
||||
|
||||
|
@ -26,7 +27,7 @@ class GPTPartitionMap(AbstractPartitionMap):
|
|||
partition.create(volume)
|
||||
|
||||
boot_idx = self.root.get_index()
|
||||
if self.boot is not None:
|
||||
if hasattr(self, 'boot'):
|
||||
boot_idx = self.boot.get_index()
|
||||
log_check_call(['/sbin/parted', '--script', volume.device_path,
|
||||
'--', 'set ' + str(boot_idx) + ' boot on'])
|
||||
|
|
|
@ -7,14 +7,15 @@ from common.tools import log_check_call
|
|||
class MBRPartitionMap(AbstractPartitionMap):
|
||||
|
||||
def __init__(self, data):
|
||||
self.boot = None
|
||||
self.swap = None
|
||||
self.partitions = []
|
||||
if 'boot' in data:
|
||||
self.boot = MBRPartition(data['boot']['size'], data['boot']['filesystem'], None)
|
||||
self.partitions.append(self.boot)
|
||||
self.root = MBRPartition(data['root']['size'], data['root']['filesystem'], self.boot)
|
||||
self.partitions.append(self.root)
|
||||
if 'swap' in data:
|
||||
self.swap = MBRSwapPartition(data['swap']['size'], self.root)
|
||||
self.partitions = filter(lambda p: p is not None, [self.boot, self.root, self.swap])
|
||||
self.partitions.append(self.swap)
|
||||
|
||||
super(MBRPartitionMap, self).__init__()
|
||||
|
||||
|
@ -26,7 +27,7 @@ class MBRPartitionMap(AbstractPartitionMap):
|
|||
partition.create(volume)
|
||||
|
||||
boot_idx = self.root.get_index()
|
||||
if self.boot is not None:
|
||||
if hasattr(self, 'boot'):
|
||||
boot_idx = self.boot.get_index()
|
||||
log_check_call(['/sbin/parted', '--script', volume.device_path,
|
||||
'--', 'set ' + str(boot_idx) + ' boot on'])
|
||||
|
|
|
@ -9,7 +9,7 @@ class NoPartitions(object):
|
|||
self.partitions = [self.root]
|
||||
|
||||
def is_blocking(self):
|
||||
return self.root.is_blocking()
|
||||
return self.root.is_state('mounted')
|
||||
|
||||
def get_total_size(self):
|
||||
return self.root.size
|
||||
|
|
|
@ -22,9 +22,6 @@ class AbstractPartition(FSMProxy):
|
|||
cfg = {'initial': 'nonexistent', 'events': self.events, 'callbacks': {}}
|
||||
super(AbstractPartition, self).__init__(cfg)
|
||||
|
||||
def is_blocking(self):
|
||||
return self.is_state('mounted')
|
||||
|
||||
def get_uuid(self):
|
||||
[uuid] = log_check_call(['/sbin/blkid', '-s', 'UUID', '-o', 'value', self.device_path])
|
||||
return uuid
|
||||
|
|
|
@ -18,9 +18,6 @@ class BasePartition(AbstractPartition):
|
|||
self.previous = previous
|
||||
super(BasePartition, self).__init__(size, filesystem)
|
||||
|
||||
def is_blocking(self):
|
||||
return self.get_state() in ['mapped', 'mounted', 'formatted']
|
||||
|
||||
def get_index(self):
|
||||
if self.previous is None:
|
||||
return 1
|
||||
|
|
|
@ -9,7 +9,7 @@ class PartitionVolume(Task):
|
|||
phase = phases.volume_preparation
|
||||
|
||||
def run(self, info):
|
||||
info.volume.partition_map.create()
|
||||
info.volume.partition_map.create(info.volume)
|
||||
|
||||
|
||||
class MapPartitions(Task):
|
||||
|
@ -19,7 +19,7 @@ class MapPartitions(Task):
|
|||
after = [PartitionVolume]
|
||||
|
||||
def run(self, info):
|
||||
info.volume.partition_map.map()
|
||||
info.volume.partition_map.map(info.volume)
|
||||
|
||||
|
||||
class UnmapPartitions(Task):
|
||||
|
@ -29,4 +29,4 @@ class UnmapPartitions(Task):
|
|||
after = [filesystem.UnmountRoot]
|
||||
|
||||
def run(self, info):
|
||||
info.volume.partition_map.unmap()
|
||||
info.volume.partition_map.unmap(info.volume)
|
||||
|
|
|
@ -30,9 +30,9 @@ class ConfigureGrub(Task):
|
|||
p_map.boot.unmount()
|
||||
p_map.root.unmount()
|
||||
if not isinstance(p_map, NoPartitions):
|
||||
p_map.unmap()
|
||||
p_map.unmap(info.volume)
|
||||
fn()
|
||||
p_map.map()
|
||||
p_map.map(info.volume)
|
||||
else:
|
||||
fn()
|
||||
p_map.root.device_path = info.volume.device_path
|
||||
|
@ -70,4 +70,4 @@ class ConfigureGrub(Task):
|
|||
raise e
|
||||
|
||||
if isinstance(info.volume, LoopbackVolume):
|
||||
remount(info.volume, info.volume.unlink_dm_node)
|
||||
remount(info.volume.unlink_dm_node)
|
||||
|
|
Loading…
Add table
Reference in a new issue