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.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +29 -8
  3. data/Rakefile +23 -12
  4. data/chef-provisioning-fog.gemspec +24 -27
  5. data/lib/chef/provider/fog_key_pair.rb +49 -53
  6. data/lib/chef/provider/scaleway_volume.rb +46 -48
  7. data/lib/chef/provisioning/driver_init/fog.rb +1 -1
  8. data/lib/chef/provisioning/fog_driver/driver.rb +646 -653
  9. data/lib/chef/provisioning/fog_driver/providers/aws.rb +411 -422
  10. data/lib/chef/provisioning/fog_driver/providers/aws/credentials.rb +88 -90
  11. data/lib/chef/provisioning/fog_driver/providers/cloudstack.rb +32 -34
  12. data/lib/chef/provisioning/fog_driver/providers/digitalocean.rb +98 -100
  13. data/lib/chef/provisioning/fog_driver/providers/google.rb +27 -34
  14. data/lib/chef/provisioning/fog_driver/providers/joyent.rb +53 -55
  15. data/lib/chef/provisioning/fog_driver/providers/openstack.rb +139 -146
  16. data/lib/chef/provisioning/fog_driver/providers/rackspace.rb +40 -44
  17. data/lib/chef/provisioning/fog_driver/providers/scaleway.rb +183 -189
  18. data/lib/chef/provisioning/fog_driver/providers/softlayer.rb +61 -64
  19. data/lib/chef/provisioning/fog_driver/providers/vcair.rb +72 -78
  20. data/lib/chef/provisioning/fog_driver/providers/xenserver.rb +56 -69
  21. data/lib/chef/provisioning/fog_driver/recipe_dsl.rb +11 -12
  22. data/lib/chef/provisioning/fog_driver/version.rb +1 -1
  23. data/lib/chef/resource/fog_key_pair.rb +8 -8
  24. data/lib/chef/resource/scaleway_volume.rb +8 -8
  25. data/spec/spec_helper.rb +7 -7
  26. data/spec/support/chef/provisioning/fog_driver/providers/testdriver.rb +3 -3
  27. data/spec/unit/chef/provisioning/fog_driver/driver_spec.rb +39 -38
  28. data/spec/unit/fog_driver_spec.rb +6 -8
  29. data/spec/unit/providers/aws/credentials_spec.rb +10 -10
  30. data/spec/unit/providers/rackspace_spec.rb +5 -6
  31. data/spec/unit/providers/scaleway_spec.rb +9 -9
  32. data/spec/unit/providers/softlayer.rb +7 -7
  33. metadata +6 -36
  34. data/README.md +0 -357
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c77d661a5523160576f2a32f6806078ed44046235fcf6effe98317b7de885042
4
- data.tar.gz: 2d5faf9cbce70c193b25f74b6a93167655cb73aa3d51595a9d0364005176c7e2
3
+ metadata.gz: 912a97376ebbc1b45d706a956c7241188f6fd1bba92ce4273ecacd2db661856c
4
+ data.tar.gz: c8fb2165d27495e7708dd054b35c38f75308f50cd239a19978a5e94a69c4694d
5
5
  SHA512:
6
- metadata.gz: d3b45b2860a0f5237572b5f114ffd50dc10f1f1c24eed6ef6de7e38a1f02c2fc5dc486509d3057332597778a1ffcc1ecf6ac1ed624d219a4f0835756accd5bdb
7
- data.tar.gz: 308fa541c12dcd5230a279dfb0491645111f9220799ee288b445942d4e62873bbdbf1318de7343f0f530ddad83fa759de945a9cee9c706d1ed234572ddc8b175
6
+ metadata.gz: 224c9427b2c417cc689c2e3353d032204a41442ce6d738966ee4a191026345c56337295740d6e4baab94d1b345f7016092d45d7e7e1e63e2dddbbad85102922a
7
+ data.tar.gz: b1f447b26a576a522b779d2de8d7ee1002f7b74996ad7e9f99a38fe979b67a0a10eb33090b10abb3640c5a7b33383e9467c7b36271192e852fa35dbb103c486a
data/Gemfile CHANGED
@@ -1,17 +1,38 @@
1
1
  source "https://rubygems.org"
2
- gemfile
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 "chef"
12
- gem 'guard'
13
- gem 'guard-rspec'
14
- gem 'rb-readline'
15
- gem 'simplecov'
16
- gem 'winrm-elevated'
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 'bundler'
2
- require 'bundler/gem_tasks'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
3
 
4
- desc "run specs"
5
- task :spec do
6
- sh "bundle exec rspec"
7
- end
4
+ RSpec::Core::RakeTask.new(:spec)
8
5
 
9
6
  begin
10
- require "github_changelog_generator/task"
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
- GitHubChangelogGenerator::RakeTask.new :changelog do |config|
13
- config.future_release = Chef::Provisioning::FogDriver::VERSION
14
- config.enhancement_labels = "enhancement,Enhancement,New Feature".split(",")
15
- config.bug_labels = "bug,Bug,Improvement,Upstream Bug".split(",")
16
- config.exclude_labels = "duplicate,question,invalid,wontfix,no_changelog,Exclude From Changelog,Question".split(",")
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
- $:.unshift(File.dirname(__FILE__) + '/lib')
2
- require 'chef/provisioning/fog_driver/version'
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 = 'chef-provisioning-fog'
5
+ s.name = "chef-provisioning-fog"
6
6
  s.version = Chef::Provisioning::FogDriver::VERSION
