Skip to content

Commit

Permalink
fix: Invalid "seedfrom" in NoCloud system configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRealFalcon authored and blackboxsw committed Sep 13, 2024
1 parent 979e637 commit df06fdb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cloudinit/sources/DataSourceNoCloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def ds_detect(self):
elif (
self.sys_cfg.get("datasource", {})
.get("NoCloud", {})
.key("seedfrom")
.get("seedfrom")
):
LOG.debug(
"Machine is configured by system configuration to run on "
Expand Down
16 changes: 12 additions & 4 deletions tests/unittests/sources/test_nocloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@

from cloudinit import helpers
from cloudinit.sources.DataSourceNoCloud import DataSourceNoCloud as dsNoCloud
from cloudinit.sources.DataSourceNoCloud import parse_cmdline_data
from cloudinit.sources.DataSourceNoCloud import (
DataSourceNoCloudNet,
parse_cmdline_data,
)
from tests.unittests.helpers import mock, populate_dir


Expand Down Expand Up @@ -87,13 +90,18 @@ def test_nocloud_seed_dir_non_lxd_platform_is_nocloud(self, mocker, paths):
assert dsrc.platform_type == "nocloud"
assert dsrc.subplatform == "seed-dir (%s)" % seed_dir

def test_nocloud_seedfrom(self, paths):
def test_nocloud_seedfrom(self, paths, caplog):
"""Check that a seedfrom triggers detection"""
assert dsNoCloud(
ds = DataSourceNoCloudNet(
sys_cfg={"datasource": {"NoCloud": {"seedfrom": "somevalue"}}},
distro=None,
paths=paths,
).ds_detect()
)
assert ds.ds_detect()
assert (
"Machine is configured by system configuration to run on "
"single datasource DataSourceNoCloudNet"
) in caplog.text

def test_nocloud_user_data_meta_data(self, paths):
"""Check that meta-data and user-data trigger detection"""
Expand Down

0 comments on commit df06fdb

Please sign in to comment.