chef 0.9.12 → 0.9.14.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. data/distro/arch/etc/conf.d/chef-client.conf +5 -0
  2. data/distro/arch/etc/conf.d/chef-server-webui.conf +10 -0
  3. data/distro/arch/etc/conf.d/chef-server.conf +10 -0
  4. data/distro/arch/etc/conf.d/chef-solr-indexer.conf +8 -0
  5. data/distro/arch/etc/conf.d/chef-solr.conf +8 -0
  6. data/distro/arch/etc/rc.d/chef-client +76 -0
  7. data/distro/arch/etc/rc.d/chef-server +82 -0
  8. data/distro/arch/etc/rc.d/chef-server-webui +82 -0
  9. data/distro/arch/etc/rc.d/chef-solr +82 -0
  10. data/distro/arch/etc/rc.d/chef-solr-indexer +82 -0
  11. data/distro/common/markdown/knife.mkd +34 -1
  12. data/distro/debian/etc/default/chef-solr +1 -0
  13. data/distro/debian/etc/init.d/chef-client +1 -1
  14. data/distro/debian/etc/init.d/chef-solr +39 -40
  15. data/distro/debian/etc/init.d/chef-solr-indexer +1 -1
  16. data/distro/redhat/etc/init.d/chef-client +1 -1
  17. data/lib/chef.rb +1 -0
  18. data/lib/chef/api_client.rb +1 -1
  19. data/lib/chef/application/agent.rb +1 -1
  20. data/lib/chef/application/client.rb +1 -1
  21. data/lib/chef/application/solo.rb +1 -1
  22. data/lib/chef/cookbook/metadata.rb +2 -2
  23. data/lib/chef/cookbook/syntax_check.rb +1 -1
  24. data/lib/chef/cookbook_version.rb +5 -1
  25. data/lib/chef/couchdb.rb +1 -1
  26. data/lib/chef/data_bag.rb +1 -1
  27. data/lib/chef/data_bag_item.rb +35 -9
  28. data/lib/chef/exceptions.rb +2 -0
  29. data/lib/chef/file_cache.rb +1 -1
  30. data/lib/chef/handler/json_file.rb +1 -1
  31. data/lib/chef/index_queue/amqp_client.rb +2 -2
  32. data/lib/chef/index_queue/consumer.rb +2 -2
  33. data/lib/chef/json.rb +52 -0
  34. data/lib/chef/knife.rb +6 -6
  35. data/lib/chef/knife/bluebox_images_list.rb +54 -0
  36. data/lib/chef/knife/bluebox_server_create.rb +157 -0
  37. data/lib/chef/knife/bluebox_server_delete.rb +63 -0
  38. data/lib/chef/knife/bluebox_server_list.rb +59 -0
  39. data/lib/chef/knife/bootstrap.rb +3 -1
  40. data/lib/chef/knife/bootstrap/archlinux-gems.erb +2 -2
  41. data/lib/chef/knife/bootstrap/centos5-gems.erb +2 -2
  42. data/lib/chef/knife/bootstrap/fedora13-gems.erb +1 -1
  43. data/lib/chef/knife/client_bulk_delete.rb +1 -1
  44. data/lib/chef/knife/client_create.rb +1 -1
  45. data/lib/chef/knife/client_delete.rb +1 -1
  46. data/lib/chef/knife/client_edit.rb +1 -1
  47. data/lib/chef/knife/client_list.rb +1 -1
  48. data/lib/chef/knife/client_reregister.rb +1 -1
  49. data/lib/chef/knife/client_show.rb +1 -1
  50. data/lib/chef/knife/cookbook_create.rb +1 -1
  51. data/lib/chef/knife/cookbook_list.rb +1 -1
  52. data/lib/chef/knife/cookbook_metadata.rb +1 -1
  53. data/lib/chef/knife/cookbook_show.rb +10 -18
  54. data/lib/chef/knife/cookbook_site_share.rb +1 -1
  55. data/lib/chef/knife/cookbook_site_vendor.rb +17 -11
  56. data/lib/chef/knife/ec2_instance_data.rb +1 -1
  57. data/lib/chef/knife/ec2_server_create.rb +8 -6
  58. data/lib/chef/knife/ec2_server_delete.rb +5 -8
  59. data/lib/chef/knife/ec2_server_list.rb +5 -4
  60. data/lib/chef/knife/exec.rb +1 -1
  61. data/lib/chef/knife/node_bulk_delete.rb +1 -1
  62. data/lib/chef/knife/node_create.rb +1 -1
  63. data/lib/chef/knife/node_delete.rb +1 -1
  64. data/lib/chef/knife/node_edit.rb +1 -1
  65. data/lib/chef/knife/node_from_file.rb +2 -2
  66. data/lib/chef/knife/node_list.rb +1 -1
  67. data/lib/chef/knife/node_run_list_add.rb +1 -1
  68. data/lib/chef/knife/node_run_list_remove.rb +1 -1
  69. data/lib/chef/knife/node_show.rb +1 -1
  70. data/lib/chef/knife/rackspace_server_create.rb +98 -70
  71. data/lib/chef/knife/rackspace_server_delete.rb +2 -2
  72. data/lib/chef/knife/rackspace_server_list.rb +2 -2
  73. data/lib/chef/knife/role_bulk_delete.rb +1 -1
  74. data/lib/chef/knife/role_create.rb +1 -1
  75. data/lib/chef/knife/role_delete.rb +1 -1
  76. data/lib/chef/knife/role_edit.rb +1 -1
  77. data/lib/chef/knife/role_from_file.rb +2 -2
  78. data/lib/chef/knife/role_list.rb +1 -1
  79. data/lib/chef/knife/role_show.rb +1 -1
  80. data/lib/chef/knife/slicehost_images_list.rb +2 -2
  81. data/lib/chef/knife/slicehost_server_create.rb +2 -2
  82. data/lib/chef/knife/slicehost_server_delete.rb +2 -2
  83. data/lib/chef/knife/slicehost_server_list.rb +2 -2
  84. data/lib/chef/knife/ssh.rb +36 -12
  85. data/lib/chef/knife/status.rb +1 -1
  86. data/lib/chef/knife/terremark_server_create.rb +1 -1
  87. data/lib/chef/knife/terremark_server_delete.rb +1 -1
  88. data/lib/chef/knife/terremark_server_list.rb +1 -1
  89. data/lib/chef/log.rb +31 -4
  90. data/lib/chef/mixin/command.rb +1 -1
  91. data/lib/chef/mixin/create_path.rb +1 -1
  92. data/lib/chef/mixin/recipe_definition_dsl_core.rb +1 -1
  93. data/lib/chef/monkey_patches/numeric.rb +7 -0
  94. data/lib/chef/node.rb +6 -8
  95. data/lib/chef/node/attribute.rb +24 -2
  96. data/lib/chef/openid_registration.rb +1 -1
  97. data/lib/chef/platform.rb +11 -0
  98. data/lib/chef/provider/breakpoint.rb +1 -1
  99. data/lib/chef/provider/cookbook_file.rb +1 -1
  100. data/lib/chef/provider/deploy/revision.rb +1 -1
  101. data/lib/chef/provider/deploy/timestamped.rb +1 -1
  102. data/lib/chef/provider/erl_call.rb +14 -2
  103. data/lib/chef/provider/git.rb +79 -55
  104. data/lib/chef/provider/group/pw.rb +1 -1
  105. data/lib/chef/provider/package/easy_install.rb +35 -13
  106. data/lib/chef/provider/service/debian.rb +65 -40
  107. data/lib/chef/provider/service/insserv.rb +52 -0
  108. data/lib/chef/provider/service/windows.rb +74 -57
  109. data/lib/chef/provider/subversion.rb +45 -10
  110. data/lib/chef/provider/user/pw.rb +1 -1
  111. data/lib/chef/providers.rb +1 -0
  112. data/lib/chef/resource/deploy_revision.rb +1 -1
  113. data/lib/chef/resource/easy_install_package.rb +16 -0
  114. data/lib/chef/resource/file.rb +8 -1
  115. data/lib/chef/resource_collection/stepable_iterator.rb +1 -1
  116. data/lib/chef/rest.rb +7 -7
  117. data/lib/chef/role.rb +2 -2
  118. data/lib/chef/run_status.rb +1 -1
  119. data/lib/chef/shef.rb +2 -2
  120. data/lib/chef/shef/ext.rb +2 -2
  121. data/lib/chef/shef/model_wrapper.rb +1 -1
  122. data/lib/chef/shef/shef_rest.rb +1 -1
  123. data/lib/chef/shef/shef_session.rb +13 -5
  124. data/lib/chef/tasks/chef_repo.rake +1 -1
  125. data/lib/chef/version.rb +1 -1
  126. data/lib/chef/webui_user.rb +1 -1
  127. metadata +329 -290
@@ -0,0 +1,52 @@
1
+ #
2
+ # Author:: Tim Hinderliter (<tim@opscode.com>)
3
+ # Copyright:: Copyright (c) 2010 Opscode, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ # Wrapper class for interacting with JSON.
19
+
20
+ require 'json'
21
+
22
+ class Chef
23
+ class JSON
24
+ JSON_MAX_NESTING = 1000
25
+
26
+ class <<self
27
+ # See PL-538. Increase the max nesting for JSON, which defaults to 19,
28
+ # and isn't enough for some deep node (for example) structures.
29
+ def opts_add_max_nesting(opts)
30
+ if opts.nil? || !opts.has_key?(:max_nesting)
31
+ opts = opts.nil? ? Hash.new : opts.clone
32
+ opts[:max_nesting] = JSON_MAX_NESTING
33
+ end
34
+ opts
35
+ end
36
+
37
+ # Just call the JSON gem's parse method with a modified :max_nesting field
38
+ def from_json(source, opts = {})
39
+ ::JSON.parse(source, opts_add_max_nesting(opts))
40
+ end
41
+
42
+ def to_json(obj, opts = nil)
43
+ #::JSON.generate(obj, opts_add_max_nesting(opts))
44
+ obj.to_json(opts_add_max_nesting(opts))
45
+ end
46
+
47
+ def to_json_pretty(obj, opts = nil)
48
+ ::JSON.pretty_generate(obj, opts_add_max_nesting(opts))
49
+ end
50
+ end
51
+ end
52
+ end
@@ -284,7 +284,7 @@ class Chef
284
284
  def output(data)
285
285
  case config[:format]
286
286
  when "json", nil
287
- stdout.puts JSON.pretty_generate(data)
287
+ stdout.puts Chef::JSON.to_json_pretty(data)
288
288
  when "yaml"
289
289
  require 'yaml'
290
290
  stdout.puts YAML::dump(data)
@@ -330,7 +330,7 @@ class Chef
330
330
  end
331
331
 
332
332
  def edit_data(data, parse_output=true)
333
- output = JSON.pretty_generate(data)
333
+ output = Chef::JSON.to_json_pretty(data)
334
334
 
335
335
  if (!config[:no_editor])
336
336
  filename = "knife-edit-"
@@ -348,7 +348,7 @@ class Chef
348
348
  File.unlink(filename)
349
349
  end
350
350
 
351
- parse_output ? JSON.parse(output) : output
351
+ parse_output ? Chef::JSON.from_json(output) : output
352
352
  end
353
353
 
354
354
  def confirm(question, append_instructions=true)
@@ -399,7 +399,7 @@ class Chef
399
399
 
400
400
  case from_file
401
401
  when /\.(js|json)$/
402
- JSON.parse(IO.read(filename))
402
+ Chef::JSON.from_json(IO.read(filename))
403
403
  when /\.rb$/
404
404
  r = klass.new
405
405
  r.from_file(filename)
@@ -429,8 +429,8 @@ class Chef
429
429
  # We wouldn't have to do these shenanigans if all the editable objects
