From f529f764258135cb326e2c557b99dab2130e410a Mon Sep 17 00:00:00 2001 From: cloudcowboyco Date: Thu, 16 Jul 2015 08:20:26 -0700 Subject: [PATCH 1/3] Added some functionallity for displaying a list of ssh keys from your account --- create_cluster.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/create_cluster.rb b/create_cluster.rb index 3be5d53..3fac446 100644 --- a/create_cluster.rb +++ b/create_cluster.rb @@ -14,6 +14,23 @@ # clear the screen system('clear') or system('cls') +session = DropletKit::Client.new(access_token: @token) +ssh_id_array = Array.new +session.ssh_keys.all().each { |x| ssh_id_array.push(x) } +puts "Enter which key you would like to use" +puts "-------------------------------------" +puts " " +count = 1 +ssh_id_array.each { |ssh_key| + puts "#{count.to_s} #{ssh_key.name} #{ssh_key.id}" + count += 1 + } +puts "-------------------------------------" +ssh_keys = ssh_id_array[gets.chomp().to_i-1].id +#puts ssh_keys + +system('clear') or system('cls') + puts "Multi-Node Wordpres Deployment Tool" puts "-----------------------------------" puts " " From 10e5433db8170955bb185d8236140a5a4aa081d1 Mon Sep 17 00:00:00 2001 From: cloudcowboyco Date: Wed, 22 Jul 2015 13:55:21 -0700 Subject: [PATCH 2/3] I have added functionallity to query DO for your SSH keys. Currently rough but it gets the job done. I plan on cleaning it up. --- create_cluster.rb | 50 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/create_cluster.rb b/create_cluster.rb index 3fac446..cc69d99 100644 --- a/create_cluster.rb +++ b/create_cluster.rb @@ -11,6 +11,56 @@ require 'securerandom' require './deploy.rb' +require 'io/console' + +def yesno() + case $stdin.getch + when "Y" then true + when "N" then false + when "n" then false + when "y" then true + else + puts "Invalid character." + yesno() + end +end + +session = DropletKit::Client.new(access_token: @token) +ssh_id_array = Array.new +session.ssh_keys.all().each { |x| ssh_id_array.push(x) } +puts "PICK YOUR SSH KEY" +count = 1 +ssh_id_array.each { |ssh_key| + puts "#{count.to_s} #{ssh_key.name} #{ssh_key.id}" + count += 1 + } + +keys_complete = false +user_keys = [] +while keys_complete == false + puts "Please select a key:" + user_input = gets.chomp() + if user_input.to_i.between?(1,session.ssh_keys.all().count.to_i) + if user_keys.include? user_input.to_i + puts 'That key has already been selected' + else + user_keys.push(user_input) + end + else + puts "You need to select a key from the list." + end + puts "Do you want to add any other keys? [Y/N]" + if yesno() + keys_complete = false + else + keys_complete = true + end +end +puts ssh_id_array[1] +user_keys.each { |keys_blah| + @ssh_keys.push(ssh_id_array[keys_blah.to_i-1].id) +} + # clear the screen system('clear') or system('cls') From 8341dc23fc4bdc67aaf2b6aa8490a9ac44174c91 Mon Sep 17 00:00:00 2001 From: CloudCowboyCo Date: Wed, 22 Jul 2015 15:02:31 -0700 Subject: [PATCH 3/3] Update create_cluster.rb Removed my original commit. --- create_cluster.rb | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/create_cluster.rb b/create_cluster.rb index cc69d99..6002e6d 100644 --- a/create_cluster.rb +++ b/create_cluster.rb @@ -64,23 +64,6 @@ def yesno() # clear the screen system('clear') or system('cls') -session = DropletKit::Client.new(access_token: @token) -ssh_id_array = Array.new -session.ssh_keys.all().each { |x| ssh_id_array.push(x) } -puts "Enter which key you would like to use" -puts "-------------------------------------" -puts " " -count = 1 -ssh_id_array.each { |ssh_key| - puts "#{count.to_s} #{ssh_key.name} #{ssh_key.id}" - count += 1 - } -puts "-------------------------------------" -ssh_keys = ssh_id_array[gets.chomp().to_i-1].id -#puts ssh_keys - -system('clear') or system('cls') - puts "Multi-Node Wordpres Deployment Tool" puts "-----------------------------------" puts " "