chef-metal-fog 0.5.beta.3 → 0.5.beta.4

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: 1eee68d2204401956fc7abcaa093bc9c203e1d28
4
- data.tar.gz: 4e14f8d8cc4e4821c79713b0a655686342837caf
3
+ metadata.gz: 556f2267637c64664e9ca20e8f1ace0925aa7d09
4
+ data.tar.gz: 5f766e9bb22d737259f91befc928cc06f5949d6d
5
5
  SHA512:
6
- metadata.gz: 35084cc9f278d5788f63094484d8f837d34ce856ef5e65076c27a1035ba5f4df57621fdaa27a97640af61956475e0524c370cabb812632bc3d297169b7b655f1
7
- data.tar.gz: 27031e7de4dc5ab6efb343bb685eeada72ef50aa49f24812583d832234431a062d55ccac657d771fdd39bb88dec40bdc5f3b8966e57b026105f620621f4e78f5
6
+ metadata.gz: c61a6f316a804d10b6fd25662d1fb27a947f0019ad5e972cdbb068a963ed760ba5f0dda0b8c5f58a7538392c4d252a0e3605385ece9199d482e70ecd1f3e32b4
7
+ data.tar.gz: 077e42b78f89ea339741257099dd5d10c0b7dc2b8a7a7e5b28499eb868a7fa2f3c489a8573bcee322da56391a160aa3c990ab7767866171f5c9481100770d98a
@@ -26,14 +26,22 @@ module ChefMetalFog
26
26
  # All Metal drivers use URLs to uniquely identify a driver's "bucket" of machines.
27
27
  # Fog URLs are of the form fog:<provider>:<identifier>:
28
28
  #
29
- # fog:AWS:<account_id>
29
+ # fog:AWS:<account_id>:<region>
30
+ # fog:AWS:<profile_name>
30
31
  # fog:OpenStack:https://identityHost:portNumber/v2.0
31
32
  # fog:DigitalOcean:<client id>
32
33
  # fog:Rackspace:https://identity.api.rackspacecloud.com/v2.0
33
34
  #
34
35
  # Identifier is generally something uniquely identifying the account. If multiple
35
36
  # users can access the account, the identifier should be the same for all of
36
- # them (do not use the username in these cases).
37
+ # them (do not use the username in these cases, use an account ID or auth server
38
+ # URL).
39
+ #
40
+ # In particular, the identifier should be specific enough that if you create a
41
+ # server with a driver with this URL, the server should be retrievable from
42
+ # the same URL *no matter what else changes*. For example, an AWS account ID
43
+ # is *not* enough for this--if you varied the region, you would no longer see
44
+ # your server in the list. Thus, AWS uses both the account ID and the region.
37
45
  #
38
46
  # ## Supporting a new Fog provider
39
47
  #
@@ -212,9 +220,9 @@ module ChefMetalFog
212
220
  end
213
221
 
214
222
  # Not meant to be part of public interface
215
- def transport_for(machine_spec, server)
223
+ def transport_for(machine_spec, machine_options, server)
216
224
  # TODO winrm
217
- create_ssh_transport(machine_spec, server)
225
+ create_ssh_transport(machine_spec, machine_options, server)
218
226
  end
219
227
 
220
228
  protected
@@ -286,6 +294,7 @@ module ChefMetalFog
286
294
  server.start
287
295
  machine_spec.location['started_at'] = Time.now.utc.to_s
288
296
  end
297
+ machine_spec.save(action_handler)
289
298
  end
290
299
  end
291
300
 
@@ -294,6 +303,7 @@ module ChefMetalFog
294
303
  server.reboot
295
304
  machine_spec.location['started_at'] = Time.now.utc.to_s
296
305
  end
306
+ machine_spec.save(action_handler)
297
307
  end
298
308
 
299
309
  def remaining_wait_time(machine_spec, machine_options)
@@ -302,6 +312,7 @@ module ChefMetalFog
302
312
  else
303
313
  timeout = option_for(machine_options, :create_timeout) - (Time.now.utc - Time.parse(machine_spec.location['allocated_at']))
304
314
  end
315
+ timeout > 0 ? timeout : 0.01
305
316
  end
306
317
 
307
318
  def wait_until_ready(action_handler, machine_spec, machine_options, server)
@@ -315,7 +326,7 @@ module ChefMetalFog
315
326
  end
316
327
 
