summaryrefslogtreecommitdiff
path: root/cloudinit/stages.py
diff options
context:
space:
mode:
authorAlberto Contreras <aciba90@gmail.com>2022-04-28 19:50:23 +0200
committerGitHub <noreply@github.com>2022-04-28 11:50:23 -0600
commit1f0baf383cb1e3d93063bdc51780f00aa3f3da06 (patch)
treea684c447de6f0d9bf24298c0e66abc9da1971f55 /cloudinit/stages.py
parent4d6576560de01ab4f4a75924a5b7b81fd9e5bd2a (diff)
downloadcloud-init-git-1f0baf383cb1e3d93063bdc51780f00aa3f3da06.tar.gz
Refactor cloudinit.sources.NetworkConfigSource to enum (#1413)
It was implemented as a namedtuple, because it was written when the codebase supported Python 2 (where using an enum would have introduced a new dependency). As enum is in the stdlib in all our supported Python releases, we can now use it without that constraint. LP: #1874875
Diffstat (limited to 'cloudinit/stages.py')
-rw-r--r--cloudinit/stages.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/cloudinit/stages.py b/cloudinit/stages.py
index 5d0806a8..ce43fd5d 100644
--- a/cloudinit/stages.py
+++ b/cloudinit/stages.py
@@ -9,7 +9,7 @@ import os
import pickle
import sys
from collections import namedtuple
-from typing import Dict, List, Optional, Set # noqa: F401
+from typing import Dict, List, Optional, Set
from cloudinit import cloud, distros, handlers, helpers, importer
from cloudinit import log as logging
@@ -807,15 +807,15 @@ class Init(object):
return (None, disable_file)
available_cfgs = {
- NetworkConfigSource.cmdline: cmdline.read_kernel_cmdline_config(),
- NetworkConfigSource.initramfs: cmdline.read_initramfs_config(),
- NetworkConfigSource.ds: None,
- NetworkConfigSource.system_cfg: self.cfg.get("network"),
+ NetworkConfigSource.CMD_LINE: cmdline.read_kernel_cmdline_config(),
+ NetworkConfigSource.INITRAMFS: cmdline.read_initramfs_config(),
+ NetworkConfigSource.DS: None,
+ NetworkConfigSource.SYSTEM_CFG: self.cfg.get("network"),
}
if self.datasource and hasattr(self.datasource, "network_config"):
available_cfgs[
- NetworkConfigSource.ds
+ NetworkConfigSource.DS
] = self.datasource.network_config
if self.datasource:
@@ -823,7 +823,7 @@ class Init(object):
else:
order = sources.DataSource.network_config_sources
for cfg_source in order:
- if not hasattr(NetworkConfigSource, cfg_source):
+ if not isinstance(cfg_source, NetworkConfigSource):
LOG.warning(
"data source specifies an invalid network cfg_source: %s",
cfg_source,
@@ -844,7 +844,7 @@ class Init(object):
return (ncfg, cfg_source)
return (
self.distro.generate_fallback_config(),
- NetworkConfigSource.fallback,
+ NetworkConfigSource.FALLBACK,
)
def _apply_netcfg_names(self, netcfg):