chef-provisioning-fog 0.26.1 → 0.26.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +29 -8
- data/Rakefile +23 -12
- data/chef-provisioning-fog.gemspec +24 -27
- data/lib/chef/provider/fog_key_pair.rb +49 -53
- data/lib/chef/provider/scaleway_volume.rb +46 -48
- data/lib/chef/provisioning/driver_init/fog.rb +1 -1
- data/lib/chef/provisioning/fog_driver/driver.rb +646 -653
- data/lib/chef/provisioning/fog_driver/providers/aws.rb +411 -422
- data/lib/chef/provisioning/fog_driver/providers/aws/credentials.rb +88 -90
- data/lib/chef/provisioning/fog_driver/providers/cloudstack.rb +32 -34
- data/lib/chef/provisioning/fog_driver/providers/digitalocean.rb +98 -100
- data/lib/chef/provisioning/fog_driver/providers/google.rb +27 -34
- data/lib/chef/provisioning/fog_driver/providers/joyent.rb +53 -55
- data/lib/chef/provisioning/fog_driver/providers/openstack.rb +139 -146
- data/lib/chef/provisioning/fog_driver/providers/rackspace.rb +40 -44
- data/lib/chef/provisioning/fog_driver/providers/scaleway.rb +183 -189
- data/lib/chef/provisioning/fog_driver/providers/softlayer.rb +61 -64
- data/lib/chef/provisioning/fog_driver/providers/vcair.rb +72 -78
- data/lib/chef/provisioning/fog_driver/providers/xenserver.rb +56 -69
- data/lib/chef/provisioning/fog_driver/recipe_dsl.rb +11 -12
- data/lib/chef/provisioning/fog_driver/version.rb +1 -1
- data/lib/chef/resource/fog_key_pair.rb +8 -8
- data/lib/chef/resource/scaleway_volume.rb +8 -8
- data/spec/spec_helper.rb +7 -7
- data/spec/support/chef/provisioning/fog_driver/providers/testdriver.rb +3 -3
- data/spec/unit/chef/provisioning/fog_driver/driver_spec.rb +39 -38
- data/spec/unit/fog_driver_spec.rb +6 -8
- data/spec/unit/providers/aws/credentials_spec.rb +10 -10
- data/spec/unit/providers/rackspace_spec.rb +5 -6
- data/spec/unit/providers/scaleway_spec.rb +9 -9
- data/spec/unit/providers/softlayer.rb +7 -7
- metadata +6 -36
- data/README.md +0 -357
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 912a97376ebbc1b45d706a956c7241188f6fd1bba92ce4273ecacd2db661856c
|
4
|
+
data.tar.gz: c8fb2165d27495e7708dd054b35c38f75308f50cd239a19978a5e94a69c4694d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 224c9427b2c417cc689c2e3353d032204a41442ce6d738966ee4a191026345c56337295740d6e4baab94d1b345f7016092d45d7e7e1e63e2dddbbad85102922a
|
7
|
+
data.tar.gz: b1f447b26a576a522b779d2de8d7ee1002f7b74996ad7e9f99a38fe979b67a0a10eb33090b10abb3640c5a7b33383e9467c7b36271192e852fa35dbb103c486a
|
data/Gemfile
CHANGED
@@ -1,17 +1,38 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
|
-
|
2
|
+
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :development do
|
6
|
+
gem "chef"
|
7
|
+
gem "chefstyle", "~> 0.10.0"
|
6
8
|
# fog-google and fog-aws have been removed as direct deps, but are necessary for testing
|
7
|
-
gem "fog-google"
|
8
9
|
gem "fog-aws"
|
10
|
+
gem "fog-google"
|
9
11
|
# fog is necessary for fog-cloudstack
|
10
12
|
gem "fog"
|
11
|
-
gem "
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
gem
|
15
|
-
gem
|
16
|
-
gem
|
13
|
+
gem "guard"
|
14
|
+
gem "guard-rspec"
|
15
|
+
gem "rake"
|
16
|
+
gem "rspec", "~> 3.0"
|
17
|
+
gem "simplecov"
|
18
|
+
gem "winrm-elevated"
|
17
19
|
end
|
20
|
+
|
21
|
+
group :debug do
|
22
|
+
gem "pry"
|
23
|
+
gem "pry-byebug"
|
24
|
+
gem "pry-stack_explorer"
|
25
|
+
gem "rb-readline"
|
26
|
+
end
|
27
|
+
|
28
|
+
group :docs do
|
29
|
+
gem "github-markup"
|
30
|
+
gem "redcarpet"
|
31
|
+
gem "yard"
|
32
|
+
end
|
33
|
+
|
34
|
+
instance_eval(ENV["GEMFILE_MOD"]) if ENV["GEMFILE_MOD"]
|
35
|
+
|
36
|
+
# If you want to load debugging tools into the bundle exec sandbox,
|
37
|
+
# add these additional dependencies into Gemfile.local
|
38
|
+
eval_gemfile(__FILE__ + ".local") if File.exist?(__FILE__ + ".local")
|
data/Rakefile
CHANGED
@@ -1,19 +1,30 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
3
|
|
4
|
-
|
5
|
-
task :spec do
|
6
|
-
sh "bundle exec rspec"
|
7
|
-
end
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
8
5
|
|
9
6
|
begin
|
10
|
-
require "
|
7
|
+
require "yard"
|
8
|
+
YARD::Rake::YardocTask.new(:docs)
|
9
|
+
rescue LoadError
|
10
|
+
puts "yard is not available. bundle install first to make sure all dependencies are installed."
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
task :console do
|
14
|
+
require "irb"
|
15
|
+
require "irb/completion"
|
16
|
+
ARGV.clear
|
17
|
+
IRB.start
|
18
|
+
end
|
19
|
+
|
20
|
+
begin
|
21
|
+
require "chefstyle"
|
22
|
+
require "rubocop/rake_task"
|
23
|
+
RuboCop::RakeTask.new(:chefstyle) do |task|
|
24
|
+
task.options << "--display-cop-names"
|
17
25
|
end
|
18
26
|
rescue LoadError
|
27
|
+
puts "chefstyle gem is not installed"
|
19
28
|
end
|
29
|
+
|
30
|
+
task default: :spec
|
@@ -1,43 +1,40 @@
|
|
1
|
-
|
2
|
-
require
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + "/lib")
|
2
|
+
require "chef/provisioning/fog_driver/version"
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
|
-
s.name =
|
5
|
+
s.name = "chef-provisioning-fog"
|
6
6
|
s.version = Chef::Provisioning::FogDriver::VERSION
|
7
|
-
s.
|
8
|
-
s.extra_rdoc_files = ['README.md', 'LICENSE' ]
|
9
|
-
s.summary = 'Driver for creating Fog instances in Chef Provisioning.'
|
7
|
+
s.summary = "Driver for creating Fog instances in Chef Provisioning."
|
10
8
|
s.description = s.summary
|
11
|
-
s.authors = [
|
12
|
-
s.email = [
|
13
|
-
s.homepage =
|
9
|
+
s.authors = ["John Keiser", "Chris McClimans", "Taylor Carpenter", "Wavell Watson", "JJ Asghar"]
|
10
|
+
s.email = ["john@johnkeiser.com", "hh@vulk.co", "t@vulk.co", "w@vulk.co", "jj@chef.io"]
|
11
|
+
s.homepage = "https://github.com/chef/chef-provisioning-fog"
|
12
|
+
s.license = "Apache-2.0"
|
13
|
+
s.required_ruby_version = ">= 2.1.9"
|
14
14
|
|
15
|
-
s.add_dependency
|
16
|
-
s.add_dependency
|
15
|
+
s.add_dependency "chef-provisioning", ">= 1.0", "< 3.0"
|
16
|
+
s.add_dependency "cheffish", ">= 13.1.0", "< 15.0"
|
17
17
|
#
|
18
18
|
# NOTE: the `fog` direct dependency has been removed from chef-provisioning-fog, if there is no meta-gem
|
19
19
|
# then users _must_ install the fog dependency manually (`chef gem install fog` for chefdk). this affects
|
20
20
|
# at least cloudstack and vcair users. aws users should use chef-provisioning-aws.
|
21
21
|
#
|
22
22
|
# s.add_dependency 'fog-aws' # Deliberately removed: chef-provisioning-aws is preferred
|
23
|
-
s.add_dependency
|
23
|
+
s.add_dependency "fog-digitalocean"
|
24
24
|
# s.add_dependency 'fog-google' # Deliberately removed: fog-google is broken with newer google-api-client
|
25
|
-
s.add_dependency
|
26
|
-
s.add_dependency
|
27
|
-
s.add_dependency
|
28
|
-
s.add_dependency
|
29
|
-
s.add_dependency
|
30
|
-
s.add_dependency
|
31
|
-
s.add_dependency
|
32
|
-
s.add_dependency
|
33
|
-
|
34
|
-
s.add_development_dependency 'rspec'
|
35
|
-
s.add_development_dependency 'rake'
|
25
|
+
s.add_dependency "fog-joyent"
|
26
|
+
s.add_dependency "fog-openstack"
|
27
|
+
s.add_dependency "fog-rackspace"
|
28
|
+
s.add_dependency "fog-scaleway"
|
29
|
+
s.add_dependency "fog-softlayer"
|
30
|
+
s.add_dependency "fog-xenserver"
|
31
|
+
s.add_dependency "retryable"
|
32
|
+
s.add_dependency "winrm-elevated"
|
36
33
|
|
37
34
|
s.bindir = "bin"
|
38
|
-
s.executables = %w
|
35
|
+
s.executables = %w{}
|
39
36
|
|
40
|
-
s.require_path =
|
41
|
-
s.files = %w
|
42
|
-
|
37
|
+
s.require_path = "lib"
|
38
|
+
s.files = %w{Gemfile Rakefile LICENSE} + Dir.glob("*.gemspec") +
|
39
|
+
Dir.glob("{distro,lib,tasks,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
|
43
40
|
end
|
@@ -1,9 +1,7 @@
|
|
1
|
-
|
2
|
-
require
|
3
|
-
require 'chef/provisioning/fog_driver/driver'
|
1
|
+
require "chef/provider/lwrp_base"
|
2
|
+
require "chef/provisioning/fog_driver/driver"
|
4
3
|
|
5
4
|
class Chef::Provider::FogKeyPair < Chef::Provider::LWRPBase
|
6
|
-
|
7
5
|
use_inline_resources
|
8
6
|
|
9
7
|
def whyrun_supported?
|
@@ -18,11 +16,11 @@ class Chef::Provider::FogKeyPair < Chef::Provider::LWRPBase
|
|
18
16
|
if current_resource_exists?
|
19
17
|
converge_by "delete #{key_description}" do
|
20
18
|
case new_driver.compute_options[:provider]
|
21
|
-
when
|
19
|
+
when "DigitalOcean"
|
22
20
|
compute.destroy_ssh_key(@current_id)
|
23
|
-
when
|
21
|
+
when "Joyent"
|
24
22
|
compute.delete_key(@current_id)
|
25
|
-
when
|
23
|
+
when "OpenStack", "Rackspace"
|
26
24
|
compute.key_pairs.destroy(@current_id)
|
27
25
|
else
|
28
26
|
compute.key_pairs.delete(new_resource.name)
|
@@ -57,12 +55,12 @@ class Chef::Provider::FogKeyPair < Chef::Provider::LWRPBase
|
|
57
55
|
end
|
58
56
|
|
59
57
|
case new_driver.compute_options[:provider]
|
60
|
-
when
|
61
|
-
new_fingerprints = [Cheffish::KeyFormatter.encode(desired_key, :
|
62
|
-
when
|
63
|
-
new_fingerprints = [Cheffish::KeyFormatter.encode(desired_key, :
|
64
|
-
when
|
65
|
-
new_fingerprints = [Cheffish::KeyFormatter.encode(desired_key, :
|
58
|
+
when "DigitalOcean"
|
59
|
+
new_fingerprints = [Cheffish::KeyFormatter.encode(desired_key, format: :openssh)]
|
60
|
+
when "Joyent"
|
61
|
+
new_fingerprints = [Cheffish::KeyFormatter.encode(desired_key, format: :rfc4716md5fingerprint)]
|
62
|
+
when "OpenStack", "Rackspace"
|
63
|
+
new_fingerprints = [Cheffish::KeyFormatter.encode(desired_key, format: :openssh)]
|
66
64
|
else
|
67
65
|
# “The nice thing about standards is that you have so many to
|
68
66
|
# choose from.” - Andrew S. Tanenbaum
|
@@ -75,11 +73,11 @@ class Chef::Provider::FogKeyPair < Chef::Provider::LWRPBase
|
|
75
73
|
#
|
76
74
|
# So compute both possible AWS fingerprints and check if either of
|
77
75
|
# them matches.
|
78
|
-
new_fingerprints = [Cheffish::KeyFormatter.encode(desired_key, :
|
76
|
+
new_fingerprints = [Cheffish::KeyFormatter.encode(desired_key, format: :fingerprint)]
|
79
77
|
if RUBY_VERSION.to_f < 2.0
|
80
78
|
if @@use_pkcs8.nil?
|
81
79
|
begin
|
82
|
-
require
|
80
|
+
require "openssl_pkcs8"
|
83
81
|
@@use_pkcs8 = true
|
84
82
|
rescue LoadError
|
85
83
|
Chef::Log.warn("The openssl_pkcs8 gem is not loaded: you may not be able to read key fingerprints created by some cloud providers. gem install openssl_pkcs8 to fix!")
|
@@ -88,26 +86,26 @@ class Chef::Provider::FogKeyPair < Chef::Provider::LWRPBase
|
|
88
86
|
end
|
89
87
|
if @@use_pkcs8
|
90
88
|
new_fingerprints << Cheffish::KeyFormatter.encode(desired_private_key,
|
91
|
-
|
89
|
+
format: :pkcs8sha1fingerprint)
|
92
90
|
end
|
93
91
|
end
|
94
92
|
end
|
95
93
|
|
96
|
-
if
|
94
|
+
if new_fingerprints.none? { |f| compare_public_key f }
|
97
95
|
if new_resource.allow_overwrite
|
98
96
|
converge_by "update #{key_description} to match local key at #{new_resource.private_key_path}" do
|
99
97
|
case new_driver.compute_options[:provider]
|
100
|
-
when
|
101
|
-
compute.create_ssh_key(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, :
|
102
|
-
when
|
103
|
-
compute.create_key(name: new_resource.name, key: Cheffish::KeyFormatter.encode(desired_key, :
|
104
|
-
when
|
105
|
-
compute.create_key_pair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, :
|
106
|
-
when
|
107
|
-
compute.create_keypair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, :
|
98
|
+
when "DigitalOcean"
|
99
|
+
compute.create_ssh_key(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, format: :openssh))
|
100
|
+
when "Joyent"
|
101
|
+
compute.create_key(name: new_resource.name, key: Cheffish::KeyFormatter.encode(desired_key, format: :openssh))
|
102
|
+
when "OpenStack"
|
103
|
+
compute.create_key_pair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, format: :openssh))
|
104
|
+
when "Rackspace"
|
105
|
+
compute.create_keypair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, format: :openssh))
|
108
106
|
else
|
109
107
|
compute.key_pairs.get(new_resource.name).destroy
|
110
|
-
compute.import_key_pair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, :
|
108
|
+
compute.import_key_pair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, format: :openssh))
|
111
109
|
end
|
112
110
|
end
|
113
111
|
else
|
@@ -121,16 +119,16 @@ class Chef::Provider::FogKeyPair < Chef::Provider::LWRPBase
|
|
121
119
|
# Create key
|
122
120
|
converge_by "create #{key_description} from local key at #{new_resource.private_key_path}" do
|
123
121
|
case new_driver.compute_options[:provider]
|
124
|
-
when
|
125
|
-
compute.create_ssh_key(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, :
|
126
|
-
when
|
127
|
-
compute.create_key(name: new_resource.name, key: Cheffish::KeyFormatter.encode(desired_key, :
|
128
|
-
when
|
129
|
-
compute.create_key_pair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, :
|
130
|
-
when
|
131
|
-
compute.create_keypair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, :
|
122
|
+
when "DigitalOcean"
|
123
|
+
compute.create_ssh_key(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, format: :openssh))
|
124
|
+
when "Joyent"
|
125
|
+
compute.create_key(name: new_resource.name, key: Cheffish::KeyFormatter.encode(desired_key, format: :openssh))
|
126
|
+
when "OpenStack"
|
127
|
+
compute.create_key_pair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, format: :openssh))
|
128
|
+
when "Rackspace"
|
129
|
+
compute.create_keypair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, format: :openssh))
|
132
130
|
else
|
133
|
-
compute.import_key_pair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, :
|
131
|
+
compute.import_key_pair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, format: :openssh))
|
134
132
|
end
|
135
133
|
end
|
136
134
|
end
|
@@ -147,7 +145,7 @@ class Chef::Provider::FogKeyPair < Chef::Provider::LWRPBase
|
|
147
145
|
private_key private_key_path do
|
148
146
|
public_key_path resource.public_key_path
|
149
147
|
if resource.private_key_options
|
150
|
-
resource.private_key_options.each_pair do |key,value|
|
148
|
+
resource.private_key_options.each_pair do |key, value|
|
151
149
|
send(key, value)
|
152
150
|
end
|
153
151
|
end
|
@@ -174,12 +172,12 @@ class Chef::Provider::FogKeyPair < Chef::Provider::LWRPBase
|
|
174
172
|
end
|
175
173
|
|
176
174
|
def current_resource_exists?
|
177
|
-
@current_resource.action != [
|
175
|
+
@current_resource.action != [:delete]
|
178
176
|
end
|
179
177
|
|
180
178
|
def compare_public_key(new)
|
181
|
-
c = @current_fingerprint.split[0,2].join(
|
182
|
-
n = new.split[0,2].join(
|
179
|
+
c = @current_fingerprint.split[0, 2].join(" ")
|
180
|
+
n = new.split[0, 2].join(" ")
|
183
181
|
c == n
|
184
182
|
end
|
185
183
|
|
@@ -208,20 +206,20 @@ class Chef::Provider::FogKeyPair < Chef::Provider::LWRPBase
|
|
208
206
|
end
|
209
207
|
|
210
208
|
def load_current_resource
|
211
|
-
|
212
|
-
raise
|
209
|
+
unless new_driver.is_a?(Chef::Provisioning::FogDriver::Driver)
|
210
|
+
raise "fog_key_pair only works with fog_driver"
|
213
211
|
end
|
214
212
|
@current_resource = Chef::Resource::FogKeyPair.new(new_resource.name, run_context)
|
215
213
|
case new_driver.provider
|
216
|
-
when
|
217
|
-
current_key_pair = compute.list_ssh_keys.body[
|
214
|
+
when "DigitalOcean"
|
215
|
+
current_key_pair = compute.list_ssh_keys.body["ssh_keys"].select { |key| key["name"] == new_resource.name }.first
|
218
216
|
if current_key_pair
|
219
|
-
@current_id = current_key_pair[
|
217
|
+
@current_id = current_key_pair["id"]
|
220
218
|
@current_fingerprint = current_key_pair ? compute.ssh_keys.get(@current_id).public_key : nil
|
221
219
|
else
|
222
220
|
current_resource.action :delete
|
223
221
|
end
|
224
|
-
when
|
222
|
+
when "Joyent"
|
225
223
|
current_key_pair = begin
|
226
224
|
compute.keys.get(new_resource.name)
|
227
225
|
rescue Fog::Compute::Joyent::Errors::NotFound
|
@@ -230,17 +228,15 @@ class Chef::Provider::FogKeyPair < Chef::Provider::LWRPBase
|
|
230
228
|
if current_key_pair
|
231
229
|
@current_id = current_key_pair.name
|
232
230
|
@current_fingerprint = if current_key_pair.respond_to?(:fingerprint)
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
nil
|
239
|
-
end
|
231
|
+
current_key_pair.fingerprint
|
232
|
+
elsif current_key_pair.respond_to?(:key)
|
233
|
+
public_key, format = Cheffish::KeyFormatter.decode(current_key_pair.key)
|
234
|
+
public_key.fingerprint
|
235
|
+
end
|
240
236
|
else
|
241
237
|
current_resource.action :delete
|
242
238
|
end
|
243
|
-
when
|
239
|
+
when "OpenStack", "Rackspace"
|
244
240
|
current_key_pair = compute.key_pairs.get(new_resource.name)
|
245
241
|
if current_key_pair
|
246
242
|
@current_id = current_key_pair.name
|
@@ -1,53 +1,51 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "chef/provider/lwrp_base"
|
2
|
+
require "openssl"
|
3
|
+
require "chef/provisioning/chef_provider_action_handler"
|
4
|
+
require "chef/provisioning/chef_managed_entry_store"
|
5
5
|
|
6
6
|
class Chef
|
7
|
-
class Provider
|
8
|
-
class ScalewayVolume < Chef::Provider::LWRPBase
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
7
|
+
class Provider
|
8
|
+
class ScalewayVolume < Chef::Provider::LWRPBase
|
9
|
+
provides :scaleway_volume
|
10
|
+
|
11
|
+
def action_handler
|
12
|
+
@action_handler ||= Chef::Provisioning::ChefProviderActionHandler.new(self)
|
13
|
+
end
|
14
|
+
|
15
|
+
def load_current_resource; end
|
16
|
+
|
17
|
+
def whyrun_supported?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def volume_spec
|
22
|
+
@volume_spec ||= chef_managed_entry_store.get_or_new(:volume, new_resource.name)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Get the driver specified in the resource
|
26
|
+
def new_driver
|
27
|
+
@new_driver ||= run_context.chef_provisioning.driver_for(new_resource.driver)
|
28
|
+
end
|
29
|
+
|
30
|
+
def chef_managed_entry_store
|
31
|
+
@chef_managed_entry_store ||= Provisioning.chef_managed_entry_store(new_resource.chef_server)
|
32
|
+
end
|
33
|
+
|
34
|
+
action :create do
|
35
|
+
unless volume_spec.reference && new_driver.volume_for(volume_spec)
|
36
|
+
new_driver.create_volume(action_handler, volume_spec,
|
37
|
+
new_resource.volume_options)
|
38
|
+
end
|
39
|
+
new_resource.id = volume_spec.reference["id"]
|
40
|
+
end
|
41
|
+
|
42
|
+
action :destroy do
|
43
|
+
if volume_spec.reference && volume_spec.reference["id"]
|
44
|
+
new_driver.destroy_volume(action_handler, volume_spec,
|
45
|
+
new_resource.volume_options)
|
46
|
+
volume_spec.delete(action_handler)
|
47
|
+
end
|
48
|
+
end
|
40
49
|
end
|
41
|
-
new_resource.id = volume_spec.reference['id']
|
42
50
|
end
|
43
|
-
|
44
|
-
action :destroy do
|
45
|
-
if volume_spec.reference && volume_spec.reference['id']
|
46
|
-
new_driver.destroy_volume(action_handler, volume_spec,
|
47
|
-
new_resource.volume_options)
|
48
|
-
volume_spec.delete(action_handler)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
51
|
end
|