def main(): # This cli object takes the documentation comment at the top of this file (__doc__) and parses it against the # command line arguments (sys.argv). Supported commands are create and deploy. The deploy function works fine as # is. ConsulStackController overrides the create action to include an Consul.io stack as an additional template. cli = CLI(doc=__doc__) env_config = EnvConfig(config_handlers=[ConsulTemplate]) ConsulStackController(view=cli, env_config=env_config)
'preferred_maintenance_window': 'sun:03:00-sun:04:00', # Name of vm snapshot to use, empty string ('') means don't use an old snapshot # Note: 'master_db_name' value will be overridden if snapshot_id is non-empty 'snapshot_id': '', 'password': '******' }, 'label2': { 'db_instance_type_default': 'db.m1.small', 'rds_user_name': 'defaultusername', # Actual database name, cannot include non-alphanumeric characters (e.g. '-') 'master_db_name': 'mydb2', 'volume_size': 100, 'backup_retention_period': 30, 'rds_engine': 'MySQL', # 5.6.19 is no longer supported 'rds_engine_version': '5.6.22', 'preferred_backup_window': '02:00-02:30', 'preferred_maintenance_window': 'sun:03:00-sun:04:00', # Name of vm snapshot to use, empty string ('') means don't use an old snapshot # Note: 'master_db_name' value will be overridden if snapshot_id is non-empty 'snapshot_id': '', 'password': '******' } } my_config = res.FACTORY_DEFAULT_CONFIG my_config['db'] = db_config env_config = EnvConfig(config_handlers=[RDS]) Controller(env_config=env_config, config_file_override=my_config)
def get_factory_defaults(): return {'my_child_template': {'favorite_color': 'blue'}} # When the user request to 'create' a new template the config.json file is read in. This file is checked to # ensure all required values are present. Because MyChildTemplate has additional requirements beyond that of # EnvironmentBase this function is used to add additional validation checks. @staticmethod def get_config_schema(): return {'my_child_template': {'favorite_color': 'str'}} class GrandchildTemplate(Template): def build_hook(self): self.add_resource( ec2.Instance("GrandchildEC2", InstanceType="m3.medium", ImageId="ami-e7527ed7", KeyName=self.ec2_key, SubnetId=self.subnets['private'][0], SecurityGroupIds=[self.common_security_group])) if __name__ == '__main__': # EnvConfig holds references to handler classes used to extend certain functionality # of EnvironmentBase. The config_handlers list takes any class that implements # get_factory_defaults() and get_config_schema(). env_config = EnvConfig(config_handlers=[ChildTemplate]) Controller(env_config=env_config)