7
- s.platform = Gem::Platform::RUBY
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 = ['John Keiser', "Chris McClimans", "Taylor Carpenter", "Wavell Watson", "JJ Asghar"]
12
- s.email = ['john@johnkeiser.com', 'hh@vulk.co', 't@vulk.co', 'w@vulk.co','jj@chef.io']
13
- s.homepage = 'https://github.com/chef/chef-provisioning-fog'
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 'chef-provisioning', '>= 1.0', '< 3.0'
16
- s.add_dependency 'cheffish', '>= 13.1.0', '< 15.0'
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 'fog-digitalocean'
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 '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'
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 = 'lib'
41
- s.files = %w(Gemfile Rakefile LICENSE README.md) + Dir.glob("*.gemspec") +
42
- Dir.glob("{distro,lib,tasks,spec}/**/*", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }
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
- # coding: utf-8
2
- require 'chef/provider/lwrp_base'
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 'DigitalOcean'
19
+ when "DigitalOcean"
22
20
  compute.destroy_ssh_key(@current_id)
23
- when 'Joyent'
21
+ when "Joyent"
24
22
  compute.delete_key(@current_id)
25
- when 'OpenStack', 'Rackspace'
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 'DigitalOcean'
61
- new_fingerprints = [Cheffish::KeyFormatter.encode(desired_key, :format => :openssh)]
62
- when 'Joyent'
63
- new_fingerprints = [Cheffish::KeyFormatter.encode(desired_key, :format => :rfc4716md5fingerprint)]
64
- when 'OpenStack', 'Rackspace'
65
- new_fingerprints = [Cheffish::KeyFormatter.encode(desired_key, :format => :openssh)]
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, :format => :fingerprint)]
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 'openssl_pkcs8'
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
- :format => :pkcs8sha1fingerprint)
89
+ format: :pkcs8sha1fingerprint)
92
90
  end
93
91
  end
94
92
  end
95
93
 
96
- if !new_fingerprints.any? { |f| compare_public_key f }
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 'DigitalOcean'
101
- compute.create_ssh_key(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, :format => :openssh))
102
- when 'Joyent'
103
- compute.create_key(name: new_resource.name, key: Cheffish::KeyFormatter.encode(desired_key, :format => :openssh))
104
- when 'OpenStack'
105
- compute.create_key_pair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, :format => :openssh))
106
- when 'Rackspace'
107
- compute.create_keypair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, :format => :openssh))
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, :format => :openssh))
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 'DigitalOcean'
125
- compute.create_ssh_key(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, :format => :openssh))
126
- when 'Joyent'
127
- compute.create_key(name: new_resource.name, key: Cheffish::KeyFormatter.encode(desired_key, :format => :openssh))
128
- when 'OpenStack'
129
- compute.create_key_pair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, :format => :openssh))
130
- when 'Rackspace'
131
- compute.create_keypair(new_resource.name, Cheffish::KeyFormatter.encode(desired_key, :format => :openssh))
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, :format => :openssh))
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 != [ :delete ]
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
- if !new_driver.kind_of?(Chef::Provisioning::FogDriver::Driver)
212
- raise 'fog_key_pair only works with fog_driver'
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 'DigitalOcean'
217
- current_key_pair = compute.list_ssh_keys.body['ssh_keys'].select { |key| key['name'] == new_resource.name }.first
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['id']
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 'Joyent'
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
- current_key_pair.fingerprint
234
- elsif current_key_pair.respond_to?(:key)
235
- public_key, format = Cheffish::KeyFormatter.decode(current_key_pair.key)
236
- public_key.fingerprint
237
- else
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 'OpenStack', 'Rackspace'
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 'chef/provider/lwrp_base'
2
- require 'openssl'
3
- require 'chef/provisioning/chef_provider_action_handler'
4
- require 'chef/provisioning/chef_managed_entry_store'
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
- provides :scaleway_volume
10
-
11
- def action_handler
12
- @action_handler ||= Chef::Provisioning::ChefProviderActionHandler.new(self)
13
- end
14
-
15
- def load_current_resource
16
- end
17
-
18
- def whyrun_supported?
19
- true
20
- end
21
-
22
- def volume_spec
23
- @volume_spec ||= chef_managed_entry_store.get_or_new(:volume, new_resource.name)
24
- end
25
-
26
- # Get the driver specified in the resource
27
- def new_driver
28
- @new_driver ||= run_context.chef_provisioning.driver_for(new_resource.driver)
29
- end
30
-
31
- def chef_managed_entry_store
32
- @chef_managed_entry_store ||= Provisioning.chef_managed_entry_store(new_resource.chef_server)
33
- end
34
-
35
-
36
- action :create do
37
- unless volume_spec.reference && new_driver.volume_for(volume_spec)
38
- new_driver.create_volume(action_handler, volume_spec,
39
- new_resource.volume_options)
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