2013-09-18 00:46:58 +02:00
|
|
|
from ..partitions.single import SinglePartition
|
2013-09-15 13:19:45 +02:00
|
|
|
|
|
|
|
|
2013-10-04 21:12:48 +02:00
|
|
|
class NoPartitions(object):
|
2014-03-23 16:04:03 +01:00
|
|
|
"""Represents a virtual 'NoPartitions' partitionmap.
|
|
|
|
This virtual partition map exists because it is easier for tasks to
|
|
|
|
simply always deal with partition maps and then let the base abstract that away.
|
|
|
|
"""
|
2013-09-15 13:19:45 +02:00
|
|
|
|
2014-01-19 01:02:29 +01:00
|
|
|
def __init__(self, data, bootloader):
|
2014-03-23 16:04:03 +01:00
|
|
|
"""
|
|
|
|
Args:
|
|
|
|
data (dict): volume.partitions part of the manifest
|
|
|
|
bootloader (str): Name of the bootloader we will use for bootstrapping
|
|
|
|
"""
|
2014-01-19 12:39:07 +01:00
|
|
|
from common.bytes import Bytes
|
2014-03-23 16:04:03 +01:00
|
|
|
# In the NoPartitions partitions map we only have a single 'partition'
|
2014-02-23 17:52:05 +01:00
|
|
|
self.root = SinglePartition(Bytes(data['root']['size']),
|
|
|
|
data['root']['filesystem'], data['root'].get('format_command', None))
|
2013-09-15 18:26:22 +02:00
|
|
|
self.partitions = [self.root]
|
2013-09-15 13:19:45 +02:00
|
|
|
|
2013-09-22 21:20:09 +02:00
|
|
|
def is_blocking(self):
|
2014-03-23 16:04:03 +01:00
|
|
|
"""Returns whether the partition map is blocking volume detach operations
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
bool.
|
|
|
|
"""
|
2013-11-26 21:07:39 +01:00
|
|
|
return self.root.fsm.current == 'mounted'
|
2013-09-22 21:20:09 +02:00
|
|
|
|
2013-09-15 13:19:45 +02:00
|
|
|
def get_total_size(self):
|
2014-03-23 16:04:03 +01:00
|
|
|
"""Returns the total size the partitions occupy
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
Bytes. The size of all the partitions
|
|
|
|
"""
|
2014-01-19 12:39:07 +01:00
|
|
|
return self.root.get_end()
|