knife-rackspace 0.11.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Seth Chisamore (<schisamo@opscode.com>)
3
- # Copyright:: Copyright (c) 2011 Opscode, Inc.
2
+ # Author:: Seth Chisamore (<schisamo@chef.io>)
3
+ # Copyright:: Copyright (c) 2011-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/knife/rackspace_base'
19
+ require "chef/knife/rackspace_base"
20
20
 
21
21
  class Chef
22
22
  class Knife
@@ -28,8 +28,8 @@ class Chef
28
28
 
29
29
  def run
30
30
  image_list = [
31
- ui.color('ID', :bold),
32
- ui.color('Name', :bold)
31
+ ui.color("ID", :bold),
32
+ ui.color("Name", :bold),
33
33
  ]
34
34
 
35
35
  connection.images.sort_by(&:name).each do |image|
@@ -1,4 +1,4 @@
1
- require 'chef/knife/rackspace_base'
1
+ require "chef/knife/rackspace_base"
2
2
 
3
3
  class Chef
4
4
  class Knife
@@ -26,9 +26,9 @@ class Chef
26
26
  exit 1
27
27
  else
28
28
  networks_list = [
29
- ui.color('Label', :bold),
30
- ui.color('CIDR', :bold),
31
- ui.color('ID', :bold)
29
+ ui.color("Label", :bold),
30
+ ui.color("CIDR", :bold),
31
+ ui.color("ID", :bold),
32
32
  ]
33
33
  end
34
34
  options = {}
@@ -1,4 +1,4 @@
1
- require 'chef/knife/rackspace_base'
1
+ require "chef/knife/rackspace_base"
2
2
 
3
3
  class Chef
4
4
  class Knife
@@ -15,7 +15,7 @@ class Chef
15
15
  else
16
16
  @name_args.each do |net_id|
17
17
  network = connection.networks.get(net_id)
18
- unless(network)
18
+ unless network
19
19
  ui.error "Could not locate network: #{net_id}"
20
20
  exit 1
21
21
  end
@@ -1,4 +1,4 @@
1
- require 'chef/knife/rackspace_base'
1
+ require "chef/knife/rackspace_base"
2
2
 
3
3
  class Chef
4
4
  class Knife
@@ -14,9 +14,9 @@ class Chef
14
14
  exit 1
15
15
  else
16
16
  networks_list = [
17
- ui.color('Label', :bold),
18
- ui.color('CIDR', :bold),
19
- ui.color('ID', :bold)
17
+ ui.color("Label", :bold),
18
+ ui.color("CIDR", :bold),
19
+ ui.color("ID", :bold),
20
20
  ]
21
21
  end
22
22
  connection.networks.sort_by(&:id).each do |network|
@@ -1,7 +1,7 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Author:: Matt Ray (<matt@opscode.com>)
4
- # Copyright:: Copyright (c) 2009-2012 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Author:: Matt Ray (<matt@chef.io>)
4
+ # Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,9 +17,9 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require 'chef/knife/rackspace_base'
21
- require 'chef/knife/winrm_base'
22
- require 'chef/knife'
20
+ require "chef/knife/rackspace_base"
21
+ require "chef/knife/winrm_base"
22
+ require "chef/knife"
23
23
 
24
24
  class Chef
25
25
  class Knife
@@ -28,12 +28,11 @@ class Chef
28
28
  include Knife::RackspaceBase
29
29
  include Chef::Knife::WinrmBase
30
30
 
31
-
32
31
  deps do
33
- require 'fog'
34
- require 'readline'
35
- require 'chef/json_compat'
36
- require 'chef/knife/bootstrap'
32
+ require "fog/rackspace"
33
+ require "readline"
34
+ require "chef/json_compat"
35
+ require "chef/knife/bootstrap"
37
36
  Chef::Knife::Bootstrap.load_deps
38
37
  end
39
38
 
@@ -79,7 +78,7 @@ class Chef
79
78
  option :bootstrap_network,
80
79
  :long => "--bootstrap-network LABEL",
81
80
  :description => "Use IP address on this network for bootstrap",
82
- :default => 'public'
81
+ :default => "public"
83
82
 
84
83
  option :private_network,
85
84
  :long => "--private-network",
@@ -160,8 +159,8 @@ class Chef
160
159
  :default => false
161
160
 
162
161
  option :rackconnect_v3_network_id,
163
- :long => '--rackconnect-v3-network-id ID',
164
- :description => 'Rackconnect V3 ONLY: Link a new server to an existing network',
162
+ :long => "--rackconnect-v3-network-id ID",
163
+ :description => "Rackconnect V3 ONLY: Link a new server to an existing network",
165
164
  :proc => lambda { |o| Chef::Config[:knife][:rackconnect_v3_network_id] = o },
166
165
  :default => nil
167
166
 
@@ -214,7 +213,7 @@ class Chef
214
213
  :default => true
215
214
 
216
215
  option :network,
217
- :long => '--network [LABEL_OR_ID]',
216
+ :long => "--network [LABEL_OR_ID]",
218
217
  :description => "Add private network. Use multiple --network options to specify multiple networks.",
219
218
  :proc => Proc.new{ |name|
220
219
  Chef::Config[:knife][:rackspace_networks] ||= []
@@ -230,7 +229,7 @@ class Chef
230
229
  :long => "--server-create-timeout timeout",
231
230
  :description => "How long to wait until the server is ready; default is 1200 seconds",
232
231
  :default => 1200,
233
- :proc => Proc.new { |v| Chef::Config[:knife][:server_create_timeout] = v}
232
+ :proc => Proc.new { |v| Chef::Config[:knife][:server_create_timeout] = v }
234
233
 
235
234
  option :bootstrap_proxy,
236
235
  :long => "--bootstrap-proxy PROXY_URL",
@@ -265,15 +264,15 @@ class Chef
265
264
  :proc => Proc.new { |sf| Chef::Config[:knife][:secret_file] = sf }
266
265
 
267
266
  option :bootstrap_vault_file,
268
- :long => '--bootstrap-vault-file VAULT_FILE',
269
- :description => 'A JSON file with a list of vault(s) and item(s) to be updated'
267
+ :long => "--bootstrap-vault-file VAULT_FILE",
268
+ :description => "A JSON file with a list of vault(s) and item(s) to be updated"
270
269
 
271
270
  option :bootstrap_vault_json,
272
- :long => '--bootstrap-vault-json VAULT_JSON',
273
- :description => 'A JSON string with the vault(s) and item(s) to be updated'
271
+ :long => "--bootstrap-vault-json VAULT_JSON",
272
+ :description => "A JSON string with the vault(s) and item(s) to be updated"
274
273
 
275
274
  option :bootstrap_vault_item,
276
- :long => '--bootstrap-vault-item VAULT_ITEM',
275
+ :long => "--bootstrap-vault-item VAULT_ITEM",
277
276
  :description => 'A single vault and item to update as "vault:item"',
278
277
  :proc => Proc.new { |i|
279
278
  (vault, item) = i.split(/:/)
@@ -284,11 +283,11 @@ class Chef
284
283
  }
285
284
 
286
285
  def load_winrm_deps
287
- require 'winrm'
288
- require 'em-winrm'
289
- require 'chef/knife/bootstrap_windows_winrm'
290
- require 'chef/knife/core/windows_bootstrap_context'
291
- require 'chef/knife/winrm'
286
+ require "winrm"
287
+ require "em-winrm"
288
+ require "chef/knife/bootstrap_windows_winrm"
289
+ require "chef/knife/core/windows_bootstrap_context"
290
+ require "chef/knife/winrm"
292
291
  end
293
292
 
294
293
  def tcp_test_ssh(server, bootstrap_ip)
@@ -298,7 +297,7 @@ class Chef
298
297
  count = 0
299
298
 
300
299
  begin
301
- Net::SSH.start(bootstrap_ip, 'root', :password => server.password ) do |ssh|
300
+ Net::SSH.start(bootstrap_ip, "root", :password => server.password ) do |ssh|
302
301
  Chef::Log.debug("sshd accepting connections on #{bootstrap_ip}")
303
302
  break
304
303
  end
@@ -306,7 +305,7 @@ class Chef
306
305
  count += 1
307
306
 
308
307
  if count <= limit
309
- print '.'
308
+ print "."
310
309
  sleep locate_config_value(:retry_ssh_every).to_i
311
310
  tcp_test_ssh(server, bootstrap_ip)
312
311
  else
@@ -317,7 +316,7 @@ class Chef
317
316
  end
318
317
 
319
318
  def parse_file_argument(arg)
320
- dest, src = arg.split('=')
319
+ dest, src = arg.split("=")
321
320
  unless dest && src
322
321
  ui.error "Unable to process file arguments #{arg}. The --file option requires both the destination on the remote machine as well as the local source be supplied using the form DESTINATION-PATH=SOURCE-PATH"
323
322
  exit 1
@@ -337,7 +336,7 @@ class Chef
337
336
  end
338
337
 
339
338
  def files
340
- return {} unless Chef::Config[:knife][:file]
339
+ return {} unless Chef::Config[:knife][:file]
341
340
 
342
341
  files = []
343
342
  Chef::Config[:knife][:file].each do |arg|
@@ -345,14 +344,12 @@ class Chef
345
344
  Chef::Log.debug("Inject file #{src} into #{dest}")
346
345
  files << {
347
346
  :path => dest,
348
- :contents => encode_file(src)
347
+ :contents => encode_file(src),
349
348
  }
350
349
  end
351
350
  files
352
351
  end
353
352
 
354
-
355
-
356
353
  def tcp_test_winrm(hostname, port)
357
354
  TCPSocket.new(hostname, port)
358
355
  return true
@@ -389,7 +386,7 @@ class Chef
389
386
  }
