Skip to content

Commit 09ab373

Browse files
committed
Fixes to allow for JSON Attribute files, removed HTTP header debugging, moved the timer to wrap the entire chef-client run
1 parent 4dbefb3 commit 09ab373

8 files changed

Lines changed: 63 additions & 150 deletions

File tree

chef-server/lib/public/stylesheets/master.css

Lines changed: 18 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -153,140 +153,21 @@ div.node {
153153
}
154154
*/
155155

156-
pre.twilight .DiffInserted {
157-
background-color: #253B22;
158-
color: #F8F8F8;
159-
}
160-
pre.twilight .DiffHeader {
161-
background-color: #0E2231;
162-
color: #F8F8F8;
163-
font-style: italic;
164-
}
165-
pre.twilight .CssPropertyValue {
166-
color: #F9EE98;
167-
}
168-
pre.twilight .CCCPreprocessorDirective {
169-
color: #AFC4DB;
170-
}
171-
pre.twilight .Constant {
172-
color: #CF6A4C;
173-
}
174-
pre.twilight .DiffChanged {
175-
background-color: #4A410D;
176-
color: #F8F8F8;
177-
}
178-
pre.twilight .EmbeddedSource {
179-
background-color: #A3A6AD;
180-
}
181-
pre.twilight .Support {
182-
color: #9B859D;
183-
}
184-
pre.twilight .MarkupList {
185-
color: #F9EE98;
186-
}
187-
pre.twilight .CssConstructorArgument {
188-
color: #8F9D6A;
189-
}
190-
pre.twilight .Storage {
191-
color: #F9EE98;
192-
}
193-
pre.twilight .line-numbers {
194-
background-color: #DDF0FF;
195-
color: #000000;
196-
}
197-
pre.twilight .CssClass {
198-
color: #9B703F;
199-
}
200-
pre.twilight .StringConstant {
201-
color: #DDF2A4;
202-
}
203-
pre.twilight .CssAtRule {
204-
color: #8693A5;
205-
}
206-
pre.twilight .MetaTagInline {
207-
color: #E0C589;
208-
}
209-
pre.twilight .MarkupHeading {
210-
color: #CF6A4C;
211-
}
212-
pre.twilight .CssTagName {
213-
color: #CDA869;
214-
}
215-
pre.twilight .SupportConstant {
216-
color: #CF6A4C;
217-
}
218-
pre.twilight .DiffDeleted {
219-
background-color: #420E09;
220-
color: #F8F8F8;
221-
}
222-
pre.twilight .CCCPreprocessorLine {
223-
color: #8996A8;
224-
}
225-
pre.twilight .StringRegexpSpecial {
226-
color: #CF7D34;
227-
}
228-
pre.twilight .EmbeddedSourceBright {
229-
background-color: #9C9EA4;
230-
}
231-
pre.twilight .InvalidIllegal {
232-
background-color: #241A24;
233-
color: #F8F8F8;
234-
}
235-
pre.twilight .SupportFunction {
236-
color: #DAD085;
237-
}
238-
pre.twilight .CssAdditionalConstants {
239-
color: #CA7840;
240-
}
241-
pre.twilight .MetaTagAll {
242-
color: #AC885B;
243-
}
244-
pre.twilight .StringRegexp {
245-
color: #E9C062;
246-
}
247-
pre.twilight .StringEmbeddedSource {
248-
color: #DAEFA3;
249-
}
250-
pre.twilight .EntityInheritedClass {
251-
color: #9B5C2E;
252-
font-style: italic;
253-
}
254-
pre.twilight .CssId {
255-
color: #8B98AB;
256-
}
257-
pre.twilight .CssPseudoClass {
258-
color: #8F9D6A;
259-
}
260-
pre.twilight .StringVariable {
261-
color: #8A9A95;
262-
}
263-
pre.twilight .String {
264-
color: #8F9D6A;
265-
}
266-
pre.twilight .Keyword {
267-
color: #CDA869;
268-
}
269-
pre.twilight {
270-
background-color: #141414;
271-
color: #F8F8F8;
272-
}
273-
pre.twilight .CssPropertyName {
274-
color: #C5AF75;
275-
}
276-
pre.twilight .DoctypeXmlProcessing {
277-
color: #494949;
278-
}
279-
pre.twilight .InvalidDeprecated {
280-
color: #D2A8A1;
281-
font-style: italic;
282-
}
283-
pre.twilight .Variable {
284-
color: #7587A6;
285-
}
286-
pre.twilight .Entity {
287-
color: #9B703F;
288-
}
289-
pre.twilight .Comment {
290-
color: #5F5A60;
291-
font-style: italic;
292-
}
156+
.ruby .normal {}
157+
.ruby .comment { color: #005; font-style: italic; }
158+
.ruby .keyword { color: #A00; font-weight: bold; }
159+
.ruby .method { color: #077; }
160+
.ruby .class { color: #074; }
161+
.ruby .module { color: #050; }
162+
.ruby .punct { color: #447; font-weight: bold; }
163+
.ruby .symbol { color: #099; }
164+
.ruby .string { color: #944; background: #FFE; }
165+
.ruby .char { color: #F07; }
166+
.ruby .ident { color: #004; }
167+
.ruby .constant { color: #07F; }
168+
.ruby .regex { color: #B66; background: #FEF; }
169+
.ruby .number { color: #F99; }
170+
.ruby .attribute { color: #7BB; }
171+
.ruby .global { color: #7FB; }
172+
.ruby .expr { color: #227; }
173+
.ruby .escape { color: #277; }

chef-server/lib/views/search/show.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
.search_result
88
%h3= "#{h result[:index_name]} (#{h result[:id]})"
99
%table
10-
- result.each do |k, v|
10+
- result.sort { |a,b| a[0] <=> b[0] }.each do |k, v|
1111
%tr.attr_group
1212
%td.attr_name= k
1313
%td.attr_value= v.kind_of?(Array) ? v.join(",") : v
0 Bytes
Binary file not shown.

chef/bin/chef-client

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,25 @@
1919
# limitations under the License.
2020

2121
require 'optparse'
22-
require 'chef'
2322
require 'rubygems'
23+
require 'chef'
2424
require 'facter'
25+
require 'json'
2526

2627
config = {
2728
:config_file => "/etc/chef/client.rb",
2829
:log_level => :info,
30+
:json_attribs => nil,
2931
:noop => false
3032
}
3133
opts = OptionParser.new do |opts|
3234
opts.banner = "Usage: #{$0} [-d DIR|-r FILE] (options)"
3335
opts.on("-c CONFIG", "--config CONFIG", "The Chef Config file to use") do |c|
3436
config[:config_file] = c
3537
end
38+
opts.on("-j JSON_ATTRIBS", "--json-attributes JSON_ATTRIBS", "Load attributes from a JSON file") do |j|
39+
config[:json_attribs] = j
40+
end
3641
opts.on("-n", "--noop", "Print what you would do, but don't actually do it.") do
3742
config[:noop] = true
3843
end
@@ -49,7 +54,15 @@ opts.parse!(ARGV)
4954
unless File.exists?(config[:config_file]) && File.readable?(config[:config_file])
5055
puts "I cannot find or read the config file: #{config[:config_file]}"
5156
puts opts
52-
exit
57+
exit 1
58+
end
59+
60+
if config[:json_attribs]
61+
unless File.exists?(config[:json_attribs])
62+
puts "I cannot find #{config[:json_attribs]}"
63+
exit 2
64+
end
65+
config[:json_attribs] = JSON.parse(IO.read(config[:json_attribs]))
5366
end
5467

5568
# Load our config file
@@ -59,4 +72,5 @@ if config[:log_level]
5972
end
6073

6174
c = Chef::Client.new
75+
c.json_attribs = config[:json_attribs]
6276
c.run

chef/lib/chef/client.rb

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,14 @@ class Client
2828
include Chef::Mixin::GenerateURL
2929
include Chef::Mixin::Checksum
3030

31-
attr_accessor :node, :registration, :safe_name
31+
attr_accessor :node, :registration, :safe_name, :json_attribs
3232

3333
# Creates a new Chef::Client.
3434
def initialize()
3535
@node = nil
3636
@safe_name = nil
3737
@registration = nil
38+
@json_attribs = nil
3839
@rest = Chef::REST.new(Chef::Config[:registration_url])
3940
end
4041

@@ -53,6 +54,9 @@ def initialize()
5354
# === Returns
5455
# true:: Always returns true.
5556
def run
57+
start_time = Time.now
58+
Chef::Log.info("Starting Chef Run")
59+
5660
build_node
5761
register
5862
authenticate
@@ -63,6 +67,9 @@ def run
6367
save_node
6468
converge
6569
save_node
70+
71+
end_time = Time.now
72+
Chef::Log.info("Chef Run complete in #{end_time - start_time} seconds")
6673
true
6774
end
6875

@@ -96,7 +103,24 @@ def build_node(node_name=nil)
96103
@node ||= Chef::Node.new
97104
@node.name(node_name)
98105
end
106+
if @json_attribs
107+
Chef::Log.debug("Adding JSON Attributes")
108+
@json_attribs.each do |key, value|
109+
if key == "recipes"
110+
value.each do |recipe|
111+
unless @node.recipes.detect { |r| r == recipe }
112+
Chef::Log.debug("Adding recipe #{recipe}")
113+
@node.recipes << recipe
114+
end
115+
end
116+
else
117+
Chef::Log.debug("JSON Attribute: #{key} - #{value.inspect}")
118+
@node[key] = value
119+
end
120+
end
121+
end
99122
Facter.each do |field, value|
123+
Chef::Log.debug("Facter Attribute: #{field} - #{value.inspect}")
100124
@node[field] = value
101125
end
102126
@node
@@ -288,7 +312,7 @@ def converge
288312
cr.converge
289313
true
290314
end
291-
315+
292316
protected
293317
# Generates a random password of "len" length.
294318
def random_password(len)

chef/lib/chef/rest.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,6 @@ def run_request(method, url, data=false, limit=10, raw=false)
136136
res = response
137137
end
138138

139-
Chef::Log.debug("HTTP request headers: #{req.to_hash.inspect} ")
140-
141-
Chef::Log.debug("HTTP response headers: #{res.to_hash.inspect} ")
142-
143139
if res.kind_of?(Net::HTTPSuccess)
144140
if res['set-cookie']
145141
@cookies["#{url.host}:#{url.port}"] = res['set-cookie']

chef/lib/chef/runner.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ def build_provider(resource)
5454
end
5555

5656
def converge
57-
start_time = Time.now
58-
Chef::Log.info("Starting Chef Run")
57+
5958
delayed_actions = Array.new
6059

6160
@collection.each do |resource|
@@ -92,8 +91,7 @@ def converge
9291

9392
# Run all our :delayed actions
9493
delayed_actions.each { |da| da.call }
95-
end_time = Time.now
96-
Chef::Log.info("Chef Run complete in #{end_time - start_time} seconds")
94+
9795
true
9896
end
9997
end

chef/pkg/chef-0.0.1.gem

512 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)