Skip to content

Commit 53f9cf0

Browse files
author
Nuo Yan
committed
Merge branch 'master' of git://github.com/opscode/chef into CHEF-677
2 parents 28c386c + d613d47 commit 53f9cf0

101 files changed

Lines changed: 3668 additions & 1607 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Rakefile‎

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,30 @@ def start_rabbitmq(type="normal")
5151
end
5252
end
5353

54+
def configure_rabbitmq(type="normal")
55+
# hack. wait for rabbit to come up.
56+
sleep 2
57+
58+
puts `rabbitmqctl add_vhost /nanite`
59+
60+
# create 'mapper' and 'nanite' users, give them each the password 'testing'
61+
%w[mapper nanite].each do |agent|
62+
puts `rabbitmqctl add_user #{agent} testing`
63+
end
64+
65+
# grant the mapper user the ability to do anything with the /nanite vhost
66+
# the three regex's map to config, write, read permissions respectively
67+
puts `rabbitmqctl set_permissions -p /nanite mapper ".*" ".*" ".*"`
68+
69+
# grant the nanite user more limited permissions on the /nanite vhost
70+
puts `rabbitmqctl set_permissions -p /nanite nanite ".*" ".*" ".*"`
71+
72+
puts `rabbitmqctl list_users`
73+
puts `rabbitmqctl list_vhosts`
74+
puts `rabbitmqctl list_permissions -p /nanite`
75+
76+
end
77+
5478
def start_chef_solr(type="normal")
5579
@chef_solr_pid = nil
5680
cid = fork
@@ -99,6 +123,7 @@ end
99123
def start_dev_environment(type="normal")
100124
start_couchdb(type)
101125
start_rabbitmq(type)
126+
configure_rabbitmq(type)
102127
start_chef_solr(type)
103128
start_chef_solr_indexer(type)
104129
start_chef_server(type)
@@ -170,9 +195,10 @@ namespace :dev do
170195
desc "Start RabbitMQ for testing"
171196
task :rabbitmq do
172197
start_rabbitmq("features")
198+
configure_rabbitmq("features")
173199
wait_for_ctrlc
174200
end
175-
201+
176202
desc "Start Chef Solr for testing"
177203
task :chef_solr do
178204
start_chef_solr("features")

‎chef-server-api/app/controllers/application.rb‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ def load_cookbook_files(cookbook)
231231

232232
if segment == :templates || segment == :files
233233
mo = sf.match("cookbooks/#{cookbook.name}/#{segment}/(.+?)/(.+)")
234+
unless mo
235+
Chef::Log.debug("Skipping file #{sf}, as it doesn't have a proper segment.")
236+
next
237+
end
234238
specificity = mo[1]
235239
file_name = mo[2]
236240
url_options = { :cookbook_id => cookbook.name.to_s, :segment => segment, :id => file_name }

‎chef-server-api/app/controllers/nodes.rb‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ def show
3939
raise NotFound, "Cannot load node #{params[:id]}"
4040
end
4141
@node.couchdb_rev = nil
42+
recipes, default, override = @node.run_list.expand("couchdb")
43+
@node.default_attrs = default
44+
@node.override_attrs = override
4245
display @node
4346
end
4447

@@ -66,6 +69,8 @@ def update
6669
updated = params['inflated_object']
6770
@node.run_list.reset(updated.run_list)
6871
@node.attribute = updated.attribute
72+
@node.override_attrs = updated.override_attrs
73+
@node.default_attrs = updated.default_attrs
6974
@node.cdb_save
7075
@node.couchdb_rev = nil
7176
display(@node)

