add .path to Raid so for_client(raid-with-partitions) works

This commit is contained in:
Michael Hudson-Doyle 2022-07-27 17:22:08 +12:00
parent cecca212f6
commit ce146ab28a
2 changed files with 16 additions and 0 deletions

View File

@ -18,12 +18,14 @@ import unittest
from subiquity.common.filesystem.labels import ( from subiquity.common.filesystem.labels import (
annotations, annotations,
for_client,
usage_labels, usage_labels,
) )
from subiquity.models.tests.test_filesystem import ( from subiquity.models.tests.test_filesystem import (
make_model, make_model,
make_model_and_disk, make_model_and_disk,
make_model_and_partition, make_model_and_partition,
make_model_and_raid,
make_partition, make_partition,
) )
@ -123,3 +125,11 @@ class TestUsageLabels(unittest.TestCase):
self.assertEqual( self.assertEqual(
usage_labels(partition), usage_labels(partition),
["to be reformatted as ext4", "mounted at /"]) ["to be reformatted as ext4", "mounted at /"])
class TestForClient(unittest.TestCase):
def test_for_client_raid_parts(self):
model, raid = make_model_and_raid()
make_partition(model, raid)
for_client(raid)

View File

@ -772,6 +772,12 @@ class Raid(_Device):
container = attributes.ref(backlink="_subvolumes", default=None) # Raid container = attributes.ref(backlink="_subvolumes", default=None) # Raid
_subvolumes = attributes.backlink(default=attr.Factory(list)) _subvolumes = attributes.backlink(default=attr.Factory(list))
@property
def path(self):
# This is just here to make for_client(raid-with-partitions) work. It
# might not be very accurate.
return '/dev/md/' + self.name
@property @property
def size(self): def size(self):
if self.preserve and self._m._probe_data: if self.preserve and self._m._probe_data: