Beispiel #1
0
def generate_partition_table_model(partition_table_dict,
                                   default_partition_start, default_alignment):
    """
    Generate a PartitionTableModel, a PartitionTable without a disk association

    Note: if label is not specified, the Press object will determine label based
     off:
        1. Device booted in UEFI mode
        2. A disk is larger then 2.2TiB

    Most people don't care if their partitions are primary/logical
    or what their gpt names are, so we'll care for them.

    :param partition_table_dict:
    :param default_alignment:
    :param default_partition_start:

    :return: PartitionTableModel
    """
    table_type = partition_table_dict['label']

    pm = PartitionTableModel(
        table_type=table_type,
        disk=partition_table_dict['disk'],
        partition_start=partition_table_dict.get('partition_start',
                                                 default_partition_start),
        alignment=partition_table_dict.get('alignment', default_alignment))

    partition_dicts = partition_table_dict.get('partitions')
    if partition_dicts:
        partitions = generate_partitions(table_type, partition_dicts)
        pm.add_partitions(partitions)
    return pm
Beispiel #2
0
               mount_point='/boot',
               fsck_option=2)
p2 = Partition('primary',
               '512MiB',
               file_system=SWAP('SWAP'),
               mount_point='swap')
p3 = Partition('primary',
               '512MiB',
               file_system=EXT4(
                   'TMP',
                   mount_options=['defaults', 'nosuid', 'noexec', 'nodev']),
               mount_point='/tmp',
               fsck_option=2)
p4 = Partition('primary', PercentString('100%FREE'), flags=['lvm'])

pm1 = PartitionTableModel('msdos', disk=disk)

pm1.add_partitions([p1, p2, p3, p4])

log.debug(pm1.allocated_space)

pv1 = PhysicalVolume(p4)
vg1 = VolumeGroupModel('vg_test', [pv1])
lv1 = LogicalVolume('lv_test1',
                    PercentString('99%FREE'),
                    file_system=EXT4('ROOT_LV'),
                    mount_point='/',
                    fsck_option=1)
vg1.add_logical_volume(lv1)

print vg1
Beispiel #3
0
from press.layout import EXT4, Partition, PercentString, Size, Layout, SWAP
from press.logger import setup_logging

import logging
setup_logging()

log = logging.getLogger(__name__)

disk = '/dev/loop0'

p1 = Partition('primary',
               PercentString('100%FREE'),
               file_system=EXT4('ROOT'),
               mount_point='/')

pm1 = PartitionTableModel('msdos', disk=disk)

pm1.add_partition(p1)

log.debug(pm1.allocated_space)

l1 = Layout(loop_only=True)

l1.add_partition_table_from_model(pm1)

log.debug(l1.disks)
log.debug(l1.disks[disk].partition_table)

l1.apply()
log.info('Apply completed!')