From 6737e2c05338c0be2b5586576d3a7091b8a5e64e Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Fri, 24 Mar 2023 14:17:00 +0100 Subject: [PATCH] filesystem: fix path property from Raid - override attribute The following commmit: ce146ab28 add .path to Raid so for_client(raid-with-partitions) works introduced a (read only) path property for Raid objects, returning an imaginary value to make for_client work with Raid objects. Later on, the following commit: 8e658998e add "path" attributes to fs model objects that curtin now provides a path for introduced a (read/write) path attribute to all filesystem objects. For Raid however, the property still takes precedence over the new attribute of the same name, so doing raid.path = x is invalid (no setter) and results in the following exception: AttributeError: can't set attribute 'path' Fixed by using a @property + @setter attribute for path. The getter returns the actual path if it exists, otherwise returns the same imaginary value as before. Signed-off-by: Olivier Gayot --- subiquity/models/filesystem.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/subiquity/models/filesystem.py b/subiquity/models/filesystem.py index 74a434f45..ebb7df0ba 100644 --- a/subiquity/models/filesystem.py +++ b/subiquity/models/filesystem.py @@ -820,16 +820,22 @@ def serialize_devices(self): wipe = attr.ib(default=None) ptable = attributes.ptable() metadata = attr.ib(default=None) - path = attr.ib(default=None) + _path = attr.ib(default=None) container = attributes.ref(backlink="_subvolumes", default=None) # Raid _subvolumes = attributes.backlink(default=attr.Factory(list)) @property def path(self): + if self._path is not None: + return self._path # This is just here to make for_client(raid-with-partitions) work. It # might not be very accurate. return '/dev/md/' + self.name + @path.setter + def path(self, value): + self._path = value + @property def size(self): if self.preserve and self._m._probe_data: