chef-provisioning-fog 0.15.3 → 0.16.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f8cd8c1afd5bad40b2fa6dd04e9637e96ad4928
4
- data.tar.gz: f6bac8c8f71b733555689223288a9f1e9e18717b
3
+ metadata.gz: 4fe75ef2b7b47f463c63d139a34b263eacf4b900
4
+ data.tar.gz: d8f13c9f9302f33dc71e234ac8f6e3a830a60d40
5
5
  SHA512:
6
- metadata.gz: 25aa7920e7fedc41467a0c9d92c632d8ba6ed6c1d9490e340a853302a82696d62ca506c4a17e77e917e6b03a58ee7d2c362433b0d5fdf8c9cdc6e426644bbc31
7
- data.tar.gz: ca9c30842125ca5d5d609698d7a2d1d9323a19868d9973001ccb69a58600495852dfcbb33a38f938d9d38360bac5f56cd299e9dc0ed1fbdae5bcc03048dfd9c4
6
+ metadata.gz: 0da8a4fa982e2d900b5fe83537276c95112280646aa60ce279f7cc2004c82f90fa6b4a1284e3eeb475e0b26c551a0207f2a68e9e81956cdb6229b92815d122a8
7
+ data.tar.gz: b16b69e8db0bf1cac20bb1dcad8952d482ad4aadb56a3e7483088c687a909cbf0df7c67f47f7fe23772008d7eb68c8d46815da38a9d60edd1d6e530f95bd152b
data/README.md CHANGED
@@ -19,15 +19,18 @@ These are the primary documents to help learn about using Provisioning and creat
19
19
 
20
20
  ## chef-provisioning-fog Usage and Examples
21
21
 
22
+ **A note about key pairs** - The key name used in `fog_key_pair` must be the same as the filename of the local key to be used. If the key does not exist in one of `private_key_paths` (which you can set in knife.rb or in a client.rb) it will be created.
23
+
22
24
  ### DigitalOcean
23
25
 
24
- If you are on DigitalOcean and using the `tugboat` gem, you can do this:
26
+ Update your knife.rb to contain your DigitalOcean API token and the driver
25
27
 
28
+ ```ruby
29
+ driver 'fog:DigitalOcean'
30
+ driver_options compute_options: { digitalocean_token: 'token' }
26
31
  ```
27
- $ gem install chef-provisioning-fog
28
- $ export CHEF_DRIVER=fog:DigitalOcean
29
- $ chef-client -z simple.rb
30
- ```
32
+
33
+ For a full example see [examples/digitalocean/simple.rb](examples/digitalocean/simple.rb).
31
34
 
32
35
  ### OpenStack
33
36
 
@@ -41,56 +44,7 @@ driver_options :compute_options => { :openstack_auth_url => 'http://YOUROPENSTAC
41
44
  :openstack_tenant => 'YOURTENANTIDNAME' }
42
45
  ```
43
46
 
44
- How to install the gem, and run a `simple.rb`.
45
-
46
- ```
47
- $ gem install chef-provisioning-fog
48
- $ chef-client -z simple.rb
49
- ```
50
-
51
- And inside your recipe, you'll need something like the following. This specifically will create 3 dev-webservers, and 1 qa-webserver.
52
-
53
- ```ruby
54
- require 'chef/provisioning'
55
-
56
- with_machine_options({
57
- :bootstrap_options => {
58
- :flavor_ref => 3,
59
- :image_ref => 'my-fake-ubuntu-image-0c1f2c38432b',
60
- :nics => [{ :net_id => 'my-tenantnetwork-id-89afddb9db6c'}],
61
- :key_name => 'mykeyname',
62
- :floating_ip_pool => 'ext-net'
63
- },
64
- :ssh_username => 'ubuntu'
65
- })
66
-
67
- machine_batch 'dev' do
68
- 1.upto(3) do |n|
69
- instance = "#{name}-webserver-#{n}"
70
- machine instance do
71
- role 'webserver'
72
- tag "#{name}-webserver-#{n}"
73
- converge true
74
- end
75
- end
76
- end
77
-
78
- machine 'qa-webserver' do
79
- tag 'qabox'
80
- machine_options({
81
- bootstrap_options: {
82
- :flavor_ref => 3,
83
- :nics => [{ :net_id => 'my-tenantnetwork-id-89afddb9db6c'}],
84
- :key_name => 'jdizzle',
85
- :image_ref => 'my-centos-image-2b0b6bb7b0c12b0b6bb7b0c1',
86
- :floating_ip_pool => 'ext-net'
87
- },
88
- :ssh_username => 'centos'
89
- })
90
- role 'webserver'
91
- converge true
92
- end
93
- ```
47
+ For a full example see [examples/openstack/simple.rb](examples/openstack/simple.rb).
94
48
 
