mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-10-10 09:09:50 +00:00
Remove FSM from NoPartitions p-map
Don't set the volume device_path by calling 'create'
This commit is contained in:
parent
ba1842ca2b
commit
387aa62750
4 changed files with 12 additions and 17 deletions
|
@ -1,27 +1,15 @@
|
|||
from ..partitions.single import SinglePartition
|
||||
from common.fsm_proxy import FSMProxy
|
||||
|
||||
|
||||
class NoPartitions(FSMProxy):
|
||||
|
||||
events = [{'name': 'create', 'src': 'nonexistent', 'dst': 'created'}]
|
||||
class NoPartitions(object):
|
||||
|
||||
def __init__(self, data):
|
||||
root = data['root']
|
||||
self.root = SinglePartition(root['size'], root['filesystem'])
|
||||
self.partitions = [self.root]
|
||||
|
||||
cfg = {'initial': 'nonexistent', 'events': self.events, 'callbacks': {}}
|
||||
super(NoPartitions, self).__init__(cfg)
|
||||
|
||||
def is_blocking(self):
|
||||
return self.root.is_blocking()
|
||||
|
||||
def get_total_size(self):
|
||||
return self.root.size
|
||||
|
||||
def create(self, volume):
|
||||
self.fsm.create(volume=volume)
|
||||
|
||||
def _before_create(self, event):
|
||||
self.root.create(event.volume)
|
||||
|
|
|
@ -3,5 +3,7 @@ from abstract import AbstractPartition
|
|||
|
||||
class SinglePartition(AbstractPartition):
|
||||
|
||||
initial_state = 'created'
|
||||
|
||||
def _before_create(self, e):
|
||||
self.device_path = e.volume.device_path
|
||||
pass
|
||||
|
|
|
@ -2,6 +2,7 @@ from abc import ABCMeta
|
|||
from common.fsm_proxy import FSMProxy
|
||||
from common.tools import log_check_call
|
||||
from exceptions import VolumeError
|
||||
from partitionmaps.none import NoPartitions
|
||||
|
||||
|
||||
class Volume(FSMProxy):
|
||||
|
@ -21,13 +22,18 @@ class Volume(FSMProxy):
|
|||
self.size = self.partition_map.get_total_size()
|
||||
|
||||
callbacks = {'onbeforedetach': self._check_blocking}
|
||||
from partitionmaps.none import NoPartitions
|
||||
if isinstance(self.partition_map, NoPartitions):
|
||||
callbacks['onafterattach'] = lambda e: self.partition_map.create(self)
|
||||
def set_dev_path(e):
|
||||
self.partition_map.root.device_path = self.device_path
|
||||
callbacks['onafterattach'] = set_dev_path
|
||||
|
||||
cfg = {'initial': 'nonexistent', 'events': self.events, 'callbacks': callbacks}
|
||||
super(Volume, self).__init__(cfg)
|
||||
|
||||
def _after_create(self, e):
|
||||
if isinstance(self.partition_map, NoPartitions):
|
||||
self.partition_map.root.create()
|
||||
|
||||
def can_mount_specials(self):
|
||||
return self.is_state('attached')
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@ def set_fs_states(volume):
|
|||
partitions_state = 'attached'
|
||||
from base.fs.partitionmaps.none import NoPartitions
|
||||
if isinstance(p_map, NoPartitions):
|
||||
p_map.set_state('created')
|
||||
partitions_state = 'formatted'
|
||||
else:
|
||||
p_map.set_state('unmapped')
|
||||
|
|
Loading…
Add table
Reference in a new issue