Class: Beaker::Hcloud
- Inherits:
-
Hypervisor
- Object
- Hypervisor
- Beaker::Hcloud
- Defined in:
- lib/beaker/hypervisor/hcloud.rb
Overview
beaker extension to manage cloud instances from www.hetzner.com/cloud
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(hosts, options) ⇒ Hcloud
constructor
A new instance of Hcloud.
- #provision ⇒ Object
Constructor Details
#initialize(hosts, options) ⇒ Hcloud
Returns a new instance of Hcloud.
14 15 16 17 18 19 20 21 22 |
# File 'lib/beaker/hypervisor/hcloud.rb', line 14 def initialize(hosts, ) # rubocop:disable Lint/MissingSuper = @logger = [:logger] || Beaker::Logger.new @hosts = hosts raise 'You need to pass a token as BEAKER_HCLOUD_TOKEN environment variable' unless ENV['BEAKER_HCLOUD_TOKEN'] @client = ::Hcloud::Client.new(token: ENV.fetch('BEAKER_HCLOUD_TOKEN')) end |
Instance Method Details
#cleanup ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/beaker/hypervisor/hcloud.rb', line 33 def cleanup @logger.notify 'Cleaning up hcloud' @hosts.each do |host| @logger.debug("Deleting hcloud server #{host.name}") @client.servers.find(host[:hcloud_id]).destroy end @logger.notify 'Deleting hcloud SSH key' @client.ssh_keys.find([:ssh][:hcloud_id]).destroy File.unlink(@key_file.path) @logger.notify 'Done cleaning up hcloud' end |
#provision ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/beaker/hypervisor/hcloud.rb', line 24 def provision @logger.notify 'Provisioning hcloud' create_ssh_key @hosts.each do |host| create_server(host) end @logger.notify 'Done provisioning hcloud' end |