chef-provisioning-fog 0.15.0 → 0.15.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +11 -0
  3. data/LICENSE +201 -201
  4. data/README.md +208 -3
  5. data/Rakefile +6 -6
  6. data/chef-provisioning-fog.gemspec +28 -0
  7. data/lib/chef/provider/fog_key_pair.rb +266 -266
  8. data/lib/chef/provisioning/driver_init/fog.rb +3 -3
  9. data/lib/chef/provisioning/fog_driver/driver.rb +736 -736
  10. data/lib/chef/provisioning/fog_driver/providers/aws.rb +492 -492
  11. data/lib/chef/provisioning/fog_driver/providers/aws/credentials.rb +115 -115
  12. data/lib/chef/provisioning/fog_driver/providers/cloudstack.rb +44 -44
  13. data/lib/chef/provisioning/fog_driver/providers/digitalocean.rb +136 -136
  14. data/lib/chef/provisioning/fog_driver/providers/google.rb +85 -85
  15. data/lib/chef/provisioning/fog_driver/providers/joyent.rb +63 -63
  16. data/lib/chef/provisioning/fog_driver/providers/openstack.rb +117 -117
  17. data/lib/chef/provisioning/fog_driver/providers/rackspace.rb +42 -42
  18. data/lib/chef/provisioning/fog_driver/providers/softlayer.rb +36 -36
  19. data/lib/chef/provisioning/fog_driver/providers/vcair.rb +409 -409
  20. data/lib/chef/provisioning/fog_driver/providers/xenserver.rb +210 -210
  21. data/lib/chef/provisioning/fog_driver/recipe_dsl.rb +32 -32
  22. data/lib/chef/provisioning/fog_driver/version.rb +7 -7
  23. data/lib/chef/resource/fog_key_pair.rb +34 -34
  24. data/spec/spec_helper.rb +18 -18
  25. data/spec/support/aws/config-file.csv +2 -2
  26. data/spec/support/aws/ini-file.ini +10 -10
  27. data/spec/support/chef_metal_fog/providers/testdriver.rb +16 -16
  28. data/spec/unit/chef/provisioning/fog_driver/driver_spec.rb +71 -71
  29. data/spec/unit/fog_driver_spec.rb +32 -32
  30. data/spec/unit/providers/aws/credentials_spec.rb +45 -45
  31. data/spec/unit/providers/rackspace_spec.rb +16 -16
  32. metadata +5 -3
