summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2012-06-08 18:04:56 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2012-06-08 18:04:56 -0700
commit8cd2871e7d7885076cc4a760d44323e480eb1b9a (patch)
tree28207868a259c925585f89135d2571cae7474ac8
parent88a0e724f8397219ae84c557d05c03c0d1ed9029 (diff)
downloadvyos-cloud-init-8cd2871e7d7885076cc4a760d44323e480eb1b9a.tar.gz
vyos-cloud-init-8cd2871e7d7885076cc4a760d44323e480eb1b9a.zip
Remove cloud config from here and move to cloud.py
-rw-r--r--cloudinit/handlers/__init__.py60
1 files changed, 9 insertions, 51 deletions
diff --git a/cloudinit/handlers/__init__.py b/cloudinit/handlers/__init__.py
index a16bdde6..3b0cdd4e 100644
--- a/cloudinit/handlers/__init__.py
+++ b/cloudinit/handlers/__init__.py
@@ -19,65 +19,23 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-import yaml
-import cloudinit
-import cloudinit.util as util
-import sys
-import traceback
import os
import subprocess
+import sys
import time
+import traceback
-per_instance = cloudinit.per_instance
-per_always = cloudinit.per_always
-per_once = cloudinit.per_once
-
-
-class CloudConfig():
- cfgfile = None
- cfg = None
-
- def __init__(self, cfgfile, cloud=None, ds_deps=None):
- if cloud == None:
- self.cloud = cloudinit.CloudInit(ds_deps)
- self.cloud.get_data_source()
- else:
- self.cloud = cloud
- self.cfg = self.get_config_obj(cfgfile)
-
- def get_config_obj(self, cfgfile):
- try:
- cfg = util.read_conf(cfgfile)
- except:
- # TODO: this 'log' could/should be passed in
- cloudinit.log.critical("Failed loading of cloud config '%s'. "
- "Continuing with empty config\n" % cfgfile)
- cloudinit.log.debug(traceback.format_exc() + "\n")
- cfg = None
- if cfg is None:
- cfg = {}
-
- try:
- ds_cfg = self.cloud.datasource.get_config_obj()
- except:
- ds_cfg = {}
+import yaml
- cfg = util.mergedict(cfg, ds_cfg)
- return(util.mergedict(cfg, self.cloud.cfg))
+from cloudinit.settings import (PER_INSTANCE, PER_ALWAYS, PER_ONCE)
- def handle(self, name, args, freq=None):
- try:
- mod = __import__("cc_" + name.replace("-", "_"), globals())
- def_freq = getattr(mod, "frequency", per_instance)
- handler = getattr(mod, "handle")
+from cloudinit import log as logging
+from cloudinit import util
- if not freq:
- freq = def_freq
+LOG = logging.getLogger(__name__)
- self.cloud.sem_and_run("config-" + name, freq, handler,
- [name, self.cfg, self.cloud, cloudinit.log, args])
- except:
- raise
+DEF_HANDLER_VERSION = 1
+DEF_FREQ = PER_INSTANCE
# reads a cloudconfig module list, returns