Class: Chef::Knife::SceKeyGet

Inherits:
Chef::Knife show all
Includes:
SceBase
Defined in:
lib/chef/knife/sce_key_get.rb

Instance Method Summary collapse

Methods included from SceBase

#connection, #connection_storage, #datacenter_id, included, #locate_config_value, #msg_pair

Instance Method Details

#runObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/chef/knife/sce_key_get.rb', line 33

def run
  
  $stdout.sync = true

  validate!
  
  @key = run!(config[:name])
  
  raise "Key #{config[:name]} does not exist." if @key.nil?
  
  msg_pair("Name", @key.name.to_s)
  msg_pair("Instances", @key.instance_ids.join(", ").to_s)
  msg_pair("Default", (@key.default ? "Yes" : "No"))
  msg_pair("Key", @key.public_key.to_s)
  
end

#run!(key_name) ⇒ Object



28
29
30
31
# File 'lib/chef/knife/sce_key_get.rb', line 28

def run!(key_name)
  @key = connection.keys.get(key_name)
  @key
end

#validate!Object



50
51
52
53
54
55
56
57
# File 'lib/chef/knife/sce_key_get.rb', line 50

def validate!
  
  super
  
  raise "No key name specified." if @name_args.length == 0
  config[:name] = @name_args[0]
  
end