chef 0.9.18 → 0.10.0.beta.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.
Files changed (177) hide show
  1. data/README.rdoc +0 -3
  2. data/distro/arch/etc/rc.d/chef-server +0 -4
  3. data/distro/arch/etc/rc.d/chef-server-webui +0 -4
  4. data/distro/arch/etc/rc.d/chef-solr +0 -4
  5. data/distro/arch/etc/rc.d/chef-solr-indexer +0 -4
  6. data/lib/chef.rb +3 -3
  7. data/lib/chef/api_client.rb +1 -1
  8. data/lib/chef/application.rb +11 -1
  9. data/lib/chef/application/client.rb +18 -22
  10. data/lib/chef/application/knife.rb +28 -29
  11. data/lib/chef/application/solo.rb +14 -12
  12. data/lib/chef/client.rb +112 -54
  13. data/lib/chef/config.rb +4 -0
  14. data/lib/chef/cookbook/chefignore.rb +66 -0
  15. data/lib/chef/cookbook/cookbook_collection.rb +6 -5
  16. data/lib/chef/cookbook/cookbook_version_loader.rb +151 -0
  17. data/lib/chef/cookbook/file_system_file_vendor.rb +10 -8
  18. data/lib/chef/cookbook/metadata.rb +200 -108
  19. data/lib/chef/cookbook_loader.rb +39 -163
  20. data/lib/chef/cookbook_uploader.rb +100 -78
  21. data/lib/chef/cookbook_version.rb +92 -47
  22. data/lib/chef/cookbook_version_selector.rb +163 -0
  23. data/lib/chef/couchdb.rb +9 -1
  24. data/lib/chef/data_bag.rb +1 -1
  25. data/lib/chef/data_bag_item.rb +1 -1
  26. data/lib/chef/encrypted_data_bag_item.rb +126 -0
  27. data/lib/chef/environment.rb +386 -0
  28. data/lib/chef/exceptions.rb +82 -1
  29. data/lib/chef/index_queue/amqp_client.rb +15 -12
  30. data/lib/chef/index_queue/indexable.rb +38 -4
  31. data/lib/chef/json_compat.rb +3 -3
  32. data/lib/chef/knife.rb +97 -202
  33. data/lib/chef/knife/bootstrap.rb +27 -61
  34. data/lib/chef/knife/bootstrap/archlinux-gems.erb +4 -2
  35. data/lib/chef/knife/bootstrap/centos5-gems.erb +6 -15
  36. data/lib/chef/knife/bootstrap/fedora13-gems.erb +3 -4
  37. data/lib/chef/knife/bootstrap/ubuntu10.04-apt.erb +2 -2
  38. data/lib/chef/knife/bootstrap/ubuntu10.04-gems.erb +6 -5
  39. data/lib/chef/knife/client_bulk_delete.rb +6 -3
  40. data/lib/chef/knife/client_create.rb +13 -10
  41. data/lib/chef/knife/client_delete.rb +10 -7
  42. data/lib/chef/knife/client_edit.rb +9 -6
  43. data/lib/chef/knife/client_list.rb +8 -5
  44. data/lib/chef/knife/client_reregister.rb +9 -6
  45. data/lib/chef/knife/client_show.rb +9 -6
  46. data/lib/chef/knife/configure.rb +15 -19
  47. data/lib/chef/knife/configure_client.rb +4 -4
  48. data/lib/chef/knife/cookbook_bulk_delete.rb +11 -8
  49. data/lib/chef/knife/cookbook_create.rb +120 -55
  50. data/lib/chef/knife/cookbook_delete.rb +18 -12
  51. data/lib/chef/knife/cookbook_download.rb +10 -6
  52. data/lib/chef/knife/cookbook_list.rb +15 -6
  53. data/lib/chef/knife/cookbook_metadata.rb +41 -21
  54. data/lib/chef/knife/cookbook_metadata_from_file.rb +4 -0
  55. data/lib/chef/knife/cookbook_show.rb +16 -5
  56. data/lib/chef/knife/cookbook_site_download.rb +2 -2
  57. data/lib/chef/knife/cookbook_site_share.rb +18 -13
  58. data/lib/chef/knife/cookbook_site_unshare.rb +7 -4
  59. data/lib/chef/knife/cookbook_site_vendor.rb +21 -18
  60. data/lib/chef/knife/cookbook_test.rb +14 -14
  61. data/lib/chef/knife/cookbook_upload.rb +91 -40
  62. data/lib/chef/knife/data_bag_create.rb +41 -6
  63. data/lib/chef/knife/data_bag_delete.rb +5 -3
  64. data/lib/chef/knife/data_bag_edit.rb +55 -11
  65. data/lib/chef/knife/data_bag_from_file.rb +47 -7
  66. data/lib/chef/knife/data_bag_list.rb +4 -1
  67. data/lib/chef/knife/data_bag_show.rb +44 -4
  68. data/lib/chef/knife/environment_create.rb +53 -0
  69. data/lib/chef/knife/environment_delete.rb +45 -0
  70. data/lib/chef/knife/environment_edit.rb +45 -0
  71. data/lib/chef/knife/environment_from_file.rb +39 -0
  72. data/lib/chef/knife/environment_list.rb +42 -0
  73. data/lib/chef/knife/environment_show.rb +46 -0
  74. data/lib/chef/knife/exec.rb +1 -1
  75. data/lib/chef/knife/index_rebuild.rb +8 -9
  76. data/lib/chef/knife/node_bulk_delete.rb +9 -6
  77. data/lib/chef/knife/node_create.rb +9 -6
  78. data/lib/chef/knife/node_delete.rb +10 -7
  79. data/lib/chef/knife/node_edit.rb +129 -10
  80. data/lib/chef/knife/node_from_file.rb +10 -7
  81. data/lib/chef/knife/node_list.rb +11 -6
  82. data/lib/chef/knife/node_run_list_add.rb +10 -7
  83. data/lib/chef/knife/node_run_list_remove.rb +9 -6
  84. data/lib/chef/knife/node_show.rb +15 -7
  85. data/lib/chef/knife/recipe_list.rb +4 -3
  86. data/lib/chef/knife/role_bulk_delete.rb +9 -6
  87. data/lib/chef/knife/role_create.rb +9 -6
  88. data/lib/chef/knife/role_delete.rb +10 -7
  89. data/lib/chef/knife/role_edit.rb +11 -8
  90. data/lib/chef/knife/role_from_file.rb +10 -7
  91. data/lib/chef/knife/role_list.rb +8 -5
  92. data/lib/chef/knife/role_show.rb +11 -8
  93. data/lib/chef/knife/search.rb +33 -10
  94. data/lib/chef/knife/ssh.rb +33 -61
  95. data/lib/chef/knife/status.rb +7 -4
  96. data/lib/chef/knife/subcommand_loader.rb +101 -0
  97. data/lib/chef/knife/tag_create.rb +31 -0
  98. data/lib/chef/knife/tag_delete.rb +31 -0
  99. data/lib/chef/knife/tag_list.rb +29 -0
  100. data/lib/chef/knife/ui.rb +229 -0
  101. data/lib/chef/knife/windows_bootstrap.rb +8 -5
  102. data/lib/chef/log.rb +5 -59
  103. data/lib/chef/mash.rb +211 -0
  104. data/lib/chef/mixins.rb +1 -2
  105. data/lib/chef/nil_argument.rb +3 -0
  106. data/lib/chef/node.rb +96 -34
  107. data/lib/chef/platform.rb +27 -0
  108. data/lib/chef/provider/cookbook_file.rb +21 -20
  109. data/lib/chef/provider/deploy/revision.rb +3 -0
  110. data/lib/chef/provider/file.rb +20 -11
  111. data/lib/chef/provider/git.rb +26 -26
  112. data/lib/chef/provider/group/aix.rb +70 -0
  113. data/lib/chef/provider/group/groupadd.rb +7 -4
  114. data/lib/chef/provider/group/usermod.rb +1 -1
  115. data/lib/chef/provider/package.rb +28 -28
  116. data/lib/chef/provider/package/dpkg.rb +1 -1
  117. data/lib/chef/provider/package/portage.rb +50 -39
  118. data/lib/chef/provider/package/rubygems.rb +1 -1
  119. data/lib/chef/provider/package/zypper.rb +3 -20
  120. data/lib/chef/provider/remote_directory.rb +0 -2
  121. data/lib/chef/provider/remote_file.rb +2 -3
  122. data/lib/chef/provider/service/arch.rb +28 -35
  123. data/lib/chef/provider/service/simple.rb +1 -1
  124. data/lib/chef/provider/subversion.rb +22 -22
  125. data/lib/chef/providers.rb +1 -0
  126. data/lib/chef/recipe.rb +10 -12
  127. data/lib/chef/resource.rb +49 -42
  128. data/lib/chef/resource/gem_package.rb +7 -3
  129. data/lib/chef/resource/git.rb +5 -5
  130. data/lib/chef/resource/package.rb +7 -7
  131. data/lib/chef/resource/scm.rb +2 -1
  132. data/lib/chef/resource/solaris_package.rb +0 -1
  133. data/lib/chef/resource/yum_package.rb +0 -1
  134. data/lib/chef/rest.rb +7 -16
  135. data/lib/chef/rest/rest_request.rb +0 -16
  136. data/lib/chef/role.rb +67 -13
  137. data/lib/chef/run_context.rb +37 -21
  138. data/lib/chef/run_list.rb +30 -15
  139. data/lib/chef/run_list/run_list_expansion.rb +41 -20
  140. data/lib/chef/run_list/run_list_item.rb +20 -6
  141. data/lib/chef/run_list/versioned_recipe_list.rb +68 -0
  142. data/lib/chef/runner.rb +7 -15
  143. data/lib/chef/search/query.rb +12 -7
  144. data/lib/chef/shef.rb +6 -7
  145. data/lib/chef/shef/shef_session.rb +40 -35
  146. data/lib/chef/shell_out.rb +22 -201
  147. data/lib/chef/shell_out/unix.rb +224 -0
  148. data/lib/chef/shell_out/windows.rb +95 -0
  149. data/lib/chef/solr_query.rb +187 -0
  150. data/lib/chef/solr_query/lucene.treetop +145 -0
  151. data/lib/chef/solr_query/lucene_nodes.rb +285 -0
  152. data/lib/chef/solr_query/query_transform.rb +65 -0
  153. data/lib/chef/solr_query/solr_http_request.rb +118 -0
  154. data/lib/chef/version.rb +4 -2
  155. data/lib/chef/version_class.rb +70 -0
  156. data/lib/chef/version_constraint.rb +116 -0
  157. metadata +68 -37
  158. data/lib/chef/cookbook/metadata/version.rb +0 -87
  159. data/lib/chef/knife/bluebox_images_list.rb +0 -54
  160. data/lib/chef/knife/bluebox_server_create.rb +0 -157
  161. data/lib/chef/knife/bluebox_server_delete.rb +0 -63
  162. data/lib/chef/knife/bluebox_server_list.rb +0 -59
  163. data/lib/chef/knife/ec2_instance_data.rb +0 -46
  164. data/lib/chef/knife/ec2_server_create.rb +0 -218
  165. data/lib/chef/knife/ec2_server_delete.rb +0 -87
  166. data/lib/chef/knife/ec2_server_list.rb +0 -89
  167. data/lib/chef/knife/rackspace_server_create.rb +0 -184
  168. data/lib/chef/knife/rackspace_server_delete.rb +0 -57
  169. data/lib/chef/knife/rackspace_server_list.rb +0 -59
  170. data/lib/chef/knife/slicehost_images_list.rb +0 -53
  171. data/lib/chef/knife/slicehost_server_create.rb +0 -103
  172. data/lib/chef/knife/slicehost_server_delete.rb +0 -61
  173. data/lib/chef/knife/slicehost_server_list.rb +0 -64
  174. data/lib/chef/knife/terremark_server_create.rb +0 -152
  175. data/lib/chef/knife/terremark_server_delete.rb +0 -87
  176. data/lib/chef/knife/terremark_server_list.rb +0 -77
  177. data/lib/chef/mixin/find_preferred_file.rb +0 -92
