spiceweasel 2.3.1 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,6 +48,7 @@ module Spiceweasel
48
48
  create_command("berks upload #{berks_options}")
49
49
  Berkshelf.ui.mute do
50
50
  Spiceweasel::Log.debug("berkshelf resolving dependencies: #{resolve_opts}")
51
+ # berks.resolve(resolve_opts) blows up with Berkshelf 2.0
51
52
  berks.resolve(resolve_opts).each do |cb|
52
53
  @cookbook_list[cb.cookbook_name] = cb.version
53
54
  delete_command("knife cookbook#{Spiceweasel::Config[:knife_options]} delete #{cb.cookbook_name} #{cb.version} -a -y")
@@ -29,6 +29,7 @@ require 'spiceweasel/roles'
29
29
  require 'spiceweasel/data_bags'
30
30
  require 'spiceweasel/nodes'
31
31
  require 'spiceweasel/clusters'
32
+ require 'spiceweasel/knife'
32
33
  require 'spiceweasel/extract_local'
33
34
  require 'spiceweasel/execute'
34
35
 
@@ -290,8 +291,9 @@ module Spiceweasel
290
291
  data_bags = DataBags.new(manifest['data bags'])
291
292
  nodes = Nodes.new(manifest['nodes'], cookbooks, environments, roles)
292
293
  clusters = Clusters.new(manifest['clusters'], cookbooks, environments, roles)
294
+ knife = Knife.new(manifest['knife'])
293
295
 
294
- create += environments.create + roles.create + data_bags.create + nodes.create + clusters.create
296
+ create += environments.create + roles.create + data_bags.create + nodes.create + clusters.create + knife.create
295
297
  delete += environments.delete + roles.delete + data_bags.delete + nodes.delete + clusters.delete
296
298
  return create, delete
297
299
  end
@@ -0,0 +1,59 @@
1
+ #
2
+ # Author:: Matt Ray (<matt@opscode.com>)
3
+ #
4
+ # Copyright:: 2013, Opscode, Inc <legal@opscode.com>
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 'mixlib/shellout'
20
+
21
+ module Spiceweasel
22
+ class Knife
23
+
24
+ include CommandHelper
25
+
26
+ attr_reader :knife_list, :create
27
+
28
+ def initialize(knives = {})
29
+ @create = Array.new
30
+ if knives
31
+ allknifes = Mixlib::ShellOut.new('knife -h').run_command.stdout.split(/\n/)
32
+ allknifes.keep_if {|x| x.start_with?('knife')}
33
+ Spiceweasel::Log.debug(allknifes)
34
+ knives.each do |knife|
35
+ Spiceweasel::Log.debug("knife: #{knife}")
36
+ knife.keys.each do |knf|
37
+ validate(knf, allknifes) unless Spiceweasel::Config[:novalidation]
38
+ if knife[knf]
39
+ knife[knf].each do |options|
40
+ create_command("knife #{knf} #{options}")
41
+ end
42
+ else
43
+ create_command("knife #{knf}")
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ # test that the knife command exists
51
+ def validate(command, allknifes)
52
+ unless allknifes.index {|x| x.start_with?("knife #{command}")}
53
+ STDERR.puts "ERROR: 'knife #{command}' is not a currently supported command for knife."
54
+ exit(-1)
55
+ end
56
+ end
57
+
58
+ end
59
+ end
@@ -17,5 +17,5 @@
17
17
  #
18
18
 
19
19
  module Spiceweasel
20
- VERSION = '2.3.1'
20
+ VERSION = '2.4.0'
21
21
  end
@@ -1,5 +1,5 @@
1
1
  # Test new 2.3 functionality
2
- describe 'The Spiceweasel binary' do
2
+ describe 'testing 2.3 functionality' do
3
3
  before(:each) do
4
4
  @expected_output = <<-OUTPUT
5
5
  knife cookbook delete apache2 -a -y
@@ -0,0 +1,18 @@
1
+ # Test new 2.4 functionality
2
+ describe 'testing knife commands' do
3
+ before(:each) do
4
+ @expected_output = <<-OUTPUT
5
+ knife node list
6
+ knife client list
7
+ knife ssh "role:database" "chef-client" -x root
8
+ knife ssh "role:webserver" "sudo chef-client" -x ubuntu
9
+ OUTPUT
10
+
11
+ @spiceweasel_binary = File.join(File.dirname(__FILE__), *%w[.. .. bin spiceweasel])
12
+ end
13
+
14
+ it "test knife commands from 2.4" do
15
+ `#{@spiceweasel_binary} examples/knife.yml`.should == @expected_output
16
+ end
17
+
18
+ end
@@ -51,6 +51,11 @@ knife ec2 server create -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-8
51
51
  knife ec2 server create -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7000f019 -f m1.small -E amazon -r 'role[webserver],recipe[mysql::client]'
52
52
  knife ec2 server create -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7000f019 -f m1.small -E amazon -r 'role[webserver],recipe[mysql::client]'
53
53
  knife ec2 server create -S mray -i ~/.ssh/mray.pem -x ubuntu -G default -I ami-7000f019 -f m1.small -E amazon -r 'role[webserver],recipe[mysql::client]'
54
+ knife ssh 'role:monitoring' 'sudo chef-client' -x user
55
+ knife rackspace server delete -y --node-name db3 --purge
56
+ knife vsphere vm clone --bootstrap --template 'abc' my-new-webserver1
57
+ knife vsphere vm clone --bootstrap --template 'def' my-new-webserver2
58
+ knife vsphere vm clone --bootstrap --template 'ghi' my-new-webserver3
54
59
  OUTPUT
55
60
 
56
61
  @spiceweasel_binary = File.join(File.dirname(__FILE__), *%w[.. .. bin spiceweasel])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spiceweasel
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-08 00:00:00.000000000 Z
12
+ date: 2013-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -178,12 +178,14 @@ files:
178
178
  - lib/spiceweasel/environments.rb
179
179
  - lib/spiceweasel/execute.rb
180
180
  - lib/spiceweasel/extract_local.rb
181
+ - lib/spiceweasel/knife.rb
181
182
  - lib/spiceweasel/log.rb
182
183
  - lib/spiceweasel/nodes.rb
183
184
  - lib/spiceweasel/roles.rb
184
185
  - lib/spiceweasel/version.rb
185
186
  - lib/spiceweasel.rb
186
187
  - spec/bin/joyent-vsphere_spec.rb
188
+ - spec/bin/knife_spec.rb
187
189
  - spec/bin/spiceweasel_spec.rb
188
190
  homepage: https://github.com/mattray/spiceweasel
189
191
  licenses:
@@ -212,4 +214,5 @@ specification_version: 3
212
214
  summary: CLI for generating Chef knife commands from a simple JSON or YAML file.
213
215
  test_files:
214
216
  - spec/bin/joyent-vsphere_spec.rb
217
+ - spec/bin/knife_spec.rb
215
218
  - spec/bin/spiceweasel_spec.rb