Class: Kitchen::Driver::Vsphere
- Inherits:
-
SSHBase
- Object
- SSHBase
- Kitchen::Driver::Vsphere
- Defined in:
- lib/kitchen/driver/vsphere.rb
Overview
Vsphere driver for Kitchen.
Instance Method Summary collapse
Instance Method Details
#create(state) ⇒ Object
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/kitchen/driver/vsphere.rb', line 52 def create(state) config[:server_name] ||= generate_name(instance.name) server = create_server(state) wait_for_sshd_updating_ip(state, server) if config[:upload_public_ssh_key] upload_public_ssh_key(state, config) end rescue ::Fog::Errors::Error, Excon::Errors::Error => ex raise ActionFailed, ex. end |
#destroy(state) ⇒ Object
63 64 65 66 67 68 69 70 71 |
# File 'lib/kitchen/driver/vsphere.rb', line 63 def destroy(state) return if state[:server_id].nil? server = compute.servers.get(state[:server_id]) server.destroy unless server.nil? info "VSphere instance <#{state[:server_id]}> destroyed." state.delete(:server_id) state.delete(:hostname) end |
#wait_for_sshd_updating_ip(state, server) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/kitchen/driver/vsphere.rb', line 37 def wait_for_sshd_updating_ip(state, server) begin state[:hostname] = server.public_ip_address timeout(5) { wait_for_sshd(state[:hostname], config[:username], { :port => config[:port] }) info "SSH connected to #{state[:hostname]}:#{config[:port]}" } rescue Timeout::Error server = compute.servers.get(state[:server_id]) retry if server raise ActionFailed, 'Server deleted' end end |