Remove mountpoints from partitions

This commit is contained in:
Anders Ingemann 2013-09-25 23:27:31 +02:00
parent ecdc255752
commit 3c32310346
4 changed files with 12 additions and 13 deletions

View file

@ -9,20 +9,17 @@ class GPTPartitionMap(AbstractPartitionMap):
def __init__(self, data):
self.boot = None
self.swap = None
self.mount_points = []
if 'boot' in data:
self.boot = GPTPartition(data['boot']['size'], data['boot']['filesystem'], 'boot', None)
self.mount_points.append(('/boot', self.boot))
self.root = GPTPartition(data['root']['size'], data['root']['filesystem'], 'root', self.boot)
self.mount_points.append(('/', self.root))
if 'swap' in data:
self.swap = GPTSwapPartition(data['swap']['size'], self.root)
self.mount_points.append(('none', self.root))
self.partitions = filter(lambda p: p is not None, [self.boot, self.root, self.swap])
super(GPTPartitionMap, self).__init__()
def _before_create(self, volume):
def _before_create(self, event):
volume = event.volume
log_check_call(['/sbin/parted', '--script', '--align', 'none', volume.device_path,
'--', 'mklabel', 'gpt'])
for partition in self.partitions:
@ -31,7 +28,7 @@ class GPTPartitionMap(AbstractPartitionMap):
boot_idx = self.root.get_index()
if self.boot is not None:
boot_idx = self.boot.get_index()
log_check_call(['/sbin/parted', '--script', volume.device_path,
'--', 'set ' + str(boot_idx) + ' bios_grub on'])
log_check_call(['/sbin/parted', '--script', volume.device_path,
'--', 'set ' + str(boot_idx) + ' boot on'])
log_check_call(['/sbin/parted', '--script', volume.device_path,
'--', 'set ' + str(boot_idx) + ' bios_grub on'])

View file

@ -9,15 +9,11 @@ class MBRPartitionMap(AbstractPartitionMap):
def __init__(self, data):
self.boot = None
self.swap = None
self.mount_points = []
if 'boot' in data:
self.boot = MBRPartition(data['boot']['size'], data['boot']['filesystem'], None)
self.mount_points.append(('/boot', self.boot))
self.root = MBRPartition(data['root']['size'], data['root']['filesystem'], self.boot)
self.mount_points.append(('/', self.root))
if 'swap' in data:
self.swap = MBRSwapPartition(data['swap']['size'], self.root)
self.mount_points.append(('none', self.root))
self.partitions = filter(lambda p: p is not None, [self.boot, self.root, self.swap])
super(MBRPartitionMap, self).__init__()

View file

@ -10,7 +10,6 @@ class NoPartitions(FSMProxy):
root = data['root']
self.root = SinglePartition(root['size'], root['filesystem'])
self.partitions = [self.root]
self.mount_points = [('/', self.root)]
cfg = {'initial': 'nonexistent', 'events': self.events, 'callbacks': {}}
super(NoPartitions, self).__init__(cfg)

View file

@ -132,8 +132,15 @@ class FStab(Task):
# device = '/dev/sda'
# if info.manifest.virtualization == 'pvm':
# device = '/dev/xvda'
p_map = info.volume.partition_map
mount_points = [('/root', p_map.root)]
if hasattr(p_map, 'boot'):
mount_points.append(('/boot', p_map.boot))
if hasattr(p_map, 'swap'):
mount_points.append(('none', p_map.swap))
fstab_lines = []
for mount_point, partition in info.volume.partition_map.mount_points:
for mount_point, partition in mount_points:
mount_opts = ['defaults']
if partition.filesystem in ['ext2', 'ext3', 'ext4']:
mount_opts.append('barrier=0')