Skip to content
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

Conversation

vojtechtrefny
Copy link
Member

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 the dry_run option for the input validation.

Pros:

  • It's easy to tell if format supports configuration of an attribute using actions.
  • Having only one class makes the API simpler for the users.
  • It's possible to use existing validation functions/tasks.

Cons:

  • Every attribute needs a special function that looks like a setter but it actually isn't (because of the dry_run option).

@vpodzime
Copy link
Contributor

vpodzime commented Jun 6, 2016

Looks good to me.

@dwlehman
Copy link
Contributor

dwlehman commented Jun 7, 2016

I notice this doesn't really do any explicit checking of the new value. I think any errors would come up in apply, which I'm not sure is what we want -- I think it might be better to check it from the constructor.

Also, I'm not sure what the value is of setting self._run in the action class.

Otherwise I think it looks good.

@vojtechtrefny
Copy link
Member Author

I notice this doesn't really do any explicit checking of the new value. I think any errors would come up in apply, which I'm not sure is what we want -- I think it might be better to check it from the constructor.

I wans't sure if the checks should go to apply or to constructor, I'll move it.

Also, I'm not sure what the value is of setting self._run in the action class.

I just didn't want to have the same code (getattr) twice in apply and execute. Maybe the name is a little misleading.

@dwlehman
Copy link
Contributor

dwlehman commented Jun 9, 2016

Yes, I think if you named it self._execute or self._commit or something else fairly explicit it would be okay. I think you should also do something along the lines of assert(callable(self._execute)) right after setting it.

@dwlehman
Copy link
Contributor

dwlehman commented Jun 9, 2016

I also think we can do better than conf_actions. I'm not sure what would be best, but config_actions or maybe even config_actions_map or config_action_methods come to mind.

@vojtechtrefny vojtechtrefny force-pushed the 3.0-devel_configuration-actions branch from 69ccd16 to f82774b Compare June 10, 2016 10:18
@vojtechtrefny
Copy link
Member Author

New version -- added ActionCofigureDevice, checks moved to action constructor, changed same attribute/function names and added some basic test for configure action functionality.

@vojtechtrefny vojtechtrefny force-pushed the 3.0-devel_configuration-actions branch from f82774b to 8086001 Compare June 10, 2016 10:37
@@ -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}
Copy link
Contributor

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?

Copy link
Member Author

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.

@vpodzime
Copy link
Contributor

Looks good to me other than the above question.

def execute(self, callbacks=None):
super().execute(callbacks=callbacks)

if self._execute:
Copy link
Contributor

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@dwlehman
Copy link
Contributor

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.
@vojtechtrefny vojtechtrefny force-pushed the 3.0-devel_configuration-actions branch from 8086001 to 7bfb770 Compare June 15, 2016 08:54
@vojtechtrefny
Copy link
Member Author

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.

@vojtechtrefny vojtechtrefny force-pushed the 3.0-devel_configuration-actions branch from 7bfb770 to 8e96e80 Compare June 22, 2016 06:30
@vojtechtrefny
Copy link
Member Author

Removed the mountpoint configuration commit.

@vpodzime vpodzime added the ACK label Jun 22, 2016
@vpodzime
Copy link
Contributor

Looks good to me.

@vojtechtrefny vojtechtrefny force-pushed the 3.0-devel_configuration-actions branch from 8e96e80 to dfa82ff Compare June 22, 2016 06:43
@vojtechtrefny
Copy link
Member Author

One PEP8 fix for a different change was part of the removed commit, fixed.

@vojtechtrefny vojtechtrefny merged commit dc3ce65 into storaged-project:3.0-devel Jun 23, 2016
@dwlehman dwlehman added this to the blivet-3.0 milestone Oct 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants