do not include unreferenced preserved things in curtin storage config
This commit is contained in:
parent
88f76faf1c
commit
c206242c4e
|
@ -1474,6 +1474,8 @@ class FilesystemModel(object):
|
||||||
def can_emit(obj):
|
def can_emit(obj):
|
||||||
for dep in dependencies(obj):
|
for dep in dependencies(obj):
|
||||||
if dep.id not in emitted_ids:
|
if dep.id not in emitted_ids:
|
||||||
|
if dep not in work:
|
||||||
|
work.append(dep)
|
||||||
return False
|
return False
|
||||||
if isinstance(obj, Mount):
|
if isinstance(obj, Mount):
|
||||||
# Any mount actions for a parent of this one have to be emitted
|
# Any mount actions for a parent of this one have to be emitted
|
||||||
|
@ -1491,7 +1493,10 @@ class FilesystemModel(object):
|
||||||
mountpoints = {m.path: m.id for m in self.all_mounts()}
|
mountpoints = {m.path: m.id for m in self.all_mounts()}
|
||||||
log.debug('mountpoints %s', mountpoints)
|
log.debug('mountpoints %s', mountpoints)
|
||||||
|
|
||||||
work = self._actions[:]
|
work = [
|
||||||
|
a for a in self._actions
|
||||||
|
if not getattr(a, 'preserve', False)
|
||||||
|
]
|
||||||
|
|
||||||
while work:
|
while work:
|
||||||
next_work = []
|
next_work = []
|
||||||
|
|
|
@ -1009,7 +1009,7 @@ class TestAutoInstallConfig(unittest.TestCase):
|
||||||
lv1 = model._one(type="lvm_partition")
|
lv1 = model._one(type="lvm_partition")
|
||||||
self.assertEqual(lv1.size, vg.available_for_partitions//2)
|
self.assertEqual(lv1.size, vg.available_for_partitions//2)
|
||||||
|
|
||||||
def test_lv_remaninig(self):
|
def test_lv_remaining(self):
|
||||||
model = make_model()
|
model = make_model()
|
||||||
make_disk(model, serial='aaaa', size=dehumanize_size("100M"))
|
make_disk(model, serial='aaaa', size=dehumanize_size("100M"))
|
||||||
fake_up_blockdata(model)
|
fake_up_blockdata(model)
|
||||||
|
@ -1043,3 +1043,18 @@ class TestAutoInstallConfig(unittest.TestCase):
|
||||||
lv2 = model._one(type="lvm_partition", id='lv2')
|
lv2 = model._one(type="lvm_partition", id='lv2')
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
lv2.size, vg.available_for_partitions - dehumanize_size("50M"))
|
lv2.size, vg.available_for_partitions - dehumanize_size("50M"))
|
||||||
|
|
||||||
|
def test_render_does_not_include_unreferenced(self):
|
||||||
|
model = make_model(Bootloader.NONE)
|
||||||
|
disk1 = make_disk(model, preserve=True)
|
||||||
|
disk2 = make_disk(model, preserve=True)
|
||||||
|
disk1p1 = make_partition(model, disk1, preserve=True)
|
||||||
|
disk2p1 = make_partition(model, disk2, preserve=True)
|
||||||
|
fs = model.add_filesystem(disk1p1, 'ext4')
|
||||||
|
model.add_mount(fs, '/')
|
||||||
|
actions = model._render_actions()
|
||||||
|
ids = {action['id'] for action in actions}
|
||||||
|
self.assertTrue(disk1.id in ids)
|
||||||
|
self.assertTrue(disk1p1.id in ids)
|
||||||
|
self.assertTrue(disk2.id not in ids)
|
||||||
|
self.assertTrue(disk2p1.id not in ids)
|
||||||
|
|
|
@ -129,8 +129,8 @@ class PartitionViewTests(unittest.TestCase):
|
||||||
partition = model.add_partition(disk, 512*(2**20))
|
partition = model.add_partition(disk, 512*(2**20))
|
||||||
partition.preserve = True
|
partition.preserve = True
|
||||||
fs = model.add_filesystem(partition, "ext4")
|
fs = model.add_filesystem(partition, "ext4")
|
||||||
fs.preserve = True
|
|
||||||
model._orig_config = model._render_actions()
|
model._orig_config = model._render_actions()
|
||||||
|
fs.preserve = True
|
||||||
view, stretchy = make_partition_view(model, disk, partition)
|
view, stretchy = make_partition_view(model, disk, partition)
|
||||||
self.assertFalse(stretchy.form.size.enabled)
|
self.assertFalse(stretchy.form.size.enabled)
|
||||||
self.assertTrue(stretchy.form.done_btn.enabled)
|
self.assertTrue(stretchy.form.done_btn.enabled)
|
||||||
|
|
Loading…
Reference in New Issue