Class: Chef::Knife::SceKeyCreate

Inherits:
Chef::Knife show all
Includes:
SceBase
Defined in:
lib/chef/knife/sce_key_create.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
# File 'lib/chef/knife/sce_key_create.rb', line 33

def run
  
  $stdout.sync = true

  validate!
  
  @key = run!(config[:name])
  
  msg_pair("Name", @key.name.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_create.rb', line 28

def run!(key_name)
  @key = connection.keys.create(:name => key_name)
  @key
end

#validate!Object



47
48
49
50
51
52
53
54
# File 'lib/chef/knife/sce_key_create.rb', line 47

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