Class: Chef::Knife::SoftlayerKeyPairCreate

Inherits:
Chef::Knife
  • Object
show all
Includes:
SoftlayerBase
Defined in:
lib/chef/knife/softlayer_key_pair_create.rb

Constant Summary

Constants included from SoftlayerBase

Chef::Knife::SoftlayerBase::USER_AGENT

Instance Method Summary collapse

Methods included from SoftlayerBase

#compute, #connection, included, #locate_config_value, #msg_pair, #network

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/chef/knife/softlayer_key_pair_create.rb', line 18

def run
  $stdout.sync = true
  opts = {
      :label => ui.ask_question("Enter the label for this key pair: "),
      :key => ui.ask("Enter path to the public key: ", lambda{ |answer| IO.read(answer) })
  }

  key_pair = connection(:compute).key_pairs.create(opts)

  if !!key_pair
    puts "#{ui.color("Key pair successfully created.  Provisioning may take a few minutes to complete.", :green)}"
    puts "#{ui.color("Key pair ID is: ", :green)} #{key_pair.id}"
  else
    puts "#{ui.color("Encountered a problem verifying key pair creation.  Please try again.", :yellow)}"
  end
end