示例#1
0
文件: wait.py 项目: waytai/doto
def main(args):
    d0 = connect_d0()
    e = Event(d0._conn, args.event_id)

    print("Event %s" % e)
    if args.wait:
        e.wait(callback=print_callback)
        print("Finished")
示例#2
0
文件: wait.py 项目: LIGHTCURV/doto2
def main(args):
    d0 = connect_d0()
    e = Event(d0._conn, args.event_id)
    
    print("Event %s" % e)
    if args.wait: 
        e.wait(callback=print_callback)
        print("Finished")
示例#3
0
文件: info.py 项目: LIGHTCURV/doto2
def main(args):
    d0 = connect_d0()
    try:
        droplet = d0.get_droplet(int(args.droplet_name))
    except ValueError:
        droplet = d0.get_droplet_by_name(args.droplet_name)

    sys.stdout.write(str(getattr(droplet, args.attr)))
示例#4
0
文件: test_gets.py 项目: waytai/doto
 def test_gets(self):
     d0 = doto.connect_d0()
     self.assertEqual(d0.get_all_ssh_keys(status_check=True), 200)
     self.assertEqual(d0.get_all_regions(status_check=True), 200)
     self.assertEqual(d0.get_sizes(status_check=True), 200)
     self.assertEqual(d0.get_all_droplets(status_check=True), 200)
     self.assertEqual(d0.get_all_images(status_check=True), 200)
     self.assertEqual(d0.get_domains(status_check=True), 200)
示例#5
0
 def test_gets(self):
     d0 = doto.connect_d0()
     self.assertEqual(d0.get_all_ssh_keys(status_check=True),200)
     self.assertEqual(d0.get_all_regions(status_check=True),200)
     self.assertEqual(d0.get_sizes(status_check=True),200)
     self.assertEqual(d0.get_all_droplets(status_check=True),200)
     self.assertEqual(d0.get_all_images(status_check=True),200)
     self.assertEqual(d0.get_domains(status_check=True),200)
示例#6
0
def main(args):
    d0 = connect_d0()
    try:
        droplet = d0.get_droplet(int(args.droplet_name))
    except ValueError:
        droplet = d0.get_droplet_by_name(args.droplet_name)

    sys.stdout.write(str(getattr(droplet, args.attr)))
示例#7
0
def main(args):
    d0 = connect_d0()

    if args.droplet_id:
        data  = d0.get_droplet(args.droplet_id,raw_data=True)
        d0._pprint_table([data['droplet']])

    else:
        d0.get_all_droplets(table=True)
示例#8
0
文件: createkey.py 项目: waytai/doto
def main(args):
    d0 = connect_d0()
    print(args.output_file)
    print(args.dry_run)

    if not args.output_file:
        print("Please provide a key name")
        raise ShowHelp()

    ssh_key_name = args.output_file
    d0.create_key_pair(ssh_key_name=ssh_key_name,cli=True,
                       dry_run=args.dry_run)
示例#9
0
文件: snapshot.py 项目: waytai/doto
def main(args):

    d0 = connect_d0()
    droplet = d0.get_droplet_by_name(args.droplet_name)

    e = droplet.create_snapshot(args.image_name)

    print("Snapshot Droplet")
    if args.wait:
        e.wait(callback=print_callback)
        print("Finished")
    else:
        print("Event %s" % e.event_id)
示例#10
0
def main(args):
    
    d0 = connect_d0()
    droplet = d0.get_droplet_by_name(args.droplet_name)
    
    e = droplet.create_snapshot(args.image_name)
    
    print("Snapshot Droplet")
    if args.wait: 
        e.wait(callback=print_callback)
        print("Finished")
    else:
        print("Event %s" % e.event_id)
示例#11
0
文件: power.py 项目: waytai/doto
def power_off(args):
    d0 = connect_d0()
    try:
        droplet = d0.get_droplet(int(args.droplet_name))
    except ValueError:
        droplet = d0.get_droplet_by_name(args.droplet_name)

    e = droplet.power_off()
    
    print("Powering Off")
    if args.wait: 
        e.wait(callback=print_callback)
        print("Finished")
    else:
        print("Event %s" % e.event_id)
示例#12
0
文件: image.py 项目: waytai/doto
def main(args):

    d0 = connect_d0()
    for image_name in args.image_names:
        image = d0.get_image_by_name(image_name)
        if image is None and args.fail_fast:
            raise Exception("Image %s does not exist" % image_name)
        elif image is None:
            print("Image %s does not exist" % image_name)
            continue

        if args.action == "show":
            print(image)
        elif args.action == "destroy":
            image.destroy()
            print("Image %s destroyed" % (image.id))
示例#13
0
文件: image.py 项目: waytai/doto
def main(args):

    d0 = connect_d0()
    for image_name in args.image_names:
        image = d0.get_image_by_name(image_name)
        if image is None and args.fail_fast:
            raise Exception("Image %s does not exist" % image_name)
        elif image is None:
            print("Image %s does not exist" % image_name)
            continue

        if args.action == 'show':
            print(image)
        elif args.action == 'destroy':
            image.destroy()
            print('Image %s destroyed' % (image.id))
示例#14
0
文件: start.py 项目: LIGHTCURV/doto2
def main(args):
    d0 = connect_d0()


    name = args.name
    size_id = args.size_id
    image_id = args.image_id
    region_id = args.region_id
    ssh_keys = args.ssh_key_ids

    #convert ssh_keys to list of ints
    ssh_keys = ssh_keys.split(',')
    ssh_key_ids = [int(key) for key in ssh_keys]

    d0.create_droplet(name=name,size_id=size_id,
                      image_id=image_id,region_id=region_id,
                      ssh_key_ids=ssh_key_ids,)
示例#15
0
def main(args):
    d0 = connect_d0()

    name = args.name
    size_id = args.size_id
    image_id = args.image_id
    region_id = args.region_id
    ssh_keys = args.ssh_key_ids

    #convert ssh_keys to list of ints
    ssh_keys = ssh_keys.split(',')
    ssh_key_ids = [int(key) for key in ssh_keys]

    d0.create_droplet(
        name=name,
        size_id=size_id,
        image_id=image_id,
        region_id=region_id,
        ssh_key_ids=ssh_key_ids,
    )
示例#16
0
文件: reset.py 项目: LIGHTCURV/doto2
def rebuild(args):
    
    d0 = connect_d0()
    droplet = d0.get_droplet_by_name(args.droplet_name)
    
    if args.image:
        try:
            image_id = int(args.image)
        except ValueError:
            image_id = d0.get_image_by_name(args.image)
    else:
        image_id = droplet.image_id
            
    e = droplet.rebuild(image_id)
    
    print("Rebuild Droplet")
    if args.wait: 
        e.wait(callback=print_callback)
        print("Finished")
    else:
        print("Event %s" % e.event_id)
示例#17
0
import doto

d0 = doto.connect_d0()
new_key = d0.create_key_pair(ssh_key_name='a_new_key_test')
d0.get_all_ssh_keys(table=True)

droplet = d0.create_droplet(name='Random',
                            size_id=66, #512MB
                            image_id=2158507, #Docker 0.8 Ubuntu 13.04 x64
                            region_id=1, #New York
                            ssh_key_ids=[new_key['id']]
                            )



while droplet.percentage_update() != '100':
    print droplet.percentage

droplet.reboot()

while droplet.percentage_update() != '100':
    print droplet.percentage

droplet.rebuild(use_current=True)

while droplet.percentage_update() != '100':
    print droplet.percentage

droplet.destroy()
d0.delete_key_pair(ssh_key_id=new_key['id'])
示例#18
0
文件: deletekey.py 项目: waytai/doto
def main(args):
    d0 = connect_d0()

    ssh_key_id = args.key_id
    _ = d0.delete_key_pair(ssh_key_id=ssh_key_id)
示例#19
0
def main(args):
    d0 = connect_d0()
    _ = d0.get_all_images(table=True)
示例#20
0
def main(args):
    d0 = connect_d0()

    id = args.droplet_id
    droplet = d0.get_droplet(id=id)
    droplet.destroy()
示例#21
0
def main(args):
    d0 = connect_d0()

    id = args.droplet_id
    droplet = d0.get_droplet(id=id)
    droplet.destroy()
示例#22
0
def main(args):
    d0 = connect_d0()
    _ = d0.get_all_ssh_keys(table=True)
示例#23
0
文件: deletekey.py 项目: waytai/doto
def main(args):
    d0 = connect_d0()

    ssh_key_id = args.key_id
    _ = d0.delete_key_pair(ssh_key_id=ssh_key_id)
示例#24
0
import os
import unittest

import doto

d0 = doto.connect_d0()

class TestConfig(unittest.TestCase):

    def test_get_all_droplets(self):
        self.assertEqual(d0.get_all_droplets(status_check=True),200)
        self.assertEqual(d0.get_sizes(status_check=True),200)
        self.assertEqual(d0.get_images(status_check=True),200)
        self.assertEqual(d0.get_domains(status_check=True),200)
        self.assertEqual(d0.get_regions(status_check=True),200)
        self.assertEqual(d0.get_ssh_keys(status_check=True),200)

if __name__ == '__main__':
    unittest.main()


droplet.power_off()
while droplet.event_status != 'done':
    droplet.event_update()