chef-server-api 0.9.8 → 0.9.10.rc.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/app/controllers/cookbooks.rb +9 -7
- data/app/controllers/nodes.rb +6 -1
- data/app/controllers/sandboxes.rb +6 -14
- data/app/helpers/tarball_helper.rb +0 -8
- data/app/models/sandbox_file.rb +2 -2
- data/bin/chef-server +10 -1
- data/config/router.rb +3 -1
- data/lib/chef-server-api/version.rb +1 -1
- metadata +20 -9
data/Rakefile
CHANGED
@@ -48,13 +48,11 @@ class Cookbooks < Application
|
|
48
48
|
display response
|
49
49
|
end
|
50
50
|
|
51
|
-
#FIXME: this is different from the rest of the API, but in a useful way...
|
52
51
|
def index_latest
|
53
52
|
cookbook_list = Chef::CookbookVersion.cdb_list_latest(true)
|
54
|
-
response =
|
55
|
-
|
56
|
-
|
57
|
-
:cookbook_name => cookbook_name, :cookbook_version=>cookbook_version}
|
53
|
+
response = cookbook_list.inject({}) do |res, cv|
|
54
|
+
res[cv.name] = absolute_url(:cookbook_version, :cookbook_name => cv.name, :cookbook_version => cv.version)
|
55
|
+
res
|
58
56
|
end
|
59
57
|
display response
|
60
58
|
end
|
@@ -86,7 +84,7 @@ class Cookbooks < Application
|
|
86
84
|
checksum = params[:checksum]
|
87
85
|
raise NotFound, "Cookbook #{cookbook_name} version #{cookbook_version} does not contain a file with checksum #{checksum}" unless cookbook.checksums.keys.include?(checksum)
|
88
86
|
|
89
|
-
filename =
|
87
|
+
filename = Chef::Checksum.new(checksum).file_location
|
90
88
|
raise InternalServerError, "File with checksum #{checksum} not found in the repository (this should not happen)" unless File.exists?(filename)
|
91
89
|
|
92
90
|
send_file(filename)
|
@@ -140,7 +138,11 @@ class Cookbooks < Application
|
|
140
138
|
raise NotFound, "Cannot find a cookbook named #{cookbook_name} with version #{cookbook_version}"
|
141
139
|
end
|
142
140
|
|
143
|
-
|
141
|
+
if params["purge"] == "true"
|
142
|
+
display cookbook.purge
|
143
|
+
else
|
144
|
+
display cookbook.cdb_destroy
|
145
|
+
end
|
144
146
|
end
|
145
147
|
|
146
148
|
private
|
data/app/controllers/nodes.rb
CHANGED
@@ -97,7 +97,12 @@ class Nodes < Application
|
|
97
97
|
private
|
98
98
|
|
99
99
|
def load_all_files(node_name)
|
100
|
-
all_cookbooks = Chef::CookbookVersion.cdb_list(true).inject({})
|
100
|
+
all_cookbooks = Chef::CookbookVersion.cdb_list(true).inject({}) do |res, cookbook|
|
101
|
+
version = Gem::Version.new cookbook.version
|
102
|
+
newest_version = res.has_key?(cookbook.name) ? version > Gem::Version.new(res[cookbook.name].version) : true
|
103
|
+
res[cookbook.name] = cookbook if newest_version
|
104
|
+
res
|
105
|
+
end
|
101
106
|
|
102
107
|
included_cookbooks = cookbooks_for_node(node_name, all_cookbooks)
|
103
108
|
nodes_cookbooks = Hash.new
|
@@ -125,21 +125,13 @@ class Sandboxes < Application
|
|
125
125
|
# we will undo the successful steps that came before it
|
126
126
|
begin
|
127
127
|
undo_steps = Array.new
|
128
|
-
existing_sandbox.checksums.each do |
|
129
|
-
checksum_filename_in_sandbox = sandbox_checksum_location(existing_sandbox.guid,
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
Chef::Log.info("sandbox finalization: move #{checksum_filename_in_sandbox} to #{checksum_filename_final}")
|
134
|
-
File.rename(checksum_filename_in_sandbox, checksum_filename_final)
|
135
|
-
|
136
|
-
# mark the checksum as successfully updated
|
137
|
-
Chef::Checksum.new(checksum).cdb_save
|
128
|
+
existing_sandbox.checksums.each do |file_checksum|
|
129
|
+
checksum_filename_in_sandbox = sandbox_checksum_location(existing_sandbox.guid, file_checksum)
|
130
|
+
checksum = Chef::Checksum.new(file_checksum)
|
131
|
+
|
132
|
+
checksum.commit_sandbox_file(checksum_filename_in_sandbox)
|
138
133
|
|
139
|
-
undo_steps << proc {
|
140
|
-
Chef::Log.warn("sandbox finalization undo: moving #{checksum_filename_final} back to #{checksum_filename_in_sandbox}")
|
141
|
-
File.rename(checksum_filename_final, checksum_filename_in_sandbox)
|
142
|
-
}
|
134
|
+
undo_steps << proc { checksum.revert_sandbox_file_commit }
|
143
135
|
end
|
144
136
|
rescue
|
145
137
|
# undo the successful moves we did before
|
@@ -42,14 +42,6 @@ module Merb
|
|
42
42
|
File.join(sandbox_location(sandbox_guid), checksum)
|
43
43
|
end
|
44
44
|
|
45
|
-
def checksum_base
|
46
|
-
Chef::Config.checksum_path
|
47
|
-
end
|
48
|
-
|
49
|
-
def checksum_location(checksum)
|
50
|
-
File.join(checksum_base, checksum[0..1], checksum)
|
51
|
-
end
|
52
|
-
|
53
45
|
def cookbook_base
|
54
46
|
[Chef::Config.cookbook_path].flatten.first
|
55
47
|
end
|
data/app/models/sandbox_file.rb
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
require 'chef/sandbox'
|
20
20
|
require 'chef/exceptions'
|
21
|
-
require 'chef/
|
21
|
+
require 'chef/checksum_cache'
|
22
22
|
|
23
23
|
module ChefServerApi
|
24
24
|
class SandboxFile
|
@@ -57,7 +57,7 @@ module ChefServerApi
|
|
57
57
|
def actual_checksum
|
58
58
|
@actual_checksum ||= begin
|
59
59
|
@input.rewind
|
60
|
-
Chef::
|
60
|
+
Chef::ChecksumCache.instance.generate_md5_checksum(@input)
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
data/bin/chef-server
CHANGED
@@ -79,4 +79,13 @@ end
|
|
79
79
|
Chef::Log.init(Chef::Config[:log_location])
|
80
80
|
Chef::Log.level = Chef::Config[:log_level]
|
81
81
|
|
82
|
-
|
82
|
+
begin
|
83
|
+
Merb.start
|
84
|
+
rescue RuntimeError => e
|
85
|
+
if e.message =~ /no acceptor/
|
86
|
+
Chef::Log.fatal("Another process is already listening on port #{Merb::Config[:port]}. Is chef-server already running?")
|
87
|
+
exit 127
|
88
|
+
else
|
89
|
+
raise
|
90
|
+
end
|
91
|
+
end
|
data/config/router.rb
CHANGED
@@ -50,6 +50,8 @@ Merb::Router.prepare do
|
|
50
50
|
:method => 'get'
|
51
51
|
).to(:controller => "cookbooks", :action => "index")
|
52
52
|
|
53
|
+
match("/cookbooks/_latest", :method=>'get').to(:controller=>'cookbooks',:action=>'index_latest')
|
54
|
+
|
53
55
|
match("/cookbooks/_recipes", :method=>'get').to(:controller=>'cookbooks',:action=>'index_recipes')
|
54
56
|
|
55
57
|
match("/cookbooks/:cookbook_name/:cookbook_version",
|
@@ -62,7 +64,7 @@ Merb::Router.prepare do
|
|
62
64
|
:method => 'get',
|
63
65
|
:cookbook_name => /[\w\.]+/,
|
64
66
|
:cookbook_version => /(\d+\.\d+\.\d+|_latest)/
|
65
|
-
).to(:controller => "cookbooks", :action => "show")
|
67
|
+
).to(:controller => "cookbooks", :action => "show").name(:cookbook_version)
|
66
68
|
|
67
69
|
match("/cookbooks/:cookbook_name/:cookbook_version",
|
68
70
|
:method => 'delete',
|
metadata
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-server-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: true
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
-
|
9
|
-
|
8
|
+
- 10
|
9
|
+
- rc
|
10
|
+
- 0
|
11
|
+
version: 0.9.10.rc.0
|
10
12
|
platform: ruby
|
11
13
|
authors:
|
12
14
|
- Opscode
|
@@ -14,7 +16,7 @@ autorequire:
|
|
14
16
|
bindir: bin
|
15
17
|
cert_chain: []
|
16
18
|
|
17
|
-
date: 2010-
|
19
|
+
date: 2010-10-07 00:00:00 -07:00
|
18
20
|
default_executable:
|
19
21
|
dependencies:
|
20
22
|
- !ruby/object:Gem::Dependency
|
@@ -97,13 +99,20 @@ dependencies:
|
|
97
99
|
requirement: &id006 !ruby/object:Gem::Requirement
|
98
100
|
none: false
|
99
101
|
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
segments:
|
105
|
+
- 1
|
106
|
+
- 4
|
107
|
+
- 4
|
108
|
+
version: 1.4.4
|
100
109
|
- - <=
|
101
110
|
- !ruby/object:Gem::Version
|
102
111
|
segments:
|
103
112
|
- 1
|
104
113
|
- 4
|
105
|
-
-
|
106
|
-
version: 1.4.
|
114
|
+
- 6
|
115
|
+
version: 1.4.6
|
107
116
|
type: :runtime
|
108
117
|
prerelease: false
|
109
118
|
version_requirements: *id006
|
@@ -216,11 +225,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
217
226
|
none: false
|
218
227
|
requirements:
|
219
|
-
- - "
|
228
|
+
- - ">"
|
220
229
|
- !ruby/object:Gem::Version
|
221
230
|
segments:
|
222
|
-
-
|
223
|
-
|
231
|
+
- 1
|
232
|
+
- 3
|
233
|
+
- 1
|
234
|
+
version: 1.3.1
|
224
235
|
requirements: []
|
225
236
|
|
226
237
|
rubyforge_project:
|