knife-rackspace 0.10.2 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTY3YTI3NWM4ZjIwMjllYWQ4ODdmYjM2OGY3ODQ3ZjVjMzJlYmQwYg==
4
+ M2NhZmI1NDM4OWUxODEwODI1ZGVmNWQ2YzgxZjBjNmJiYjMzOGVkYQ==
5
5
  data.tar.gz: !binary |-
6
- M2UxNzc5OTNhOTc0ZWY2M2YxZWUxMjZmYTJjYjE2ZDg3NDE5MmIyMg==
6
+ OTY4MTM0MTMzNzY5M2U4NWUwMmMxNmFhZWEyNjQ3YjQzYTdkNWMwZA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NmY5ZjRkODg0MTVjMGE0ZjMzNjAxNDM4ZjMzOTgwNDRhYjYwZDZkN2M4Yzg5
10
- MGZiMjY3MjhmZjk3ZWZkNzY5NmE1MWMxZjNkMjg2OGYyMWZiMjBlN2UxNzYx
11
- NDEzZTI2ZDNjZTc3Y2JhOTI4NWZjMzgxNTk3YTJiMGI0NWQ0NDY=
9
+ NTdjN2ZlMzBiNjUwZDZjODQ0M2U1YmQyODkwMTA0MGMyMTIxYjZmYTNhODQ5
10
+ MGExY2U5NmEzMzc5MTUxMWE4YzkwZDBiMGJmNzMxZTAyODc2MzZmMjdiMjg1
11
+ NzVlMWU0NWZlYjY1Yzc5MDU2OWE4MjI4NGUxMjM4N2I5MGFjZjQ=
12
12
  data.tar.gz: !binary |-
13
- M2Y2MzU3MTI5YzAyMTkwMjQwYjE4ZTU3ZjdiYWU3Y2YwMjAxYWNjNmUxMjI2
14
- ODJkM2YzZTYwYzgwZDZmMTdhNjFkZDQwNThjMGQ1OWQzODU2YzRlMDg0NDIx
15
- MTA0YjQ4NzFhMDY3NWNkMWM5MmJhNzBkYWNmZjJlYjEzNGE1MTk=
13
+ YTVkNjkwMjM4MDM0YTZhZDdjNmEzZDhlYzY2OTk4NTA3MTdmODE2YjgyNzRj
14
+ MzJjODA0MjY1MmFhNjY5NzFmMWFhMzY4YjhlZjQ4OTA1MTkwNGRlMjBiZTc4
15
+ Mzk4MjE1OGU3ODkyOTM3NDJmMWQ1ZDcxYWQ5MGY4YjI4ZTdjN2E=
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
+ ## v0.11.0
2
+ * Add -B (boot volume ID) to `knife rackspace server create` - #91
3
+
1
4
  ## v0.10.1
2
- * Support new chef-vault bootrap flags (--bootstrap-vault-file, -bootstrap-vault-json, and --bootstrap-vault-item)
5
+ * Support new chef-vault boostrap flags (--bootstrap-vault-file, -bootstrap-vault-json, and --bootstrap-vault-item)
3
6
 
4
7
  ## v0.10.0
5
8
  * KNIFE-498 knife rackspace uses direct TCP connection on port 22 to verify SSHD
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.add_dependency "knife-windows"
20
- s.add_dependency "fog", '>= 1.22'
20
+ s.add_dependency "fog", '>= 1.24'
21
21
  s.add_dependency "chef", ">= 0.10.10"
22
22
  s.require_paths = ["lib"]
23
23
 
@@ -54,6 +54,12 @@ class Chef
54
54
  :description => "The image of the server",
55
55
  :proc => Proc.new { |i| Chef::Config[:knife][:image] = i.to_s }
56
56
 
57
+ option :boot_volume_id,
58
+ :short => "-B BOOT_VOLUME_ID",
59
+ :long => "--boot-volume-id UUID",
60
+ :description => "The image CBS UUID to use as the server's boot device",
61
+ :proc => Proc.new { |i| Chef::Config[:knife][:boot_volume_id] = i.to_s }
62
+
57
63
  option :server_name,
58
64
  :short => "-S NAME",
59
65
  :long => "--server-name NAME",
@@ -365,52 +371,78 @@ class Chef
365
371
  def run
366
372
  $stdout.sync = true
367
373
 
374
+ server_create_options = {
375
+ :metadata => Chef::Config[:knife][:rackspace_metadata],
376
+ :disk_config => Chef::Config[:knife][:rackspace_disk_config],
377
+ :user_data => user_data,
378
+ :config_drive => locate_config_value(:rackspace_config_drive) || false,
379
+ :personality => files,
380
+ :key_name => Chef::Config[:knife][:rackspace_ssh_keypair],
381
+ :name => get_node_name(config[:chef_node_name] || config[:server_name]),
382
+ :networks => get_networks(Chef::Config[:knife][:rackspace_networks], Chef::Config[:knife][:rackconnect_v3_network_id]),
383
+ }
384
+
368
385
  # Maybe deprecate this option at some point
369
386
  config[:bootstrap_network] = 'private' if config[:private_network]
370
387
 
371
- unless Chef::Config[:knife][:image]
372
- ui.error("You have not provided a valid image value. Please note the short option for this value recently changed from '-i' to '-I'.")
388
+ flavor_id = locate_config_value(:flavor)
389
+ flavor = connection.flavors.get(flavor_id)
390
+ if !flavor
391
+ ui.error("Invalid Flavor ID: #{flavor_id}")
373
392
  exit 1
