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")
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)))
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)
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)
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)
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)
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)
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)
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))
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))
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,)
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, )
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)
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'])
def main(args): d0 = connect_d0() ssh_key_id = args.key_id _ = d0.delete_key_pair(ssh_key_id=ssh_key_id)
def main(args): d0 = connect_d0() _ = d0.get_all_images(table=True)
def main(args): d0 = connect_d0() id = args.droplet_id droplet = d0.get_droplet(id=id) droplet.destroy()
def main(args): d0 = connect_d0() _ = d0.get_all_ssh_keys(table=True)
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()