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

[sonic_installer] Refactor sonic_installer code #953

Merged

Conversation

Staphylo
Copy link
Contributor

Add a new Bootloader abstraction.
This makes it easier to add bootloader specific behavior while keeping
the main logic identical.
It is also a step that will ease the introduction of secureboot which
relies on bootloader specific behaviors.

Shuffle code around to get rid of the hacky if/else all over the place.
There are now 3 bootloader classes

  • AbootBootloader
  • GrubBootloader
  • UbootBootloader

There was almost no logic change in any of the implementations.
Only the AbootBootloader saw some small improvements.
More will follow in subsequent changes.

@jleveque
Copy link
Contributor

Thanks for this enhancement, Samuel! Would you mind pulling the new classes (Bootloader, AbootBootloader, GrubBootloader, UbootBootloader) out into their own sepearate files? This will help make main.py more readable/managable and keep the different bootloader logic isolated.

@Staphylo
Copy link
Contributor Author

Will do!

Do you have a preference for the location of these files?
Also because there are some common constants that are needed by all these classes I will have to move them to a separate file.

I'm thinking of

sonic_installer/__init__.py
sonic_installer/aboot.py
sonic_installer/consts.py
sonic_installer/bootloader.py
sonic_installer/grub.py
sonic_installer/main.py
sonic_installer/uboot.py

Alternatively

sonic_installer/__init__.py
sonic_installer/bootloader/__init__.py # Bootloader class definition
sonic_installer/bootloader/aboot.py
sonic_installer/bootloader/grub.py
sonic_installer/bootloader/uboot.py
sonic_installer/consts.py
sonic_installer/main.py

Let me know what you think.

@jleveque
Copy link
Contributor

@Staphylo: I prefer the bootloader/ subdirectory in the latter, but I believe the base Bootloader class definition should not live in the init.py file, but rather a separate file, like bootloader/bootloader.py or bootloader/bootloader_base.py because the primary purpose of the init.py file is to initialize the package, not to hold content. Thanks!

@Staphylo Staphylo force-pushed the master-sonic-installer-refactor branch 2 times, most recently from 42d2882 to 5c831c3 Compare June 20, 2020 02:46
sonic_installer/main.py Outdated Show resolved Hide resolved
Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

As comments

@Staphylo Staphylo force-pushed the master-sonic-installer-refactor branch 3 times, most recently from 13a6b14 to 1f0429f Compare June 23, 2020 19:02
jleveque
jleveque previously approved these changes Jun 23, 2020
@jleveque
Copy link
Contributor

Retest this please

Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

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

Unblock

Add a new Bootloader abstraction.
This makes it easier to add bootloader specific behavior while keeping
the main logic identical.
It is also a step that will ease the introduction of secureboot which
relies on bootloader specific behaviors.

Shuffle code around to get rid of the hacky if/else all over the place.
There are now 3 bootloader classes
 - AbootBootloader
 - GrubBootloader
 - UbootBootloader

There was almost no logic change in any of the implementations.
Only the AbootBootloader saw some small improvements.
More will follow in subsequent changes.
@qiluo-msft qiluo-msft merged commit a4e64d1 into sonic-net:master Jun 26, 2020
abdosi pushed a commit to abdosi/sonic-utilities that referenced this pull request Aug 4, 2020
Add a new Bootloader abstraction.
This makes it easier to add bootloader specific behavior while keeping
the main logic identical.
It is also a step that will ease the introduction of secureboot which
relies on bootloader specific behaviors.

Shuffle code around to get rid of the hacky if/else all over the place.
There are now 3 bootloader classes
 - AbootBootloader
 - GrubBootloader
 - UbootBootloader

There was almost no logic change in any of the implementations.
Only the AbootBootloader saw some small improvements.
More will follow in subsequent changes.
lguohan pushed a commit that referenced this pull request Aug 21, 2020
The import re line was removed from the file in #953. However, it is still referenced in the update_sonic_environment() function. Adding it back.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants