-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration actions #434
Configuration actions #434
Conversation
Looks good to me. |
I notice this doesn't really do any explicit checking of the new value. I think any errors would come up in Also, I'm not sure what the value is of setting Otherwise I think it looks good. |
I wans't sure if the checks should go to apply or to constructor, I'll move it.
I just didn't want to have the same code (getattr) twice in |
Yes, I think if you named it |
I also think we can do better than |
69ccd16
to
f82774b
Compare
New version -- added ActionCofigureDevice, checks moved to action constructor, changed same attribute/function names and added some basic test for configure action functionality. |
f82774b
to
8086001
Compare
@@ -77,7 +77,8 @@ class FS(DeviceFormat): | |||
# value is already unpredictable and can change in the future... | |||
_metadata_size_factor = 1.0 | |||
|
|||
config_actions_map = {"label" : "write_label"} | |||
config_actions_map = {"label": "write_label", | |||
"mountpoint": None} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose and result of this action?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intended to change (future) mountpoint for existing devices during installation or some "installation mode". It indeed is quite a weird action because it does nothing during execute
, it just set the attribute.
Looks good to me other than the above question. |
def execute(self, callbacks=None): | ||
super().execute(callbacks=callbacks) | ||
|
||
if self._execute: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self._execute is not None:
would be better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Overall I like it, but I have some concern about the device and format configuration action classes being almost identical. I realize that trying to combine them into a single class brings its own issues (and complexity), but it seems like asking for trouble requiring every change to made in two classes rather than one. |
New actions ActionConfigureDevice and ActionConfigureFormat allow changing selected attributes of a device or format. List of attributes that can be changed with methods used to write the changes to disk is part of the device or format class.
8086001
to
7bfb770
Compare
I think it makes sense to have two actions because we already have two actions for everything -- API users probably might expect to have a different actions for devices and formats. Maybe an abstract class with common functionality could be useful. |
7bfb770
to
8e96e80
Compare
Removed the mountpoint configuration commit. |
Looks good to me. |
8e96e80
to
dfa82ff
Compare
One PEP8 fix for a different change was part of the removed commit, fixed. |
This is not a final version, just a "request for comments".
I've decided to use the "single class" approach with a dict of supported ("configurable") attributes and functions used to set the attribute. I didn't have to create a special function for label configuration -- we already have the
write_label
functions so I've just changed it to take thedry_run
option for the input validation.Pros:
Cons:
dry_run
option).