def main(args, evpc=None): """ Creates a new VPC and related services, modeled from a YAML template. :param args: The parsed arguments and flags from the CLI. :param evpc: :meth:`botoform.enriched.vpc.EnrichedVPC` or None. :returns: None """ # TODO: tags not implemented, not used. Pass to template or builder? aws_tags = key_value_to_dict(args.tags) # get extra_vars (context_vars) from command line. context_vars = key_value_to_dict(args.extra_vars) # get directionary from ArgParse Namespace object and merge into context_vars. context_vars.update(vars(args)) loader = ConfigLoader(context_vars=context_vars) config = loader.load(template_path=args.config) ebuilder = EnvironmentBuilder(args.vpc_name, config, args.region, args.profile) if args.dry_run: print(config) return None ebuilder.apply_all()
def main(args, evpc=None): """ Creates a new VPC and related services, modeled from a YAML template. :param args: The parsed arguments and flags from the CLI. :param evpc: :meth:`botoform.enriched.vpc.EnrichedVPC` or None. :returns: None """ # TODO: tags not implemented, not used. Pass to template or builder? aws_tags = key_value_to_dict(args.tags) # get extra_vars (context_vars) from command line. context_vars = key_value_to_dict(args.extra_vars) # get directionary from ArgParse Namespace object and merge into context_vars. context_vars.update(vars(args)) loader = ConfigLoader(context_vars = context_vars) config = loader.load(template_path = args.config) ebuilder = EnvironmentBuilder( args.vpc_name, config, args.region, args.profile) if args.dry_run: print(config) return None ebuilder.apply_all()
def get_builder_for_existing_vpc(evpc, config_path): loader = ConfigLoader(context_vars={'vpc_name' : evpc.name, 'vpc_cidr' : evpc.cidr_block}) config = loader.load(config_path) builder = EnvironmentBuilder(evpc.name, config, evpc.boto.region_name, evpc.boto.profile_name) builder.evpc = evpc builder.amis = config['amis'] return builder
def get_builder_for_existing_vpc(evpc, config_path): loader = ConfigLoader(context_vars={'vpc_name' : evpc.name, 'vpc_cidr' : evpc.cidr_block}) config = loader.load(config_path) builder = EnvironmentBuilder(evpc.name, config, evpc.boto.region_name, evpc.boto.profile_name) builder.evpc = evpc builder.amis = config['amis'] return builder
def test_load_template_file_without_context(self): loader = ConfigLoader() config = loader.load(template_path=self.template_path) self.assertEqual(len(config), 9) self.assertEqual(len(config['instance_roles']), 3) self.assertEqual(len(config['amis']), 4) self.assertEqual(len(config['security_groups']), 4) self.assertEqual(len(config['security_groups']['web']), 2)
def test_load_template_file_without_context(self): loader = ConfigLoader() config = loader.load(template_path=self.template_path) self.assertEqual(len(config), 12) self.assertEqual(len(config["instance_roles"]), 4) self.assertEqual(len(config["amis"]), 4) self.assertEqual(len(config["security_groups"]), 7) self.assertEqual(len(config["security_groups"]["web"]["inbound"]), 1)
def test_load_template_file_without_context(self): loader = ConfigLoader() config = loader.load(template_path = self.template_path) self.assertEqual(len(config), 12) self.assertEqual(len(config['instance_roles']), 4) self.assertEqual(len(config['amis']), 4) self.assertEqual(len(config['security_groups']), 7) self.assertEqual(len(config['security_groups']['web']['inbound']), 1)
def test_load_template_string_without_context(self): loader = ConfigLoader() loader.template_dir = "tests/fixtures" config = loader.load(template_string=self.template_string) self.assertEqual(len(config), 12) self.assertEqual(len(config["instance_roles"]), 4) self.assertEqual(len(config["amis"]), 4) self.assertEqual(len(config["security_groups"]), 7) self.assertEqual(len(config["security_groups"]["web"]["inbound"]), 1)
def test_load_template_string_without_context(self): loader = ConfigLoader() loader.template_dir = 'tests/fixtures' config = loader.load(template_string=self.template_string) self.assertEqual(len(config), 9) self.assertEqual(len(config['instance_roles']), 3) self.assertEqual(len(config['amis']), 4) self.assertEqual(len(config['security_groups']), 4) self.assertEqual(len(config['security_groups']['web']), 2)
def test_load_template_string_without_context(self): loader = ConfigLoader() loader.template_dir = 'tests/fixtures' config = loader.load(template_string = self.template_string) self.assertEqual(len(config), 12) self.assertEqual(len(config['instance_roles']), 4) self.assertEqual(len(config['amis']), 4) self.assertEqual(len(config['security_groups']), 7) self.assertEqual(len(config['security_groups']['web']['inbound']), 1)
def main(args, evpc): """Output a list of instance names. (example botoform plugin)""" context_vars = key_value_to_dict(args.vars) aws_tags = key_value_to_dict(args.tags) loader = ConfigLoader(context_vars=context_vars) config = loader.load(template_path=args.config) ebuilder = EnvironmentBuilder(args.vpc_name, config, args.region, args.profile) ebuilder.build_vpc(args.cidrblock) ebuilder.apply_all()
def main(args, evpc=None): """ Creates a new VPC and related services, modeled from a YAML template. :param args: The parsed arguments and flags from the CLI. :param evpc: :meth:`botoform.enriched.vpc.EnrichedVPC` or None. :returns: None """ extra_vars = key_value_to_dict(args.extra_vars) aws_tags = key_value_to_dict(args.tags) loader = ConfigLoader(context_vars=extra_vars) config = loader.load(template_path=args.config) ebuilder = EnvironmentBuilder(args.vpc_name, config, args.region, args.profile) ebuilder.apply_all()
def main(args, evpc=None): """ Creates a new VPC and related services, modeled from a YAML template. :param args: The parsed arguments and flags from the CLI. :param evpc: :meth:`botoform.enriched.vpc.EnrichedVPC` or None. :returns: None """ extra_vars = key_value_to_dict(args.extra_vars) aws_tags = key_value_to_dict(args.tags) loader = ConfigLoader(context_vars = extra_vars) config = loader.load(template_path = args.config) ebuilder = EnvironmentBuilder( args.vpc_name, config, args.region, args.profile) ebuilder.apply_all()
def get_builder_for_existing_vpc(evpc, args): # get extra_vars (context_vars) from command line. context_vars = key_value_to_dict(args.extra_vars) # get dictionary from ArgParse Namespace object and merge into context_vars. context_vars.update(vars(args)) # add some vars from evpc object. context_vars.update( {"vpc_name": evpc.name, "vpc_cidr": evpc.cidr_block, "region": evpc.region_name} ) loader = ConfigLoader(context_vars=context_vars) config = loader.load(args.config) builder = EnvironmentBuilder( evpc.name, config, evpc.boto.region_name, evpc.boto.profile_name ) builder.evpc = evpc builder.amis = config["amis"] return builder
def test_load_template_with_boolean(self): loader = ConfigLoader() config = loader.load(template_path=self.template_path) self.assertEqual(config["instance_roles"]["web"]["autoscaling"], True)
def test_constructor_context_vars_is_set(self): loader = ConfigLoader(context_vars=self.context_vars) self.assertTrue(len(loader.context_vars.keys()) == 2) self.assertTrue('cidrblock' in loader.context_vars.keys())
def test_constructor_default_context_vars_is_empty_dict(self): loader = ConfigLoader() self.assertTrue(len(loader.context_vars) == 0) self.assertEqual(loader.context_vars, {})
def test_load_template_with_boolean(self): loader = ConfigLoader() config = loader.load(template_path = self.template_path) self.assertEqual(config['instance_roles']['web']['autoscaling'], True)
def test_load_template_with_boolean(self): loader = ConfigLoader() config = loader.load(template_path=self.template_path) self.assertEqual(config['instance_roles']['web']['autoscaling'], True)