chef-server-slice 0.7.10
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +201 -0
- data/README.rdoc +135 -0
- data/app/controllers/application.rb +228 -0
- data/app/controllers/cookbook_attributes.rb +59 -0
- data/app/controllers/cookbook_definitions.rb +60 -0
- data/app/controllers/cookbook_files.rb +94 -0
- data/app/controllers/cookbook_libraries.rb +60 -0
- data/app/controllers/cookbook_recipes.rb +59 -0
- data/app/controllers/cookbook_templates.rb +80 -0
- data/app/controllers/cookbooks.rb +63 -0
- data/app/controllers/exceptions.rb +33 -0
- data/app/controllers/main.rb +7 -0
- data/app/controllers/nodes.rb +144 -0
- data/app/controllers/openid_consumer.rb +133 -0
- data/app/controllers/openid_register.rb +113 -0
- data/app/controllers/openid_server.rb +252 -0
- data/app/controllers/roles.rb +138 -0
- data/app/controllers/search.rb +58 -0
- data/app/controllers/search_entries.rb +73 -0
- data/app/controllers/status.rb +34 -0
- data/app/helpers/application_helper.rb +144 -0
- data/app/helpers/cookbook_attributes_helper.rb +7 -0
- data/app/helpers/cookbook_definitions_helper.rb +8 -0
- data/app/helpers/cookbook_files_helper.rb +8 -0
- data/app/helpers/cookbook_libraries_helper.rb +7 -0
- data/app/helpers/cookbook_recipes_helper.rb +8 -0
- data/app/helpers/cookbook_templates_helper.rb +8 -0
- data/app/helpers/cookbooks_helper.rb +31 -0
- data/app/helpers/exceptions_helper.rb +6 -0
- data/app/helpers/global_helpers.rb +39 -0
- data/app/helpers/nodes_helper.rb +33 -0
- data/app/helpers/openid_consumer_helper.rb +8 -0
- data/app/helpers/openid_register_helper.rb +8 -0
- data/app/helpers/openid_server_helper.rb +6 -0
- data/app/helpers/openid_server_helpers.rb +29 -0
- data/app/helpers/roles_helper.rb +5 -0
- data/app/helpers/search_entries_helper.rb +8 -0
- data/app/helpers/search_helper.rb +38 -0
- data/app/helpers/status_helper.rb +26 -0
- data/app/views/cookbook_templates/index.html.haml +7 -0
- data/app/views/cookbooks/index.html.haml +10 -0
- data/app/views/cookbooks/show.html.haml +40 -0
- data/app/views/exceptions/bad_request.json.erb +1 -0
- data/app/views/exceptions/internal_server_error.html.erb +216 -0
- data/app/views/exceptions/not_acceptable.html.erb +63 -0
- data/app/views/exceptions/not_found.html.erb +47 -0
- data/app/views/exceptions/standard_error.html.erb +217 -0
- data/app/views/layout/chef_server_slice.html.haml +53 -0
- data/app/views/layout/login.html.haml +37 -0
- data/app/views/main/index.html.erb +1 -0
- data/app/views/nodes/_action.html.haml +13 -0
- data/app/views/nodes/_form.html.haml +56 -0
- data/app/views/nodes/_navigation.html.haml +9 -0
- data/app/views/nodes/_resource.html.haml +22 -0
- data/app/views/nodes/edit.html.haml +7 -0
- data/app/views/nodes/index.html.haml +25 -0
- data/app/views/nodes/new.html.haml +6 -0
- data/app/views/nodes/show.html.haml +60 -0
- data/app/views/openid_consumer/index.html.haml +23 -0
- data/app/views/openid_consumer/start.html.haml +4 -0
- data/app/views/openid_login/index.html.haml +5 -0
- data/app/views/openid_register/index.html.haml +19 -0
- data/app/views/openid_register/show.html.haml +7 -0
- data/app/views/openid_server/decide.html.haml +27 -0
- data/app/views/roles/_form.html.haml +48 -0
- data/app/views/roles/_navigation.html.haml +9 -0
- data/app/views/roles/edit.html.haml +6 -0
- data/app/views/roles/index.html.haml +22 -0
- data/app/views/roles/new.html.haml +6 -0
- data/app/views/roles/show.html.haml +29 -0
- data/app/views/search/_search_form.html.haml +6 -0
- data/app/views/search/index.html.haml +9 -0
- data/app/views/search/show.html.haml +14 -0
- data/app/views/search_entries/index.html.haml +8 -0
- data/app/views/search_entries/show.html.haml +7 -0
- data/app/views/status/index.html.haml +88 -0
- data/config/init.rb +48 -0
- data/config/router.rb +6 -0
- data/lib/chef-server-slice.rb +150 -0
- data/lib/chef-server-slice/merbtasks.rb +103 -0
- data/lib/chef-server-slice/slicetasks.rb +20 -0
- data/lib/chef-server-slice/spectasks.rb +53 -0
- data/public/facebox/README.txt +4 -0
- data/public/facebox/b.png +0 -0
- data/public/facebox/bl.png +0 -0
- data/public/facebox/br.png +0 -0
- data/public/facebox/closelabel.gif +0 -0
- data/public/facebox/facebox.css +95 -0
- data/public/facebox/facebox.js +319 -0
- data/public/facebox/loading.gif +0 -0
- data/public/facebox/tl.png +0 -0
- data/public/facebox/tr.png +0 -0
- data/public/images/avatar.png +0 -0
- data/public/images/black_big.png +0 -0
- data/public/images/indicator.gif +0 -0
- data/public/images/merb.jpg +0 -0
- data/public/images/toggle-collapse-dark.png +0 -0
- data/public/images/toggle-collapse-light.png +0 -0
- data/public/images/toggle-collapse.gif +0 -0
- data/public/images/toggle-expand-dark.png +0 -0
- data/public/images/toggle-expand-light.png +0 -0
- data/public/images/toggle-expand.gif +0 -0
- data/public/images/treeBuilderImages/Thumbs.db +0 -0
- data/public/images/treeBuilderImages/doc.gif +0 -0
- data/public/images/treeBuilderImages/docNode.gif +0 -0
- data/public/images/treeBuilderImages/docNodeLast.gif +0 -0
- data/public/images/treeBuilderImages/docNodeLastFirst.gif +0 -0
- data/public/images/treeBuilderImages/folder.gif +0 -0
- data/public/images/treeBuilderImages/folderNode.gif +0 -0
- data/public/images/treeBuilderImages/folderNodeFirst.gif +0 -0
- data/public/images/treeBuilderImages/folderNodeLast.gif +0 -0
- data/public/images/treeBuilderImages/folderNodeLastFirst.gif +0 -0
- data/public/images/treeBuilderImages/folderNodeOpen.gif +0 -0
- data/public/images/treeBuilderImages/folderNodeOpenFirst.gif +0 -0
- data/public/images/treeBuilderImages/folderNodeOpenLast.gif +0 -0
- data/public/images/treeBuilderImages/folderNodeOpenLastFirst.gif +0 -0
- data/public/images/treeBuilderImages/folderOpen.gif +0 -0
- data/public/images/treeBuilderImages/vertLine.gif +0 -0
- data/public/javascripts/JSONeditor.js +1171 -0
- data/public/javascripts/chef.js +126 -0
- data/public/javascripts/jquery-1.3.2.min.js +19 -0
- data/public/javascripts/jquery-ui-1.7.1.custom.min.js +65 -0
- data/public/javascripts/jquery.editinline.js +108 -0
- data/public/javascripts/jquery.jeditable.mini.js +30 -0
- data/public/javascripts/jquery.livequery.js +250 -0
- data/public/javascripts/jquery.localscroll.js +104 -0
- data/public/javascripts/jquery.scrollTo.js +150 -0
- data/public/javascripts/jquery.tools.min.js +17 -0
- data/public/javascripts/jquery.treeTable.min.js +165 -0
- data/public/stylesheets/base.css +336 -0
- data/public/stylesheets/chef.css +157 -0
- data/public/stylesheets/images/ui-bg_diagonals-small_0_aaaaaa_40x40.png +0 -0
- data/public/stylesheets/images/ui-bg_diagonals-thick_15_444444_40x40.png +0 -0
- data/public/stylesheets/images/ui-bg_glass_100_f0f0f0_1x400.png +0 -0
- data/public/stylesheets/images/ui-bg_glass_50_99c2ff_1x400.png +0 -0
- data/public/stylesheets/images/ui-bg_glass_55_fbf5d0_1x400.png +0 -0
- data/public/stylesheets/images/ui-bg_glass_80_e6e6e6_1x400.png +0 -0
- data/public/stylesheets/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/public/stylesheets/images/ui-bg_highlight-hard_100_f9f9f9_1x100.png +0 -0
- data/public/stylesheets/images/ui-bg_highlight-soft_100_e7eef3_1x100.png +0 -0
- data/public/stylesheets/images/ui-icons_222222_256x240.png +0 -0
- data/public/stylesheets/images/ui-icons_2694e8_256x240.png +0 -0
- data/public/stylesheets/images/ui-icons_2e83ff_256x240.png +0 -0
- data/public/stylesheets/images/ui-icons_72a7cf_256x240.png +0 -0
- data/public/stylesheets/images/ui-icons_888888_256x240.png +0 -0
- data/public/stylesheets/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/public/stylesheets/images/ui-icons_ffffff_256x240.png +0 -0
- data/public/stylesheets/jquery-ui-1.7.1.custom.css +404 -0
- data/public/stylesheets/jquery.treeTable.css +43 -0
- data/public/stylesheets/themes/bec-green/style.css +290 -0
- data/public/stylesheets/themes/bec/style.css +301 -0
- data/public/stylesheets/themes/blue/style.css +280 -0
- data/public/stylesheets/themes/default/style.css +267 -0
- data/public/stylesheets/themes/djime-cerulean/style.css +298 -0
- data/public/stylesheets/themes/kathleene/style.css +272 -0
- data/public/stylesheets/themes/orange/style.css +263 -0
- data/public/stylesheets/themes/reidb-greenish/style.css +301 -0
- metadata +341 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Brown (<cb@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'chef' / 'mixin' / 'checksum'
|
21
|
+
|
22
|
+
class ChefServerSlice::CookbookAttributes < ChefServerSlice::Application
|
23
|
+
|
24
|
+
provides :html, :json
|
25
|
+
|
26
|
+
before :login_required
|
27
|
+
|
28
|
+
include Chef::Mixin::Checksum
|
29
|
+
|
30
|
+
def load_cookbook_attributes()
|
31
|
+
@attribute_files = load_cookbook_segment(params[:cookbook_id], :attributes)
|
32
|
+
end
|
33
|
+
|
34
|
+
def index
|
35
|
+
if params[:id]
|
36
|
+
show
|
37
|
+
else
|
38
|
+
load_cookbook_attributes()
|
39
|
+
display @attribute_files
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def show
|
44
|
+
only_provides :json
|
45
|
+
load_cookbook_attributes
|
46
|
+
raise NotFound, "Cannot find a suitable attribute file!" unless @attribute_files.has_key?(params[:id])
|
47
|
+
to_send = @attribute_files[params[:id]][:file]
|
48
|
+
current_checksum = checksum(to_send)
|
49
|
+
Chef::Log.debug("old sum: #{params[:checksum]}, new sum: #{current_checksum}")
|
50
|
+
if current_checksum == params[:checksum]
|
51
|
+
display "File #{to_send} has not changed", :status => 304
|
52
|
+
else
|
53
|
+
send_file(to_send)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Brown (<cb@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'chef' / 'mixin' / 'checksum'
|
21
|
+
|
22
|
+
class ChefServerSlice::CookbookDefinitions < ChefServerSlice::Application
|
23
|
+
|
24
|
+
provides :html, :json
|
25
|
+
|
26
|
+
before :login_required
|
27
|
+
|
28
|
+
include Chef::Mixin::Checksum
|
29
|
+
|
30
|
+
def load_cookbook_definitions()
|
31
|
+
@definition_files = load_cookbook_segment(params[:cookbook_id], :definitions)
|
32
|
+
end
|
33
|
+
|
34
|
+
def index
|
35
|
+
if params[:id]
|
36
|
+
show
|
37
|
+
else
|
38
|
+
load_cookbook_definitions()
|
39
|
+
display @definition_files
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def show
|
44
|
+
only_provides :json
|
45
|
+
load_cookbook_definitions
|
46
|
+
raise NotFound, "Cannot find a suitable definition file!" unless @definition_files.has_key?(params[:id])
|
47
|
+
|
48
|
+
to_send = @definition_files[params[:id]][:file]
|
49
|
+
current_checksum = checksum(to_send)
|
50
|
+
Chef::Log.debug("Old sum: #{params[:checksum]}, New sum: #{current_checksum}")
|
51
|
+
if current_checksum == params[:checksum]
|
52
|
+
display "File #{to_send} has not changed", :status => 304
|
53
|
+
else
|
54
|
+
send_file(to_send)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Brown (<cb@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'chef' / 'mixin' / 'checksum'
|
21
|
+
require 'chef' / 'cookbook_loader'
|
22
|
+
require 'chef' / 'mixin' / 'find_preferred_file'
|
23
|
+
|
24
|
+
class ChefServerSlice::CookbookFiles < ChefServerSlice::Application
|
25
|
+
|
26
|
+
provides :html, :json
|
27
|
+
before :login_required
|
28
|
+
|
29
|
+
include Chef::Mixin::Checksum
|
30
|
+
include Chef::Mixin::FindPreferredFile
|
31
|
+
|
32
|
+
layout nil
|
33
|
+
|
34
|
+
def index
|
35
|
+
if params[:id]
|
36
|
+
if params[:recursive] == "true"
|
37
|
+
show_directory
|
38
|
+
else
|
39
|
+
show
|
40
|
+
end
|
41
|
+
else
|
42
|
+
@remote_files = load_cookbook_files(params[:cookbook_id], :remote_file)
|
43
|
+
display @remote_files
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def show
|
48
|
+
only_provides :json
|
49
|
+
begin
|
50
|
+
to_send = find_preferred_file(
|
51
|
+
params[:cookbook_id],
|
52
|
+
:remote_file,
|
53
|
+
params[:id],
|
54
|
+
params[:fqdn],
|
55
|
+
params[:platform],
|
56
|
+
params[:version]
|
57
|
+
)
|
58
|
+
rescue Chef::Exceptions::FileNotFound
|
59
|
+
raise NotFound, "Cannot find a suitable file!"
|
60
|
+
end
|
61
|
+
|
62
|
+
current_checksum = checksum(to_send)
|
63
|
+
Chef::Log.debug("old sum: #{params[:checksum]}, new sum: #{current_checksum}")
|
64
|
+
if current_checksum == params[:checksum]
|
65
|
+
render "File #{to_send} has not changed", :status => 304
|
66
|
+
else
|
67
|
+
send_file(to_send)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def show_directory
|
72
|
+
dir_to_send = find_preferred_file(
|
73
|
+
params[:cookbook_id],
|
74
|
+
:remote_file,
|
75
|
+
params[:id],
|
76
|
+
params[:fqdn],
|
77
|
+
params[:platform],
|
78
|
+
params[:version]
|
79
|
+
)
|
80
|
+
unless (dir_to_send && File.directory?(dir_to_send))
|
81
|
+
raise NotFound, "Cannot find a suitable directory"
|
82
|
+
end
|
83
|
+
|
84
|
+
@directory_listing = Array.new
|
85
|
+
Dir[::File.join(dir_to_send, '**', '*')].sort { |a,b| b <=> a }.each do |file_to_send|
|
86
|
+
next if File.directory?(file_to_send)
|
87
|
+
file_to_send =~ /^#{dir_to_send}\/(.+)$/
|
88
|
+
@directory_listing << $1
|
89
|
+
end
|
90
|
+
|
91
|
+
display @directory_listing
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Brown (<cb@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'chef' / 'mixin' / 'checksum'
|
21
|
+
require 'chef' / 'cookbook_loader'
|
22
|
+
|
23
|
+
class ChefServerSlice::CookbookLibraries < ChefServerSlice::Application
|
24
|
+
|
25
|
+
provides :html, :json
|
26
|
+
before :login_required
|
27
|
+
|
28
|
+
include Chef::Mixin::Checksum
|
29
|
+
|
30
|
+
def load_cookbook_libs()
|
31
|
+
@lib_files = load_cookbook_segment(params[:cookbook_id], :libraries)
|
32
|
+
end
|
33
|
+
|
34
|
+
def index
|
35
|
+
if params[:id]
|
36
|
+
show
|
37
|
+
else
|
38
|
+
load_cookbook_libs()
|
39
|
+
display @lib_files
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def show
|
44
|
+
only_provides :json
|
45
|
+
load_cookbook_libs
|
46
|
+
raise NotFound, "Cannot find a suitable library file!" unless @lib_files.has_key?(params[:id])
|
47
|
+
|
48
|
+
to_send = @lib_files[params[:id]][:file]
|
49
|
+
current_checksum = checksum(to_send)
|
50
|
+
Chef::Log.debug("Old sum: #{params[:checksum]}, New sum: #{current_checksum}")
|
51
|
+
if current_checksum == params[:checksum]
|
52
|
+
display "File #{to_send} has not changed", :status => 304
|
53
|
+
else
|
54
|
+
send_file(to_send)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Brown (<cb@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'chef' / 'mixin' / 'checksum'
|
21
|
+
|
22
|
+
class ChefServerSlice::CookbookRecipes < ChefServerSlice::Application
|
23
|
+
|
24
|
+
provides :html, :json
|
25
|
+
before :login_required
|
26
|
+
|
27
|
+
include Chef::Mixin::Checksum
|
28
|
+
|
29
|
+
def load_cookbook_recipes()
|
30
|
+
@recipe_files = load_cookbook_segment(params[:cookbook_id], :recipes)
|
31
|
+
end
|
32
|
+
|
33
|
+
def index
|
34
|
+
if params[:id]
|
35
|
+
show
|
36
|
+
else
|
37
|
+
load_cookbook_recipes()
|
38
|
+
display @recipe_files
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def show
|
43
|
+
only_provides :json
|
44
|
+
load_cookbook_recipes
|
45
|
+
raise NotFound, "Cannot find a suitable recipe file!" unless @recipe_files.has_key?(params[:id])
|
46
|
+
|
47
|
+
to_send = @recipe_files[params[:id]][:file]
|
48
|
+
current_checksum = checksum(to_send)
|
49
|
+
Chef::Log.debug("old sum: #{params[:checksum]}, new sum: #{current_checksum}")
|
50
|
+
if current_checksum == params[:checksum]
|
51
|
+
display "File #{to_send} has not changed", :status => 304
|
52
|
+
else
|
53
|
+
send_file(to_send)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Brown (<cb@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'chef' / 'mixin' / 'checksum'
|
21
|
+
require 'chef' / 'cookbook_loader'
|
22
|
+
require 'chef' / 'mixin' / 'find_preferred_file'
|
23
|
+
|
24
|
+
class ChefServerSlice::CookbookTemplates < ChefServerSlice::Application
|
25
|
+
|
26
|
+
provides :html, :json
|
27
|
+
before :login_required
|
28
|
+
|
29
|
+
include Chef::Mixin::Checksum
|
30
|
+
include Chef::Mixin::FindPreferredFile
|
31
|
+
|
32
|
+
# def load_cookbook_templates()
|
33
|
+
# @cl = Chef::CookbookLoader.new
|
34
|
+
# @cookbook = @cl[params[:cookbook_id]]
|
35
|
+
# raise NotFound unless @cookbook
|
36
|
+
#
|
37
|
+
# @templates = Hash.new
|
38
|
+
# @cookbook.template_files.each do |tf|
|
39
|
+
# full = File.expand_path(tf)
|
40
|
+
# name = File.basename(full)
|
41
|
+
# tf =~ /^.+#{params[:cookbook_id]}[\\|\/]templates[\\|\/](.+?)[\\|\/]#{name}/
|
42
|
+
# singlecopy = $1
|
43
|
+
# @templates[full] = {
|
44
|
+
# :name => name,
|
45
|
+
# :singlecopy => singlecopy,
|
46
|
+
# :file => full,
|
47
|
+
# }
|
48
|
+
# end
|
49
|
+
# @templates
|
50
|
+
# end
|
51
|
+
|
52
|
+
def index
|
53
|
+
if params[:id]
|
54
|
+
show
|
55
|
+
else
|
56
|
+
@templates = load_cookbook_files(params[:cookbook_id], :template)
|
57
|
+
display @templates
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def show
|
62
|
+
to_send = find_preferred_file(
|
63
|
+
params[:cookbook_id],
|
64
|
+
:template,
|
65
|
+
params[:id],
|
66
|
+
params[:fqdn],
|
67
|
+
params[:platform],
|
68
|
+
params[:version]
|
69
|
+
)
|
70
|
+
raise NotFound, "Cannot find a suitable template!" unless to_send
|
71
|
+
current_checksum = checksum(to_send)
|
72
|
+
Chef::Log.debug("old sum: #{params[:checksum]}, new sum: #{current_checksum}")
|
73
|
+
if current_checksum == params[:checksum]
|
74
|
+
render "Template #{to_send} has not changed", :status => 304
|
75
|
+
else
|
76
|
+
send_file(to_send)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#
|
2
|
+
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
+
# Author:: Christopher Brown (<cb@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'chef' / 'cookbook_loader'
|
21
|
+
|
22
|
+
class ChefServerSlice::Cookbooks < ChefServerSlice::Application
|
23
|
+
|
24
|
+
provides :html, :json
|
25
|
+
before :login_required
|
26
|
+
|
27
|
+
def index
|
28
|
+
@cl = Chef::CookbookLoader.new
|
29
|
+
display @cl
|
30
|
+
end
|
31
|
+
|
32
|
+
def show
|
33
|
+
@cl = Chef::CookbookLoader.new
|
34
|
+
@cookbook = @cl[params[:id]]
|
35
|
+
raise NotFound unless @cookbook
|
36
|
+
display @cookbook
|
37
|
+
end
|
38
|
+
|
39
|
+
def recipe_files
|
40
|
+
node = params.has_key?('node') ? params[:node] : nil
|
41
|
+
@recipe_files = load_all_files(:recipes, node)
|
42
|
+
display @recipe_files
|
43
|
+
end
|
44
|
+
|
45
|
+
def attribute_files
|
46
|
+
node = params.has_key?('node') ? params[:node] : nil
|
47
|
+
@attribute_files = load_all_files(:attributes, node)
|
48
|
+
display @attribute_files
|
49
|
+
end
|
50
|
+
|
51
|
+
def definition_files
|
52
|
+
node = params.has_key?('node') ? params[:node] : nil
|
53
|
+
@definition_files = load_all_files(:definitions, node)
|
54
|
+
display @definition_files
|
55
|
+
end
|
56
|
+
|
57
|
+
def library_files
|
58
|
+
node = params.has_key?('node') ? params[:node] : nil
|
59
|
+
@lib_files = load_all_files(:libraries, node)
|
60
|
+
display @lib_files
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|