317
328
  def wait_for_transport(action_handler, machine_spec, machine_options, server)
318
- transport = transport_for(machine_spec, server)
329
+ transport = transport_for(machine_spec, machine_options, server)
319
330
  if !transport.available?
320
331
  if action_handler.should_perform_actions
321
332
  action_handler.report_progress "waiting for #{machine_spec.name} (#{server.id} on #{driver_url}) to be connectable (transport up and running) ..."
@@ -453,9 +464,9 @@ module ChefMetalFog
453
464
  end
454
465
 
455
466
  if machine_spec.location['is_windows']
456
- ChefMetal::Machine::WindowsMachine.new(machine_spec, transport_for(machine_spec, server), convergence_strategy_for(machine_spec, machine_options))
467
+ ChefMetal::Machine::WindowsMachine.new(machine_spec, transport_for(machine_spec, machine_options, server), convergence_strategy_for(machine_spec, machine_options))
457
468
  else
458
- ChefMetal::Machine::UnixMachine.new(machine_spec, transport_for(machine_spec, server), convergence_strategy_for(machine_spec, machine_options))
469
+ ChefMetal::Machine::UnixMachine.new(machine_spec, transport_for(machine_spec, machine_optins, server), convergence_strategy_for(machine_spec, machine_options))
459
470
  end
460
471
  end
461
472
 
@@ -494,7 +505,7 @@ module ChefMetalFog
494
505
  result
495
506
  end
496
507
 
497
- def create_ssh_transport(machine_spec, server)
508
+ def create_ssh_transport(machine_spec, machine_options, server)
498
509
  ssh_options = ssh_options_for(machine_spec, server)
499
510
  # If we're on AWS, the default is to use ubuntu, not root
500
511
  if provider == 'AWS'
@@ -502,6 +513,9 @@ module ChefMetalFog
502
513
  else
503
514
  username = machine_spec.location['ssh_username'] || 'root'
504
515
  end
516
+ if machine_options.has_key?(:ssh_username) && machine_options[:ssh_username] != machine_spec.location['ssh_username']
517
+ Chef::Log.warn("Server #{machine_spec.name} was created with SSH username #{machine_spec.location['ssh_username']} and machine_options specifies username #{machine_options[:ssh_username]}. Using #{machine_spec.location['ssh_username']}. Please edit the node and change the metal.location.ssh_username attribute if you want to change it.")
518
+ end
505
519
  options = {}
506
520
  if machine_spec.location[:sudo] || (!machine_spec.location.has_key?(:sudo) && username != 'root')
507
521
  options[:prefix] = 'sudo '
@@ -511,7 +525,7 @@ module ChefMetalFog
511
525
  if machine_spec.location['use_private_ip_for_ssh']
512
526
  remote_host = server.private_ip_address
513
527
  elsif !server.public_ip_address
514
- Chef::Log.warn("Server has no public ip address. Using private ip '#{server.private_ip_address}'. Set driver option 'use_private_ip_for_ssh' => true if this will always be the case ...")
528
+ Chef::Log.warn("Server #{machine_spec.name} has no public ip address. Using private ip '#{server.private_ip_address}'. Set driver option 'use_private_ip_for_ssh' => true if this will always be the case ...")
515
529
  remote_host = server.private_ip_address
516
530
  elsif server.public_ip_address
517
531
  remote_host = server.public_ip_address
@@ -533,11 +547,19 @@ module ChefMetalFog
533
547
  new_compute_options[:provider] = provider
534
548
  new_config = { :driver_options => { :compute_options => new_compute_options }}
535
549
 
536
- # Set the identifier from the URL
550
+ # Get data from the identifier in the URL
537
551
  if id && id != ''
538
552
  case provider
539
553
  when 'AWS'
540
- if id !~ /^\d{12}$/
554
+ # AWS canonical URLs are of the form fog:AWS:
555
+ if id =~ /^(\d{12})(:(.+))?$/
556
+ if $2
557
+ id = $1
558
+ driver_options[:region] = $3
559
+ else
560
+ Chef::Log.warn("Old-style AWS URL #{id} from an early beta of chef-metal (before 0.11-final) found. If you have servers in multiple regions on this account, you may see odd behavior like servers being recreated. To fix, edit any nodes with attribute metal.location.driver_url to include the region like so: fog:AWS:#{id}:<region> (e.g. us-east-1)")
561
+ end
562
+ else
541
563
  # Assume it is a profile name, and set that.