390
387
 
391
388
  # Maybe deprecate this option at some point
392
- config[:bootstrap_network] = 'private' if locate_config_value(:private_network)
389
+ config[:bootstrap_network] = "private" if locate_config_value(:private_network)
393
390
 
394
391
  flavor_id = locate_config_value(:flavor)
395
392
  flavor = connection.flavors.get(flavor_id)
@@ -406,25 +403,25 @@ class Chef
406
403
  # In the case we are trying to create one of these flavors, we should
407
404
  # swap out the image_id argument with the boot_image_id argument.
408
405
  if flavor.disk == 0
409
- server_create_options[:image_id] = ''
406
+ server_create_options[:image_id] = ""
410
407
  server_create_options[:boot_volume_id] = locate_config_value(:boot_volume_id)
411
408
  server_create_options[:boot_image_id] = locate_config_value(:image)
412
409
  server_create_options[:boot_volume_size] = locate_config_value(:boot_volume_size)
413
410
 
414
411
  if server_create_options[:boot_image_id] && server_create_options[:boot_volume_id]
415
- ui.error('Please specify either --boot-volume-id (-B) or --image (-I)')
412
+ ui.error("Please specify either --boot-volume-id (-B) or --image (-I)")
416
413
  exit 1
417
414
  end
418
415
  else
419
416
  server_create_options[:image_id] = locate_config_value(:image)
420
417
 
421
418
  if !server_create_options[:image_id]
422
- ui.error('Please specify an Image ID for the server with --image (-I)')
419
+ ui.error("Please specify an Image ID for the server with --image (-I)")
423
420
  exit 1
424
421
  end
425
422
  end
426
423
 
427
- if locate_config_value(:bootstrap_protocol) == 'winrm'
424
+ if locate_config_value(:bootstrap_protocol) == "winrm"
428
425
  load_winrm_deps
429
426
  end
430
427
 
@@ -448,36 +445,36 @@ class Chef
448
445
  msg_pair("Metadata", server.metadata.all)
