Merge pull request #864 from mwhudson/dasd-rework-2
fixes for FBA, unformatted, and passed-via virtio dasds
This commit is contained in:
commit
2bc274eda0
|
@ -42,7 +42,7 @@ parts:
|
|||
plugin: python
|
||||
source-type: git
|
||||
source: https://git.launchpad.net/curtin
|
||||
source-branch: ubuntu/devel
|
||||
source-commit: 6b34b6aa1b43becab5d50e90435ea7a9092dd38f
|
||||
requirements: [requirements.txt]
|
||||
organize:
|
||||
'lib/python*/site-packages/usr/lib/curtin': 'usr/lib/'
|
||||
|
@ -152,5 +152,5 @@ parts:
|
|||
build-packages: [python-setuptools, build-essential, libnl-3-dev, libnl-genl-3-dev, libnl-route-3-dev]
|
||||
source: https://github.com/CanonicalLtd/probert.git
|
||||
source-type: git
|
||||
source-commit: e34bee1a363615e71d38aff15d00e1837c62729b
|
||||
source-commit: 844c957b7f61f78bbd814cceef87f0d8eb218675
|
||||
requirements: [requirements.txt]
|
||||
|
|
|
@ -636,12 +636,6 @@ class _Device(_Formattable, ABC):
|
|||
def ptable_for_new_partition(self):
|
||||
if self.ptable is not None:
|
||||
return self.ptable
|
||||
for action in self._m._orig_config:
|
||||
if action['id'] == self.id:
|
||||
if action.get('ptable') == 'vtoc':
|
||||
return action['ptable']
|
||||
if self.dasd() is not None:
|
||||
return 'vtoc'
|
||||
return 'gpt'
|
||||
|
||||
def partitions(self):
|
||||
|
@ -781,6 +775,17 @@ class Disk(_Device):
|
|||
}
|
||||
return dinfo
|
||||
|
||||
def ptable_for_new_partition(self):
|
||||
if self.ptable is not None:
|
||||
return self.ptable
|
||||
dasd_config = self._m._probe_data.get('dasd', {}).get(self.path)
|
||||
if dasd_config is not None:
|
||||
if dasd_config['type'] == "FBA":
|
||||
return 'msdos'
|
||||
else:
|
||||
return 'vtoc'
|
||||
return 'gpt'
|
||||
|
||||
@property
|
||||
def size(self):
|
||||
return align_down(self._info.size)
|
||||
|
@ -848,7 +853,10 @@ class Disk(_Device):
|
|||
return False
|
||||
if self.free_for_partitions <= 0:
|
||||
return False
|
||||
if self.ptable == 'vtoc' and len(self._partitions) >= 3:
|
||||
# We only create msdos partition tables with FBA dasds, which
|
||||
# only support 3 partitions. As and when we support editing
|
||||
# partition msdos tables we'll need to be more clever here.
|
||||
if self.ptable in ['vtoc', 'msdos'] and len(self._partitions) >= 3:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
@ -1647,6 +1655,24 @@ class FilesystemModel(object):
|
|||
return config
|
||||
|
||||
def load_probe_data(self, probe_data):
|
||||
for devname, devdata in probe_data['blockdev'].items():
|
||||
if int(devdata['attrs']['size']) != 0:
|
||||
continue
|
||||
# An unformatted (ECKD) dasd reports a size of 0 via e.g. blockdev
|
||||
# --getsize64. So figuring out how big it is requires a bit more
|
||||
# work.
|
||||
data = probe_data.get('dasd', {}).get(devname)
|
||||
if data is None or data['type'] != 'ECKD':
|
||||
continue
|
||||
tracks_per_cylinder = data['tracks_per_cylinder']
|
||||
cylinders = data['cylinders']
|
||||
blocksize = 4096 # hard coded for us!
|
||||
blocks_per_track = 12 # just a mystery fact that has to be known
|
||||
size = \
|
||||
blocksize * blocks_per_track * tracks_per_cylinder * cylinders
|
||||
log.debug(
|
||||
"computing size on unformatted dasd from %s as %s", data, size)
|
||||
devdata['attrs']['size'] = str(size)
|
||||
self._probe_data = probe_data
|
||||
self.reset()
|
||||
|
||||
|
@ -1716,7 +1742,8 @@ class FilesystemModel(object):
|
|||
device.ptable = device.ptable_for_new_partition()
|
||||
dasd = device.dasd()
|
||||
if dasd is not None:
|
||||
dasd.device_layout = 'cdl'
|
||||
dasd.disk_layout = 'cdl'
|
||||
dasd.blocksize = 4096
|
||||
dasd.preserve = False
|
||||
self._actions.append(p)
|
||||
return p
|
||||
|
|
|
@ -31,7 +31,7 @@ class FilesystemViewTests(unittest.TestCase):
|
|||
|
||||
def test_one_disk(self):
|
||||
model = mock.create_autospec(spec=FilesystemModel)
|
||||
model._orig_config = []
|
||||
model._probe_data = {}
|
||||
model._actions = []
|
||||
disk = Disk(
|
||||
m=model, serial="DISK-SERIAL", path='/dev/thing',
|
||||
|
|
Loading…
Reference in New Issue