chef-provisioning-fog 0.14.0 → 0.15.0
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 +4 -4
- data/LICENSE +201 -201
- data/README.md +3 -3
- data/Rakefile +6 -6
- data/lib/chef/provider/fog_key_pair.rb +266 -266
- data/lib/chef/provisioning/driver_init/fog.rb +3 -3
- data/lib/chef/provisioning/fog_driver/driver.rb +736 -709
- data/lib/chef/provisioning/fog_driver/providers/aws.rb +492 -492
- data/lib/chef/provisioning/fog_driver/providers/aws/credentials.rb +115 -115
- data/lib/chef/provisioning/fog_driver/providers/cloudstack.rb +44 -44
- data/lib/chef/provisioning/fog_driver/providers/digitalocean.rb +136 -136
- data/lib/chef/provisioning/fog_driver/providers/google.rb +85 -84
- data/lib/chef/provisioning/fog_driver/providers/joyent.rb +63 -59
- data/lib/chef/provisioning/fog_driver/providers/openstack.rb +117 -41
- data/lib/chef/provisioning/fog_driver/providers/rackspace.rb +42 -42
- data/lib/chef/provisioning/fog_driver/providers/softlayer.rb +36 -36
- data/lib/chef/provisioning/fog_driver/providers/vcair.rb +409 -376
- data/lib/chef/provisioning/fog_driver/providers/xenserver.rb +210 -0
- data/lib/chef/provisioning/fog_driver/recipe_dsl.rb +32 -32
- data/lib/chef/provisioning/fog_driver/version.rb +7 -7
- data/lib/chef/resource/fog_key_pair.rb +34 -34
- data/spec/spec_helper.rb +18 -18
- data/spec/support/aws/config-file.csv +2 -2
- data/spec/support/aws/ini-file.ini +10 -10
- data/spec/support/chef_metal_fog/providers/testdriver.rb +16 -16
- data/spec/unit/chef/provisioning/fog_driver/driver_spec.rb +71 -0
- data/spec/unit/fog_driver_spec.rb +32 -32
- data/spec/unit/providers/aws/credentials_spec.rb +45 -45
- data/spec/unit/providers/rackspace_spec.rb +16 -16
- metadata +5 -3
@@ -1,84 +1,85 @@
|
|
1
|
-
class Chef
|
2
|
-
module Provisioning
|
3
|
-
module FogDriver
|
4
|
-
module Providers
|
5
|
-
class Google < FogDriver::Driver
|
6
|
-
Driver.register_provider_class('Google', FogDriver::Providers::Google)
|
7
|
-
|
8
|
-
def creator
|
9
|
-
''
|
10
|
-
end
|
11
|
-
|
12
|
-
def converge_floating_ips(action_handler, machine_spec, machine_options, server)
|
13
|
-
end
|
14
|
-
|
15
|
-
def server_for(machine_spec)
|
16
|
-
if machine_spec.name
|
17
|
-
compute.servers.get(machine_spec.name)
|
18
|
-
else
|
19
|
-
nil
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def servers_for(machine_specs)
|
24
|
-
result = {}
|
25
|
-
machine_specs.each do |machine_spec|
|
26
|
-
result[machine_spec] = server_for(machine_spec)
|
27
|
-
end
|
28
|
-
result
|
29
|
-
end
|
30
|
-
|
31
|
-
def bootstrap_options_for(action_handler, machine_spec, machine_options)
|
32
|
-
bootstrap_options = symbolize_keys(machine_options[:bootstrap_options] || {})
|
33
|
-
bootstrap_options[:image_name]
|
34
|
-
bootstrap_options[:machine_type]
|
35
|
-
bootstrap_options[:zone_name]
|
36
|
-
bootstrap_options[:name]
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
disk
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
strategy
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
new_compute_options
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
:
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
1
|
+
class Chef
|
2
|
+
module Provisioning
|
3
|
+
module FogDriver
|
4
|
+
module Providers
|
5
|
+
class Google < FogDriver::Driver
|
6
|
+
Driver.register_provider_class('Google', FogDriver::Providers::Google)
|
7
|
+
|
8
|
+
def creator
|
9
|
+
''
|
10
|
+
end
|
11
|
+
|
12
|
+
def converge_floating_ips(action_handler, machine_spec, machine_options, server)
|
13
|
+
end
|
14
|
+
|
15
|
+
def server_for(machine_spec)
|
16
|
+
if machine_spec.name
|
17
|
+
compute.servers.get(machine_spec.name)
|
18
|
+
else
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def servers_for(machine_specs)
|
24
|
+
result = {}
|
25
|
+
machine_specs.each do |machine_spec|
|
26
|
+
result[machine_spec] = server_for(machine_spec)
|
27
|
+
end
|
28
|
+
result
|
29
|
+
end
|
30
|
+
|
31
|
+
def bootstrap_options_for(action_handler, machine_spec, machine_options)
|
32
|
+
bootstrap_options = symbolize_keys(machine_options[:bootstrap_options] || {})
|
33
|
+
bootstrap_options[:image_name] ||= 'debian-7-wheezy-v20150325'
|
34
|
+
bootstrap_options[:machine_type] ||= 'n1-standard-1'
|
35
|
+
bootstrap_options[:zone_name] ||= 'europe-west1-b'
|
36
|
+
bootstrap_options[:name] ||= machine_spec.name
|
37
|
+
bootstrap_options[:disk_size] ||= 10
|
38
|
+
|
39
|
+
if bootstrap_options[:disks].nil?
|
40
|
+
# create the persistent boot disk
|
41
|
+
disk_defaults = {
|
42
|
+
:name => machine_spec.name,
|
43
|
+
:size_gb => bootstrap_options[:disk_size],
|
44
|
+
:zone_name => bootstrap_options[:zone_name],
|
45
|
+
:source_image => bootstrap_options[:image_name],
|
46
|
+
}
|
47
|
+
|
48
|
+
disk = compute.disks.create(disk_defaults)
|
49
|
+
disk.wait_for { disk.ready? }
|
50
|
+
bootstrap_options[:disks] = [disk]
|
51
|
+
end
|
52
|
+
|
53
|
+
bootstrap_options
|
54
|
+
end
|
55
|
+
|
56
|
+
def destroy_machine(action_handler, machine_spec, machine_options)
|
57
|
+
server = server_for(machine_spec)
|
58
|
+
if server && server.state != 'archive'
|
59
|
+
action_handler.perform_action "destroy machine #{machine_spec.name} (#{machine_spec.location['server_id']} at #{driver_url})" do
|
60
|
+
server.destroy
|
61
|
+
end
|
62
|
+
end
|
63
|
+
machine_spec.location = nil
|
64
|
+
strategy = convergence_strategy_for(machine_spec, machine_options)
|
65
|
+
strategy.cleanup_convergence(action_handler, machine_spec)
|
66
|
+
end
|
67
|
+
|
68
|
+
def self.compute_options_for(provider, id, config)
|
69
|
+
new_compute_options = {}
|
70
|
+
new_compute_options[:provider] = provider
|
71
|
+
new_config = { :driver_options => { :compute_options => new_compute_options }}
|
72
|
+
new_defaults = {
|
73
|
+
:driver_options => { :compute_options => {} },
|
74
|
+
:machine_options => { :bootstrap_options => {}, :ssh_options => {} }
|
75
|
+
}
|
76
|
+
result = Cheffish::MergedConfig.new(new_config, config, new_defaults)
|
77
|
+
|
78
|
+
[result, '']
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -1,59 +1,63 @@
|
|
1
|
-
require 'fog/joyent'
|
2
|
-
|
3
|
-
# fog:Joyent:<joyent_url>
|
4
|
-
class Chef
|
5
|
-
module Provisioning
|
6
|
-
module FogDriver
|
7
|
-
module Providers
|
8
|
-
class Joyent < FogDriver::Driver
|
9
|
-
|
10
|
-
Driver.register_provider_class('Joyent', FogDriver::Providers::Joyent)
|
11
|
-
|
12
|
-
def creator
|
13
|
-
compute_options[:joyent_username]
|
14
|
-
end
|
15
|
-
|
16
|
-
def bootstrap_options_for(action_handler, machine_spec, machine_options)
|
17
|
-
bootstrap_options = symbolize_keys(machine_options[:bootstrap_options] || {})
|
18
|
-
|
19
|
-
bootstrap_options[:tags] = default_tags(machine_spec, bootstrap_options[:tags] || {})
|
20
|
-
|
21
|
-
bootstrap_options[:tags].each do |key, val|
|
22
|
-
bootstrap_options["tag.#{key}"] = val
|
23
|
-
end
|
24
|
-
|
25
|
-
bootstrap_options[:name] ||= machine_spec.name
|
26
|
-
|
27
|
-
bootstrap_options
|
28
|
-
end
|
29
|
-
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
}
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
new_compute_options[:
|
45
|
-
|
46
|
-
|
47
|
-
new_compute_options[:
|
48
|
-
new_compute_options[:
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
[
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
1
|
+
require 'fog/joyent'
|
2
|
+
|
3
|
+
# fog:Joyent:<joyent_url>
|
4
|
+
class Chef
|
5
|
+
module Provisioning
|
6
|
+
module FogDriver
|
7
|
+
module Providers
|
8
|
+
class Joyent < FogDriver::Driver
|
9
|
+
|
10
|
+
Driver.register_provider_class('Joyent', FogDriver::Providers::Joyent)
|
11
|
+
|
12
|
+
def creator
|
13
|
+
compute_options[:joyent_username]
|
14
|
+
end
|
15
|
+
|
16
|
+
def bootstrap_options_for(action_handler, machine_spec, machine_options)
|
17
|
+
bootstrap_options = symbolize_keys(machine_options[:bootstrap_options] || {})
|
18
|
+
|
19
|
+
bootstrap_options[:tags] = default_tags(machine_spec, bootstrap_options[:tags] || {})
|
20
|
+
|
21
|
+
bootstrap_options[:tags].each do |key, val|
|
22
|
+
bootstrap_options["tag.#{key}"] = val
|
23
|
+
end
|
24
|
+
|
25
|
+
bootstrap_options[:name] ||= machine_spec.name
|
26
|
+
|
27
|
+
bootstrap_options
|
28
|
+
end
|
29
|
+
|
30
|
+
def find_floating_ips(server, action_handler)
|
31
|
+
[]
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.compute_options_for(provider, id, config)
|
35
|
+
new_compute_options = {}
|
36
|
+
new_compute_options[:provider] = provider
|
37
|
+
new_config = { :driver_options => { :compute_options => new_compute_options }}
|
38
|
+
new_defaults = {
|
39
|
+
:driver_options => { :compute_options => {} },
|
40
|
+
:machine_options => { :bootstrap_options => {} }
|
41
|
+
}
|
42
|
+
result = Cheffish::MergedConfig.new(new_config, config, new_defaults)
|
43
|
+
|
44
|
+
new_compute_options[:joyent_url] = id if (id && id != '')
|
45
|
+
credential = Fog.credentials
|
46
|
+
|
47
|
+
new_compute_options[:joyent_username] ||= credential[:joyent_username]
|
48
|
+
new_compute_options[:joyent_password] ||= credential[:joyent_password]
|
49
|
+
new_compute_options[:joyent_keyname] ||= credential[:joyent_keyname]
|
50
|
+
new_compute_options[:joyent_keyfile] ||= credential[:joyent_keyfile]
|
51
|
+
new_compute_options[:joyent_url] ||= credential[:joyent_url]
|
52
|
+
new_compute_options[:joyent_version] ||= credential[:joyent_version]
|
53
|
+
|
54
|
+
id = result[:driver_options][:compute_options][:joyent_url]
|
55
|
+
|
56
|
+
[result, id]
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -1,41 +1,117 @@
|
|
1
|
-
# fog:OpenStack:https://identifyhost:portNumber/v2.0
|
2
|
-
class Chef
|
3
|
-
module Provisioning
|
4
|
-
module FogDriver
|
5
|
-
module Providers
|
6
|
-
class OpenStack < FogDriver::Driver
|
7
|
-
|
8
|
-
Driver.register_provider_class('OpenStack', FogDriver::Providers::OpenStack)
|
9
|
-
|
10
|
-
def creator
|
11
|
-
compute_options[:openstack_username]
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.compute_options_for(provider, id, config)
|
15
|
-
new_compute_options = {}
|
16
|
-
new_compute_options[:provider] = provider
|
17
|
-
new_config = { :driver_options => { :compute_options => new_compute_options }}
|
18
|
-
new_defaults = {
|
19
|
-
:driver_options => { :compute_options => {} },
|
20
|
-
:machine_options => { :bootstrap_options => {} }
|
21
|
-
}
|
22
|
-
result = Cheffish::MergedConfig.new(new_config, config, new_defaults)
|
23
|
-
|
24
|
-
new_compute_options[:openstack_auth_url] = id if (id && id != '')
|
25
|
-
credential = Fog.credentials
|
26
|
-
|
27
|
-
new_compute_options[:openstack_username] ||= credential[:openstack_username]
|
28
|
-
new_compute_options[:openstack_api_key] ||= credential[:openstack_api_key]
|
29
|
-
new_compute_options[:openstack_auth_url] ||= credential[:openstack_auth_url]
|
30
|
-
new_compute_options[:openstack_tenant] ||= credential[:openstack_tenant]
|
31
|
-
|
32
|
-
id = result[:driver_options][:compute_options][:openstack_auth_url]
|
33
|
-
|
34
|
-
[result, id]
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
1
|
+
# fog:OpenStack:https://identifyhost:portNumber/v2.0
|
2
|
+
class Chef
|
3
|
+
module Provisioning
|
4
|
+
module FogDriver
|
5
|
+
module Providers
|
6
|
+
class OpenStack < FogDriver::Driver
|
7
|
+
|
8
|
+
Driver.register_provider_class('OpenStack', FogDriver::Providers::OpenStack)
|
9
|
+
|
10
|
+
def creator
|
11
|
+
compute_options[:openstack_username]
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.compute_options_for(provider, id, config)
|
15
|
+
new_compute_options = {}
|
16
|
+
new_compute_options[:provider] = provider
|
17
|
+
new_config = { :driver_options => { :compute_options => new_compute_options }}
|
18
|
+
new_defaults = {
|
19
|
+
:driver_options => { :compute_options => {} },
|
20
|
+
:machine_options => { :bootstrap_options => {} }
|
21
|
+
}
|
22
|
+
result = Cheffish::MergedConfig.new(new_config, config, new_defaults)
|
23
|
+
|
24
|
+
new_compute_options[:openstack_auth_url] = id if (id && id != '')
|
25
|
+
credential = Fog.credentials
|
26
|
+
|
27
|
+
new_compute_options[:openstack_username] ||= credential[:openstack_username]
|
28
|
+
new_compute_options[:openstack_api_key] ||= credential[:openstack_api_key]
|
29
|
+
new_compute_options[:openstack_auth_url] ||= credential[:openstack_auth_url]
|
30
|
+
new_compute_options[:openstack_tenant] ||= credential[:openstack_tenant]
|
31
|
+
|
32
|
+
id = result[:driver_options][:compute_options][:openstack_auth_url]
|
33
|
+
|
34
|
+
[result, id]
|
35
|
+
end
|
36
|
+
|
37
|
+
# Image methods
|
38
|
+
def allocate_image(action_handler, image_spec, image_options, machine_spec, machine_options)
|
39
|
+
image = image_for(image_spec)
|
40
|
+
if image
|
41
|
+
raise "The image already exists, why are you asking me to create it? I can't do that, Dave."
|
42
|
+
end
|
43
|
+
action_handler.perform_action "Create image #{image_spec.name} from machine #{machine_spec.name} with options #{image_options.inspect}" do
|
44
|
+
response = compute.create_image(
|
45
|
+
machine_spec.reference['server_id'], image_spec.name,
|
46
|
+
{
|
47
|
+
description: "The Image named '#{image_spec.name}"
|
48
|
+
})
|
49
|
+
|
50
|
+
image_spec.reference = {
|
51
|
+
driver_url: driver_url,
|
52
|
+
driver_version: FogDriver::VERSION,
|
53
|
+
image_id: response.body['image']['id'],
|
54
|
+
creator: creator,
|
55
|
+
allocated_it: Time.new.to_i
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def ready_image(action_handler, image_spec, image_options)
|
61
|
+
actual_image = image_for(image_spec)
|
62
|
+
if actual_image.nil?
|
63
|
+
raise 'Cannot ready an image that does not exist'
|
64
|
+
else
|
65
|
+
if actual_image.status != 'ACTIVE'
|
66
|
+
action_handler.report_progress 'Waiting for image to be active ...'
|
67
|
+
wait_until_ready_image(action_handler, image_spec, actual_image)
|
68
|
+
else
|
69
|
+
action_handler.report_progress "Image #{image_spec.name} is active!"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def destroy_image(action_handler, image_spec, image_options)
|
75
|
+
image = image_for(image_spec)
|
76
|
+
unless image.status == "DELETED"
|
77
|
+
image.destroy
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def wait_until_ready_image(action_handler, image_spec, image=nil)
|
82
|
+
wait_until_image(action_handler, image_spec, image) { image.status == 'ACTIVE' }
|
83
|
+
end
|
84
|
+
|
85
|
+
def wait_until_image(action_handler, image_spec, image=nil, &block)
|
86
|
+
image ||= image_for(image_spec)
|
87
|
+
time_elapsed = 0
|
88
|
+
sleep_time = 10
|
89
|
+
max_wait_time = 300
|
90
|
+
if !yield(image)
|
91
|
+
action_handler.report_progress "waiting for image #{image_spec.name} (#{image.id} on #{driver_url}) to be active ..."
|
92
|
+
while time_elapsed < max_wait_time && !yield(image)
|
93
|
+
action_handler.report_progress "been waiting #{time_elapsed}/#{max_wait_time} -- sleeping #{sleep_time} seconds for image #{image_spec.name} (#{image.id} on #{driver_url}) to be ACTIVE instead of #{image.status}..."
|
94
|
+
sleep(sleep_time)
|
95
|
+
image.reload
|
96
|
+
time_elapsed += sleep_time
|
97
|
+
end
|
98
|
+
unless yield(image)
|
99
|
+
raise "Image #{image.id} did not become ready within #{max_wait_time} seconds"
|
100
|
+
end
|
101
|
+
action_handler.report_progress "Image #{image_spec.name} is now ready"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def image_for(image_spec)
|
106
|
+
if image_spec.reference
|
107
|
+
compute.images.get(image_spec.reference[:image_id]) || compute.images.get(image_spec.reference['image_id'])
|
108
|
+
else
|
109
|
+
nil
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|