449
446
  msg_pair("ConfigDrive", server.config_drive)
450
447
  msg_pair("UserData", locate_config_value(:rackspace_user_data))
451
- msg_pair("RackConnect Wait", rackconnect_wait ? 'yes' : 'no')
452
- msg_pair("RackConnect V3", locate_config_value(:rackconnect_v3_network_id) ? 'yes' : 'no')
453
- msg_pair("ServiceLevel Wait", rackspace_servicelevel_wait ? 'yes' : 'no')
448
+ msg_pair("RackConnect Wait", rackconnect_wait ? "yes" : "no")
449
+ msg_pair("RackConnect V3", locate_config_value(:rackconnect_v3_network_id) ? "yes" : "no")
450
+ msg_pair("ServiceLevel Wait", rackspace_servicelevel_wait ? "yes" : "no")
454
451
  msg_pair("SSH Key", locate_config_value(:rackspace_ssh_keypair))
455
452
 
456
453
  # wait for it to be ready to do stuff
457
454
  begin
458
- server.wait_for(Integer(locate_config_value(:server_create_timeout))) {
455
+ server.wait_for(Integer(locate_config_value(:server_create_timeout))) do
459
456
  print ".";
460
457
  Chef::Log.debug("#{progress}%")
461
458
 
462
- if rackconnect_wait and rackspace_servicelevel_wait
459
+ if rackconnect_wait && rackspace_servicelevel_wait
463
460
  Chef::Log.debug("rackconnect_automation_status: #{metadata.all['rackconnect_automation_status']}")
464
461
  Chef::Log.debug("rax_service_level_automation: #{metadata.all['rax_service_level_automation']}")
465
- ready? and metadata.all['rackconnect_automation_status'] == 'DEPLOYED' and metadata.all['rax_service_level_automation'] == 'Complete'
462
+ ready? && metadata.all["rackconnect_automation_status"] == "DEPLOYED" && metadata.all["rax_service_level_automation"] == "Complete"
466
463
  elsif rackconnect_wait
467
464
  Chef::Log.debug("rackconnect_automation_status: #{metadata.all['rackconnect_automation_status']}")
468
- ready? and metadata.all['rackconnect_automation_status'] == 'DEPLOYED'
465
+ ready? && metadata.all["rackconnect_automation_status"] == "DEPLOYED"
469
466
  elsif rackspace_servicelevel_wait
470
467
  Chef::Log.debug("rax_service_level_automation: #{metadata.all['rax_service_level_automation']}")
471
- ready? and metadata.all['rax_service_level_automation'] == 'Complete'
468
+ ready? && metadata.all["rax_service_level_automation"] == "Complete"
472
469
  else
473
470
  ready?
474
471
  end
475
- }
472
+ end
476
473
  rescue Fog::Errors::TimeoutError
477
- ui.error('Timeout waiting for the server to be created')
478
- msg_pair('Progress', "#{server.progress}%")
479
- msg_pair('rackconnect_automation_status', server.metadata.all['rackconnect_automation_status'])
480
- msg_pair('rax_service_level_automation', server.metadata.all['rax_service_level_automation'])
474
+ ui.error("Timeout waiting for the server to be created")
475
+ msg_pair("Progress", "#{server.progress}%")
476
+ msg_pair("rackconnect_automation_status", server.metadata.all["rackconnect_automation_status"])
477
+ msg_pair("rax_service_level_automation", server.metadata.all["rax_service_level_automation"])
481
478
  Chef::Application.fatal! 'Server didn\'t finish on time'
482
479
  end
483
480
 
@@ -497,12 +494,12 @@ class Chef
497
494
  end
498
495
 
499
496
  if server_create_options[:networks] && locate_config_value(:rackspace_networks)
500
- msg_pair("Networks", locate_config_value(:rackspace_networks).sort.join(', '))
497
+ msg_pair("Networks", locate_config_value(:rackspace_networks).sort.join(", "))
501
498
  end
