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
Add Netbsd support #62
Conversation
142770f
to
0397ebc
Compare
021c311
to
12bd49f
Compare
f7a3ac6
to
a2e1d2f
Compare
dd2312f
to
36d59dd
Compare
9489b64
to
2c001cd
Compare
cloudinit/distros/netbsd.py
Outdated
return bsd_util.get_rc_config_value('hostname') | ||
|
||
def _write_hostname(self, hostname, filename): | ||
bsd_util.set_rc_config_value('hostname', hostname, |
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.
in freebsd, we use rhel_util, how is this different?
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.
on NetBSD, the /etc/rc.conf
comes with a if
block. As a result, it's not a simple list of key/value anymore. The rhel_util
parser cannot parse the file properly. And so I decided to write these two light setter/getter functions. The code is rather naive, but I think it's enough for now.
We can potentially find the same situation on FreeBSD, so I updated the FreeBSD files to use them too.
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.
Shallow person question: Is there enough alignment between netbsd and freebsd that one could a be a subclass of the other distro? (like ubuntu.py is a subclass of debian distro as it is a derivative work that can share the same distro class methods). As you've implemented this netbsd is a subclass only of top-level Distro class and thus has to redefine all methods.
cloudinit/distros/netbsd.py
Outdated
util.subp(cmd, env=e, capture=False) | ||
|
||
def apply_locale(self, locale, out_fn=None): | ||
pass |
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.
eehhh?
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.
I don't really plan to implement that. I don't think it makes any sense in 2019 to change the locale.
5cc3629
to
8069556
Compare
517531a
to
23ca438
Compare
Add a comment in the module to explain the difference with the other rc file parse: cloudinit.distros.parsers.sys_conf On NetBSD, /etc/rc.conf comes with a if block: if [ -r /etc/defaults/rc.conf ]; then as a consequence, the file is not a regular key/value list anymore and we cannot use cloudinit.distros.parsers.sys_conf The module comes with a more naive parser, but is able to preserve these if blocks. See: canonical#62 (comment)
As suggested by Chad Smith. See: canonical#62 (comment)
Add a comment in the module to explain the difference with the other rc file parse: cloudinit.distros.parsers.sys_conf On NetBSD, /etc/rc.conf comes with a if block: if [ -r /etc/defaults/rc.conf ]; then as a consequence, the file is not a regular key/value list anymore and we cannot use cloudinit.distros.parsers.sys_conf The module comes with a more naive parser, but is able to preserve these if blocks. See: canonical#62 (comment)
As suggested by Chad Smith. See: canonical#62 (comment)
Add a comment in the module to explain the difference with the other rc file parse: cloudinit.distros.parsers.sys_conf On NetBSD, /etc/rc.conf comes with a if block: if [ -r /etc/defaults/rc.conf ]; then as a consequence, the file is not a regular key/value list anymore and we cannot use cloudinit.distros.parsers.sys_conf The module comes with a more naive parser, but is able to preserve these if blocks. See: canonical#62 (comment)
As suggested by Chad Smith. See: canonical#62 (comment)
Add support for the NetBSD Operating System. This branch has been tested with: - NoCloud and OpenStack (with and without config-drive) - and NetBSD 7.1, 8.0 and 8.1. - Python 3.7 only, because of the dependency oncrypt.METHOD_BLOWFISH. This version is available in NetBSD 7, 8 and 9 anyway.
Add a comment in the module to explain the difference with the other rc file parse: cloudinit.distros.parsers.sys_conf On NetBSD, /etc/rc.conf comes with a if block: if [ -r /etc/defaults/rc.conf ]; then as a consequence, the file is not a regular key/value list anymore and we cannot use cloudinit.distros.parsers.sys_conf The module comes with a more naive parser, but is able to preserve these if blocks. See: canonical#62 (comment)
As suggested by Chad Smith. See: canonical#62 (comment)
Ensure `members` is an optional argument, like in the master class.
This was just a duplicated copy of the original `create_user()`.
In the original `create_group()`, `members` is an optional argument.
The original `create_user()` method should work just fine on FreeBSD.
The BSD distros will now inherite from this base BSD class.
There is a lot of duplication of code that could be shared between the FreeBSD and NetBSD classes. Let's avoid as much boilerplate cut-n-paste as possible. Move the following methods up into the parent BSD class: * create_group which now uses group_add_cmd_prefix and _get_add_member_to_group_cmd to specialize subclass commands * install_packages can be generalized since NetBSD.update_package_sources is nothing * package_command is generalized with minor command diffs sourced from class attributes pkg_cmd_install_prefix and pkg_cmd_remove_prefix and custom environment given by _get_pkg_cmd_environ Also in this commit: * A bug fix in existing Freebsd which was switching group name and and username parameters * I left a TODO message for your review as I don't think either BSD class handles a distro.package_command('upgrade') call and it might be needed in a followup PR
Looks really good.
I've rebased against current master and tried consolidating a couple of more common methods up from Freebsd and Netbsd into the parent BSD class.
Please see what you think. The git show 7ee08d3 should show the set of diffs I was thinking of:
Move the following methods up into the parent BSD class:
* create_group which now uses group_add_cmd_prefix and
_get_add_member_to_group_cmd to specialize subclass commands
* install_packages can be generalized since NetBSD.update_package_sources
is nothing
* package_command is generalized with minor command diffs sourced from
class attributes pkg_cmd_install_prefix and pkg_cmd_remove_prefix and
custom environment given by _get_pkg_cmd_environ
Also in this commit:
* A bug fix in existing Freebsd which was switching group name and
and username parameters
* I left a TODO message for your review as I don't think either BSD class
handles a distro.package_command('upgrade') call and it might be needed
in a followup PR
@goneri I'm ok with this if you are ok with the patch I added. the one question is when you'd like to handle package_command('upgrade') |
Looks good to me:
|
Add a comment in the module to explain the difference with the other rc file parse: cloudinit.distros.parsers.sys_conf On NetBSD, /etc/rc.conf comes with a if block: if [ -r /etc/defaults/rc.conf ]; then as a consequence, the file is not a regular key/value list anymore and we cannot use cloudinit.distros.parsers.sys_conf The module comes with a more naive parser, but is able to preserve these if blocks. See: canonical#62 (comment)
As suggested by Chad Smith. See: canonical#62 (comment)
Add support for the NetBSD Operating System.
Features in this branch:
This branch has been tested with:
This version is available in NetBSD 7, 8 and 9 anyway.