summaryrefslogtreecommitdiff
path: root/tests/unittests/cmd/test_status.py
diff options
context:
space:
mode:
authorChad Smith <chad.smith@canonical.com>2022-01-13 10:12:23 -0700
committerGitHub <noreply@github.com>2022-01-13 11:12:23 -0600
commit0de7acb194dc15650eee1d5332efed82ef162f84 (patch)
treee223562b3031a82894ceda71d6361aad9f570732 /tests/unittests/cmd/test_status.py
parente3f3485d875f021915654bf2b64678e151a8d6f6 (diff)
downloadvyos-cloud-init-0de7acb194dc15650eee1d5332efed82ef162f84.tar.gz
vyos-cloud-init-0de7acb194dc15650eee1d5332efed82ef162f84.zip
cli: cloud-id report not-run or disabled state as cloud-id (#1162)
This fix has two elements: - cloud-init status will not correctly report 'not-run' prior to systemd generator running. Only report "disabled" when generator has run and /run/cloud-init/disabled exists. - Expose not-run and disabled state in cloud-id responses - Add unique error codes from cloud-id for error, disabled and not-run. The new cloud-id exit codes: 0: success 1: error 2: cloud-init is in disabled state 3: cloud-init generator has not run yet
Diffstat (limited to 'tests/unittests/cmd/test_status.py')
-rw-r--r--tests/unittests/cmd/test_status.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/unittests/cmd/test_status.py b/tests/unittests/cmd/test_status.py
index acd1fea5..17d27597 100644
--- a/tests/unittests/cmd/test_status.py
+++ b/tests/unittests/cmd/test_status.py
@@ -89,7 +89,7 @@ class TestStatus(CiTestCase):
)
def test__is_cloudinit_disabled_true_on_kernel_cmdline(self):
- """When using systemd and disable_file is present return disabled."""
+ """When kernel command line disables cloud-init return True."""
(is_disabled, reason) = wrap_and_call(
"cloudinit.cmd.status",
{
@@ -107,9 +107,9 @@ class TestStatus(CiTestCase):
)
def test__is_cloudinit_disabled_true_when_generator_disables(self):
- """When cloud-init-generator doesn't write enabled file return True."""
- enabled_file = os.path.join(self.paths.run_dir, "enabled")
- self.assertFalse(os.path.exists(enabled_file))
+ """When cloud-init-generator writes disabled file return True."""
+ disabled_file = os.path.join(self.paths.run_dir, "disabled")
+ ensure_file(disabled_file)
(is_disabled, reason) = wrap_and_call(
"cloudinit.cmd.status",
{"uses_systemd": True, "get_cmdline": "something"},
@@ -137,7 +137,7 @@ class TestStatus(CiTestCase):
)
def test_status_returns_not_run(self):
- """When status.json does not exist yet, return 'not run'."""
+ """When status.json does not exist yet, return 'not-run'."""
self.assertFalse(
os.path.exists(self.status_file), "Unexpected status.json found"
)
@@ -154,7 +154,7 @@ class TestStatus(CiTestCase):
cmdargs,
)
self.assertEqual(0, retcode)
- self.assertEqual("status: not run\n", m_stdout.getvalue())
+ self.assertEqual("status: not-run\n", m_stdout.getvalue())
def test_status_returns_disabled_long_on_presence_of_disable_file(self):
"""When cloudinit is disabled, return disabled reason."""