示例#1
0
文件: create.py 项目: flug/gonzo
def image_create(args):
    """ Create an image for a given instance, identified by name
    """

    cloud = get_current_cloud()
    instance = cloud.get_instance_by_name(args.instance_name)
    cloud.create_image(instance, args.image_name)
示例#2
0
def image_create(args):
    """ Create an image for a given instance, identified by name
    """

    cloud = get_current_cloud()
    instance = cloud.get_instance_by_name(args.instance_name)
    cloud.create_image(instance, args.image_name)
示例#3
0
文件: delete.py 项目: flug/gonzo
def image_delete(args):
    """ Delete an image for a given instance, identified by name
    """

    cloud = get_current_cloud()
    image = cloud.get_image_by_name(args.image_name)

    if image is not None:
        image.delete()
示例#4
0
def list_(args):
    """ Print summary info for all running stacks, or all stacks
        in any state (e.g. terminated) if args.only_running == True

    """

    cloud = get_current_cloud()
    stacks = cloud.list_stacks(only_running=args.only_running)

    print_table(print_stack_summary, headers, stacks, use_color=args.color)
示例#5
0
文件: show.py 项目: pombredanne/gonzo
def show(args):
    """ Print summary info for all running stacks, or all stacks
        in any state (e.g. terminated) if args.only_running == True

    """
    colorize_ = partial(colorize, use_color=args.color)

    cloud = get_current_cloud()
    stack = cloud.get_stack(args.stack_name_or_id)

    print_stack(stack, colorize_)
示例#6
0
def instance(*names):
    """ Set hosts to be that having the tags Name set to each of the
        arguments. Takes multiple names.
    """

    cloud = get_current_cloud()
    for name in names:
        inst = cloud.get_instance_by_name(name)
        dns_name = get_hostname(inst)
        env.hosts.append(dns_name)

    print env.hosts
示例#7
0
def list_(args):
    """ Print summary info for all running instances, or all instances
        in any state (e.g. terminated) if args.only_running == True

    """

    cloud = get_current_cloud()
    instances = cloud.list_instances(only_running=args.only_running)

    if args.order == 'name':
        instances.sort(key=lambda i: i.tags.get(args.order))

    print_table(print_instance_summary, headers, instances,
                use_color=args.color)
示例#8
0
def group(*env_type_pairs):
    """ Set hosts by group (environment-server_type) """

    cloud = get_current_cloud()
    for env_type_pair in env_type_pairs:
        # env_type_pair is e.g. produiction-platform-app
        # we want production, and platform-app
        environment, server_type = env_type_pair.split("-", 1)

        instances = cloud.get_instance_by_tags(
            environment=environment, server_type=server_type)
        env.hosts.extend([get_hostname(inst) for inst in instances])

    print env.hosts
示例#9
0
def terminate(args):
    """ Launch stacks """

    cloud = get_current_cloud()
    stack = cloud.get_stack(args.stack_name)
    stack_name = stack.name  # Get the name before it's deleted

    for instance in stack.get_instances():
        instance.delete_dns_entries()

    stack.delete()
    show_delete_progress(stack)

    colorize_ = partial(colorize, use_color=args.color)
    print colorize_('Deleted Stack', 'red'), stack_name
示例#10
0
def template(args):
    """ Print the template of a given stack or, if no stack is found, print
    the template that would be generated when launching.

    """

    cloud = get_current_cloud()
    stack_name = args.stack_name_or_id

    try:
        template_ = cloud.orchestration_connection.get_template(stack_name)
        template_ = json.dumps(template_, sort_keys=True, indent=4, separators=(",", ": "))
    except BotoServerError:
        # Stack doesn't exist. Generate a new template.
        stack_type = stack_name
        template_ = generate_stack_template(stack_type, stack_name, args.template_uri, args.template_params)

    print template_