Method: Beaker::OpenStack#key_name

Defined in:
lib/beaker/hypervisor/openstack.rb

#key_name(host) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Get key_name from options or generate a new rsa key and add it to OpenStack keypairs



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/beaker/hypervisor/openstack.rb', line 324

def key_name(host)
  if @options[:openstack_keyname]
    @logger.debug "Adding optional key_name #{@options[:openstack_keyname]} to #{host.name} (#{host[:vmhostname]})"
    @options[:openstack_keyname]
  else
    @logger.debug "Generate a new rsa key"
    key = OpenSSL::PKey::RSA.new 2048
    type = key.ssh_type
    data = [ key.to_blob ].pack('m0')
    @logger.debug "Creating Openstack keypair for public key '#{type} #{data}'"
    @compute_client.create_key_pair host[:vmhostname], "#{type} #{data}"
    host['ssh'][:key_data] = [ key.to_pem ]
    host[:vmhostname]
  end
end