Created
February 13, 2018 16:35
-
-
Save futoase/9f96137fce91d74b87c59b53587ad6bd to your computer and use it in GitHub Desktop.
Revisions
-
futoase created this gist
Feb 13, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ require 'openssl' require 'droplet_kit' PREFIX = 'prefix-' CLIENT_COUNT = 50 digest = OpenSSL::Digest.new("sha256") # get application token from https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-api-v2 # export DIGITAL_OCEAN_TOKEN=XXXXXXXX client = DropletKit::Client.new(access_token: ENV['DIGITAL_OCEAN_TOKEN']) my_ssh_keys = client.ssh_keys.all.collect { |key| key.fingerprint } CLIENT_COUNT.times do droplet = DropletKit::Droplet.new( name: "#{PREFIX}-#{digest.hexdigest(Time.now.to_s)}", region: 'sgp1', image: 'ubuntu-16-04-x64', size: '512mb', ssh_keys: my_ssh_keys ) p client.droplets.create(droplet) sleep 1 end # #p client.droplets.all().count # #client.droplets.all().each do |droplet| # p droplet.id #end