502
499
 
503
500
  msg_pair("Public DNS Name", public_dns_name(server))
504
- msg_pair("Public IP Address", ip_address(server, 'public'))
505
- msg_pair("Private IP Address", ip_address(server, 'private'))
501
+ msg_pair("Public IP Address", ip_address(server, "public"))
502
+ msg_pair("Private IP Address", ip_address(server, "private"))
506
503
  msg_pair("Password", server.password)
507
504
  msg_pair("Metadata", server.metadata.all)
508
505
 
@@ -514,7 +511,7 @@ class Chef
514
511
  exit 1
515
512
  end
516
513
 
517
- if locate_config_value(:bootstrap_protocol) == 'winrm'
514
+ if locate_config_value(:bootstrap_protocol) == "winrm"
518
515
  print "\n#{ui.color("Waiting for winrm", :magenta)}"
519
516
  print(".") until tcp_test_winrm(bootstrap_ip_address, locate_config_value(:winrm_port))
520
517
  bootstrap_for_windows_node(server, bootstrap_ip_address).run
@@ -533,11 +530,11 @@ class Chef
533
530
  msg_pair("Boot Image ID", server.boot_image_id) if server.boot_image_id
534
531
  msg_pair("Metadata", server.metadata)
535
532
  msg_pair("Public DNS Name", public_dns_name(server))
536
- msg_pair("Public IP Address", ip_address(server, 'public'))
537
- msg_pair("Private IP Address", ip_address(server, 'private'))
533
+ msg_pair("Public IP Address", ip_address(server, "public"))
534
+ msg_pair("Private IP Address", ip_address(server, "private"))
538
535
  msg_pair("Password", server.password)
539
- msg_pair("Environment", config[:environment] || '_default')
540
- msg_pair("Run List", config[:run_list].join(', '))
536
+ msg_pair("Environment", config[:environment] || "_default")
537
+ msg_pair("Run List", config[:run_list].join(", "))
541
538
  end
542
539
 
543
540
  def setup_rackconnect_network!(server)
@@ -549,8 +546,8 @@ class Chef
549
546
  Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
550
547
  begin
551
548
  req = Net::HTTP::Post.new(uri.request_uri)
552
- req['X-Auth-Token'] = auth_token
553
- req['Content-Type'] = 'application/json'
549
+ req["X-Auth-Token"] = auth_token
550
+ req["Content-Type"] = "application/json"
554
551
  req.body = JSON.dump("cloud_server" => { "id" => server.id })
555
552
  http.use_ssl = true
556
553
  http.request req
@@ -586,8 +583,8 @@ class Chef
586
583
  bootstrap.config[:bootstrap_vault_json] = locate_config_value(:bootstrap_vault_json) if locate_config_value(:bootstrap_vault_json)
587
584
  bootstrap.config[:bootstrap_vault_item] = locate_config_value(:bootstrap_vault_item) if locate_config_value(:bootstrap_vault_item)
588
585
  # bootstrap will run as root...sudo (by default) also messes up Ohai on CentOS boxes
589
- bootstrap.config[:use_sudo] = true unless locate_config_value(:ssh_user) == 'root'
590
- bootstrap.config[:distro] = locate_config_value(:distro) || 'chef-full'
586
+ bootstrap.config[:use_sudo] = true unless locate_config_value(:ssh_user) == "root"
587
+ bootstrap.config[:distro] = locate_config_value(:distro) || "chef-full"
591
588
  bootstrap_common_params(bootstrap, server)
592
589
  end
593
590
 
@@ -608,7 +605,7 @@ class Chef
608
605
  # bootstrap.config[:encrypted_data_bag_secret] = config[:encrypted_data_bag_secret]
609
606
  # bootstrap.config[:encrypted_data_bag_secret_file] = config[:encrypted_data_bag_secret_file]
610
607
  bootstrap.config[:secret] = locate_config_value(:secret)
