Merge lp:~sidnei/juju-deployer/config-yaml-loader into lp:~gandelman-a/juju-deployer/trunk

Proposed by Sidnei da Silva
Status: Merged
Merged at revision: 71
Proposed branch: lp:~sidnei/juju-deployer/config-yaml-loader
Merge into: lp:~gandelman-a/juju-deployer/trunk
Diff against target: 47 lines (+4/-5)
1 file modified
deployer.py (+4/-5)
To merge this branch: bzr merge lp:~sidnei/juju-deployer/config-yaml-loader
Reviewer Review Type Date Requested Status
Adam Gandelman Pending
Review via email: mp+160481@code.launchpad.net

Commit message

Switch to using yaml to load the config, so it works with either json or yaml.

Description of the change

Switch to using yaml to load the config, so it works with either json or yaml.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'deployer.py'
--- deployer.py 2013-03-04 18:05:48 +0000
+++ deployer.py 2013-04-23 19:54:26 +0000
@@ -5,7 +5,6 @@
5import time5import time
6import os6import os
7import yaml7import yaml
8import json
9import optparse8import optparse
10import pprint9import pprint
11import signal10import signal
@@ -24,7 +23,7 @@
2423
25parser = optparse.OptionParser()24parser = optparse.OptionParser()
26parser.add_option('-c', '--config',25parser.add_option('-c', '--config',
27 help=('File containing deployment(s) json config. This '26 help=('File containing deployment(s) config. This '
28 'option can be repeated, with later files overriding '27 'option can be repeated, with later files overriding '
29 'values in earlier ones.'),28 'values in earlier ones.'),
30 dest='configs', action='append')29 dest='configs', action='append')
@@ -104,7 +103,7 @@
104 rc = find_service(juju_status(opts.juju_env), opts.find_service)103 rc = find_service(juju_status(opts.juju_env), opts.find_service)
105 exit(rc)104 exit(rc)
106105
107# load the json configuration for possible deployments.106# load the configuration for possible deployments.
108missing_configs = [c for c in opts.configs if not os.path.exists(c)]107missing_configs = [c for c in opts.configs if not os.path.exists(c)]
109if missing_configs:108if missing_configs:
110 log.error("Configuration not found: {}".format(", ".join(missing_configs)))109 log.error("Configuration not found: {}".format(", ".join(missing_configs)))
@@ -117,7 +116,7 @@
117 include_dirs.append(dirname(abspath(config)))116 include_dirs.append(dirname(abspath(config)))
118 with open(config, 'r') as f:117 with open(config, 'r') as f:
119 try:118 try:
120 cfg = dict_merge(cfg, json.load(f))119 cfg = dict_merge(cfg, yaml.safe_load(f))
121 except ValueError as exc:120 except ValueError as exc:
122 log.error("Error parsing config: {}".format(config))121 log.error("Error parsing config: {}".format(config))
123 log.error(exc)122 log.error(exc)
@@ -205,7 +204,7 @@
205 if os.path.exists("%s/config.yaml" % charm_path):204 if os.path.exists("%s/config.yaml" % charm_path):
206 debug_msg("Loading config.yaml from %s/config.yaml" % charm_path)205 debug_msg("Loading config.yaml from %s/config.yaml" % charm_path)
207 conf = open("%s/config.yaml" % charm_path)206 conf = open("%s/config.yaml" % charm_path)
208 CHARMS[k]["config"] = yaml.load(conf)["options"]207 CHARMS[k]["config"] = yaml.safe_load(conf)["options"]
209 conf.close()208 conf.close()
210 if "units" not in CHARMS[k].keys():209 if "units" not in CHARMS[k].keys():
211 CHARMS[k]["units"] = 1210 CHARMS[k]["units"] = 1

Subscribers

People subscribed via source and target branches