‎chef-server-webui/app/controllers/nodes.rb‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ def create
7979
end
8080
redirect(slice_url(:nodes), :message => { :notice => "Created Node #{@node.name}" })
8181
rescue StandardError => e
82+
Chef::Log.error("StandardError creating node: #{e.message}")
8283
@node.attribute = JSON.parse(params[:attributes])
8384
@available_recipes = get_available_recipes
8485
@available_roles = Chef::Role.list.keys.sort
8586
@node.run_list params[:for_node]
8687
@run_list = @node.run_list
87-
@_message = { :error => $! }
88+
@_message = { :error => "Exception raised creating node, please check logs for details" }
8889
render :new
8990
end
9091
end
@@ -102,11 +103,13 @@ def update
102103
@node.save
103104
@_message = { :notice => "Updated Node" }
104105
render :show
105-
rescue
106+
rescue Exception => e
107+
Chef::Log.error("Exception updating node: #{e.message}")
106108
@available_recipes = get_available_recipes
107109
@available_roles = Chef::Role.list.keys.sort
108110
@run_list = Chef::RunList.new
109111
@run_list.reset(params[:for_node])
112+
@_message = { :error => "Exception raised updating node, please check logs for details" }
110113
render :edit
111114
end
112115
end
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
- throw_content :header_content do
2+
= css_include_tag "jsonedit_main.css"
3+
= js_include_tag "json.js"
4+
= js_include_tag "yetii-min.js"
5+
%script{:type=>"text/javascript", :src => "/javascripts/jsonedit_main.js"}
6+
7+
%script= "$(document).ready(function() { $$(\"jsonstr\").value = JSON.stringify(#{json}); if (BCJTEP.build()) { $$(\"results\").innerHTML = \" \"; $$(\"editortab\").className = \"show\"; $$(\"searchtab\").className = \"show\"; }});"
8+
%div#jsoneditor
9+
%div#treecontainer
10+
%div#div1
11+
%div#tabcontainer
12+
%div#tab-container-1.tablayout
13+
%ul#tab-container-1-nav.tablayout
14+
%li#searchtab.noshow
15+
%a{ :href => "#tab1"} search
16+
%li#editortab.noshow
17+
%a{ :href => "#tab2"} editor
18+
%li#sourcetab
19+
%a{ :href => "#tab3"} source
20+
%div#tab1.tab
21+
%table.icanhastable
22+
%tr
23+
%td
24+
%span search :
25+
%input#keyword{:type => "text"}
26+
%input#search{:type => "button", :value => "Find"}
27+
%tr
28+
%td
29+
%div#results  
30+
%div#tab2.tab
31+
%table.icanhastable
32+
%tr
33+
%td
34+
%div#add.button{:title => "Add a new attribute"}
35+
%div#delete.button{:title => "Delete current attribute"}
36+
%div#savedstatus{:style => "display:none;"}
37+
%img{ :src=> "/images/jsonedit/saved.png"}
38+
%span Saved!
39+
%div#deletedstatus{:style => "display:none;"}
40+
%img{ :src=> "/images/jsonedit/deleted.png"}
41+
%span Deleted!
42+
%td
43+
type :
44+
%select#jsontypes
45+
%option Select Type
46+
%tr
47+
%td{:colspan => "2"}
48+
%div#jsonnameinput
49+
name :
50+
%input#jsonname{:type => "text", :size=>"55", :class => ""}
51+
%tr
52+
%td{:colspan => "2"}
53+
%textarea#jsonvalue{:wrap => "virtual", :cols => "55", :rows => "5", :class => ""}
54+
%tr
55+
%td{:colspan => "2"}
56+
%div#jsonpath  
57+
%div#jsonmode  
58+
%tr
59+
%td{:style => "text-align:left !important"}
60+
%input#autodetect{:type => "checkbox", :checked=> "true"}
61+
%label{:for => "autodetect"} Autodetect type of attribute?
62+
%td
63+
%input#savebutton{:type => "button", :value => "Save Attribute"}
64+
%input#addbutton{:type => "button", :value => "Add Attribute"}
65+
%div#tab3.tab
66+
%div#tab-container-2.tablayout.nested
67+
%ul#tab-container-2-nav.tablayout
68+
%li
69+
%a{ :href => "#tab3a" } json
70+
%div#tab1a.tabn
71+
%table.icanhastable
72+
%tr
73+
%td
74+
%div#refresh.button{:title => "Reload JSON from Tree"}
75+
%div#buildbutton.button{:title => "Load JSON from Source"}
76+
%tr
77+
%td
78+
%textarea#jsonstr{:wrap => "virtual", :cols => "55", :rows => "10", :class => ""}
79+
%div#console
80+
%div#bar
81+
%a#consolebar Error Console
82+
%div#log

‎chef-server-webui/app/views/layout/chef_server_webui.html.haml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
%head
55
%meta{ "http-equiv" => "content-type", :content => "text/html; charset=utf-8" }
66
%title Chef Server
7-
= css_include_tag "base", "themes/djime-cerulean/style", "chef", "/facebox/facebox.css", "jquery-ui-1.7.1.custom", "jquery.treeTable"
7+
= css_include_tag "base", "themes/djime-cerulean/style", "chef", "/facebox/facebox.css", "jquery-ui-1.7.1.custom", "jquery.treeTable", "jsonedit_main.css"
88
= js_include_tag "jquery-1.3.2.min", "jquery.jeditable.mini", "jquery.livequery", "jquery.localscroll", "jquery.scrollTo", "jquery.tools.min"
99
= js_include_tag "/facebox/facebox.js"
1010
= js_include_tag "jquery-ui-1.7.1.custom.min"
1111
= js_include_tag "jquery.treeTable.min"
12-
= js_include_tag "JSONeditor"
1312
= js_include_tag "chef"
13+
14+
= catch_content :header_content
1415
1516
%body
1617
#container

‎chef-server-webui/app/views/nodes/_form.html.haml‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,10 @@
4040
%li{ :id => "recipe[#{recipe}]", :class => 'ui-state-default' }= h recipe
4141

4242

43-
%div.group.form
43+
%div.group.form{:style => "position:relative;"}
4444
%label.label Attributes
45-
%div.editor
46-
%div#tree
47-
%div#jform
48-
%div.clear
49-
%script= "$(document).ready(function() { JSONeditor.start('tree', 'jform', #{@node.attribute.to_json}, false); });"
45+
= partial '../layout/jsonedit', :json =>@node.attribute.to_json
46+
%div.group.form
5047
%span.description A JSON hash for default attributes for nodes of this node. These attributes will only be applied if the node does not already have a value for the attributes.
5148

5249
= form(:action => form_url, :method => :post, :id => form_id, :class => 'form') do

‎chef-server-webui/app/views/roles/_form.html.haml‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,9 @@
3434
Drag recipes from the list of Available Recipes section on the left, and drop them
3535
in the "Recipes for this Role" section on the right. Then sort the recipes for this role list to the order you would like to see the recipes applied.
3636

37-
%div.group.form
37+
%div.group.form{:style => "position:relative;"}
3838
%label.label Default and Override Attributes
39-
%div.editor
40-
%div#tree
41-
%div#jform
42-
%div.clear
43-
%script= "$(document).ready(function() { JSONeditor.start('tree', 'jform', #{ { :defaults => @role.default_attributes, :overrides => @role.override_attributes }.to_json }, false); });"
39+
= partial '../layout/jsonedit', :json => { :defaults => @role.default_attributes, :overrides => @role.override_attributes }.to_json
4440
%span.description A JSON hash for default attributes for nodes of this role. These attributes will only be applied if the node does not already have a value for the attributes.
4541
= form(:action => form_url, :method => :post, :id => form_id, :class => 'form') do
4642
%div.group
643 Bytes
Loading
749 Bytes
Loading

0 commit comments

Comments
 (0)