95
49
  ### Rackspace
96
50
 
@@ -106,42 +60,7 @@ You must configure some credentials and region in a `knife.rb` file like so:
106
60
  }
107
61
  ```
108
62
 
109
- Ensure your Gemfile has (or install these with `gem install`):
110
- ```
111
- gem 'chef-provisioning'
112
- gem 'chef-provisioning-fog'
113
- ```
114
-
115
- Then, here's an example of making a keypair and booting a server:
116
- ```ruby
117
- require 'chef/provisioning'
118
- require 'chef/provisioning/fog_driver/recipe_dsl'
119
-
120
- # create/update a keypair at Rackspace's API endpoint, so we can use it later
121
- fog_key_pair 'example_id_rsa'
122
-
123
- # Options to bootstrap 2gb General instance with CentOS 6 (PVHVM)
124
- with_machine_options({
125
- :bootstrap_options => {
126
- :flavor_id => 'general1-2', # required
127
- :image_id => 'fabe045f-43f8-4991-9e6c-5cabd617538c', # required
128
- :key_name => 'example_id_rsa',
129
-
130
- # optional attributes:
131
- # :disk_config, :metadata, :personality, :config_drive,
132
- # :boot_volume_id, :boot_image_id
133
- #
134
- # ** :image_id must be "" if :boot_volume_id or :boot_image_id is provided
135
- }
136
- })
137
-
138
- machine 'mario' do
139
- tag 'itsa_me'
140
- converge true
141
- end
142
- ```
143
-
144
- If you run into SSH key trouble, [see this issue](https://github.com/chef/chef-provisioning-fog/issues/130) for some background of the chef-provisioning-fog driver and the fog library's different ways of bootstraping a server at Rackspace.
63
+ For a full example see [examples/rackspace/simple.rb](examples/rackspace/simple.rb).
145
64
 
146
65
  ### Cleaning up
147
66
 
@@ -203,6 +122,58 @@ The driver API is separated out so that new drivers can be made with minimal eff
203
122
 
204
123
  Drivers save their data in the Chef node itself, so that they will be accessible to everyone who is using the Chef server to manage the nodes.
205
124
 
125
+ ### Tuning Timeouts
126
+
127
+ `chef-provisioning-fog` interacts with your cloud provider's endpoint. Most of
128
+ the time, default timeouts for the following would be sufficient.
129
+
130
+ #### Fog `connection_options`
131
+
132
+ Modify the defaults if your Fog endpoint takes awhile to send/receive API requests. Normally, if you see `Excon` timeouts you should tune these [parameters](https://github.com/excon/excon/blob/75d85a7e304cbd1c9dc3c7c40c6de5a995f5cd04/lib/excon/constants.rb#L110-L139).
133
+
134
+ ```ruby
135
+ with_driver 'fog:foo',
136
+ :compute_options => {
137
+ :connection_options => {
138
+ # set connection to persist (default is false)
139
+ :persistent => true,
140
+ # set longer connect_timeout (default is 60 seconds)
141
+ :connect_timeout => 360,
142
+ # set longer read_timeout (default is 60 seconds)
143
+ :read_timeout => 360,
144
+ # set longer write_timeout (default is 60 seconds)
145
+ :write_timeout => 360,
146
+ }
147
+ }
148
+ ```
149
+ #### `machine_option` timeouts
150
+
151
+ Modify these timeouts if you need Chef to wait a bit of time to allow for the machine to be ready.
152
+
153
+ ```ruby
154
+ with_machine_options({
155
+ # set longer to wait for the instance to boot to ssh (defaults to 180)
156
+ :create_timeout => 360,
157
+ # set longer to wait for the instance to start (defaults to 180)
158
+ :start_timeout => 360,
159
+ # set longer to wait for ssh to be available if the instance is detected up (defaults to 20)
160
+ :ssh_timeout => 360
161
+ })
162
+ ```
163
+
164
+ #### Chef Client `convergence_options`
165
+
166
+ Modify this if your chef client convergences take awhile.
167
+
168
+ ```ruby
169
+ with_machine_options({
170
+ :convergence_options => {
171
+ # set longer if you need more time to converge (default: 2 hours)
172
+ :chef_client_timeout => 120*60
173
+ }
174
+ })
175
+ ```
176
+
206
177
  [gem]: https://rubygems.org/gems/chef-provisioning-fog
207
178
  [travis]: https://travis-ci.org/chef/chef-provisioning-fog
208
179
  [gemnasium]: https://gemnasium.com/chef/chef-provisioning-fog
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.homepage = 'https://github.com/opscode/chef-provisioning-fog'
14
14
 
15
15
  s.add_dependency 'chef-provisioning', '~> 1.0'
16
- s.add_dependency 'fog'
16
+ s.add_dependency 'fog', '>= 1.35.0'
17
17
  s.add_dependency 'retryable'
18
18
 
19
19
  s.add_development_dependency 'rspec'
@@ -216,7 +216,7 @@ class Chef::Provider::FogKeyPair < Chef::Provider::LWRPBase
216
216
  current_key_pair = compute.ssh_keys.select { |key| key.name == new_resource.name }.first
217
217
  if current_key_pair
218
218
  @current_id = current_key_pair.id
219
- @current_fingerprint = current_key_pair ? compute.ssh_keys.get(@current_id).ssh_pub_key : nil
219
+ @current_fingerprint = current_key_pair ? compute.ssh_keys.get(@current_id).public_key : nil
220
220
  else
221
221
  current_resource.action :delete
222
222
  end
@@ -297,7 +297,7 @@ module FogDriver
297
297
  specs_and_options.each do |machine_spec, machine_options|
298
298
  server = specs_and_servers[machine_spec]
299
299
  if server
300
- if %w(terminated archive).include?(server.state) # Can't come back from that
300
+ if %w(terminated archive).include?(server.status) # Can't come back from that
301
301
  Chef::Log.warn "Machine #{machine_spec.name} (#{server.id} on #{driver_url}) is terminated. Recreating ..."
302
302
  else
303
303
  yield machine_spec, server if block_given?
@@ -370,14 +370,14 @@ module FogDriver
370
370
  end
371
371
 
372
372
  def start_server(action_handler, machine_spec, server)
373
- # If it is stopping, wait for it to get out of "stopping" transition state before starting
374
- if server.state == 'stopping'
373
+ # If it is stopping, wait for it to get out of "stopping" transition status before starting
374
+ if server.status == 'stopping'
375
375
  action_handler.report_progress "wait for #{machine_spec.name} (#{server.id} on #{driver_url}) to finish stopping ..."
376
- server.wait_for { server.state != 'stopping' }
376
+ server.wait_for { server.status != 'stopping' }
377
377
  action_handler.report_progress "#{machine_spec.name} is now stopped"
378
378
  end
379
379
 
380
- if server.state == 'stopped'
380
+ if server.status == 'stopped'
381
381
  action_handler.perform_action "start machine #{machine_spec.name} (#{server.id} on #{driver_url})" do
382
382
  server.start
383
383
  machine_spec.reference['started_at'] = Time.now.to_i
@@ -633,6 +633,7 @@ module FogDriver
633
633
  # @param [Chef::Provisioning::Machine] server a Machine representing the server
634
634
  # @return [String] PEM-encoded private key
635
635
  def private_key_for(machine_spec, machine_options, server)
636
+ bootstrap_options = machine_options[:bootstrap_options] || {}
636
637
  if server.respond_to?(:private_key) && server.private_key
637
638
  server.private_key
638
639
  elsif server.respond_to?(:key_name) && server.key_name
@@ -647,13 +648,14 @@ module FogDriver
647
648
  raise "Server was created with key name '#{machine_spec.reference['key_name']}', but the corresponding private key was not found locally. Check if the key is in Chef::Config.private_key_paths: #{Chef::Config.private_key_paths.join(', ')}"
648
649
  end
649
650
  key
650
- elsif machine_options[:bootstrap_options][:key_path]
651
- IO.read(machine_options[:bootstrap_options][:key_path])
652
- elsif machine_options[:bootstrap_options][:key_name]
653
- get_private_key(machine_options[:bootstrap_options][:key_name])
651
+ elsif bootstrap_options[:key_path]
652
+ IO.read(bootstrap_options[:key_path])
653
+ elsif bootstrap_options[:key_name]
654
+ get_private_key(bootstrap_options[:key_name])
654
655
  else
655
656
  # TODO make a way to suggest other keys to try ...
656
- raise "No key found to connect to #{machine_spec.name} (#{machine_spec.reference.inspect})!"
657
+ raise "No key found to connect to #{machine_spec.name} (#{machine_spec.reference.inspect})" \
658
+ " : machine_options -> (#{machine_options.inspect})!"
657
659
  end
658
660
  end
659
661
 
@@ -16,7 +16,7 @@ module FogDriver
16
16
 
17
17
  def bootstrap_options_for(action_handler, machine_spec, machine_options)
18
18
  bootstrap_options = symbolize_keys(machine_options[:bootstrap_options] || {})
19
- if bootstrap_options[:key_path]
19
+ if bootstrap_options[:key_path] || bootstrap_options[:key_name]
20
20
  bootstrap_options[:key_name] ||= File.basename(bootstrap_options[:key_path])
21
21
  # Verify that the provided key name and path are in line (or create the key pair if not!)
22
22
  driver = self
@@ -27,12 +27,12 @@ module FogDriver
27
27
  end
28
28
  end
29
29
  else
30
- bootstrap_options[:key_name] = overwrite_default_key_willy_nilly(action_handler, machine_spec)
30
+ bootstrap_options[:key_name] ||= overwrite_default_key_willy_nilly(action_handler, machine_spec)
31
31
  end
32
32
 
33
33
  bootstrap_options[:tags] = default_tags(machine_spec, bootstrap_options[:tags] || {})
34
34
 
35
- if !bootstrap_options[:image_id]
35
+ if !bootstrap_options[:image_id] && !bootstrap_options[:image]
36
36
  if !bootstrap_options[:image_distribution] && !bootstrap_options[:image_name]
37
37
  bootstrap_options[:image_distribution] = 'CentOS'
38
38
  bootstrap_options[:image_name] = '6.5 x64'
@@ -45,44 +45,44 @@ module FogDriver
45
45
  if images.empty?
46
46
  raise "No images on DigitalOcean with distribution #{bootstrap_options[:image_distribution].inspect} and name #{bootstrap_options[:image_name].inspect}"
47
47
  end
48
- bootstrap_options[:image_id] = images.first.id
48
+ bootstrap_options[:image] = images.first.id
49
49
  end
50
- if !bootstrap_options[:flavor_id]
50
+ if !bootstrap_options[:flavor_id] && !bootstrap_options[:size]
51
51
  bootstrap_options[:flavor_name] ||= '512MB'
52
52
  flavors = compute.flavors.select do |f|
53
- f.name == bootstrap_options[:flavor_name]
53
+ f.slug.downcase == bootstrap_options[:flavor_name].downcase
54
54
  end
55
55
  if flavors.empty?
56
56
  raise "Could not find flavor named '#{bootstrap_options[:flavor_name]}' on #{driver_url}"
57
57
  end
58
- bootstrap_options[:flavor_id] = flavors.first.id
58
+ bootstrap_options[:size] = flavors.first.slug
59
59
  end
60
- if !bootstrap_options[:region_id]
60
+ if !bootstrap_options[:region]
61
61
  bootstrap_options[:region_name] ||= 'San Francisco 1'
62
62
  regions = compute.regions.select { |region| region.name == bootstrap_options[:region_name] }
63
63
  if regions.empty?
64
64
  raise "Could not find region named '#{bootstrap_options[:region_name]}' on #{driver_url}"
65
65
  end
66
- bootstrap_options[:region_id] = regions.first.id
66
+ bootstrap_options[:region] = regions.first.slug
67
67
  end
68
68
  keys = compute.ssh_keys.select { |k| k.name == bootstrap_options[:key_name] }
69
69
  if keys.empty?
70
70
  raise "Could not find key named '#{bootstrap_options[:key_name]}' on #{driver_url}"
71
71
  end
72
72
  found_key = keys.first
73
- bootstrap_options[:ssh_key_ids] ||= [ found_key.id ]
73
+ bootstrap_options[:ssh_keys] ||= [ found_key.id ]
74
74
 
75
75
  # You don't get to specify name yourself
76
76
  bootstrap_options[:name] = machine_spec.name
77
-
77
+ bootstrap_options[:version] ||= :v2
78
78
  bootstrap_options
79
79
  end
80
80
 
81
81
  def destroy_machine(action_handler, machine_spec, machine_options)
82
82
  server = server_for(machine_spec)
83
- if server && server.state != 'archive'
83
+ if server && server.status != 'archive'
84
84
  action_handler.perform_action "destroy machine #{machine_spec.name} (#{machine_spec.location['server_id']} at #{driver_url})" do
85
- server.destroy
85
+ server.delete
86
86
  end
87
87
  end
88
88
  machine_spec.location = nil
@@ -95,38 +95,14 @@ module FogDriver
95
95
  new_compute_options[:provider] = provider
96
96
  new_config = { :driver_options => { :compute_options => new_compute_options }}
97
97
  new_defaults = {
98
- :driver_options => { :compute_options => {} },
98
+ :driver_options => { :compute_options => { version: :v2 } },
99
99
  :machine_options => { :bootstrap_options => {}, :ssh_options => {} }
100
100
  }
101
101
  result = Cheffish::MergedConfig.new(new_config, config, new_defaults)
102
102
 
103
- new_compute_options[:digitalocean_client_id] = id if (id && id != '')
104
-
105
- # This uses ~/.tugboat, generated by "tugboat authorize" - see https://github.com/pearkes/tugboat
106
- tugboat_file = File.expand_path('~/.tugboat')
107
- if File.exist?(tugboat_file)
108
- tugboat_data = YAML.load(IO.read(tugboat_file))
109
-
110
- new_bootstrap_options = new_defaults[:machine_options][:bootstrap_options]
111
- if tugboat_data['authentication']
112
- new_compute_options[:digitalocean_client_id] = tugboat_data['authentication']['client_key'] if tugboat_data['authentication']['client_key'] && tugboat_data['authentication']['client_key'].size > 0
113
- new_compute_options[:digitalocean_api_key] = tugboat_data['authentication']['api_key'] if tugboat_data['authentication']['api_key'] && tugboat_data['authentication']['api_key'].size > 0
114
- end
115
- if tugboat_data['defaults']
116
- new_bootstrap_options[:region_id] = tugboat_data['defaults']['region'].to_i if tugboat_data['defaults']['region'] && tugboat_data['defaults']['region'].size > 0
117
- new_bootstrap_options[:image_id] = tugboat_data['defaults']['image'].to_i if tugboat_data['defaults']['image'] && tugboat_data['defaults']['image'].size > 0
118
- new_bootstrap_options[:size_id] = tugboat_data['defaults']['size'].to_i if tugboat_data['defaults']['size'] && tugboat_data['defaults']['size'].size > 0
119
- new_bootstrap_options[:private_networking] = (tugboat_data['defaults']['private_networking'] == 'true') if tugboat_data['defaults']['private_networking'] && tugboat_data['defaults']['private_networking'].size > 0
120
- new_bootstrap_options[:backups_enabled] = (tugboat_data['defaults']['backups_enabled'] == 'true') if tugboat_data['defaults']['backups_enabled'] && tugboat_data['defaults']['backups_enabled'].size > 0
121
- new_bootstrap_options[:key_name] = tugboat_data['defaults']['ssh_key'] if tugboat_data['defaults']['ssh_key'] && tugboat_data['defaults']['ssh_key'].size > 0
122
- end
123
- if tugboat_data['ssh']
124
- new_bootstrap_options[:key_path] = tugboat_data['ssh']['ssh_key_path'] if tugboat_data['ssh']['ssh_key_path'] && tugboat_data['ssh']['ssh_key_path'].size > 0
125
- new_defaults[:machine_options][:ssh_options][:port] = tugboat_data['ssh']['ssh_port'] if tugboat_data['ssh']['ssh_port'] if tugboat_data['ssh']['ssh_port'].size > 0
126
- end
127
- end
103
+ new_compute_options[:digitalocean_token] = id if (id && id != '')
128
104
 
129
- [result, new_compute_options[:digitalocean_client_id]]
105
+ [result, new_compute_options[:digitalocean_token]]
130
106
  end
131
107
 
132
108
  end
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  module Provisioning
3
3
  module FogDriver
4
- VERSION = '0.15.3'
4
+ VERSION = '0.16.0'
5
5
  end
6
6
  end
7
7
  end
@@ -2,7 +2,7 @@ $:.unshift File.expand_path('../../lib', __FILE__)
2
2
  $:.unshift File.expand_path('../support', __FILE__)
3
3
  require 'fog'
4
4
  require 'chef/provisioning'
5
- require 'chef/provisioning/fog_driver'
5
+ require 'chef/provisioning/fog_driver/driver'
6
6
 
7
7
  RSpec.configure do |config|
8
8
  config.run_all_when_everything_filtered = true
@@ -1,2 +1,2 @@
1
1
  User Name,Access Key Id,Secret Access Key
2
- test,12345,abcde
2
+ test,67890,fghij
@@ -0,0 +1,20 @@
1
+ class Chef
2
+ module Provisioning
3
+ module FogDriver
4
+ module Providers
5
+ class TestDriver < FogDriver::Driver
6
+ Driver.register_provider_class('TestDriver', Chef::Provisioning::FogDriver::Providers::TestDriver)
7
+
8
+ attr_reader :config
9
+ def initialize(driver_url, config)
10
+ super
11
+ end
12
+
13
+ def self.compute_options_for(provider, id, config)
14
+ [config, 'test']
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -68,4 +68,43 @@ describe Chef::Provisioning::FogDriver::Driver do
68
68
  end
69
69
  end
70
70
  end
71
+
72
+ describe '#private_key_for' do
73
+ let(:machine_spec) { double('machine_spec', reference: {}, name: 'my_machine') }
74
+ let(:machine_options) { { bootstrap_options: bootstrap_options } }
75
+
76
+ context 'when the machine has a key path in bootstrap options' do
77
+ let(:bootstrap_options) { { key_path: '/tmp/test_private_key_file' } }
78
+
79
+ it 'reads the key file' do
80
+ allow(IO).to receive(:read).and_return 'test_private_key'
81
+ expect(driver.private_key_for(machine_spec, machine_options, nil)).to eq 'test_private_key'
82
+ end
83
+ end
84
+
85
+ context 'when the machine has a key name in bootstrap options' do
86
+ let(:bootstrap_options) { { key_name: 'test_private_key_name' } }
87
+
88
+ it 'calls get_private_key' do
89
+ expect(driver).to receive(:get_private_key).with('test_private_key_name').and_return 'test_private_key'
90
+ expect(driver.private_key_for(machine_spec, machine_options, nil)).to eq 'test_private_key'
91
+ end
92
+ end
93
+
94
+ context 'when the machine has no bootstrap options' do
95
+ it 'raises an error' do
96
+ expect { driver.private_key_for(machine_spec, {}, nil) }
97
+ .to raise_error(RuntimeError, 'No key found to connect to my_machine ({}) : machine_options -> ({})!')
98
+ end
99
+ end
100
+
101
+ context 'when the machine has no key path or key name bootstrap options' do
102
+ let(:bootstrap_options) { {} }
103
+
104
+ it 'raises an error' do
105
+ expect { driver.private_key_for(machine_spec, machine_options, nil) }.to raise_error(
106
+ RuntimeError, 'No key found to connect to my_machine ({}) : machine_options -> ({:bootstrap_options=>{}})!')
107
+ end
108
+ end
109
+ end
71
110
  end
@@ -1,10 +1,10 @@
1
1
  require 'spec_helper'
2
- require 'chef/provisioning/fog_driver'
2
+ require 'chef/provisioning/fog_driver/providers/testdriver'
3
3
 
4
4
  describe Chef::Provisioning::FogDriver do
5
5
 
6
6
  describe ".from_url" do
7
- subject { Chef::Provisioning::FogDriver.from_provider('TestDriver', {}) }
7
+ subject { Chef::Provisioning::FogDriver::Driver.from_provider('TestDriver', {}) }
8
8
 
9
9
  it "should return the correct class" do
10
10
  expect(subject).to be_an_instance_of Chef::Provisioning::FogDriver::Providers::TestDriver
@@ -20,12 +20,12 @@ describe Chef::Provisioning::FogDriver do
20
20
 
21
21
  describe "when creating a new class" do
22
22
  it "should return the correct class" do
23
- test = Chef::Provisioning::FogDriver.new('fog:TestDriver:foo', {})
23
+ test = Chef::Provisioning::FogDriver::Driver.new('fog:TestDriver:foo', {})
24
24
  expect(test).to be_an_instance_of Chef::Provisioning::FogDriver::Providers::TestDriver
25
25
  end
26
26
 
27
27
  it "should populate config" do
28
- test = Chef::Provisioning::FogDriver.new('fog:TestDriver:foo', {test: "chef_provisioning"})
28
+ test = Chef::Provisioning::FogDriver::Driver.new('fog:TestDriver:foo', {test: "chef_provisioning"})
29
29
  expect(test.config[:test]).to eq "chef_provisioning"
30
30
  end
31
31
  end
@@ -1,45 +1,47 @@
1
1
  require 'chef/provisioning/fog_driver/providers/aws/credentials'
2
2
 
3
3
  describe Chef::Provisioning::FogDriver::Providers::AWS::Credentials do
4
- describe "#load_ini" do
4
+ let(:credentials) { Chef::Provisioning::FogDriver::Providers::AWS::Credentials.new }
5
+
6
+ describe "#load_inis" do
5
7
  let(:aws_credentials_ini_file) { File.join(File.expand_path('../../../../support', __FILE__), 'aws/ini-file.ini') }
6
8
 
7
9
  before do
8
- described_class.load_ini(aws_credentials_ini_file)
10
+ credentials.load_inis(aws_credentials_ini_file)
9
11
  end
10
12
 
11
13
  it "should load a default profile" do
12
- expect(described_class['default']).to include(:aws_access_key_id)
14
+ expect(credentials['default']).to include(:aws_access_key_id)
13
15
  end
14
16
 
15
17
  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"
18
+ expect(credentials['default'][:aws_access_key_id]).to eq "12345"
19
+ expect(credentials['default'][:aws_secret_access_key]).to eq "abcde"
20
+ expect(credentials['default'][:region]).to eq "us-east-1"
21
+ expect(credentials['default'][:aws_session_token]).to eq "mysecret"
20
22
  end
21
23
 
22
24
  it "should load several profiles" do
23
- expect(described_class.keys.length).to eq 2
25
+ expect(credentials.keys.length).to eq 2
24
26
  end
25
27
  end
26
28
 
27
29
  describe "#load_csv" do
28
30
  let(:aws_credentials_csv_file) { File.join(File.expand_path('../../../../support', __FILE__), 'aws/config-file.csv') }
29
31
  before do
30
- described_class.load_csv(aws_credentials_csv_file)
32
+ credentials.load_csv(aws_credentials_csv_file)
31
33
  end
32
34
 
33
35
  it "should load a single profile" do
34
- expect(described_class['default']).to include(:aws_access_key_id)
36
+ expect(credentials['test']).to include(:aws_access_key_id)
35
37
  end
36
38
 
37
39
  it "should load the correct values" do
38
- expect(described_class['default'][:aws_access_key_id]).to eq "12345"
40
+ expect(credentials['test'][:aws_access_key_id]).to eq "67890"
39
41
  end
40
42
 
41
43
  it "should load several profiles" do
42
- expect(described_class.keys.length).to eq 2
44
+ expect(credentials.keys.length).to eq 1
43
45
  end
44
46
  end
45
47
  end
@@ -1,8 +1,14 @@
1
- require 'chef/provisioning/fog_driver'
1
+ require 'spec_helper'
2
2
  require 'chef/provisioning/fog_driver/providers/rackspace'
3
3
 
4
4
  describe Chef::Provisioning::FogDriver::Providers::Rackspace do
5
- subject { Chef::Provisioning::FogDriver.from_provider('Rackspace',{}) }
5
+ subject do
6
+ Chef::Provisioning::FogDriver::Driver.from_provider(
7
+ 'Rackspace', driver_options: { compute_options: {
8
+ rackspace_username: 'test_username', rackspace_api_key: 'test_api_key'}
9
+ }
10
+ )
11
+ end
6
12
 
7
13
  it "returns the correct driver" do
8
14
  expect(subject).to be_an_instance_of Chef::Provisioning::FogDriver::Providers::Rackspace
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.15.3
4
+ version: 0.16.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-11-09 00:00:00.000000000 Z
14
+ date: 2016-02-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: chef-provisioning
@@ -33,14 +33,14 @@ dependencies:
33
33
  requirements:
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: '0'
36
+ version: 1.35.0
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
- version: '0'
43
+ version: 1.35.0
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: retryable
46
46
  requirement: !ruby/object:Gem::Requirement
@@ -120,7 +120,7 @@ files:
120
120
  - spec/spec_helper.rb
121
121
  - spec/support/aws/config-file.csv
122
122
  - spec/support/aws/ini-file.ini
123
- - spec/support/chef_metal_fog/providers/testdriver.rb
123
+ - spec/support/chef/provisioning/fog_driver/providers/testdriver.rb
124
124
  - spec/unit/chef/provisioning/fog_driver/driver_spec.rb
125
125
  - spec/unit/fog_driver_spec.rb
126
126
  - spec/unit/providers/aws/credentials_spec.rb
@@ -144,7 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  version: '0'
145
145
  requirements: []
146
146
  rubyforge_project:
147
- rubygems_version: 2.2.3
147
+ rubygems_version: 2.2.2
148
148
  signing_key:
149
149
  specification_version: 4
150
150
  summary: Driver for creating Fog instances in Chef Provisioning.
@@ -1,16 +0,0 @@
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