393
+ else
394
+ server_create_options[:flavor_id] = flavor.id
395
+ end
396
+
397
+ # This is somewhat a hack, but Rackspace's API returns '0' for flavors
398
+ # that must be backed by a CBS volume.
399
+ #
400
+ # In the case we are trying to create one of these flavors, we should
401
+ # swap out the image_id argument with the boot_image_id argument.
402
+ if flavor.disk == 0
403
+ server_create_options[:image_id] = ''
404
+ server_create_options[:boot_volume_id] = Chef::Config[:knife][:boot_volume_id]
405
+ server_create_options[:boot_image_id] = Chef::Config[:knife][:image]
406
+
407
+ if server_create_options[:boot_image_id] && server_create_options[:boot_volume_id]
408
+ ui.error('Please specify exactly one of --boot-volume-id (-B) and --image (-I)')
409
+ exit 1
410
+ end
411
+ else
412
+ server_create_options[:image_id] = Chef::Config[:knife][:image]
413
+
414
+ if !server_create_options[:image_id]
415
+ ui.error('Please specify an Image ID for the server with --image (-I)')
416
+ exit 1
417
+ end
374
418
  end
375
419
 
376
420
  if locate_config_value(:bootstrap_protocol) == 'winrm'
377
421
  load_winrm_deps
378
422
  end
379
423
 
380
- rackconnect_wait = Chef::Config[:knife][:rackconnect_wait] || config[:rackconnect_wait]
381
- rackconnect3 = Chef::Config[:knife][:rackconnect_v3_network_id] || config[:rackconnect_v3_network_id]
382
- rackspace_servicelevel_wait = Chef::Config[:knife][:rackspace_servicelevel_wait] || config[:rackspace_servicelevel_wait]
383
- node_name = get_node_name(config[:chef_node_name] || config[:server_name])
384
- networks = get_networks(Chef::Config[:knife][:rackspace_networks], rackconnect3)
385
-
386
- server = connection.servers.new(
387
- :name => node_name,
388
- :image_id => Chef::Config[:knife][:image],
389
- :flavor_id => locate_config_value(:flavor),
390
- :metadata => Chef::Config[:knife][:rackspace_metadata],
391
- :disk_config => Chef::Config[:knife][:rackspace_disk_config],
392
- :user_data => user_data,
393
- :config_drive => locate_config_value(:rackspace_config_drive) || false,
394
- :personality => files,
395
- :key_name => Chef::Config[:knife][:rackspace_ssh_keypair]
396
- )
424
+ server = connection.servers.new(server_create_options)
397
425
 
398
426
  if version_one?
399
427
  server.save
400
428
  else
401
- server.save(:networks => networks)
429
+ server.save(:networks => server_create_options[:networks])
402
430
  end
403
431
 
432
+ rackconnect_wait = Chef::Config[:knife][:rackconnect_wait] || config[:rackconnect_wait]
433
+ rackspace_servicelevel_wait = Chef::Config[:knife][:rackspace_servicelevel_wait] || config[:rackspace_servicelevel_wait]
434
+
404
435
  msg_pair("Instance ID", server.id)
405
436
  msg_pair("Host ID", server.host_id)
406
437
  msg_pair("Name", server.name)
407
438
  msg_pair("Flavor", server.flavor.name)
408
- msg_pair("Image", server.image.name)
439
+ msg_pair("Image", server.image.name) if server.image
440
+ msg_pair("Boot Image ID", server.boot_image_id) if server.boot_image_id
409
441
  msg_pair("Metadata", server.metadata.all)
410
442
  msg_pair("ConfigDrive", server.config_drive)
411
443
  msg_pair("UserData", Chef::Config[:knife][:rackspace_user_data])
412
444
  msg_pair("RackConnect Wait", rackconnect_wait ? 'yes' : 'no')
413
- msg_pair("RackConnect V3", rackconnect3 ? 'yes' : 'no')
445
+ msg_pair("RackConnect V3", Chef::Config[:knife][:rackconnect_v3_network_id] ? 'yes' : 'no')
414
446
  msg_pair("ServiceLevel Wait", rackspace_servicelevel_wait ? 'yes' : 'no')
415
447
  msg_pair("SSH Key", Chef::Config[:knife][:rackspace_ssh_keypair])
416
448
 
@@ -457,7 +489,7 @@ class Chef
457
489
  end
458
490
  end
459
491
 
460
- if networks && Chef::Config[:knife][:rackspace_networks]
492
+ if server_create_options[:networks] && Chef::Config[:knife][:rackspace_networks]
461
493
  msg_pair("Networks", Chef::Config[:knife][:rackspace_networks].sort.join(', '))
462
494
  end
463
495
 
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Rackspace
3
- VERSION = '0.10.2'
3
+ VERSION = '0.11.0'
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-rackspace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.2
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Jacob
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-07-15 00:00:00.000000000 Z
15
+ date: 2015-09-08 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: knife-windows
@@ -34,14 +34,14 @@ dependencies:
34
34
  requirements:
35
35
  - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: '1.22'
37
+ version: '1.24'
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
42
  - - ! '>='
43
43
  - !ruby/object:Gem::Version
44
- version: '1.22'
44
+ version: '1.24'
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: chef
47
47
  requirement: !ruby/object:Gem::Requirement