← Back to team overview

cloud-init team mailing list archive

Nocloud data source and network-config

 

Hi there!

I was attempting to use the nocloud data source with a custom seed dir
including a network-config, but this did not seem to work. I think
others may have had the same problem [1][2], so I decided to look into it.

Just looking at the code path, the issue is rather obvious: when
specifying e.g. `ds=nocloud;s=/` on the command line, cloud-init will
use `util.read_seeded` [3] on that, which simply never looks for a
network-config.

As a first test, I replaced the call to `read_seeded` with one to
`pathprefix2dict` alread used elsewhere in the data source. You can see
the diff here [4]. This works for me, but I know this is not a solution:
it would break the nocloud-net data source, as `pathprefix2dict` only
operates on local files, whereas `read_seeded` handles URLs as well.

Now, I will admit, I am not sure I have really understood the greater
scheme of things with the various loading and merging of dicts in the
nocloud datasource, but my guess would be that `read_seeded` (and in
fact it's companion `read_optional_seed`) can be considered deprecated,
as they do not handle network-config and their function signature does
not allow adding that without touching all callers. Instead, I thought
it might make sense to support URLs in `pathprefix2dict`?

I'd be very happy to supply patches for this if someone can confirm that
it makes sense or can point out a more appropriate approach.

Thanks a lot for keeping all the clouds running,
Conrad

[1] https://bugs.launchpad.net/cloud-init/+bug/1809180
[2] https://lists.launchpad.net/cloud-init/msg00188.html
[3]
https://git.launchpad.net/cloud-init/tree/cloudinit/sources/DataSourceNoCloud.py#n168
[4]
https://git.launchpad.net/~bitfehler/cloud-init/commit/?id=0735b3ea5489869b29fa50123564d45b4cdca6ca


Follow ups