knife-whisk 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -30,10 +30,10 @@ mixins:
30
30
 
31
31
  provider_config:
32
32
  aws:
33
- cli_command: "ec2 sever create"
34
- security-groups:
35
- default: sg-12345678
36
- java_app_server: sg-34567890
33
+ cli_command: "ec2 server create"
34
+ security-groups:
35
+ default: sg-12345678
36
+ java_app_server: sg-34567890
37
37
  kvm:
38
38
  cli_command: "vm create"
39
39
 
data/knife-whisk.gemspec CHANGED
@@ -8,13 +8,14 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Knife::Whisk::VERSION
9
9
  gem.authors = ["Nic Grayson"]
10
10
  gem.email = ["nic.grayson@banno.com"]
11
- gem.summary = %q{Extends knife to display knife ec2 server create commands}
11
+ gem.summary = %q{Extends knife to display knife cloud server create commands}
12
12
  gem.description = %q{A utility for quickly whipping up new servers in a team environment}
13
13
  gem.homepage = ""
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.add_dependency 'safe_yaml'
18
19
  gem.add_development_dependency 'chef'
19
20
  gem.require_paths = ["lib"]
20
21
  end
@@ -1,5 +1,5 @@
1
1
  require 'chef/knife'
2
- require 'yaml'
2
+ require 'safe_yaml'
3
3
 
4
4
  class Chef
5
5
  class Knife
@@ -12,13 +12,13 @@ class Chef
12
12
  :long => '--whisk-config PATH',
13
13
  :description => "Specify path to your whisk.yml file",
14
14
  :proc => Proc.new { |path| Chef::Config[:knife][:whisk_config_file] = path }
15
-
15
+
16
16
  option :mixins,
17
17
  :short => '-M MIXINS',
18
18
  :long => '--mixins MIXINS',
19
19
  :description => "Overrides server mixins, takes comma seperated list of mixins",
20
20
  :proc => Proc.new { |input| input.split(",") }
21
-
21
+
22
22
  option :overrides,
23
23
  :short => '-O STRING',
24
24
  :long => '--overrides STRING',
@@ -35,19 +35,19 @@ class Chef
35
35
  end
36
36
 
37
37
  def exit_with_message(message)
38
- ui.fatal message
39
- Kernel.exit(1)
38
+ ui.fatal message
39
+ Kernel.exit(1)
40
40
  end
41
-
41
+
42
42
  def get_config
43
43
  if Chef::Config[:knife][:whisk_config_file].nil?
44
44
  if File.exists?(::Chef::Knife::chef_config_dir+"/whisk.yml")
45
- YAML.load_file(::Chef::Knife::chef_config_dir+"/whisk.yml")
45
+ YAML.load_file(::Chef::Knife::chef_config_dir+"/whisk.yml", :safe => true)
46
46
  else
47
47
  return false
48
48
  end
49
49
  else
50
- YAML.load_file(Chef::Config[:knife][:whisk_config_file])
50
+ YAML.load_file(Chef::Config[:knife][:whisk_config_file], :safe => true)
51
51
  end
52
52
  end
53
53
 
@@ -55,7 +55,7 @@ class Chef
55
55
  groups.split(',').map! { |name| name.replace(get_config["provider_config"]["aws"]["security-groups"][name]) }.join(',')
56
56
  end
57
57
 
58
- def security_group_exists?(group)
58
+ def security_group_exists?(group)
59
59
  ! get_config["provider_config"]["aws"]["security-groups"][group].nil?
60
60
  end
61
61
 
@@ -77,7 +77,7 @@ class Chef
77
77
  class WhiskServerList < Chef::Knife
78
78
  include Knife::WhiskBase
79
79
  banner "knife whisk server list"
80
-
80
+
81
81
  def run
82
82
  exit_with_message("Required whisk.yml does not exist") unless get_config
83
83
  get_config["servers"].each do |server|
@@ -89,11 +89,11 @@ class Chef
89
89
  class WhiskServerShow < Chef::Knife
90
90
  include Knife::WhiskBase
91
91
  banner "knife whisk server show SERVER"
92
-
92
+
93
93
  def run
94
94
  exit_with_message("Required whisk.yml does not exist") unless get_config
95
95
  exit_with_message("You must specify a server name") unless name_args.size == 1
96
-
96
+
97
97
  if server_exists?(name_args.first)
98
98
  puts name_args.first
99
99
  puts get_config["servers"]["#{name_args.first}"].to_yaml
@@ -106,7 +106,7 @@ class Chef
106
106
  class WhiskMixinList < Chef::Knife
107
107
  include Knife::WhiskBase
108
108
  banner "knife whisk mixin list"
109
-
109
+
110
110
  def run
111
111
  exit_with_message("Required whisk.yml does not exist") unless get_config
112
112
  get_config["mixins"].each do |mixin|
@@ -118,11 +118,11 @@ class Chef
118
118
  class WhiskMixinShow < Chef::Knife
119
119
  include Knife::WhiskBase
120
120
  banner "knife whisk mixin show MIXIN"
121
-
121
+
122
122
  def run
123
123
  exit_with_message("Required whisk.yml does not exist") unless get_config
124
124
  exit_with_message("You must specify a mixin") unless name_args.size == 1
125
-
125
+
126
126
  if mixin_exists?(name_args.first)
127
127
  puts name_args.first
128
128
  puts get_config["mixins"]["#{name_args.first}"].to_yaml
@@ -135,12 +135,12 @@ class Chef
135
135
  class WhiskGenerate < Chef::Knife
136
136
  include Knife::WhiskBase
137
137
  banner "knife whisk generate [SERVER]"
138
-
138
+
139
139
  def run
140
140
  exit_with_message("Required whisk.yml does not exist") unless get_config
141
-
141
+
142
142
  full_hash = get_config
143
-
143
+
144
144
  if name_args.size == 0
145
145
  server_config = full_hash["mixins"]["defaults"]
146
146
  server_mixins = ["defaults"]
@@ -150,7 +150,7 @@ class Chef
150
150
  else
151
151
  exit_with_message("#{name_args.first} server template does not exist")
152
152
  end
153
-
153
+
154
154
  unless @config[:mixins].nil?
155
155
  server_mixins = server_mixins + @config[:mixins]
156
156
  end
@@ -160,19 +160,19 @@ class Chef
160
160
 
161
161
  #merges together all mixin config values with server config values
162
162
  output_hash = server_mixins.inject(Hash.new) {|output, mixin| output.merge(full_hash["mixins"][mixin])}.merge(server_config)
163
-
163
+
164
164
  #convert config values that are arrays to comma seperates strings
165
165
  output_hash.each do |mixin, value|
166
166
  if value.kind_of?(Array)
167
167
  output_hash[mixin] = value.join(",")
168
168
  end
169
169
  end
170
-
170
+
171
171
  unless @config[:overrides].nil?
172
172
  exit_with_message("Please use long form flags only in overrides") unless @config[:overrides].kind_of?(Hash)
173
173
  output_hash = output_hash.merge(@config[:overrides])
174
174
  end
175
-
175
+
176
176
  #check things for aws
177
177
  if output_hash["provider"]["aws"]
178
178
  #convert security-group names to ids if needed and make sure they exist in the lookup hash
@@ -183,10 +183,10 @@ class Chef
183
183
  output_hash.delete("security-groups")
184
184
  end
185
185
  end
186
-
186
+
187
187
  #some values need quotes for knife ec2 to accept the arg
188
188
  output_hash["run-list"] = add_quotes(output_hash["run-list"]) unless output_hash["run-list"].nil?
189
- # json doesn't work currently output_hash["json-attributes"] = add_quotes(output_hash["json-attributes"]) unless output_hash["json-attributes"].nil?
189
+ # json doesn't work currently output_hash["json-attributes"] = add_quotes(output_hash["json-attributes"]) unless output_hash["json-attributes"].nil?
190
190
 
191
191
  #get config string and check to make sure it exists
192
192
  exit_with_message("provider attribute must be provided") unless output_hash["provider"]
@@ -1,5 +1,5 @@
1
1
  module Knife
2
2
  module Whisk
3
- VERSION = "2.0.0"
3
+ VERSION = "2.0.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-whisk
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,24 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-22 00:00:00.000000000 Z
12
+ date: 2013-08-13 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: safe_yaml
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: chef
16
32
  requirement: !ruby/object:Gem::Requirement
@@ -69,5 +85,5 @@ rubyforge_project:
69
85
  rubygems_version: 1.8.23
70
86
  signing_key:
71
87
  specification_version: 3
72
- summary: Extends knife to display knife ec2 server create commands
88
+ summary: Extends knife to display knife cloud server create commands
73
89
  test_files: []