Exemple #1
0
def test_bees_project():
    expected = File(BEES_ROOT.child("expected/bees_with_guns.json")).read_all()
    conf_path = BEES_ROOT.child("project.yaml")
    conf = yaml.load(File(conf_path).read_all())
    conf["file_path"] = conf_path
    generator.render_project(conf)
    actual = File(TEMP.child("cfn.template")).read_all()
    assert_text_equals(actual, expected)
Exemple #2
0
 def main(self, args, skip=False):
     conf = File(Folder(os.getcwd()).child(args.config))
     if not conf.exists:
         raise Exception(
             'Config file [{conf}] does not exist'.format(conf=conf.path))
     self.config = yaml.load(conf.read_all())
     self.config['file_path'] = conf.path
     if not skip:
         generator.render_project(self.config)
Exemple #3
0
def validate_stack(config, **kwargs):
    config, env, files = generator.render_project(config)
    cf = connect_cf(config.region, **kwargs)
    for rpath, (source, target) in files.iteritems():
        try:
            cf.validate_template(template_body=target.read_all())
        except Exception, e:
            print e
            print "Validation failed for template: [%s]" % rpath
            print e.error_message
            return (False, False, False)
Exemple #4
0
def get_params(config):
    config, env, files = generator.render_project(config)
    main_stack = _get_main_stack(config, files)
    try:
        source, target = files[main_stack]
    except KeyError:
        raise Exception("Cannot find the main stack[{main}]".format(main=main_stack))

    obj = json.loads(target.read_all())
    params = obj.get("Parameters", {})

    result = ConfigDict()
    for param, info in params.iteritems():
        value = config.publish.params.get(param, None)
        if not value:
            value = info.get("Default", None)
        info["value"] = value
        result[param] = ConfigDict(info)
    return result