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

Fixed the default behaviour of the autopartitioning (#1380767) #941

Merged

Conversation

poncovka
Copy link
Contributor

Always set the default partitioning

  • The default partitioning of the install class should be always set.

Enable to define the autopart type in an install class

  • The default partitioning scheme can be defined in an install class.
    If the kickstart file defines the scheme, it will be used instead.

Resolves: rhbz#1380767

@Frodox
Copy link
Contributor

Frodox commented Feb 1, 2017

Great +1 for this!

Copy link
Contributor

@vpodzime vpodzime left a comment

Choose a reason for hiding this comment

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

Looks nice to me otherwise.

@@ -290,7 +290,7 @@ def execute(self, storage, ksdata, instClass):

# sets up default autopartitioning. use clearpart separately
# if you want it
instClass.setDefaultPartitioning(storage)
refreshAutoSwapSize(storage)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please also describe this particular change in the commit message.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@@ -58,6 +58,10 @@ class BaseInstallClass(object):
# Blivet uses by default.
defaultFS = None

# The default partitioning scheme to use for autopartitioning.
# If None, we will use DEFAULT_AUTOPART_TYPE.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it being set to None then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could change None to DEFAULT_AUTOPART_TYPE, but then it is not necessary to have the constant DEFAULT_AUTOPART_TYPE at all, because it will be used only here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Still better to have a constant for this -- for other installclasses, addons,...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

"""Return the first argument that is not None."""
for arg in args:
if arg is not None:
return arg
Copy link
Contributor

Choose a reason for hiding this comment

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

This whole function can be written as:

return next((arg for arg in args if arg is not None), None)

Copy link
Contributor

Choose a reason for hiding this comment

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

And if it is a function, it should be generic -- i.e. take any iterable as a single argument and return the first item that is not None. AFAICT there's no need to use *args machinery here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've seen this implementation before, but it is really hard to read. What are the advantages?

Copy link
Contributor Author

@poncovka poncovka Feb 2, 2017

Choose a reason for hiding this comment

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

I can make the function generic, though.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's no advantage, it just looks more "pythonic", whatever that means. :) Feel free to leave the for cycle in place. My main concern here is the (non-)genericity.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

from pykickstart.errors import KickstartValueError

from collections import OrderedDict

import logging
log = logging.getLogger("anaconda")

__all__ = ["StorageSpoke", "AutoPartSpoke"]
__all__ = ["StorageSpoke"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this change intentional? What is the purpose?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In tui, it does not make sense to enable automatic import of indirect spokes, because we always create them and use them only in other spokes. With automatic import, they will be found by a hub, created, initialized and forgotten.

Also, I've added a new parameter to the AutoPartSpoke.__init__ method and the initialization in a hub does not work anymore.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the extra explanation. I think this deserves a separate commit or at least some explanation in the commit message, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

The default partitioning of the installclass should be always set.
Then it is not necessary to set it again, but always refresh the
size of swap before autopartitioning.

Resolves: rhbz#1380767
The default partitioning scheme can be defined in an install class.
If the kickstart file defines the scheme, it will be used instead.

Resolves: rhbz#1380767
In tui, it does not make sense to enable automatic import of indirect
spokes, because we always create them and use them only in other
spokes. With automatic import, they will be found by a hub, created,
initialized and forgotten.
Copy link
Member

@jkonecny12 jkonecny12 left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@poncovka poncovka merged commit 9083c26 into rhinstaller:rhel7-branch Feb 16, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
4 participants