Class: Kitchen::Driver::Softlayer

Inherits:
SSHBase
  • Object
show all
Defined in:
lib/kitchen/driver/softlayer.rb

Overview

Softlayer driver for Kitchen. rubocop:disable Metrics/LineLength

Instance Method Summary collapse

Instance Method Details

#create(state) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/kitchen/driver/softlayer.rb', line 78

def create(state)
  config[:server_name] = default_name unless config[:server_name]
  config[:disable_ssl_validation] && disable_ssl_validation
  server = find_server(config[:hostname])
  server = create_server unless server
  state[:server_id] = server.id
  info "Softlayer instance <#{state[:server_id]}> created."
  server.wait_for do
    print '.'
    ready?
  end
  info "\n(server ready)"
  tag_server(server)
  if config[:ssh_via_hostname]
    state[:hostname] = config[:hostname]
  elsif config[:alternate_ip]
    state[:hostname] = config[:alternate_ip]
  else
    state[:hostname] = get_ip(server)
  end
  setup_ssh(server, state)
  wait_for_ssh_key_access(state)
rescue Fog::Errors::Error, Excon::Errors::Error => ex
  raise ActionFailed, ex.message
end

#destroy(state) ⇒ Object



104
105
106
107
108
109
110
111
112
113
114
# File 'lib/kitchen/driver/softlayer.rb', line 104

def destroy(state)
  return if state[:server_id].nil?

  config[:disable_ssl_validation] && disable_ssl_validation
  server = compute.servers.get(state[:server_id])
  server.destroy unless server.nil? || server.id.nil?
  wait_for_server_to_delete(state) if config[:destroy_wait]
  info "Softlayer instance <#{state[:server_id]}> destroyed."
  state.delete(:server_id)
  state.delete(:hostname)
end