542
564
  driver_options[:aws_profile] = id
543
565
  id = nil
@@ -564,8 +586,8 @@ module ChefMetalFog
564
586
  when 'AWS'
565
587
  # Grab the profile
566
588
  aws_profile = FogDriverAWS.get_aws_profile(driver_options, id)
567
- [ :aws_access_key_id, :aws_secret_access_key, :aws_session_token, :region ].each do |key|
568
- new_compute_options[key] = aws_profile[key] if aws_profile[key]
589
+ [ :aws_access_key_id, :aws_secret_access_key, :aws_security_token, :region].each do |key|
590
+ new_compute_options[key] = aws_profile[key] if aws_profile.has_key?(key)
569
591
  end
570
592
  when 'OpenStack'
571
593
  # TODO it is supposed to be unnecessary to load credentials from fog this way;
@@ -594,7 +616,7 @@ module ChefMetalFog
594
616
  when 'AWS'
595
617
  account_info = FogDriverAWS.aws_account_info_for(config[:driver_options][:compute_options])
596
618
  new_config[:driver_options][:aws_account_info] = account_info
597
- account_info[:aws_account_id]
619
+ "#{account_info[:aws_account_id]}:#{config[:driver_options][:compute_options][:region]}"
598
620
  when 'DigitalOcean'
599
621
  config[:driver_options][:compute_options][:digitalocean_client_id]
600
622
  when 'OpenStack'
@@ -8,9 +8,9 @@ module ChefMetalFog
8
8
  aws_credentials = get_aws_credentials(driver_options)
9
9
 
10
10
  # Order of operations:
11
- # driver_options[:aws_access_key_id] / driver_options[:aws_secret_access_key] / driver_options[:aws_security_token]
11
+ # driver_options[:aws_access_key_id] / driver_options[:aws_secret_access_key] / driver_options[:aws_security_token] / driver_options[:region]
12
12
  # driver_options[:aws_profile]
13
- # ENV['AWS_ACCESS_KEY_ID'] / ENV['AWS_SECRET_ACCESS_KEY'] / ENV['AWS_SECURITY_TOKEN']
13
+ # ENV['AWS_ACCESS_KEY_ID'] / ENV['AWS_SECRET_ACCESS_KEY'] / ENV['AWS_SECURITY_TOKEN'] / ENV['AWS_REGION']
14
14
  # ENV['AWS_PROFILE']
15
15
  # ENV['DEFAULT_PROFILE']
16
16
  # 'default'
@@ -19,7 +19,8 @@ module ChefMetalFog
19
19
  {
20
20
  :aws_access_key_id => driver_options[:aws_access_key_id],
21
21
  :aws_secret_access_key => driver_options[:aws_secret_access_key],
22
- :aws_security_token => driver_options[:aws_security_token]
22
+ :aws_security_token => driver_options[:aws_security_token],
23
+ :region => driver_options[:region]
23
24
  }
24
25
  elsif driver_options[:aws_profile]
25
26
  Chef::Log.debug("Using AWS profile #{driver_options[:aws_profile]}")
@@ -29,7 +30,8 @@ module ChefMetalFog
29
30
  {
30
31
  :aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'],
31
32
  :aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'],
32
- :aws_security_token => ENV['AWS_SECURITY_TOKEN']
33
+ :aws_security_token => ENV['AWS_SECURITY_TOKEN'],
34
+ :region => ENV['AWS_REGION']
33
35
  }
34
36
  elsif ENV['AWS_PROFILE']
35
37
  Chef::Log.debug("Using AWS profile #{ENV['AWS_PROFILE']} from AWS_PROFILE environment variable")
@@ -54,8 +56,6 @@ module ChefMetalFog
54
56
  raise "No AWS profile specified! Are you missing something in the Chef config or ~/.aws/config?"
55
57
  end
56
58
 
57
- # Set region
58
- aws_profile[:region] ||= ENV['AWS_DEFAULT_REGION']
59
59
  aws_profile.delete_if { |key, value| value.nil? }
60
60
  aws_profile
61
61
  end
@@ -1,3 +1,3 @@
1
1
  module ChefMetalFog
2
- VERSION = '0.5.beta.3'
2
+ VERSION = '0.5.beta.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-metal-fog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.beta.3
4
+ version: 0.5.beta.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-31 00:00:00.000000000 Z
11
+ date: 2014-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef