Class: ClusterChef::Ec2Keypair

Inherits:
PrivateKey show all
Defined in:
lib/cluster_chef/private_key.rb

Instance Attribute Summary

Attributes inherited from PrivateKey

#name, #on_update, #proxy

Instance Method Summary collapse

Methods inherited from PrivateKey

#body=, create!, #filename, #initialize, #load, #save, #to_s

Methods inherited from DslObject

#configure, #die, #dump, has_keys, #initialize, #reverse_merge!, #safely, #set, #step, #to_hash, #to_mash, #to_s, ui, #ui

Constructor Details

This class inherits a constructor from ClusterChef::PrivateKey

Instance Method Details

#bodyObject


99
100
101
102
103
104
105
106
107
# File 'lib/cluster_chef/private_key.rb', line 99

def body
  return @body if @body
  if proxy && proxy.private_key && (not proxy.private_key.empty?)
    @body = proxy.private_key
  else
    load
  end
  @body
end

#create_proxy!Object


109
110
111
112
113
114
115
116
117
# File 'lib/cluster_chef/private_key.rb', line 109

def create_proxy!
  safely do
    step("    key #{name} - creating", :green)
    @proxy = ClusterChef.fog_connection.key_pairs.create(:name => name.to_s)
  end
  ClusterChef.fog_keypairs[name] = proxy
  self.body = proxy.private_key
  save
end

#key_dirObject


119
120
121
122
123
124
125
126
127
# File 'lib/cluster_chef/private_key.rb', line 119

def key_dir
  if Chef::Config.ec2_key_dir
    return Chef::Config.ec2_key_dir
  else
    dir = "#{ENV['HOME']}/.chef/ec2_keys"
    warn "Please set 'ec2_key_dir' in your knife.rb. Will use #{dir} as a default"
    dir
  end
end