chef-provisioning-fog 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +201 -201
  3. data/README.md +3 -3
  4. data/Rakefile +6 -6
  5. data/lib/chef/provider/fog_key_pair.rb +266 -266
  6. data/lib/chef/provisioning/driver_init/fog.rb +3 -3
  7. data/lib/chef/provisioning/fog_driver/driver.rb +736 -709
  8. data/lib/chef/provisioning/fog_driver/providers/aws.rb +492 -492
  9. data/lib/chef/provisioning/fog_driver/providers/aws/credentials.rb +115 -115
  10. data/lib/chef/provisioning/fog_driver/providers/cloudstack.rb +44 -44
  11. data/lib/chef/provisioning/fog_driver/providers/digitalocean.rb +136 -136
  12. data/lib/chef/provisioning/fog_driver/providers/google.rb +85 -84
  13. data/lib/chef/provisioning/fog_driver/providers/joyent.rb +63 -59
  14. data/lib/chef/provisioning/fog_driver/providers/openstack.rb +117 -41
  15. data/lib/chef/provisioning/fog_driver/providers/rackspace.rb +42 -42
  16. data/lib/chef/provisioning/fog_driver/providers/softlayer.rb +36 -36
  17. data/lib/chef/provisioning/fog_driver/providers/vcair.rb +409 -376
  18. data/lib/chef/provisioning/fog_driver/providers/xenserver.rb +210 -0
  19. data/lib/chef/provisioning/fog_driver/recipe_dsl.rb +32 -32
  20. data/lib/chef/provisioning/fog_driver/version.rb +7 -7
  21. data/lib/chef/resource/fog_key_pair.rb +34 -34
  22. data/spec/spec_helper.rb +18 -18
  23. data/spec/support/aws/config-file.csv +2 -2
  24. data/spec/support/aws/ini-file.ini +10 -10
  25. data/spec/support/chef_metal_fog/providers/testdriver.rb +16 -16
  26. data/spec/unit/chef/provisioning/fog_driver/driver_spec.rb +71 -0
  27. data/spec/unit/fog_driver_spec.rb +32 -32
  28. data/spec/unit/providers/aws/credentials_spec.rb +45 -45
  29. data/spec/unit/providers/rackspace_spec.rb +16 -16
  30. metadata +5 -3
@@ -0,0 +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,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
@@ -1,16 +1,16 @@
1
- require 'chef/provisioning/fog_driver'
2
- require 'chef/provisioning/fog_driver/providers/rackspace'
3
-
4
- describe Chef::Provisioning::FogDriver::Providers::Rackspace do
5
- subject { Chef::Provisioning::FogDriver.from_provider('Rackspace',{}) }
6
-
7
- it "returns the correct driver" do
8
- expect(subject).to be_an_instance_of Chef::Provisioning::FogDriver::Providers::Rackspace
9
- end
10
-
11
- it "has a Fog backend" do
12
- pending unless Fog.mock?
13
- expect(subject.compute).to be_an_instance_of Fog::Compute::RackspaceV2::Mock
14
- end
15
-
16
- end
1
+ require 'chef/provisioning/fog_driver'
2
+ require 'chef/provisioning/fog_driver/providers/rackspace'
3
+
4
+ describe Chef::Provisioning::FogDriver::Providers::Rackspace do
5
+ subject { Chef::Provisioning::FogDriver.from_provider('Rackspace',{}) }
6
+
7
+ it "returns the correct driver" do
8
+ expect(subject).to be_an_instance_of Chef::Provisioning::FogDriver::Providers::Rackspace
9
+ end
10
+
11
+ it "has a Fog backend" do
12
+ pending unless Fog.mock?
13
+ expect(subject.compute).to be_an_instance_of Fog::Compute::RackspaceV2::Mock
14
+ end
15
+
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-provisioning-fog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-08-12 00:00:00.000000000 Z
14
+ date: 2015-09-16 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: chef-provisioning
@@ -111,6 +111,7 @@ files:
111
111
  - lib/chef/provisioning/fog_driver/providers/rackspace.rb
112
112
  - lib/chef/provisioning/fog_driver/providers/softlayer.rb
113
113
  - lib/chef/provisioning/fog_driver/providers/vcair.rb
114
+ - lib/chef/provisioning/fog_driver/providers/xenserver.rb
114
115
  - lib/chef/provisioning/fog_driver/recipe_dsl.rb
115
116
  - lib/chef/provisioning/fog_driver/version.rb
116
117
  - lib/chef/resource/fog_key_pair.rb
@@ -118,6 +119,7 @@ files:
118
119
  - spec/support/aws/config-file.csv
119
120
  - spec/support/aws/ini-file.ini
120
121
  - spec/support/chef_metal_fog/providers/testdriver.rb
122
+ - spec/unit/chef/provisioning/fog_driver/driver_spec.rb
121
123
  - spec/unit/fog_driver_spec.rb
122
124
  - spec/unit/providers/aws/credentials_spec.rb
123
125
  - spec/unit/providers/rackspace_spec.rb
@@ -140,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
142
  version: '0'
141
143
  requirements: []
142
144
  rubyforge_project:
143
- rubygems_version: 2.4.7
145
+ rubygems_version: 2.4.8
144
146
  signing_key:
145
147
  specification_version: 4
146
148
  summary: Driver for creating Fog instances in Chef Provisioning.