Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
 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()
Ejemplo n.º 4
0
    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()
Ejemplo n.º 5
0
    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()
Ejemplo n.º 6
0
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
Ejemplo n.º 7
0
def test_key_value_to_dict():
    key_value_list = ["a=1,b=2", "c=3, d=4", "e=5"]
    desired_result = {"a": "1", "b": "2", "c": "3", "d": "4", "e": "5"}
    assert key_value_to_dict(key_value_list) == desired_result
Ejemplo n.º 8
0
def test_key_value_to_dict():
    key_value_list = ['a=1,b=2', 'c=3, d=4', 'e=5']
    desired_result = {'a':'1', 'b':'2', 'c':'3', 'd':'4', 'e':'5'}
    assert(key_value_to_dict(key_value_list) == desired_result)
Ejemplo n.º 9
0
def test_key_value_to_dict():
    key_value_list = ['a=1,b=2', 'c=3, d=4', 'e=5']
    desired_result = {'a': '1', 'b': '2', 'c': '3', 'd': '4', 'e': '5'}
    assert (key_value_to_dict(key_value_list) == desired_result)