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