beaker-digitalocean 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/beaker/hypervisor/digitalocean.rb +60 -0
- metadata +59 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: '0039c19e03a103ef5437faf9fd935db50720f9c8'
|
|
4
|
+
data.tar.gz: 29504504b003e61d0da7de415995c4de8e3965ca
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 61f5b915c4b4a5c914b48789419fa50fcb9803dca83b45311ad735c1ab0911db0b1753bc0f63f877d78431b62b07f8329c416662ea6da65b63439c33438c6956
|
|
7
|
+
data.tar.gz: 37088cec40151a624439a2ee15931e7e7b10b8c21f9286496ecf4ee5af2f41a2381b47a66257d919b55b65fe01f912e8461ba404bb6030131adbbe66a9b1852b
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'barge'
|
|
2
|
+
|
|
3
|
+
module Beaker
|
|
4
|
+
|
|
5
|
+
class Digitalocean < Beaker::Hypervisor
|
|
6
|
+
|
|
7
|
+
SLEEPWAIT = 5
|
|
8
|
+
|
|
9
|
+
def initialize(digitalocean_hosts, options)
|
|
10
|
+
@options = options
|
|
11
|
+
@logger = options[:logger]
|
|
12
|
+
@hosts = digitalocean_hosts
|
|
13
|
+
@vms = []
|
|
14
|
+
@digitalocean_access_token = ENV['DO_TOKEN'] || @options[:digitalocean_access_token]
|
|
15
|
+
@digitalocean_ssh_keys = ENV['DO_SSH_KEY'] || @options[:digitalocean_ssh_keys]
|
|
16
|
+
@do ||= Barge::Client.new(access_token: @digitalocean_access_token )
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def provision
|
|
20
|
+
@hosts.each do |host|
|
|
21
|
+
host[:vmhostname] = generate_host_name
|
|
22
|
+
@logger.notify "Provisioning DigitalOcean #{host} droplet"
|
|
23
|
+
opts = {
|
|
24
|
+
:name => host[:vmhostname],
|
|
25
|
+
:image => host[:image],
|
|
26
|
+
:size => host[:size],
|
|
27
|
+
:region => host[:region],
|
|
28
|
+
:ssh_keys => [ @digitalocean_ssh_keys ],
|
|
29
|
+
}
|
|
30
|
+
vm = @do.droplet.create(opts)
|
|
31
|
+
|
|
32
|
+
if vm.success?
|
|
33
|
+
@logger.notify "Waiting for #{host.name} (#{host[:vmhostname]}) to respond"
|
|
34
|
+
wait = 0
|
|
35
|
+
loop do
|
|
36
|
+
sleep(1)
|
|
37
|
+
wait += 1
|
|
38
|
+
if wait > 180
|
|
39
|
+
fail 'Droplet taking too long to respond...'
|
|
40
|
+
end
|
|
41
|
+
@logger.notify "Waiting for #{host.name} (#{host[:vmhostname]}) to respond"
|
|
42
|
+
@doresp = @do.droplet.show(vm.droplet.id)
|
|
43
|
+
break if @doresp.droplet.status == 'active'
|
|
44
|
+
end
|
|
45
|
+
ip = @doresp.droplet.networks.v4.detect { |z| z.type == 'public' }
|
|
46
|
+
host[:ip] = ip.ip_address
|
|
47
|
+
@vms << vm
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def cleanup
|
|
53
|
+
@logger.notify "Cleaning DigitalOcean created instances"
|
|
54
|
+
@vms.each do |vm|
|
|
55
|
+
@logger.notify "Destroying host: #{vm.name}"
|
|
56
|
+
@do.droplet.destroy(vm.droplet.id)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: beaker-digitalocean
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Andre Tiengo
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-07-20 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: barge
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 0.11.0
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 0.11.0
|
|
27
|
+
description: Puppetlabs accceptance testing harness, using Digital Ocean as a hypervisor
|
|
28
|
+
email:
|
|
29
|
+
- andretiengo@gmail.com
|
|
30
|
+
executables: []
|
|
31
|
+
extensions: []
|
|
32
|
+
extra_rdoc_files: []
|
|
33
|
+
files:
|
|
34
|
+
- lib/beaker/hypervisor/digitalocean.rb
|
|
35
|
+
homepage: https://github.com/tiengo/beaker-digitalocean
|
|
36
|
+
licenses:
|
|
37
|
+
- Apache2
|
|
38
|
+
metadata: {}
|
|
39
|
+
post_install_message:
|
|
40
|
+
rdoc_options: []
|
|
41
|
+
require_paths:
|
|
42
|
+
- lib
|
|
43
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
|
+
requirements:
|
|
50
|
+
- - ">="
|
|
51
|
+
- !ruby/object:Gem::Version
|
|
52
|
+
version: '0'
|
|
53
|
+
requirements: []
|
|
54
|
+
rubyforge_project:
|
|
55
|
+
rubygems_version: 2.6.6
|
|
56
|
+
signing_key:
|
|
57
|
+
specification_version: 4
|
|
58
|
+
summary: Let's test Puppet, using Digital Ocean!
|
|
59
|
+
test_files: []
|