430
430
  # implemented to_hash, or if to_json against a hash returned a string
431
431
  # with stable key order.
432
- object_parsed_again = JSON.parse(object.to_json, :create_additions => false)
433
- output_parsed_again = JSON.parse(output.to_json, :create_additions => false)
432
+ object_parsed_again = Chef::JSON.from_json(Chef::JSON.to_json(object), :create_additions => false)
433
+ output_parsed_again = Chef::JSON.from_json(Chef::JSON.to_json(output), :create_additions => false)
434
434
  if object_parsed_again != output_parsed_again
435
435
  output.save
436
436
  self.msg("Saved #{output}")
@@ -0,0 +1,54 @@
1
+ #
2
+ # Author:: Jesse Proudman (<jesse.proudman@blueboxgrp.com>)
3
+ # Copyright:: Copyright (c) 2010 Blue Box Group
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/knife'
20
+ require 'chef/json'
21
+
22
+ class Chef
23
+ class Knife
24
+ class BlueboxImagesList < Knife
25
+
26
+ banner "knife bluebox images list"
27
+
28
+ def highline
29
+ @highline ||= HighLine.new
30
+ end
31
+
32
+ def run
33
+ require 'fog'
34
+ require 'highline'
35
+
36
+ bluebox = Fog::Bluebox::Compute.new(
37
+ :bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
38
+ :bluebox_api_key => Chef::Config[:knife][:bluebox_api_key]
39
+ )
40
+
41
+ images = bluebox.images.inject({}) { |h,i| h[i.id] = i.description; h }
42
+
43
+ image_list = [ highline.color('ID', :bold), highline.color('Name', :bold) ]
44
+
45
+ bluebox.images.each do |server|
46
+ image_list << server.id.to_s
47
+ image_list << server.description
48
+ end
49
+ puts highline.list(image_list, :columns_across, 2)
50
+
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,157 @@
1
+ #
2
+ # Author:: Jesse Proudman (<jesse.proudman@blueboxgrp.com>)
3
+ # Copyright:: Copyright (c) 2010 Blue Box Group
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/knife'
20
+ require 'chef/json'
21
+
22
+ class Chef
23
+ class Knife
24
+ class BlueboxServerCreate < Knife
25
+
26
+ banner "knife bluebox server create [RUN LIST...] (options)"
27
+
28
+ option :flavor,
29
+ :short => "-f FLAVOR",
30
+ :long => "--flavor FLAVOR",
31
+ :description => "The flavor of server",
32
+ :default => "94fd37a7-2606-47f7-84d5-9000deda52ae"
33
+
34
+ option :image,
35
+ :short => "-i IMAGE",
36
+ :long => "--image IMAGE",
37
+ :description => "The image of the server",
38
+ :default => "03807e08-a13d-44e4-b011-ebec7ef2c928"
39
+
40
+ option :username,
41
+ :short => "-U KEY",
42
+ :long => "--username username",
43
+ :description => "Username on new server",
44
+ :default => "deploy"
45
+
46
+ option :password,
47
+ :short => "-P password",
48
+ :long => "--password password",
49
+ :description => "User password on new server.",
50
+ :default => ""
51
+
52
+ option :bootstrap,
53
+ :long => "--bootstrap false",
54
+ :description => "Disables the bootstrapping process.",
55
+ :default => true
56
+
57
+ def h
58
+ @highline ||= HighLine.new
59
+ end
60
+
61
+ def run
62
+ require 'fog'
63
+ require 'highline'
64
+ require 'net/ssh/multi'
65
+ require 'readline'
66
+ require 'erb'
67
+
68
+ bluebox = Fog::Bluebox::Compute.new(
69
+ :bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
70
+ :bluebox_api_key => Chef::Config[:knife][:bluebox_api_key]
71
+ )
72
+
73
+ flavors = bluebox.flavors.inject({}) { |h,f| h[f.id] = f.description; h }
74
+ images = bluebox.images.inject({}) { |h,i| h[i.id] = i.description; h }
75
+
76
+ puts "#{h.color("Deploying a new Blue Box Block...", :green)}\n\n"
77
+ server_args = {
78
+ :flavor_id => config[:flavor],
79
+ :image_id => config[:image],
80
+ :user => config[:username],
81
+ :password => config[:password]
82
+ }
83
+ server_args[:ssh_key] = Chef::Config[:knife][:ssh_key] if Chef::Config[:knife][:ssh_key]
84
+
85
+ server = bluebox.servers.new(server_args)
86
+ response = server.save
87
+ $stdout.sync = true
88
+
89
+ # Wait for the server to start
90
+ begin
91
+
92
+ # Make sure we could properly queue the server for creation on BBG.
93
+ raise Fog::Bluebox::BlockInstantiationError if server.status != "queued"
94
+ puts "#{h.color("Hostname", :cyan)}: #{server.hostname}"
95
+ puts "#{h.color("Server Status", :cyan)}: #{server.status.capitalize}"
96
+ puts "#{h.color("Flavor", :cyan)}: #{flavors[server.flavor_id]}"
97
+ puts "#{h.color("Image", :cyan)}: #{images[server.image_id]}"
98
+ puts "#{h.color("IP Address", :cyan)}: #{server.ips[0]['address']}"
99
+
100
+ # The server was succesfully queued... Now wait for it to spin up...
101
+ print "\n#{h.color("Requesting status of #{server.hostname}\n", :magenta)}"
102
+
103
+ # Allow for 5 minutes to time out...
104
+ # ready? will raise Fog::Bluebox::BlockInstantiationError if block creation fails.
105
+ unless server.wait_for( 5 * 60 ){ print "."; STDOUT.flush; ready? }
106
+
107
+ # The server wasn't started in 5 minutes... Send a destroy call to make sure it doesn't spin up on us later...
108
+ server.destroy
109
+ raise Fog::Bluebox::BlockInstantiationError, "BBG server not available after 5 minutes"
110
+
111
+ else
112
+ print "\n\n#{h.color("BBG Server startup succesful. Accessible at #{server.hostname}\n", :green)}"
113
+
114
+ # Make sure we should be bootstrapping.
115
+ unless config[:bootstrap]
116
+ puts "\n\n#{h.color("Boostrapping disabled per command line inputs. Exiting here.}", :green)}"
117
+ return true
118
+ end
119
+
120
+ # Bootstrap away!
121
+ print "\n\n#{h.color("Starting bootstrapping process...", :green)}\n"
122
+
123
+ # Connect via SSH and make this all happen.
124
+ begin
125
+ bootstrap = Chef::Knife::Bootstrap.new
126
+ bootstrap.name_args = [ server.ips[0]['address'] ]
127
+ bootstrap.config[:run_list] = @name_args
128
+ unless Chef::Config[:knife][:ssh_key]
129
+ bootstrap.config[:password] = password
130
+ end
131
+ bootstrap.config[:ssh_user] = config[:username]
132
+ bootstrap.config[:identity_file] = config[:identity_file]
133
+ bootstrap.config[:chef_node_name] = config[:chef_node_name] || server.hostname
134
+ bootstrap.config[:use_sudo] = true
135
+ bootstrap.run
136
+ rescue Errno::ECONNREFUSED
137
+ puts h.color("Connection refused on SSH, retrying - CTRL-C to abort")
138
+ sleep 1
139
+ retry
140
+ rescue Errno::ETIMEDOUT
141
+ puts h.color("Connection timed out on SSH, retrying - CTRL-C to abort")
142
+ sleep 1
143
+ retry
144
+ end
145
+
146
+ end
147
+
148
+ rescue Fog::Bluebox::BlockInstantiationError => e
149
+
150
+ puts "\n\n#{h.color("Encountered error starting up BBG block. Auto destroy called. Please try again.", :red)}"
151
+
152
+ end
153
+
154
+ end
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,63 @@
1
+ #
2
+ # Author:: Jesse Proudman (<jesse.proudman@blueboxgrp.com>)
3
+ # Copyright:: Copyright (c) 2010 Blue Box Group
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/knife'
20
+ require 'chef/json'
21
+
22
+ class Chef
23
+ class Knife
24
+ class BlueboxServerDelete < Knife
25
+
26
+ banner "knife bluebox server delete BLOCK-HOSTNAME"
27
+
28
+ def h
29
+ @highline ||= HighLine.new
30
+ end
31
+
32
+ def run
33
+ require 'fog'
34
+ require 'highline'
35
+ require 'readline'
36
+
37
+ bluebox = Fog::Bluebox::Compute.new(
38
+ :bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
39
+ :bluebox_api_key => Chef::Config[:knife][:bluebox_api_key]
40
+ )
41
+
42
+ # Build hash of hostname => id
43
+ servers = bluebox.servers.inject({}) { |h,f| h[f.hostname] = f.id; h }
44
+
45
+ unless servers.has_key?(@name_args[0])
46
+ Chef::Log.warn("I can't find a block named #{@name_args[0]}")
47
+ return false
48
+ end
49
+
50
+ confirm(h.color("Do you really want to delete block UUID #{servers[@name_args[0]]} with hostname #{@name_args[0]}", :green))
51
+
52
+ begin
53
+ response = bluebox.destroy_block(servers[@name_args[0]])
54
+ if response.status == 200
55
+ Chef::Log.warn("Deleted server #{servers[@name_args[0]]} named #{@name_args[0]}")
56
+ end
57
+ rescue Excon::Errors::UnprocessableEntity
58
+ Chef::Log.warn("There was a problem deleting #{@name_args[0]}. Please check Box Panel.")
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,59 @@
1
+ #
2
+ # Author:: Jesse Proudman (<jesse.proudman@blueboxgrp.com>)
3
+ # Copyright:: Copyright (c) 2010 Blue Box Group
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'chef/knife'
20
+ require 'chef/json'
21
+
22
+ class Chef
23
+ class Knife
24
+ class BlueboxServerList < Knife
25
+
26
+ banner "knife bluebox server list (options)"
27
+
28
+ def h
29
+ @highline ||= HighLine.new
30
+ end
31
+
32
+ def run
33
+ require 'fog'
34
+ require 'highline'
35
+ require 'net/ssh/multi'
36
+ require 'readline'
37
+
38
+ bluebox = Fog::Bluebox::Compute.new(
39
+ :bluebox_customer_id => Chef::Config[:knife][:bluebox_customer_id],
40
+ :bluebox_api_key => Chef::Config[:knife][:bluebox_api_key]
41
+ )
42
+
43
+ # Make hash of flavor id => name and image id => name
44
+ flavors = bluebox.flavors.inject({}) { |h,f| h[f.id] = f.description; h }
45
+ images = bluebox.images.inject({}) { |h,i| h[i.id] = i.description; h }
46
+
47
+ server_list = [ h.color('ID', :bold), h.color('Hostname', :bold), h.color('IP Address', :bold) ]
48
+
49
+ bluebox.servers.each do |server|
50
+ server_list << server.id.to_s
51
+ server_list << server.hostname
52
+ server_list << server.ips[0]["address"]
53
+ end
54
+ puts h.list(server_list, :columns_across, 3)
55
+
56
+ end
57
+ end
58
+ end
59
+ end
@@ -17,7 +17,7 @@
17
17
  #
18
18
 
19
19
  require 'chef/knife'
20
- require 'json'
20
+ require 'chef/json'
21
21
  require 'tempfile'
22
22
  require 'erubis'
23
23
 
@@ -121,6 +121,8 @@ class Chef
121
121
 
122
122
  Chef::Log.info("Bootstrapping Chef on #{h.color(config[:server_name], :bold)}")
123
123
 
124
+ knife_ssh.load_late_dependencies
125
+
124
126
  begin
125
127
  knife_ssh.run
126
128
  rescue Net::SSH::AuthenticationFailed