@@ -1,87 +0,0 @@
1
- #
2
- # Author:: AJ Christensen (<aj@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 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
-
19
- require 'chef/cookbook_version'
20
- require 'chef/cookbook/metadata'
21
-
22
- class Chef::Cookbook::Metadata
23
- class Version
24
- include Comparable
25
-
26
- attr_accessor :major,
27
- :minor,
28
- :patch
29
-
30
- def initialize(str="")
31
- @major, @minor, @patch = _parse(str)
32
- end
33
-
34
- def _parse(str="")
35
- @major, @minor, @patch = case str.to_s
36
- when /^(\d+)\.(\d+)\.(\d+)$/
37
- [ $1.to_i, $2.to_i, $3.to_i ]
38
- when /^(\d+)\.(\d+)$/
39
- [ $1.to_i, $2.to_i, 0 ]
40
- else
41
- raise "Metadata version '#{str.to_s}' does not match 'x.y.z' or 'x.y'"
42
- end
43
- end
44
-
45
- def inspect
46
- "#{@major}.#{@minor}.#{@patch}"
47
- end
48
-
49
- def to_s
50
- "#{@major}.#{@minor}.#{@patch}"
51
- end
52
-
53
- def <=>(v)
54
- major, minor, patch = (
55
- [ :major, :minor, :patch ].collect do |method|
56
- self.send(method) <=> v.send(method)
57
- end
58
- )
59
-
60
- Chef::Log.debug "(#{self.to_s}/#{v.to_s}) major,minor,patch: #{[major,minor,patch].join(',')}"
61
-
62
- # all these returns feels like C, surely there is a better way!
63
-
64
- if major == 0 && minor == 0 && patch == 0
65
- comp = 0
66
- end
67
-
68
- if major == 1
69
- comp = 1
70
- end
71
-
72
- if major == 0 && minor == 1 && patch == -1
73
- comp = 1
74
- end
75
-
76
- if minor == 1 && major == 0 && patch == 0
77
- comp = 1
78
- end
79
-
80
- if patch == 1 && major == 0 && minor == 0
81
- comp = 1
82
- end
83
-
84
- return (comp || -1)
85
- end
86
- end
87
- end
@@ -1,54 +0,0 @@
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_compat'
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
@@ -1,157 +0,0 @@
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_compat'
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
@@ -1,63 +0,0 @@
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_compat'
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
@@ -1,59 +0,0 @@
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_compat'
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
@@ -1,46 +0,0 @@
1
- #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2009 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
-
19
- require 'chef/knife'
20
- require 'chef/json_compat'
21
-
22
- class Chef
23
- class Knife
24
- class Ec2InstanceData < Knife
25
-
26
- banner "knife ec2 instance data [RUN LIST...] (options)"
27
-
28
- option :edit,
29
- :short => "-e",
30
- :long => "--edit",
31
- :description => "Edit the instance data"
32
-
33
- def run
34
- data = {
35
- "chef_server" => Chef::Config[:chef_server_url],
36
- "validation_client_name" => Chef::Config[:validation_client_name],
37
- "validation_key" => IO.read(Chef::Config[:validation_key]),
38
- "attributes" => { "run_list" => @name_args }
39
- }
40
- data = edit_data(data) if config[:edit]
41
- output(data)
42
- end
43
- end
44
- end
45
- end
46
-