-
Notifications
You must be signed in to change notification settings - Fork 835
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use cc_* module meta defintion over hardcoded vars (SC-888) (#1385)
Previously, each cc_* module required a hardcoded 'distro' and 'frequency' variable to control the respective distro to run on and run frequency. If undefined or invalid, we silently changed this to a default value. Instead, this commit will validate the MetaSchema definition and raise an exception if invalid. This means every module MUST contain a MetaSchema definition. Additionally, the Modules class was moved out of stages.py into its own module, along with some helper functions in config/__init__.py.
- Loading branch information
1 parent
729545c
commit 8a6be66
Showing
17 changed files
with
456 additions
and
428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +0,0 @@ | ||
# Copyright (C) 2008-2010 Canonical Ltd. | ||
# Copyright (C) 2012 Hewlett-Packard Development Company, L.P. | ||
# | ||
# Author: Chuck Short <chuck.short@canonical.com> | ||
# Author: Juerg Haefliger <juerg.haefliger@hp.com> | ||
# | ||
# This file is part of cloud-init. See LICENSE file for license information. | ||
|
||
from cloudinit import log as logging | ||
from cloudinit.settings import FREQUENCIES, PER_INSTANCE | ||
|
||
LOG = logging.getLogger(__name__) | ||
|
||
# This prefix is used to make it less | ||
# of a chance that when importing | ||
# we will not find something else with the same | ||
# name in the lookup path... | ||
MOD_PREFIX = "cc_" | ||
|
||
|
||
def form_module_name(name): | ||
canon_name = name.replace("-", "_") | ||
if canon_name.lower().endswith(".py"): | ||
canon_name = canon_name[0 : (len(canon_name) - 3)] | ||
canon_name = canon_name.strip() | ||
if not canon_name: | ||
return None | ||
if not canon_name.startswith(MOD_PREFIX): | ||
canon_name = "%s%s" % (MOD_PREFIX, canon_name) | ||
return canon_name | ||
|
||
|
||
def fixup_module(mod, def_freq=PER_INSTANCE): | ||
if not hasattr(mod, "frequency"): | ||
setattr(mod, "frequency", def_freq) | ||
else: | ||
freq = mod.frequency | ||
if freq and freq not in FREQUENCIES: | ||
LOG.warning("Module %s has an unknown frequency %s", mod, freq) | ||
if not hasattr(mod, "distros"): | ||
setattr(mod, "distros", []) | ||
if not hasattr(mod, "osfamilies"): | ||
setattr(mod, "osfamilies", []) | ||
return mod | ||
|
||
|
||
# vi: ts=4 expandtab | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.