611
- bootstrap.config[:secret_file] = locate_config_value(:secret_file) || ""
608
+ bootstrap.config[:secret_file] = locate_config_value(:secret_file) || ""
612
609
 
613
610
  Chef::Config[:knife][:hints] ||= {}
614
611
  Chef::Config[:knife][:hints]["rackspace"] ||= {}
@@ -618,11 +615,11 @@ class Chef
618
615
  def bootstrap_for_windows_node(server, bootstrap_ip_address)
619
616
  bootstrap = Chef::Knife::BootstrapWindowsWinrm.new
620
617
  bootstrap.name_args = [bootstrap_ip_address]
621
- bootstrap.config[:winrm_user] = locate_config_value(:winrm_user) || 'Administrator'
618
+ bootstrap.config[:winrm_user] = locate_config_value(:winrm_user) || "Administrator"
622
619
  bootstrap.config[:winrm_password] = locate_config_value(:winrm_password) || server.password
623
620
  bootstrap.config[:winrm_transport] = locate_config_value(:winrm_transport)
624
621
  bootstrap.config[:winrm_port] = locate_config_value(:winrm_port)
625
- bootstrap.config[:distro] = locate_config_value(:distro) || 'windows-chef-client-msi'
622
+ bootstrap.config[:distro] = locate_config_value(:distro) || "windows-chef-client-msi"
626
623
  bootstrap_common_params(bootstrap, server)
627
624
  end
628
625
 
@@ -631,29 +628,29 @@ class Chef
631
628
  def get_node_name(chef_node_name)
632
629
  return chef_node_name unless chef_node_name.nil?
633
630
  #lazy uuids
634
- chef_node_name = "rs-"+rand.to_s.split('.')[1] unless version_one?
631
+ chef_node_name = "rs-" + rand.to_s.split(".")[1] unless version_one?
635
632
  end
636
633
 
637
- def get_networks(names, rackconnect3=false)
634
+ def get_networks(names, rackconnect3 = false)
638
635
  names = Array(names)
639
636
 
640
- if(locate_config_value(:rackspace_version) == 'v2')
637
+ if locate_config_value(:rackspace_version) == "v2"
641
638
  nets = if rackconnect3
642
- [locate_config_value(:rackconnect_v3_network_id)]
643
- elsif locate_config_value(:default_networks)
644
- [
645
- '00000000-0000-0000-0000-000000000000',
646
- '11111111-1111-1111-1111-111111111111'
647
- ]
648
- else
649
- []
650
- end
639
+ [locate_config_value(:rackconnect_v3_network_id)]
640
+ elsif locate_config_value(:default_networks)
641
+ [
642
+ "00000000-0000-0000-0000-000000000000",
643
+ "11111111-1111-1111-1111-111111111111",
644
+ ]
645
+ else
646
+ []
647
+ end
651
648
 
652
649
  available_networks = connection.networks.all
653
650
 
654
651
  names.each do |name|
655
- net = available_networks.detect{|n| n.label == name || n.id == name}
656
- if(net)
652
+ net = available_networks.detect { |n| n.label == name || n.id == name }
653
+ if net
657
654
  nets << net.id
658
655
  else
659
656
  ui.error("Failed to locate network: #{name}")
@@ -661,7 +658,7 @@ class Chef
661
658
  end
662
659
  end
663
660
  nets
664
- elsif(names && !names.empty?)
661
+ elsif names && !names.empty?
665
662
  ui.error("Custom networks are only available in v2 API")
666
663
  exit 1
667
664
  end
@@ -1,7 +1,7 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Author:: Matt Ray (<matt@opscode.com>)
4
- # Copyright:: Copyright (c) 2009-2012 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Author:: Matt Ray (<matt@chef.io>)
4
+ # Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
5
5
  # License:: Apache License, Version 2.0
6
6
  #
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,11 +17,11 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require 'chef/knife/rackspace_base'
20
+ require "chef/knife/rackspace_base"
21
21
 
22
22
  # These two are needed for the '--purge' deletion case
