osbuild: error when {Device,Mount} is modified after creation

This is a drive-by change after spending some quality time with the
mount code. The `id` field of `Mount` is calculated only once and
only when creating a `Mount`. This seems slightly dangerous as
any change to an attribute after creation will not update the
id. This means two options:
1. dynamically update the `id` on changes
2. forbid changes after the `id` is calculcated

I went with (2) but happy to discuss of course but it seems more
the spirit of the class.

It also does the same change for "devices.Device"
This commit is contained in:
Michael Vogt 2023-12-21 19:04:52 +01:00 committed by Simon de Vlieger
parent 4977501cc6
commit f5d6d11f1d
5 changed files with 51 additions and 3 deletions

View file

@ -16,9 +16,10 @@ from typing import Dict, List
from osbuild import host
from osbuild.devices import DeviceManager
from osbuild.mixins import MixinImmutableID
class Mount:
class Mount(MixinImmutableID):
"""
A single mount with its corresponding options
"""