示例#1
0
def machine_action(args):

    client = authenticate()

    if args.action == "list-machines":
        if args.backend or args.backend_id or args.backend_name:
            backend = return_backend(client, args)
        else:
            backend = None

        pretty = args.pretty
        metadata = args.metadata

        list_machines(client, backend, metadata, pretty)

    elif args.action == "describe-machine":
        machine = choose_machine(client, args)

        display_machine(machine)

    elif args.action == "create-machine":
        backend = return_backend(client, args)
        create_machine(client, backend, args)
        print "Created machine %s" % args.machine_name

    elif args.action in ["start", "stop", "reboot", "destroy", "probe"]:
        machine = choose_machine(client, args)

        machine_take_action(machine, args.action)
    elif args.action == "enable-monitoring":
        machine = choose_machine(client, args)
        machine.enable_monitoring()
        print "Enabled monitoring to machine %s" % machine.name

    elif args.action == "disable-monitoring":
        machine = choose_machine(client, args)
        machine.disable_monitoring()
        print "Disabled monitoring to machine %s" % machine.name

    elif args.action == "tag":
        machine = choose_machine(client, args)

        if machine.info["can_tag"]:
            machine.tag(tag=args.new_tag)
            print "Add tag %s to machine %s" % (args.new_tag, machine.name)
        else:
            print "Cannot tag machine on provider %s" % machine.backend.title
            sys.exit(0)
示例#2
0
def machine_action(args):

    client = authenticate()

    if args.action == 'list-machines':
        if args.backend or args.backend_id or args.backend_name:
            backend = return_backend(client, args)
        else:
            backend = None

        pretty = args.pretty
        metadata = args.metadata

        list_machines(client, backend, metadata, pretty)

    elif args.action == 'describe-machine':
        machine = choose_machine(client, args)

        display_machine(machine)

    elif args.action == 'create-machine':
        backend = return_backend(client, args)
        create_machine(client, backend, args)
        print "Created machine %s" % args.machine_name

    elif args.action in ['start', 'stop', 'reboot', 'destroy', 'probe']:
        machine = choose_machine(client, args)

        machine_take_action(machine, args.action)
    elif args.action == 'enable-monitoring':
        machine = choose_machine(client, args)
        machine.enable_monitoring()
        print "Enabled monitoring to machine %s" % machine.name

    elif args.action == 'disable-monitoring':
        machine = choose_machine(client, args)
        machine.disable_monitoring()
        print "Disabled monitoring to machine %s" % machine.name

    elif args.action == 'tag':
        machine = choose_machine(client, args)

        if machine.info['can_tag']:
            machine.tag(tag=args.new_tag)
            print "Add tag %s to machine %s" % (args.new_tag, machine.name)
        else:
            print "Cannot tag machine on provider %s" % machine.backend.title
            sys.exit(0)
示例#3
0
def network_action(args):
    if args.action == 'list-networks':
        client = authenticate()
        backend = return_backend(client, args)
        pretty = args.pretty

        list_networks(backend, pretty)
示例#4
0
def network_action(args):
    if args.action == 'list-networks':
        client = authenticate()
        backend = return_backend(client, args)
        pretty = args.pretty

        list_networks(backend, pretty)
示例#5
0
def machine_action(args):

    client = authenticate()

    if args.action == 'list-machines':
        if args.backend or args.backend_id or args.backend_name:
            backend = return_backend(client, args)
        else:
            backend = None

        pretty = args.pretty

        list_machines(client, backend, pretty)

    elif args.action == 'describe-machine':
        machine = choose_machine(client, args)

        display_machine(machine)

    elif args.action == 'create-machine':
        backend = return_backend(client, args)
        create_machine(client, backend, args)
        print "Created machine %s" % args.machine_name

    elif args.action in ['start', 'stop', 'reboot', 'destroy', 'probe']:
        machine = choose_machine(client, args)

        machine_take_action(machine, args.action)
    elif args.action == 'enable-monitoring':
        machine = choose_machine(client, args)
        machine.enable_monitoring()
        print "Enabled monitoring to machine %s" % machine.name

    elif args.action == 'disable-monitoring':
        machine = choose_machine(client, args)
        machine.disable_monitoring()
        print "Disabled monitoring to machine %s" % machine.name

    elif args.action == 'tag':
        machine = choose_machine(client, args)

        if machine.info['can_tag']:
            machine.tag(tag=args.new_tag)
            print "Add tag %s to machine %s" % (args.new_tag, machine.name)
        else:
            print "Cannot tag machine on provider %s" % machine.backend.title
            sys.exit(0)
示例#6
0
def size_action(args):

    if args.action == "list-sizes":
        client = authenticate()
        backend = return_backend(client, args)

        pretty = args.pretty
        list_sizes(backend, pretty)
示例#7
0
def location_action(args):

    if args.action == 'list-locations':
        client = authenticate()
        backend = return_backend(client, args)
        pretty = args.pretty

        list_locations(backend, pretty)
示例#8
0
def size_action(args):

    if args.action == 'list-sizes':
        client = authenticate()
        backend = return_backend(client, args)

        pretty = args.pretty
        list_sizes(backend, pretty)
示例#9
0
def image_action(args):

    if args.action == 'list-images':
        client = authenticate()
        backend = return_backend(client, args)
        search_term = args.search
        pretty = args.pretty

        list_images(backend, search_term, pretty)