@@ -1,7 +1,7 @@
1
- class Chef
2
- module Provisioning
3
- module FogDriver
4
- VERSION = '0.15.0'
5
- end
6
- end
7
- end
1
+ class Chef
2
+ module Provisioning
3
+ module FogDriver
4
+ VERSION = '0.15.1'
5
+ end
6
+ end
7
+ end
@@ -1,34 +1,34 @@
1
- require 'chef/provisioning'
2
-
3
- class Chef::Resource::FogKeyPair < Chef::Resource::LWRPBase
4
- self.resource_name = 'fog_key_pair'
5
-
6
- def initialize(*args)
7
- super
8
- @driver = run_context.chef_provisioning.current_driver
9
- end
10
-
11
- actions :create, :delete, :nothing
12
- default_action :create
13
-
14
- attribute :driver
15
- # Private key to use as input (will be generated if it does not exist)
16
- attribute :private_key_path, :kind_of => String
17
- # Public key to use as input (will be generated if it does not exist)
18
- attribute :public_key_path, :kind_of => String
19
- # List of parameters to the private_key resource used for generation of the key
20
- attribute :private_key_options, :kind_of => Hash
21
-
22
- # TODO what is the right default for this?
23
- attribute :allow_overwrite, :kind_of => [TrueClass, FalseClass], :default => false
24
-
25
- # Proc that runs after the resource completes. Called with (resource, private_key, public_key)
26
- def after(&block)
27
- block ? @after = block : @after
28
- end
29
-
30
- # We are not interested in Chef's cloning behavior here.
31
- def load_prior_resource(*args)
32
- Chef::Log.debug("Overloading #{resource_name}.load_prior_resource with NOOP")
33
- end
34
- end
1
+ require 'chef/provisioning'
2
+
3
+ class Chef::Resource::FogKeyPair < Chef::Resource::LWRPBase
4
+ self.resource_name = 'fog_key_pair'
5
+
6
+ def initialize(*args)
7
+ super
8
+ @driver = run_context.chef_provisioning.current_driver
9
+ end
10
+
11
+ actions :create, :delete, :nothing
12
+ default_action :create
13
+
14
+ attribute :driver
15
+ # Private key to use as input (will be generated if it does not exist)
16
+ attribute :private_key_path, :kind_of => String
17
+ # Public key to use as input (will be generated if it does not exist)
18
+ attribute :public_key_path, :kind_of => String
19
+ # List of parameters to the private_key resource used for generation of the key
20
+ attribute :private_key_options, :kind_of => Hash
21
+
22
+ # TODO what is the right default for this?
23
+ attribute :allow_overwrite, :kind_of => [TrueClass, FalseClass], :default => false
24
+
25
+ # Proc that runs after the resource completes. Called with (resource, private_key, public_key)
26
+ def after(&block)
27
+ block ? @after = block : @after
28
+ end
29
+
30
+ # We are not interested in Chef's cloning behavior here.
31
+ def load_prior_resource(*args)
32
+ Chef::Log.debug("Overloading #{resource_name}.load_prior_resource with NOOP")
33
+ end
34
+ end
@@ -1,18 +1,18 @@
1
- $:.unshift File.expand_path('../../lib', __FILE__)
2
- $:.unshift File.expand_path('../support', __FILE__)
3
- require 'fog'
4
- require 'chef/provisioning'
5
- require 'chef/provisioning/fog_driver'
6
-
7
- RSpec.configure do |config|
8
- config.run_all_when_everything_filtered = true
9
- config.filter_run :focus
10
-
11
- # Run specs in random order to surface order dependencies. If you find an
12
- # order dependency and want to debug it, you can fix the order by providing
13
- # the seed, which is printed after each run.
14
- # --seed 1234
15
- config.order = 'random'
16
- end
17
-
18
- Fog.mock!
1
+ $:.unshift File.expand_path('../../lib', __FILE__)
2
+ $:.unshift File.expand_path('../support', __FILE__)
3
+ require 'fog'
4
+ require 'chef/provisioning'
5
+ require 'chef/provisioning/fog_driver'
6
+
7
+ RSpec.configure do |config|
8
+ config.run_all_when_everything_filtered = true
9
+ config.filter_run :focus
10
+
11
+ # Run specs in random order to surface order dependencies. If you find an
12
+ # order dependency and want to debug it, you can fix the order by providing
13
+ # the seed, which is printed after each run.
14
+ # --seed 1234
15
+ config.order = 'random'
16
+ end
17
+
18
+ Fog.mock!
@@ -1,2 +1,2 @@
1
- User Name,Access Key Id,Secret Access Key
2
- test,12345,abcde
1
+ User Name,Access Key Id,Secret Access Key
2
+ test,12345,abcde
@@ -1,10 +1,10 @@
1
- [default]
2
- aws_access_key_id = 12345
3
- aws_secret_access_key = abcde
4
- aws_session_token = mysecret
5
- region = us-east-1
6
-
7
- [profile test]
8
- aws_access_key_id = foobar
9
- aws_secret_access_key = canteloupe
10
- region = us-east-1
1
+ [default]
2
+ aws_access_key_id = 12345
3
+ aws_secret_access_key = abcde
4
+ aws_session_token = mysecret
5
+ region = us-east-1
6
+
7
+ [profile test]
8
+ aws_access_key_id = foobar
9
+ aws_secret_access_key = canteloupe
10
+ region = us-east-1
@@ -1,16 +1,16 @@
1
- class Chef
2
- module Provisioning
3
- class FogDriver::Providers
4
- class TestDriver < Chef::Provisioning::FogDriver
5
- Chef::Provisioning::FogDriver.register_provider_class('TestDriver', Chef::Provisioning::FogDriver::Providers::TestDriver)
6
-
7
- attr_reader :config
8
- def initialize(driver_url, config)
9
- super
10
- end
11
-
12
- def self.compute_options_for(provider, id, config)
13
- [config, 'test']
14
- end
15
- end
16
- end
1
+ class Chef
2
+ module Provisioning
3
+ class FogDriver::Providers
4
+ class TestDriver < Chef::Provisioning::FogDriver
5
+ Chef::Provisioning::FogDriver.register_provider_class('TestDriver', Chef::Provisioning::FogDriver::Providers::TestDriver)
6
+
7
+ attr_reader :config
8
+ def initialize(driver_url, config)
9
+ super
10
+ end
11
+
12
+ def self.compute_options_for(provider, id, config)
13
+ [config, 'test']
14
+ end
15
+ end
16
+ end
@@ -1,71 +1,71 @@
1
- require 'chef/provisioning/fog_driver/driver'
2
-
3
- describe Chef::Provisioning::FogDriver::Driver do
4
- let(:driver) { Chef::Provisioning::FogDriver::Driver.new("fog:OpenStack", {}) }
5
-
6
- before(:each) do
7
- Chef::Provisioning::FogDriver::Driver.send(:public, *Chef::Provisioning::FogDriver::Driver.protected_instance_methods)
8
- end
9
-
10
- describe "#determine_remote_host" do
11
- let(:machine_spec) { double("machine_spec", :reference => reference, :name => 'name') }
12
- let(:server) { double("server", :private_ip_address => 'private', :public_ip_address => 'public', :ip_addresses => ['first_ip_address'])}
13
-
14
- context "when 'use_private_ip_for_ssh' is specified in the machine_spec.reference" do
15
- let(:reference) { { 'use_private_ip_for_ssh' => true } }
16
- it "returns the private ip" do
17
- expect(driver.determine_remote_host(machine_spec, server)).to eq('private')
18
- expect(reference).to eq( {'transport_address_location' => :private_ip} )
19
- end
20
- end
21
-
22
- context "when 'transport_address_location' is set to :private_ip" do
23
- let(:reference) { { 'transport_address_location' => :private_ip } }
24
- it "returns the private ip" do
25
- expect(driver.determine_remote_host(machine_spec, server)).to eq('private')
26
- end
27
- end
28
-
29
- context "when 'transport_address_location' is set to :ip_addresses" do
30
- let(:reference) { { 'transport_address_location' => :ip_addresses } }
31
- it "returns the first ip_address from array" do
32
- expect(driver.determine_remote_host(machine_spec, server)).to eq('first_ip_address')
33
- end
34
- end
35
-
36
- context "when 'transport_address_location' is set to :public_ip" do
37
- let(:reference) { { 'transport_address_location' => :public_ip } }
38
- it "returns the public ip" do
39
- expect(driver.determine_remote_host(machine_spec, server)).to eq('public')
40
- end
41
- end
42
-
43
- context "when machine_spec.reference does not specify the transport type" do
44
- let(:reference) { Hash.new }
45
-
46
- context "when the machine does not have a public_ip_address" do
47
- let(:server) { double("server", :private_ip_address => 'private', :public_ip_address => nil, :ip_addresses => ['first_ip_address'])}
48
-
49
- it "returns the private ip" do
50
- expect(driver.determine_remote_host(machine_spec, server)).to eq('private')
51
- end
52
- end
53
-
54
- context "when the machine has a public_ip_address" do
55
- let(:server) { double("server", :private_ip_address => 'private', :public_ip_address => 'public', :ip_addresses => ['first_ip_address'])}
56
-
57
- it "returns the public ip" do
58
- expect(driver.determine_remote_host(machine_spec, server)).to eq('public')
59
- end
60
- end
61
-
62
- context "when the machine does not have a public_ip_address or private_ip_address" do
63
- let(:server) { double("server", :private_ip_address => nil, :public_ip_address => nil, :ip_addresses => ['first_ip_address'], :id => 'id')}
64
-
65
- it "raises an error" do
66
- expect {driver.determine_remote_host(machine_spec, server)}.to raise_error("Server #{server.id} has no private or public IP address!")
67
- end
68
- end
69
- end
70
- end
71
- end
1
+ require 'chef/provisioning/fog_driver/driver'
2
+
3
+ describe Chef::Provisioning::FogDriver::Driver do
4
+ let(:driver) { Chef::Provisioning::FogDriver::Driver.new("fog:OpenStack", {}) }
5
+
6
+ before(:each) do
7
+ Chef::Provisioning::FogDriver::Driver.send(:public, *Chef::Provisioning::FogDriver::Driver.protected_instance_methods)
8
+ end
9
+
10
+ describe "#determine_remote_host" do
11
+ let(:machine_spec) { double("machine_spec", :reference => reference, :name => 'name') }
12
+ let(:server) { double("server", :private_ip_address => 'private', :public_ip_address => 'public', :ip_addresses => ['first_ip_address'])}
13
+
14
+ context "when 'use_private_ip_for_ssh' is specified in the machine_spec.reference" do
15
+ let(:reference) { { 'use_private_ip_for_ssh' => true } }
16
+ it "returns the private ip" do
17
+ expect(driver.determine_remote_host(machine_spec, server)).to eq('private')
18
+ expect(reference).to eq( {'transport_address_location' => :private_ip} )
19
+ end
20
+ end
21
+
22
+ context "when 'transport_address_location' is set to :private_ip" do
23
+ let(:reference) { { 'transport_address_location' => :private_ip } }
24
+ it "returns the private ip" do
25
+ expect(driver.determine_remote_host(machine_spec, server)).to eq('private')
26
+ end
27
+ end
28
+
29
+ context "when 'transport_address_location' is set to :ip_addresses" do
30
+ let(:reference) { { 'transport_address_location' => :ip_addresses } }
31
+ it "returns the first ip_address from array" do
32
+ expect(driver.determine_remote_host(machine_spec, server)).to eq('first_ip_address')
33
+ end
34
+ end
35
+
36
+ context "when 'transport_address_location' is set to :public_ip" do
37
+ let(:reference) { { 'transport_address_location' => :public_ip } }
38
+ it "returns the public ip" do
39
+ expect(driver.determine_remote_host(machine_spec, server)).to eq('public')
40
+ end
41
+ end
42
+
43
+ context "when machine_spec.reference does not specify the transport type" do
44
+ let(:reference) { Hash.new }
45
+
46
+ context "when the machine does not have a public_ip_address" do
47
+ let(:server) { double("server", :private_ip_address => 'private', :public_ip_address => nil, :ip_addresses => ['first_ip_address'])}
48
+
49
+ it "returns the private ip" do
50
+ expect(driver.determine_remote_host(machine_spec, server)).to eq('private')
51
+ end
52
+ end
53
+
54
+ context "when the machine has a public_ip_address" do
55
+ let(:server) { double("server", :private_ip_address => 'private', :public_ip_address => 'public', :ip_addresses => ['first_ip_address'])}
56
+
57
+ it "returns the public ip" do
58
+ expect(driver.determine_remote_host(machine_spec, server)).to eq('public')
59
+ end
60
+ end
61
+
62
+ context "when the machine does not have a public_ip_address or private_ip_address" do
63
+ let(:server) { double("server", :private_ip_address => nil, :public_ip_address => nil, :ip_addresses => ['first_ip_address'], :id => 'id')}
64
+
65
+ it "raises an error" do
66
+ expect {driver.determine_remote_host(machine_spec, server)}.to raise_error("Server #{server.id} has no private or public IP address!")
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -1,32 +1,32 @@
1
- require 'spec_helper'
2
- require 'chef/provisioning/fog_driver'
3
-
4
- describe Chef::Provisioning::FogDriver do
5
-
6
- describe ".from_url" do
7
- subject { Chef::Provisioning::FogDriver.from_provider('TestDriver', {}) }
8
-
9
- it "should return the correct class" do
10
- expect(subject).to be_an_instance_of Chef::Provisioning::FogDriver::Providers::TestDriver
11
- end
12
-
13
- it "should call the target compute_options_for" do
14
- expect(Chef::Provisioning::FogDriver::Providers::TestDriver).to receive(:compute_options_for)
15
- .with('TestDriver', anything, {}).and_return([{}, 'test']).twice
16
- subject
17
- end
18
-
19
- end
20
-
21
- describe "when creating a new class" do
22
- it "should return the correct class" do
23
- test = Chef::Provisioning::FogDriver.new('fog:TestDriver:foo', {})
24
- expect(test).to be_an_instance_of Chef::Provisioning::FogDriver::Providers::TestDriver
25
- end
26
-
27
- it "should populate config" do
28
- test = Chef::Provisioning::FogDriver.new('fog:TestDriver:foo', {test: "chef_provisioning"})
29
- expect(test.config[:test]).to eq "chef_provisioning"
30
- end
31
- end
32
- end
1
+ require 'spec_helper'
2
+ require 'chef/provisioning/fog_driver'
3
+
4
+ describe Chef::Provisioning::FogDriver do
5
+
6
+ describe ".from_url" do
7
+ subject { Chef::Provisioning::FogDriver.from_provider('TestDriver', {}) }
8
+
9
+ it "should return the correct class" do
10
+ expect(subject).to be_an_instance_of Chef::Provisioning::FogDriver::Providers::TestDriver
11
+ end
12
+
13
+ it "should call the target compute_options_for" do
14
+ expect(Chef::Provisioning::FogDriver::Providers::TestDriver).to receive(:compute_options_for)
15
+ .with('TestDriver', anything, {}).and_return([{}, 'test']).twice
16
+ subject
17
+ end
18
+
19
+ end
20
+
21
+ describe "when creating a new class" do
22
+ it "should return the correct class" do
23
+ test = Chef::Provisioning::FogDriver.new('fog:TestDriver:foo', {})
24
+ expect(test).to be_an_instance_of Chef::Provisioning::FogDriver::Providers::TestDriver
25
+ end
26
+
27
+ it "should populate config" do
28
+ test = Chef::Provisioning::FogDriver.new('fog:TestDriver:foo', {test: "chef_provisioning"})
29
+ expect(test.config[:test]).to eq "chef_provisioning"
30
+ end
31
+ end
32
+ end
@@ -1,45 +1,45 @@
1
- require 'chef/provisioning/fog_driver/providers/aws/credentials'
2
-
3
- describe Chef::Provisioning::FogDriver::Providers::AWS::Credentials do
4
- describe "#load_ini" do
5
- let(:aws_credentials_ini_file) { File.join(File.expand_path('../../../../support', __FILE__), 'aws/ini-file.ini') }
6
-
7
- before do
8
- described_class.load_ini(aws_credentials_ini_file)
9
- end
10
-
11
- it "should load a default profile" do
12
- expect(described_class['default']).to include(:aws_access_key_id)
13
- end
14
-
15
- it "should load the correct values" do
16
- expect(described_class['default'][:aws_access_key_id]).to eq "12345"
17
- expect(described_class['default'][:aws_secret_access_key]).to eq "abcde"
18
- expect(described_class['default'][:region]).to eq "us-east-1"
19
- expect(described_class['default'][:aws_session_token]).to eq "mysecret"
20
- end
21
-
22
- it "should load several profiles" do
23
- expect(described_class.keys.length).to eq 2
24
- end
25
- end
26
-
27
- describe "#load_csv" do
28
- let(:aws_credentials_csv_file) { File.join(File.expand_path('../../../../support', __FILE__), 'aws/config-file.csv') }
29
- before do
30
- described_class.load_csv(aws_credentials_csv_file)
31
- end
32
-
33
- it "should load a single profile" do
34
- expect(described_class['default']).to include(:aws_access_key_id)
35
- end
36
-
37
- it "should load the correct values" do
38
- expect(described_class['default'][:aws_access_key_id]).to eq "12345"
39
- end
40
-
41
- it "should load several profiles" do
42
- expect(described_class.keys.length).to eq 2
43
- end
44
- end
45
- end
1
+ require 'chef/provisioning/fog_driver/providers/aws/credentials'
2
+
3
+ describe Chef::Provisioning::FogDriver::Providers::AWS::Credentials do
4
+ describe "#load_ini" do
5
+ let(:aws_credentials_ini_file) { File.join(File.expand_path('../../../../support', __FILE__), 'aws/ini-file.ini') }
6
+
7
+ before do
8
+ described_class.load_ini(aws_credentials_ini_file)
9
+ end
10
+
11
+ it "should load a default profile" do
12
+ expect(described_class['default']).to include(:aws_access_key_id)
13
+ end
14
+
15
+ it "should load the correct values" do
16
+ expect(described_class['default'][:aws_access_key_id]).to eq "12345"
17
+ expect(described_class['default'][:aws_secret_access_key]).to eq "abcde"
18
+ expect(described_class['default'][:region]).to eq "us-east-1"
19
+ expect(described_class['default'][:aws_session_token]).to eq "mysecret"
20
+ end
21
+
22
+ it "should load several profiles" do
23
+ expect(described_class.keys.length).to eq 2
24
+ end
25
+ end
26
+
27
+ describe "#load_csv" do
28
+ let(:aws_credentials_csv_file) { File.join(File.expand_path('../../../../support', __FILE__), 'aws/config-file.csv') }
29
+ before do
30
+ described_class.load_csv(aws_credentials_csv_file)
31
+ end
32
+
33
+ it "should load a single profile" do
34
+ expect(described_class['default']).to include(:aws_access_key_id)
35
+ end
36
+
37
+ it "should load the correct values" do
38
+ expect(described_class['default'][:aws_access_key_id]).to eq "12345"
39
+ end
40
+
41
+ it "should load several profiles" do
42
+ expect(described_class.keys.length).to eq 2
43
+ end
44
+ end
45
+ end