~bloodearnest/juju-deployer/annotate-branches

« back to all changes in this revision

Viewing changes to deployer/config.py

  • Committer: Simon Davy
  • Date: 2015-03-30 15:16:10 UTC
  • mfrom: (126.1.18 juju-deployer)
  • Revision ID: bloodearnest@gmail.com-20150330151610-ft7lwajcbnnroa39
merge upstream and fix review comments

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
    def __init__(self, config_files, cli_series=None):
20
20
        self.config_files = config_files
21
21
        self.cli_series = cli_series
 
22
        self.version = 3
22
23
        self.data = {}
23
24
        self.yaml = {}
24
25
        self.include_dirs = []
42
43
 
43
44
        with open(config_file) as fh:
44
45
            try:
45
 
                self.yaml[config_file] = yaml_load(fh.read())
 
46
                yaml_result = yaml_load(fh.read())
46
47
            except Exception, e:
47
48
                self.log.warning(
48
49
                    "Couldn't load config file @ %r, error: %s:%s",
49
50
                    config_file, type(e), e)
50
51
                raise
51
52
 
 
53
        # Check if this is a v4 bundle.
 
54
        if 'services' in yaml_result:
 
55
            if 'machines' in yaml_result:
 
56
                self.version = 4
 
57
            yaml_result = {config_file: yaml_result}
 
58
 
 
59
        self.yaml[config_file] = yaml_result
 
60
 
52
61
        return self.yaml[config_file]
53
62
 
54
63
    def keys(self):
60
69
                             key, ", ".join(self.keys()))
61
70
            raise ErrorExit()
62
71
        deploy_data = self.data[key]
63
 
        deploy_data = self._resolve_inherited(deploy_data)
 
72
        if self.version < 4:
 
73
            deploy_data = self._resolve_inherited(deploy_data)
64
74
        if self.cli_series:
65
75
            deploy_data['series'] = self.cli_series
66
76
        return Deployment(
67
77
            key, deploy_data, self.include_dirs,
68
 
            repo_path=os.environ.get("JUJU_REPOSITORY", ""))
 
78
            repo_path=os.environ.get("JUJU_REPOSITORY", ""),
 
79
            version=self.version)
69
80
 
70
81
    def load(self):
71
82
        data = {}