Fix up issues with partition tables when not needed
- Don't include Disk entries in storage config unless they've been modified - Make sure underlying devices don't include partition table unless needed Signed-off-by: Ryan Harper <ryan.harper@canonical.com>
This commit is contained in:
parent
e9e951a8d7
commit
c8123f9f38
|
@ -15,4 +15,4 @@
|
|||
|
||||
""" Subiquity """
|
||||
|
||||
__version__ = "0.0.4"
|
||||
__version__ = "0.0.5"
|
||||
|
|
|
@ -121,6 +121,9 @@ class DiskAction():
|
|||
def get_parent(self):
|
||||
return self.parent
|
||||
|
||||
def clear_ptable(self):
|
||||
self._ptable = None
|
||||
|
||||
@property
|
||||
def action_id(self):
|
||||
return str(self._action_id)
|
||||
|
@ -137,10 +140,11 @@ class DiskAction():
|
|||
action = {
|
||||
'id': self.action_id,
|
||||
'model': self._model,
|
||||
'ptable': self._ptable,
|
||||
'serial': self._serial,
|
||||
'type': self._type,
|
||||
}
|
||||
if self._ptable:
|
||||
action.update({'ptable': self._ptable})
|
||||
if self._wipe:
|
||||
action.update({'wipe': self._wipe})
|
||||
# if we don't have a valid serial, then we must use
|
||||
|
|
|
@ -335,6 +335,11 @@ class Blockdev():
|
|||
log.debug('Partition Added')
|
||||
return new_size
|
||||
|
||||
def clear_ptable(self):
|
||||
''' clear any partition table setting on underlying device '''
|
||||
if self.baseaction.type == 'disk':
|
||||
self.baseaction.clear_ptable()
|
||||
|
||||
def format_device(self, fstype, mountpoint):
|
||||
log.debug('format:' ' fstype:%s mountpoint:%s' % (
|
||||
fstype, mountpoint))
|
||||
|
@ -353,6 +358,9 @@ class Blockdev():
|
|||
self._mountactions[mntdev] = MountAction(fs_action, mountpoint)
|
||||
log.debug('Mounting {} at {}'.format(mntdev, mountpoint))
|
||||
|
||||
# remove any partition table
|
||||
self.clear_ptable()
|
||||
|
||||
def get_partition(self, devpath):
|
||||
[partnum] = re.findall('\d+$', devpath)
|
||||
return self.disk.partitions[int(partnum)]
|
||||
|
@ -455,16 +463,16 @@ class Bcachedev(Blockdev):
|
|||
self._backing_device = backing_device
|
||||
self._cache_device = cache_device
|
||||
self.baseaction = BcacheAction(os.path.basename(self.disk.devpath),
|
||||
self._backing_device,
|
||||
self._cache_device)
|
||||
self._backing_device.id,
|
||||
self._cache_device.id)
|
||||
|
||||
@property
|
||||
def cache_device(self):
|
||||
return self.baseaction.cache_device
|
||||
return self._cache_device.devpath
|
||||
|
||||
@property
|
||||
def backing_device(self):
|
||||
return self.baseaction.backing_device
|
||||
return self._backing_device.devpath
|
||||
|
||||
|
||||
def sort_actions(actions):
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
from os.path import realpath
|
||||
|
||||
from .blockdev import (Bcachedev,
|
||||
Blockdev,
|
||||
|
@ -192,6 +192,9 @@ class FilesystemModel(ModelPolicy):
|
|||
return the parent disk. /dev/sda2 --> /dev/sda obj'''
|
||||
log.debug('probe_storage: get_disk({})'.format(disk))
|
||||
|
||||
if not disk.startswith('/dev/'):
|
||||
disk = os.path.join('/dev', disk)
|
||||
|
||||
if disk not in self.devices:
|
||||
try:
|
||||
self.devices[disk] = Blockdev(disk, self.info[disk].serial,
|
||||
|
@ -447,7 +450,7 @@ class FilesystemModel(ModelPolicy):
|
|||
# create a Bcachedev (pass in only the names)
|
||||
bcache_dev = Bcachedev(bcache_dev_name, bcache_serial, bcache_model,
|
||||
bcache_parttype, bcache_size,
|
||||
backing_device.devpath, cache_device.devpath)
|
||||
backing_device, cache_device)
|
||||
|
||||
# mark bcache holders
|
||||
self.set_holder(backing_device.devpath, bcache_dev_name)
|
||||
|
@ -591,7 +594,7 @@ class FilesystemModel(ModelPolicy):
|
|||
raise ValueError('Does not start with /')
|
||||
|
||||
# remove redundent // and ..
|
||||
mountpoint = realpath(mountpoint)
|
||||
mountpoint = os.path.realpath(mountpoint)
|
||||
|
||||
# /usr/include/linux/limits.h:PATH_MAX
|
||||
if len(mountpoint) > 4095:
|
||||
|
@ -652,7 +655,9 @@ class FilesystemModel(ModelPolicy):
|
|||
def get_actions(self):
|
||||
actions = []
|
||||
for dev in self.devices.values():
|
||||
actions += dev.get_actions()
|
||||
# don't write out actions for devices not in use
|
||||
if not dev.available:
|
||||
actions += dev.get_actions()
|
||||
|
||||
log.debug('****')
|
||||
log.debug('all actions:{}'.format(actions))
|
||||
|
|
Loading…
Reference in New Issue