2014-03-23 20:02:26 +01:00
|
|
|
from ....common.tools import log_check_call
|
2013-09-18 00:46:58 +02:00
|
|
|
from base import BasePartition
|
|
|
|
|
|
|
|
|
|
|
|
class GPTPartition(BasePartition):
|
2014-03-23 16:04:03 +01:00
|
|
|
"""Represents a GPT partition
|
|
|
|
"""
|
2013-09-18 00:46:58 +02:00
|
|
|
|
2014-02-23 17:52:05 +01:00
|
|
|
def __init__(self, size, filesystem, format_command, name, previous):
|
2014-03-23 16:04:03 +01:00
|
|
|
"""
|
|
|
|
Args:
|
|
|
|
size (Bytes): Size of the partition
|
|
|
|
filesystem (str): Filesystem the partition should be formatted with
|
|
|
|
format_command (list): Optional format command, valid variables are fs, device_path and size
|
|
|
|
name (str): The name of the partition
|
|
|
|
previous (BasePartition): The partition that preceeds this one
|
|
|
|
"""
|
2013-09-18 00:46:58 +02:00
|
|
|
self.name = name
|
2014-02-23 17:52:05 +01:00
|
|
|
super(GPTPartition, self).__init__(size, filesystem, format_command, previous)
|
2013-09-18 00:46:58 +02:00
|
|
|
|
2013-09-22 21:20:09 +02:00
|
|
|
def _before_create(self, e):
|
2014-03-23 16:04:03 +01:00
|
|
|
# Create the partition and then set the name of the partition afterwards
|
2014-01-19 01:02:29 +01:00
|
|
|
super(GPTPartition, self)._before_create(e)
|
2014-01-18 23:10:16 +01:00
|
|
|
# partition name only works for gpt, for msdos that becomes the part-type (primary, extended, logical)
|
|
|
|
name_command = ('name {idx} {name}'
|
|
|
|
.format(idx=self.get_index(),
|
|
|
|
name=self.name))
|
2014-02-23 22:16:10 +01:00
|
|
|
log_check_call(['parted', '--script', e.volume.device_path,
|
2014-01-18 23:10:16 +01:00
|
|
|
'--', name_command])
|