23
- require 'chef/node'
24
- require 'chef/api_client'
23
+ require "chef/node"
24
+ require "chef/api_client"
25
25
 
26
26
  class Chef
27
27
  class Knife
@@ -68,8 +68,8 @@ class Chef
68
68
  msg_pair("Flavor", server.flavor.name)
69
69
  msg_pair("Image", server.image.name) if server.image
70
70
  msg_pair("Boot Image ID", server.boot_image_id) if server.boot_image_id
71
- msg_pair("Public IP Address", ip_address(server, 'public'))
72
- msg_pair("Private IP Address", ip_address(server, 'private'))
71
+ msg_pair("Public IP Address", ip_address(server, "public"))
72
+ msg_pair("Private IP Address", ip_address(server, "private"))
73
73
 
74
74
  puts "\n"
75
75
  confirm("Do you really want to delete this server")
@@ -1,6 +1,6 @@
1
1
  #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2009 Opscode, Inc.
2
+ # Author:: Adam Jacob (<adam@chef.io>)
3
+ # Copyright:: Copyright (c) 2009-2016 Chef Software, Inc.
4
4
  # License:: Apache License, Version 2.0
5
5
  #
6
6
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,7 +16,7 @@
16
16
  # limitations under the License.
17
17
  #
18
18
 
19
- require 'chef/knife/rackspace_base'
19
+ require "chef/knife/rackspace_base"
20
20
 
21
21
  class Chef
22
22
  class Knife
@@ -30,34 +30,38 @@ class Chef
30
30
  $stdout.sync = true
31
31
 
32
32
  server_list = [
33
- ui.color('Instance ID', :bold),
34
- ui.color('Name', :bold),
35
- ui.color('Public IP', :bold),
36
- ui.color('Private IP', :bold),
37
- ui.color('Flavor', :bold),
38
- ui.color('Image', :bold),
39
- ui.color('State', :bold)
33
+ ui.color("Instance ID", :bold),
34
+ ui.color("Name", :bold),
35
+ ui.color("Flavor", :bold),
36
+ ui.color("Image", :bold),
37
+ ui.color("State", :bold),
40
38
  ]
39
+ if version_one?
40
+ network_list = %w{public private}
41
+ else
42
+ network_list = connection.images.sort_by(&:name).collect { |t| t.label }
43
+ end
44
+ server_list.insert(2, network_list.collect { |n| ui.color("#{n.capitalize} IP", :bold) }).flatten!
45
+ num_columns_across = server_list.length
41
46
  connection.servers.all.each do |server|
42
47
  server = connection.servers.get(server.id)
43
48
  server_list << server.id.to_s
44
49
  server_list << server.name
45
- server_list << ip_address(server, 'public')
46
- server_list << ip_address(server, 'private')
50
+ server_list += network_list.collect { |n| ip_address(server, n) }
47
51
  server_list << (server.flavor_id == nil ? "" : server.flavor_id.to_s)
48
52
  server_list << (server.image_id == nil ? "" : server.image_id.to_s)
49
53
  server_list << begin
50
54
  case server.state.downcase
51
- when 'deleted','suspended'
55
+ when "deleted", "suspended"
52
56
  ui.color(server.state.downcase, :red)
53
- when 'build','unknown'
57
+ when "build", "unknown"
54
58
  ui.color(server.state.downcase, :yellow)
55
59
  else
56
60
  ui.color(server.state.downcase, :green)
57
61
  end
58
62
  end
59
63
  end
60
- puts ui.list(server_list, :uneven_columns_across, 7)
64
+ puts ui.list(server_list, :uneven_columns_across, num_columns_across)
61
65
  end
62
66
  end
63
67
  end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Rackspace
3
- VERSION = '0.11.1'
4
- MAJOR, MINOR, TINY = VERSION.split('.')
3
+ VERSION = "1.0.0"
4
+ MAJOR, MINOR, TINY = VERSION.split(".")
5
5
  end
6
6
  end