cloud-init team mailing list archive
Mailing list archive
Re: How to handle platform diferences in cloudinit.net module
I like the idea you have.
I put up a example of how I think we could re-work those to more
easily be aware of freebsd.
the other alternative is a class like solution, which would provide
the safety of required implementation of functions.
I'm open to thoughts on that.
thanks for your post.
On Mon, Oct 29, 2018 at 9:50 AM Igor Galić <igalic@xxxxxxxxxxxxx> wrote:
> > scott said:
> > > As a first-pass answer, I think the goal woudl be really to get
> > stuff into the cloudinit/net/ module that
> > > then had sane methodds that did the right thing. I do realize that
> > freebsd did/does have lots of "if"s sprinkled throughout.
> > >
> > > I think we would like to better abstract / design this.
> > given similar uses in other parts of the code, i started with
> > something like this:
> > https://git.launchpad.net/~i.galic/cloud-init/commit/?h=refactor/net-fbsd&id=65d8328a5a12b1a435d4386c0963774ea08c319e
> After a weekend of not looking at this code, i believe i have now come
> up with a slightly better approach.
> From my understanding, `net` is used to gather and setup the low level
> state of the network. For this it uses `/sys/classes/net/*` and `ip` on
> linux, and would use `ifconfig` and `route` on freebsd.
> We can leave most of the high-level function declarations in `net` as
> they are, and, on-load, dispatch an import of their actual
> import util
> net_class = None
> if util.system()['vendor'] is not 'freebsd':
> from net.linux import Linux
> net_class = Linux
> from net.freebsd import FreeBSD
> net_class = FreeBSD
> def is_up(interface)
> return net_class.is_up(interface)
> # etc…
> the `distro` classes would still hold the distro specific configuration
> mechanisms (/etc/network/interfaces vs /etc/sysconf/network vs
> /etc/rc.conf, etc…)
> (Furthermore, FreeBSD should also return FreeBSD as distro ;)
> Mailing list: https://launchpad.net/~cloud-init
> Post to : cloud-init@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~cloud-init
> More help : https://help.launchpad.net/ListHelp