summaryrefslogtreecommitdiff
path: root/chef-server-api/app
diff options
context:
space:
mode:
Diffstat (limited to 'chef-server-api/app')
-rw-r--r--chef-server-api/app/controllers/application.rb137
-rw-r--r--chef-server-api/app/controllers/clients.rb118
-rw-r--r--chef-server-api/app/controllers/cookbooks.rb231
-rw-r--r--chef-server-api/app/controllers/data_bags.rb75
-rw-r--r--chef-server-api/app/controllers/data_item.rb108
-rw-r--r--chef-server-api/app/controllers/environments.rb207
-rw-r--r--chef-server-api/app/controllers/exceptions.rb40
-rw-r--r--chef-server-api/app/controllers/main.rb25
-rw-r--r--chef-server-api/app/controllers/nodes.rb115
-rw-r--r--chef-server-api/app/controllers/roles.rb91
-rw-r--r--chef-server-api/app/controllers/sandboxes.rb161
-rw-r--r--chef-server-api/app/controllers/search.rb58
-rw-r--r--chef-server-api/app/controllers/users.rb78
-rw-r--r--chef-server-api/app/helpers/cookbook_version_helper.rb72
-rw-r--r--chef-server-api/app/helpers/tarball_helper.rb100
-rw-r--r--chef-server-api/app/models/sandbox_file.rb120
-rw-r--r--chef-server-api/app/views/exceptions/bad_request.json.erb1
-rw-r--r--chef-server-api/app/views/exceptions/internal_server_error.html.erb216
-rw-r--r--chef-server-api/app/views/exceptions/not_acceptable.html.haml5
-rw-r--r--chef-server-api/app/views/exceptions/not_found.html.erb47
-rw-r--r--chef-server-api/app/views/exceptions/standard_error.html.erb217
-rw-r--r--chef-server-api/app/views/layout/application.html.erb49
-rw-r--r--chef-server-api/app/views/main/index.html.erb0
23 files changed, 0 insertions, 2271 deletions
diff --git a/chef-server-api/app/controllers/application.rb b/chef-server-api/app/controllers/application.rb
deleted file mode 100644
index 66e3d760a2..0000000000
--- a/chef-server-api/app/controllers/application.rb
+++ /dev/null
@@ -1,137 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Author:: Christopher Brown (<cb@opscode.com>)
-# Author:: Christopher Walters (<cw@opscode.com>)
-# Author:: Tim Hinderliter (<tim@opscode.com>)
-# Copyright:: Copyright (c) 2008-2010 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require "chef/mixin/checksum"
-require "chef/cookbook_loader"
-require "mixlib/authentication/signatureverification"
-require 'chef/json_compat'
-
-class Application < Merb::Controller
-
- include Chef::Mixin::Checksum
-
- def authenticate_every
- begin
- # Raises an error if required auth headers are missing
- authenticator = Mixlib::Authentication::SignatureVerification.new(request)
-
- username = authenticator.user_id
- Chef::Log.info("Authenticating client #{username}")
-
- user = Chef::ApiClient.cdb_load(username)
- user_key = OpenSSL::PKey::RSA.new(user.public_key)
- Chef::Log.debug "Authenticating Client:\n #{user.inspect}\n"
-
- # Store this for later..
- @auth_user = user
- authenticator.authenticate_request(user_key)
- rescue Mixlib::Authentication::MissingAuthenticationHeader => e
- Chef::Log.debug "Authentication failed: #{e.class.name}: #{e.message}\n#{e.backtrace.join("\n")}"
- raise BadRequest, "#{e.class.name}: #{e.message}"
- rescue StandardError => se
- Chef::Log.debug "Authentication failed: #{se}, #{se.backtrace.join("\n")}"
- raise Unauthorized, "Failed to authenticate. Ensure that your client key is valid."
- end
-
- unless authenticator.valid_request?
- if authenticator.valid_timestamp?
- raise Unauthorized, "Failed to authenticate. Ensure that your client key is valid."
- else
- raise Unauthorized, "Failed to authenticate. Please synchronize the clock on your client"
- end
- end
- true
- end
-
- def is_admin
- if @auth_user.admin
- true
- else
- raise Forbidden, "You are not allowed to take this action."
- end
- end
-
- def is_admin_or_validator
- if @auth_user.admin || @auth_user.name == Chef::Config[:validation_client_name]
- true
- else
- raise Forbidden, "You are not allowed to take this action."
- end
- end
-
- def admin_or_requesting_node
- if @auth_user.admin || @auth_user.name == params[:id]
- true
- else
- raise Forbidden, "You are not the correct node (auth_user name: #{@auth_user.name}, params[:id]: #{params[:id]}), or are not an API administrator (admin: #{@auth_user.admin})."
- end
- end
-
- # Store the URI of the current request in the session.
- #
- # We can return to this location by calling #redirect_back_or_default.
- def store_location
- session[:return_to] = request.uri
- end
-
- # Redirect to the URI stored by the most recent store_location call or
- # to the passed default.
- def redirect_back_or_default(default)
- loc = session[:return_to] || default
- session[:return_to] = nil
- redirect loc
- end
-
- def access_denied
- raise Unauthorized, "You must authenticate first!"
- end
-
- def get_available_recipes
- all_cookbooks_list = Chef::CookbookVersion.cdb_list(true)
- available_recipes = all_cookbooks_list.sort{ |a,b| a.name.to_s <=> b.name.to_s }.inject([]) do |result, element|
- element.recipes.sort.each do |r|
- if r =~ /^(.+)::default$/
- result << $1
- else
- result << r
- end
- end
- result
- end
- available_recipes
- end
-
- # Fix CHEF-1292/PL-538; cause Merb to pass the max nesting constant into
- # obj.to_json, which it calls by default based on the original request's
- # accept headers and the type passed into Merb::Controller.display
- #--
- # TODO: tim, 2010-11-24: would be nice to instead have Merb call
- # Chef::JSONCompat.to_json, instead of obj.to_json, but changing that
- # behavior is convoluted in Merb. This override is assuming that
- # Merb is eventually calling obj.to_json, which takes the :max_nesting
- # option.
- override! :display
- def display(obj)
- super(obj, nil, {:max_nesting => Chef::JSONCompat::JSON_MAX_NESTING})
- end
-
-end
-
diff --git a/chef-server-api/app/controllers/clients.rb b/chef-server-api/app/controllers/clients.rb
deleted file mode 100644
index eafeb15c36..0000000000
--- a/chef-server-api/app/controllers/clients.rb
+++ /dev/null
@@ -1,118 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Author:: Nuo Yan (<nuo@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require 'chef/api_client'
-
-class Clients < Application
- provides :json
-
- before :authenticate_every
- before :is_admin, :only => [ :index, :update ]
- before :is_admin_or_validator, :only => [ :create ]
- before :admin_or_requesting_node, :only => [ :show, :destroy ]
-
- # GET /clients
- def index
- @list = Chef::ApiClient.cdb_list(true)
- display(@list.inject({}) { |result, element| result[element.name] = absolute_url(:client, :id => element.name); result })
- end
-
- # GET /clients/:id
- def show
- begin
- @client = Chef::ApiClient.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load client #{params[:id]}"
- end
- #display({ :name => @client.name, :admin => @client.admin, :public_key => @client.public_key })
- display @client
- end
-
- # POST /clients
- def create
- exists = true
- if params.has_key?(:inflated_object)
- params[:name] ||= params[:inflated_object].name
- params[:admin] ||= params[:inflated_object].admin
- end
-
- # We can only create clients if we're the admin or the validator.
- # But only allow creating admin clients if we're already an admin.
- if params[:admin] == true && @auth_user.admin != true
- raise Forbidden, "You are not allowed to take this action."
- end
-
- begin
- Chef::ApiClient.cdb_load(params[:name])
- rescue Chef::Exceptions::CouchDBNotFound
- exists = false
- end
- raise Conflict, "Client already exists" if exists
-
- @client = Chef::ApiClient.new
- @client.name(params[:name])
- @client.admin(params[:admin]) if params[:admin]
- @client.create_keys
- @client.cdb_save
-
- self.status = 201
- headers['Location'] = absolute_url(:client, @client.name)
- display({ :uri => absolute_url(:client, @client.name), :private_key => @client.private_key })
- end
-
- # PUT /clients/:id
- def update
- if params.has_key?(:inflated_object)
- params[:private_key] ||= params[:inflated_object].private_key
- params[:admin] ||= params[:inflated_object].admin
- end
-
- begin
- @client = Chef::ApiClient.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load client #{params[:id]}"
- end
-
- @client.admin(params[:admin]) unless params[:admin].nil?
-
- results = { :name => @client.name, :admin => @client.admin }
-
- if params[:private_key] == true
- @client.create_keys
- results[:private_key] = @client.private_key
- end
-
- @client.cdb_save
-
- display(results)
- end
-
- # DELETE /clients/:id
- def destroy
- begin
- @client = Chef::ApiClient.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load client #{params[:id]}"
- end
- @client.cdb_destroy
- display({ :name => @client.name })
- end
-
-end
-
diff --git a/chef-server-api/app/controllers/cookbooks.rb b/chef-server-api/app/controllers/cookbooks.rb
deleted file mode 100644
index 7d4993d60a..0000000000
--- a/chef-server-api/app/controllers/cookbooks.rb
+++ /dev/null
@@ -1,231 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Author:: Christopher Brown (<cb@opscode.com>)
-# Author:: Christopher Walters (<cw@opscode.com>)
-# Author:: Tim Hinderliter (<tim@opscode.com>)
-# Copyright:: Copyright (c) 2008, 2009, 2010 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require 'chef/cookbook_loader'
-require 'chef/cookbook/metadata'
-
-class Cookbooks < Application
-
- include Merb::CookbookVersionHelper
-
- provides :json
-
- before :authenticate_every
- before :params_helper
- before :is_admin, :only => [ :update, :destroy ]
-
- attr_accessor :cookbook_name, :cookbook_version
-
- def params_helper
- self.cookbook_name = params[:cookbook_name]
- self.cookbook_version = params[:cookbook_version]
- end
-
- include Chef::Mixin::Checksum
- include Merb::TarballHelper
-
- def index
- if request.env['HTTP_X_CHEF_VERSION'] =~ /0\.9/
- index_09
- else
- index_010
- end
- end
-
- # GET /cookbooks
- # returns data in the format of:
- # {"apache2" => {
- # :url => "http://url",
- # :versions => [{:url => "http://url/1.0.0", :version => "1.0.0"}, {:url => "http://url/0.0.1", :version=>"0.0.1"}]
- # }
- # }
- def index_010
- cookbook_list = Chef::CookbookVersion.cdb_list
- # cookbook_list is in the format of {"apache2" => [0.0.1, 0.0.0]} where the version numbers are DepSelector::Version objects
- num_versions = num_versions!
- display(cookbook_list.inject({}) {|res, (cookbook_name, versions)|
- versions = versions.map{ |x| DepSelector::Version.new(x) }.sort.reverse.map{ |x| x.to_s }
- res[cookbook_name] = expand_cookbook_urls(cookbook_name, versions, num_versions)
- res
- })
- end
-
- # GET /cookbooks
- #
- # returns data in the format of:
- # {
- # "apache2" => "http://url/apache2",
- # "python" => "http://url/python"
- # }
- def index_09
- cookbook_list = Chef::CookbookVersion.cdb_list_latest(false).keys.sort
- response = Hash.new
- cookbook_list.map! do |cookbook_name|
- response[cookbook_name] = absolute_url(:cookbook, :cookbook_name => cookbook_name)
- end
- display response
- end
-
- def index_recipes
- recipes_with_versions = Chef::CookbookVersion.cdb_list(true).inject({}) do|memo, f|
- memo[f.name] ||= {}
- memo[f.name][f.version] = f.recipe_filenames_by_name.keys
- memo
- end
- display recipes_with_versions
- end
-
- def show_versions
- if request.env['HTTP_X_CHEF_VERSION'] =~ /0\.9/
- show_versions_09
- else
- show_versions_010
- end
- end
-
- # GET /cookbooks/:cookbook_name
- #
- # returns data in the format of:
- # {"apache2" => {
- # :url => "http://url",
- # :versions => [{:url => "http://url/1.0.0", :version => "1.0.0"}, {:url => "http://url/0.0.1", :version=>"0.0.1"}]
- # }
- # }
- def show_versions_010
- versions = Chef::CookbookVersion.cdb_by_name(cookbook_name)
- raise NotFound, "Cannot find a cookbook named #{cookbook_name}" unless versions && versions.size > 0
- num_versions = num_versions!("all")
- cb_versions = versions[cookbook_name].map{ |x| DepSelector::Version.new(x) }.sort.reverse.map{ |x| x.to_s }
- display({ cookbook_name => expand_cookbook_urls(cookbook_name, cb_versions, num_versions) })
- end
-
- # GET /cookbooks/:cookbook_name
- #
- # returns data in the format of:
- # {"apache2" => ["1.0.0", "0.0.1"]}
- def show_versions_09
- versions = Chef::CookbookVersion.cdb_by_name(cookbook_name)
- raise NotFound, "Cannot find a cookbook named #{requested_cookbook_name}" unless versions && versions.size > 0
-
- display versions
- end
-
- def show
- cookbook = get_cookbook_version(cookbook_name, cookbook_version)
- display cookbook.generate_manifest_with_urls { |opts| absolute_url(:cookbook_file, opts) }
- end
-
- def show_file
- cookbook = get_cookbook_version(cookbook_name, cookbook_version)
-
- checksum = params[:checksum]
- raise NotFound, "Cookbook #{cookbook_name} version #{cookbook_version} does not contain a file with checksum #{checksum}" unless cookbook.checksums.keys.include?(checksum)
-
- begin
- filename = Chef::Checksum.new(checksum).storage.file_location
-
- send_file(filename)
- rescue Errno::ENOENT => e
- raise InternalServerError, "File with checksum #{checksum} not found in the repository (this should not happen)"
- end
- end
-
- def update
- raise(BadRequest, "You didn't pass me a valid object!") unless params.has_key?('inflated_object')
- raise(BadRequest, "You didn't pass me a Chef::CookbookVersion object!") unless params['inflated_object'].kind_of?(Chef::CookbookVersion)
- unless params["inflated_object"].name == cookbook_name
- raise(BadRequest, "You said the cookbook was named #{params['inflated_object'].name}, but the URL says it should be #{cookbook_name}.")
- end
-
- unless params["inflated_object"].version == cookbook_version
- raise(BadRequest, "You said the cookbook was version #{params['inflated_object'].version}, but the URL says it should be #{cookbook_version}.")
- end
-
- begin
- cookbook = Chef::CookbookVersion.cdb_load(cookbook_name, cookbook_version)
- cookbook.manifest = params['inflated_object'].manifest
- new_cookbook = false
- rescue Chef::Exceptions::CouchDBNotFound => e
- Chef::Log.debug("Cookbook #{cookbook_name} version #{cookbook_version} does not exist")
- cookbook = params['inflated_object']
- new_cookbook = true
- end
-
- unless new_cookbook
- if cookbook.frozen_version? && params[:force].nil?
- raise Conflict, "The cookbook #{cookbook.name} at version #{cookbook.version} is frozen. Use the 'force' option to override."
- end
- end
-
- cookbook.freeze_version if params["inflated_object"].frozen_version?
-
- # ensure that all checksums referred to by the manifest have been uploaded.
- Chef::CookbookVersion::COOKBOOK_SEGMENTS.each do |segment|
- next unless cookbook.manifest[segment]
- cookbook.manifest[segment].each do |manifest_record|
- checksum = manifest_record[:checksum]
- path = manifest_record[:path]
-
- begin
- checksum_obj = Chef::Checksum.cdb_load(checksum)
- rescue Chef::Exceptions::CouchDBNotFound => cdbx
- checksum_obj = nil
- end
-
- raise BadRequest, "Manifest has checksum #{checksum} (path #{path}) but it hasn't yet been uploaded" unless checksum_obj
- end
- end
-
- raise InternalServerError, "Error saving cookbook" unless cookbook.cdb_save
-
- display cookbook
- end
-
- def destroy
- begin
- cookbook = get_cookbook_version(cookbook_name, cookbook_version)
- rescue ArgumentError => e
- raise NotFound, "Cannot find a cookbook named #{cookbook_name} with version #{cookbook_version}"
- end
-
- if params["purge"] == "true"
- display cookbook.purge
- else
- display cookbook.cdb_destroy
- end
- end
-
- private
-
- def get_cookbook_version(name, version)
- Chef::CookbookVersion.cdb_load(name, version)
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot find a cookbook named #{name} with version #{version}"
- rescue Net::HTTPServerException => e
- if e.to_s =~ /^404/
- raise NotFound, "Cannot find a cookbook named #{name} with version #{version}"
- else
- raise
- end
- end
-
-end
-
diff --git a/chef-server-api/app/controllers/data_bags.rb b/chef-server-api/app/controllers/data_bags.rb
deleted file mode 100644
index 8a4a8e015a..0000000000
--- a/chef-server-api/app/controllers/data_bags.rb
+++ /dev/null
@@ -1,75 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Author:: Christopher Brown (<cb@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require 'chef/data_bag'
-
-class DataBags < Application
-
- provides :json
-
- before :authenticate_every
- before :is_admin, :only => [ :create, :destroy ]
-
- def index
- @bag_list = Chef::DataBag.cdb_list(false)
- display(@bag_list.inject({}) { |r,b| r[b] = absolute_url(:datum, :id => b); r })
-
- end
-
- def show
- begin
- @data_bag = Chef::DataBag.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load data bag #{params[:id]}"
- end
- display(@data_bag.list.inject({}) { |res, i| res[i] = absolute_url(:data_bag_item, :data_bag_id => @data_bag.name, :id => i); res })
- end
-
- def create
- @data_bag = nil
- if params.has_key?("inflated_object")
- @data_bag = params["inflated_object"]
- else
- @data_bag = Chef::DataBag.new
- @data_bag.name(params["name"])
- end
- exists = true
- begin
- Chef::DataBag.cdb_load(@data_bag.name)
- rescue Chef::Exceptions::CouchDBNotFound
- exists = false
- end
- raise Conflict, "Data bag already exists" if exists
- self.status = 201
- @data_bag.cdb_save
- display({ :uri => absolute_url(:datum, :id => @data_bag.name) })
- end
-
- def destroy
- begin
- @data_bag = Chef::DataBag.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load data bag #{params[:id]}"
- end
- @data_bag.cdb_destroy
- @data_bag.couchdb_rev = nil
- display @data_bag
- end
-
-end
diff --git a/chef-server-api/app/controllers/data_item.rb b/chef-server-api/app/controllers/data_item.rb
deleted file mode 100644
index f88a2507e8..0000000000
--- a/chef-server-api/app/controllers/data_item.rb
+++ /dev/null
@@ -1,108 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Author:: Christopher Brown (<cb@opscode.com>)
-# Author:: Nuo Yan (<nuo@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require 'chef/data_bag'
-require 'chef/data_bag_item'
-
-class DataItem < Application
-
- provides :json
-
- before :populate_data_bag
- before :authenticate_every
- before :is_admin, :only => [ :create, :update, :destroy ]
-
- def populate_data_bag
- begin
- @data_bag = Chef::DataBag.cdb_load(params[:data_bag_id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load data bag #{params[:data_bag_id]}"
- end
- end
-
- def show
- begin
- @data_bag_item = Chef::DataBagItem.cdb_load(params[:data_bag_id], params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load data bag #{params[:data_bag_id]} item #{params[:id]}"
- end
- display @data_bag_item.raw_data
- end
-
- def create
- raw_data = nil
- if params.has_key?("inflated_object")
- raw_data = params["inflated_object"].raw_data
- else
- raw_data = params
- raw_data.delete(:action)
- raw_data.delete(:controller)
- raw_data.delete(:data_bag_id)
- end
- @data_bag_item = nil
- begin
- @data_bag_item = Chef::DataBagItem.cdb_load(@data_bag.name, params[:id])
- rescue Chef::Exceptions::CouchDBNotFound
- @data_bag_item = Chef::DataBagItem.new
- @data_bag_item.data_bag(@data_bag.name)
- else
- raise Conflict, "Databag Item #{params[:id]} already exists" if @data_bag_item
- end
- @data_bag_item.raw_data = raw_data
- @data_bag_item.cdb_save
- display @data_bag_item.raw_data
- end
-
- def update
- raw_data = nil
- if params.has_key?("inflated_object")
- raw_data = params["inflated_object"].raw_data
- else
- raw_data = params
- raw_data.delete(:action)
- raw_data.delete(:controller)
- raw_data.delete(:data_bag_id)
- end
-
- begin
- @data_bag_item = Chef::DataBagItem.cdb_load(@data_bag.name, params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load Databag Item #{params[:id]}"
- end
-
- @data_bag_item.raw_data = raw_data
- @data_bag_item.cdb_save
- display @data_bag_item.raw_data
-
- end
-
-
- def destroy
- begin
- @data_bag_item = Chef::DataBagItem.cdb_load(params[:data_bag_id], params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load data bag #{params[:data_bag_id]} item #{params[:id]}"
- end
- @data_bag_item.cdb_destroy
- @data_bag_item.couchdb_rev = nil
- display @data_bag_item
- end
-
-end
diff --git a/chef-server-api/app/controllers/environments.rb b/chef-server-api/app/controllers/environments.rb
deleted file mode 100644
index d5e20171fe..0000000000
--- a/chef-server-api/app/controllers/environments.rb
+++ /dev/null
@@ -1,207 +0,0 @@
-#
-# Author:: Stephen Delano (<stephen@opscode.com>)
-# Author:: Tim Hinderliter (<tim@opscode.com>)
-# Copyright:: Copyright (c) 2010, 2011 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require 'chef/environment'
-require 'chef/cookbook_version_selector'
-
-class Environments < Application
-
- include Merb::CookbookVersionHelper
-
- provides :json
-
- before :authenticate_every
- before :is_admin, :only => [ :create, :update, :destroy ]
-
- # GET /environments
- def index
- environment_list = Chef::Environment.cdb_list(true)
- display(environment_list.inject({}) { |res, env| res[env.name] = absolute_url(:environment, env.name); res })
- end
-
- # GET /environments/:id
- def show
- begin
- environment = Chef::Environment.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load environment #{params[:id]}"
- end
- environment.couchdb_rev = nil
- display environment
- end
-
- # POST /environments
- def create
- env = params["inflated_object"]
- exists = true
- begin
- Chef::Environment.cdb_load(env.name)
- rescue Chef::Exceptions::CouchDBNotFound
- exists = false
- end
- raise Conflict, "Environment already exists" if exists
-
- env.cdb_save
- self.status = 201
- display({:uri => absolute_url(:environment, env.name)})
- end
-
- # PUT /environments/:id
- def update
- raise MethodNotAllowed if params[:id] == "_default"
- begin
- env = Chef::Environment.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound
- raise NotFound, "Cannot load environment #{params[:id]}"
- end
-
- env.update_from!(params["inflated_object"])
- env.cdb_save
- env.couchdb_rev = nil
- self.status = 200
- display(env)
- end
-
- # DELETE /environments/:id
- def destroy
- raise MethodNotAllowed if params[:id] == "_default"
- begin
- env = Chef::Environment.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound
- raise NotFound, "Cannot load environment #{params[:id]}"
- end
- env.cdb_destroy
- display(env)
- end
-
- # GET /environments/:environment_id/cookbooks
- # returns data in the format of:
- # {"apache2" => {
- # :url => "http://url",
- # :versions => [{:url => "http://url/1.0.0", :version => "1.0.0"}, {:url => "http://url/0.0.1", :version=>"0.0.1"}]
- # }
- # }
- def list_cookbooks
- begin
- filtered_cookbooks = Chef::Environment.cdb_load_filtered_cookbook_versions(params[:environment_id])
- rescue Chef::Exceptions::CouchDBNotFound
- raise NotFound, "Cannot load environment #{params[:environment_id]}"
- end
- num_versions = num_versions!
- display(filtered_cookbooks.inject({}) {|res, (cookbook_name,versions)|
- versions.map!{|v| v.version.to_s}
- res[cookbook_name] = expand_cookbook_urls(cookbook_name, versions, num_versions)
- res
- })
- end
-
- # GET /environments/:environment_id/cookbooks/:cookbook_id
- # returns data in the format of:
- # {"apache2" => {
- # :url => "http://url",
- # :versions => [{:url => "http://url/1.0.0", :version => "1.0.0"}, {:url => "http://url/0.0.1", :version=>"0.0.1"}]
- # }
- # }
- def cookbook
- cookbook_name = params[:cookbook_id]
- begin
- filtered_cookbooks = Chef::Environment.cdb_load_filtered_cookbook_versions(params[:environment_id])
- rescue Chef::Exceptions::CouchDBNotFound
- raise NotFound, "Cannot load environment #{params[:environment_id]}"
- end
- raise NotFound, "Cannot load cookbook #{cookbook_name}" unless filtered_cookbooks.has_key?(cookbook_name)
- versions = filtered_cookbooks[cookbook_name].map{|v| v.version.to_s}
- num_versions = num_versions!("all")
- display({ cookbook_name => expand_cookbook_urls(cookbook_name, versions, num_versions) })
- end
-
- # GET /environments/:environment/recipes
- def list_recipes
- display(Chef::Environment.cdb_load_filtered_recipe_list(params[:environment_id]))
- end
-
- # GET /environments/:environment_id/nodes
- def list_nodes
- node_list = Chef::Node.cdb_list_by_environment(params[:environment_id])
- display(node_list.inject({}) {|r,n| r[n] = absolute_url(:node, n); r})
- end
-
- # GET /environments/:environment_id/roles/:role_id
- def role
- begin
- role = Chef::Role.cdb_load(params[:role_id])
- rescue Chef::Exceptions::CouchDBNotFound
- raise NotFound, "Cannot load role #{params[:role_id]}"
- end
- display("run_list" => role.env_run_lists[params[:environment_id]])
- end
-
- # POST /environments/:environment_id/cookbook_versions
- #
- # Take the given run_list and return the versions of cookbooks that would
- # be used after applying the constraints of the given environment.
- #
- # INPUT:
- # :run_list = an Array of String's, e.g.,
- # ["recipe[apache2]", "recipe[runit]"]
- #
- # OUT:
- # Hash of cookbook names cookbook manifest
- #
- # NOTE: This method is a POST, not because it's a mutator (it's idempotent),
- # but the run_list can likely exceed Merb's query string limit for GET
- # of 1024 characters.
- def cookbook_versions_for_run_list
- begin
- # not possible to be nil due to the route to get us to this API
- # endpoint
- environment_input = params[:environment_id]
-
- run_list_input = params[:run_list]
- raise BadRequest, "Missing param: run_list" unless run_list_input
- raise BadRequest, "Param run_list is not an Array: #{run_list_input.class}" unless run_list_input.is_a?(Array)
-
- # Convert the input array of strings to a RunList containing
- # RunListItem's.
- run_list = Chef::RunList.new
- run_list_input.each do |run_list_item_string|
- run_list << run_list_item_string
- end
-
- # Expand the run list in the scope of the specified environment.
- names_to_cookbook_version = Chef::CookbookVersionSelector.expand_to_cookbook_versions(run_list, environment_input)
- rescue Chef::Exceptions::CouchDBNotFound
- raise NotFound, "Cannot load environment #{params[:environment_id]}"
- rescue Chef::Exceptions::CookbookVersionSelection::InvalidRunListItems => e
- raise PreconditionFailed, e.to_json
- rescue Chef::Exceptions::CookbookVersionSelection::UnsatisfiableRunListItem => e
- raise PreconditionFailed, e.to_json
- end
-
- # Convert from
- # name => CookbookVersion
- # to
- # name => cookbook manifest
- # and display.
- display(names_to_cookbook_version.inject({}) do |res, (cookbook_name, cookbook_version)|
- res[cookbook_name] = cookbook_version.generate_manifest_with_urls {|opts| absolute_url(:cookbook_file, opts) }
- res
- end)
- end
-end
diff --git a/chef-server-api/app/controllers/exceptions.rb b/chef-server-api/app/controllers/exceptions.rb
deleted file mode 100644
index db1acdb167..0000000000
--- a/chef-server-api/app/controllers/exceptions.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Author:: Christopher Brown (<cb@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-class Exceptions < Application
-
- provides :json
-
- def not_acceptable
- if request.accept =~ /application\/json/
- display({ "error" => request.exceptions })
- else
- render
- end
- end
-
- def standard_error
- if request.accept =~ /application\/json/
- display({ "error" => request.exceptions })
- else
- raise request.exceptions.first
- end
- end
-
-end
diff --git a/chef-server-api/app/controllers/main.rb b/chef-server-api/app/controllers/main.rb
deleted file mode 100644
index 2c5158fc21..0000000000
--- a/chef-server-api/app/controllers/main.rb
+++ /dev/null
@@ -1,25 +0,0 @@
-class Main < Application
-
- provides :html, :json
-
- def index
- case content_type
- when :json
- display absolute_url(:nodes) => "Manage Nodes",
- absolute_url(:roles) => "Manage Roles",
- absolute_url(:cookbooks) => "Manage Cookbooks",
- absolute_url(:data) => "Manage Data Bags",
- absolute_url(:search) => "Search"
- else
- @webui_url = if Chef::Config[:chef_webui_url]
- Chef::Config[:chef_webui_url]
- elsif request.host =~ /(.*):4000/
- absolute_url(:top, :host => "#{$1}:4040")
- else
- nil
- end
- render
- end
- end
-
-end
diff --git a/chef-server-api/app/controllers/nodes.rb b/chef-server-api/app/controllers/nodes.rb
deleted file mode 100644
index 72564f02fe..0000000000
--- a/chef-server-api/app/controllers/nodes.rb
+++ /dev/null
@@ -1,115 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Author:: Christopher Brown (<cb@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require 'chef/node'
-require 'chef/version_class'
-require 'chef/version_constraint'
-require 'chef/cookbook_version_selector'
-
-class Nodes < Application
-
- provides :json
-
- before :authenticate_every
- before :admin_or_requesting_node, :only => [ :update, :destroy, :cookbooks ]
-
- def index
- @node_list = Chef::Node.cdb_list
- display(@node_list.inject({}) do |r,n|
- r[n] = absolute_url(:node, n); r
- end)
- end
-
- def show
- begin
- @node = Chef::Node.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load node #{params[:id]}"
- end
- @node.couchdb_rev = nil
- display @node
- end
-
- def create
- @node = params["inflated_object"]
- begin
- Chef::Node.cdb_load(@node.name)
- raise Conflict, "Node already exists"
- rescue Chef::Exceptions::CouchDBNotFound
- end
- self.status = 201
- @node.cdb_save
- display({ :uri => absolute_url(:node, @node.name) })
- end
-
- def update
- begin
- @node = Chef::Node.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load node #{params[:id]}"
- end
-
- @node.update_from!(params['inflated_object'])
- @node.cdb_save
- @node.couchdb_rev = nil
- display(@node)
- end
-
- def destroy
- begin
- @node = Chef::Node.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load node #{params[:id]}"
- end
- @node.cdb_destroy
- @node.couchdb_rev = nil
- display @node
- end
-
- # Return a hash, cookbook_name => cookbook manifest, of the cookbooks
- # appropriate for this node, using its run_list and environment.
- def cookbooks
- begin
- @node = Chef::Node.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load node #{params[:id]}"
- end
-
- # Get the mapping of cookbook_name => CookbookVersion applicable to
- # this node's run_list and its environment.
- begin
- included_cookbooks = Chef::CookbookVersionSelector.expand_to_cookbook_versions(@node.run_list, @node.chef_environment)
- rescue Chef::Exceptions::CookbookVersionSelection::InvalidRunListItems => e
- raise PreconditionFailed, e.to_json
- rescue Chef::Exceptions::CookbookVersionSelection::UnsatisfiableRunListItem => e
- raise PreconditionFailed, e.to_json
- end
-
- # Convert from
- # name => CookbookVersion
- # to
- # name => cookbook manifest
- # and display.
- display(included_cookbooks.inject({}) do |acc, (cookbook_name, cookbook_version)|
- acc[cookbook_name.to_s] = cookbook_version.generate_manifest_with_urls{|opts| absolute_url(:cookbook_file, opts) }
- acc
- end)
- end
-
-end
diff --git a/chef-server-api/app/controllers/roles.rb b/chef-server-api/app/controllers/roles.rb
deleted file mode 100644
index 6dfe5ec03e..0000000000
--- a/chef-server-api/app/controllers/roles.rb
+++ /dev/null
@@ -1,91 +0,0 @@
-require 'chef/role'
-
-class Roles < Application
- provides :json
-
- before :authenticate_every
- before :is_admin, :only => [ :create, :update, :destroy ]
-
- # GET /roles
- def index
- @role_list = Chef::Role.cdb_list(true)
- display(@role_list.inject({}) { |r,role| r[role.name] = absolute_url(:role, role.name); r })
- end
-
- # GET /roles/:id
- def show
- begin
- @role = Chef::Role.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load role #{params[:id]}"
- end
- @role.couchdb_rev = nil
- display @role
- end
-
- # POST /roles
- def create
- @role = params["inflated_object"]
- exists = true
- begin
- Chef::Role.cdb_load(@role.name)
- rescue Chef::Exceptions::CouchDBNotFound
- exists = false
- end
- raise Conflict, "Role already exists" if exists
-
- @role.cdb_save
-
- self.status = 201
- display({ :uri => absolute_url(:role, :id => @role.name) })
- end
-
- # PUT /roles/:id
- def update
- begin
- @role = Chef::Role.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load role #{params[:id]}"
- end
-
- @role.update_from!(params["inflated_object"])
- @role.cdb_save
- self.status = 200
- @role.couchdb_rev = nil
- display(@role)
- end
-
- # DELETE /roles/:id
- def destroy
- begin
- @role = Chef::Role.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load role #{params[:id]}"
- end
- @role.cdb_destroy
- display @role
- end
-
- # GET /roles/:id/environments/:env_id
- def environment
- begin
- @role = Chef::Role.cdb_load(params[:role_id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load role #{params[:role_id]}"
- end
- display("run_list" => @role.env_run_lists[params[:env_id]])
- end
-
- # GET /roles/:id/environments
- def environments
- begin
- @role = Chef::Role.cdb_load(params[:role_id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load role #{params[:role_id]}"
- end
-
- display(@role.env_run_lists.keys.sort)
- end
-
-
-end
diff --git a/chef-server-api/app/controllers/sandboxes.rb b/chef-server-api/app/controllers/sandboxes.rb
deleted file mode 100644
index c1eb552b9c..0000000000
--- a/chef-server-api/app/controllers/sandboxes.rb
+++ /dev/null
@@ -1,161 +0,0 @@
-#
-# Author:: Tim Hinderliter (<tim@opscode.com>)
-# Copyright:: Copyright (c) 2010 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require 'chef/sandbox'
-require 'chef/checksum'
-
-# Sandboxes are used to upload files to the server (e.g., cookbook upload).
-class Sandboxes < Application
-
- provides :json
-
- before :authenticate_every
-
- include Chef::Mixin::Checksum
- include Merb::TarballHelper
-
- def index
- couch_sandbox_list = Chef::Sandbox::cdb_list(true)
-
- sandbox_list = Hash.new
- couch_sandbox_list.each do |sandbox|
- sandbox_list[sandbox.guid] = absolute_url(:sandbox, :sandbox_id => sandbox.guid)
- end
- display sandbox_list
- end
-
- def show
- begin
- sandbox = Chef::Sandbox.cdb_load(params[:sandbox_id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot find a sandbox named #{params[:sandbox_id]}"
- end
-
- display sandbox
- end
-
- def create
- checksums = params[:checksums]
-
- raise BadRequest, "missing required parameter: checksums" unless checksums
- raise BadRequest, "required parameter checksums is not a hash: #{checksums.class.name}" unless checksums.is_a?(Hash)
-
- new_sandbox = Chef::Sandbox.new
- result_checksums = Hash.new
-
- all_existing_checksums = Chef::Checksum.cdb_all_checksums
- checksums.keys.each do |checksum|
- if all_existing_checksums[checksum]
- result_checksums[checksum] = {
- :needs_upload => false
- }
- else
- result_checksums[checksum] = {
- :url => absolute_url(:sandbox_checksum, :sandbox_id => new_sandbox.guid, :checksum => checksum),
- :needs_upload => true
- }
- new_sandbox.checksums << checksum
- end
- end
-
- FileUtils.mkdir_p(sandbox_location(new_sandbox.guid))
-
- new_sandbox.cdb_save
-
- # construct successful response
- self.status = 201
- location = absolute_url(:sandbox, :sandbox_id => new_sandbox.guid)
- headers['Location'] = location
- result = { 'uri' => location, 'checksums' => result_checksums, 'sandbox_id' => new_sandbox.guid }
- #result = { 'uri' => location }
-
- display result
- end
-
- def upload_checksum
- sandbox_file = ChefServerApi::SandboxFile.new(self.request.env["rack.input"], params)
- raise BadRequest, sandbox_file.error if sandbox_file.invalid_params?
- raise NotFound, sandbox_file.error if sandbox_file.invalid_sandbox?
- raise BadRequest, sandbox_file.error if sandbox_file.invalid_file?
-
- sandbox_file.commit_to(sandbox_checksum_location(sandbox_file.sandbox_id, sandbox_file.expected_checksum))
-
- url = absolute_url(:sandbox_checksum, sandbox_file.resource_params)
- result = { 'uri' => url }
- display result
- end
-
- def update
- # look up the sandbox by its guid
- existing_sandbox = Chef::Sandbox.cdb_load(params[:sandbox_id])
- raise NotFound, "cannot find sandbox with guid #{params[:sandbox_id]}" unless existing_sandbox
-
- if existing_sandbox.is_completed
- Chef::Log.warn("Sandbox finalization: #{params[:sandbox_id]} is already complete, ignoring")
- return display(existing_sandbox)
- end
-
- if params[:is_completed]
- existing_sandbox.is_completed = (params[:is_completed] == true)
-
- if existing_sandbox.is_completed
- # Check if files were uploaded to sandbox directory before we
- # commit the sandbox. Fail if any weren't.
- existing_sandbox.checksums.each do |checksum|
- checksum_filename = sandbox_checksum_location(existing_sandbox.guid, checksum)
- if !File.exists?(checksum_filename)
- raise BadRequest, "cannot update sandbox #{params[:sandbox_id]}: checksum #{checksum} was not uploaded"
- end
- end
-
- # If we've gotten here all the files have been uploaded.
- # Track the steps to undo everything we've done. If any steps fail,
- # we will undo the successful steps that came before it
- begin
- undo_steps = Array.new
- existing_sandbox.checksums.each do |file_checksum|
- checksum_filename_in_sandbox = sandbox_checksum_location(existing_sandbox.guid, file_checksum)
- checksum = Chef::Checksum.new(file_checksum)
-
- checksum.commit_sandbox_file(checksum_filename_in_sandbox)
-
- undo_steps << proc { checksum.revert_sandbox_file_commit }
- end
- rescue
- # undo the successful moves we did before
- Chef::Log.error("Sandbox finalization: got exception moving files, undoing previous changes: #{$!} -- #{$!.backtrace.join("\n")}")
- undo_steps.each do |undo_step|
- undo_step.call
- end
- raise
- end
-
- end
- end
-
- existing_sandbox.cdb_save
-
- display existing_sandbox
- end
-
- def destroy
- raise NotFound, "Destroy not implemented"
- end
-
-end
-
diff --git a/chef-server-api/app/controllers/search.rb b/chef-server-api/app/controllers/search.rb
deleted file mode 100644
index 77f83d0da0..0000000000
--- a/chef-server-api/app/controllers/search.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@opscode.com>)
-# Author:: Christopher Brown (<cb@opscode.com>)
-# Copyright:: Copyright (c) 2008 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-require 'chef/solr_query'
-
-class Search < Application
- provides :json
-
- before :authenticate_every
- before :is_admin, :only => [:reindex]
-
- def index
- indexes = valid_indexes
- display(indexes.inject({}) { |r,i| r[i] = absolute_url(:search_show, i); r })
- end
-
- def valid_indexes
- indexes = Chef::DataBag.cdb_list(false)
- indexes += %w{ role node client environment}
- end
-
- def show
- unless valid_indexes.include?(params[:id])
- raise NotFound, "I don't know how to search for #{params[:id]} data objects."
- end
- params[:type] = params.delete(:id)
- display(Chef::SolrQuery.from_params(params).search)
- rescue Chef::Exceptions::QueryParseError => e
- # we set status rather than raising BadRequest to avoid a
- # stacktrace in the server log
- self.status = 400
- e_msg = e.message.gsub(/\n/, " ")
- msg = "invalid search query: '#{params[:q]}' #{e_msg}"
- Chef::Log.warn("400 #{msg}")
- display({ "error" => [msg] })
- end
-
- def reindex
- display(Chef::SolrQuery.new.rebuild_index)
- end
-
-end
diff --git a/chef-server-api/app/controllers/users.rb b/chef-server-api/app/controllers/users.rb
deleted file mode 100644
index a336f04f03..0000000000
--- a/chef-server-api/app/controllers/users.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-#
-# Author:: Nuo Yan (<nuo@opscode.com>)
-# Copyright:: Copyright (c) 2009 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-require File.join("chef", "webui_user")
-
-class Users < Application
- provides :json
-
- before :authenticate_every
- before :is_admin, :only => [ :create, :destroy, :update ]
-
- # GET to /users
- def index
- @user_list = Chef::WebUIUser.cdb_list
- display(@user_list.inject({}) { |r,n| r[n] = absolute_url(:user, n); r })
- end
-
- # GET to /users/:id
- def show
- begin
- @user = Chef::WebUIUser.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load user #{params[:id]}"
- end
- display @user
- end
-
- # PUT to /users/:id
- def update
- begin
- Chef::WebUIUser.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load user #{params[:id]}"
- end
- @user = params['inflated_object']
- @user.cdb_save
- display(@user)
- end
-
- # POST to /users
- def create
- @user = params["inflated_object"]
- begin
- Chef::WebUIUser.cdb_load(@user.name)
- rescue Chef::Exceptions::CouchDBNotFound
- @user.cdb_save
- self.status = 201
- else
- raise Conflict, "User already exists"
- end
- display({ :uri => absolute_url(:user, @user.name) })
- end
-
- def destroy
- begin
- @user = Chef::WebUIUser.cdb_load(params[:id])
- rescue Chef::Exceptions::CouchDBNotFound => e
- raise NotFound, "Cannot load user #{params[:id]}"
- end
- @user.cdb_destroy
- display @user
- end
-end
diff --git a/chef-server-api/app/helpers/cookbook_version_helper.rb b/chef-server-api/app/helpers/cookbook_version_helper.rb
deleted file mode 100644
index 76c70ddc06..0000000000
--- a/chef-server-api/app/helpers/cookbook_version_helper.rb
+++ /dev/null
@@ -1,72 +0,0 @@
-#
-# Author:: Stephen Delano (<stephen@opscode.com>)
-# Copyright:: Copyright (c) 2011 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-module Merb
- module CookbookVersionHelper
-
- include Merb::ControllerExceptions
-
- # takes a cookbook_name and an array of versions and returns a hash
- # params:
- # - cookbook_name: the name of the cookbook
- # - versions: a sorted list of version strings
- #
- # returns:
- # {
- # :url => http://url,
- # :versions => [
- # { :version => version, :url => http://url/version },
- # { :version => version, :url => http://url/version }
- # ]
- # }
- def expand_cookbook_urls(cookbook_name, versions, num_versions)
- versions = versions[0...num_versions.to_i] unless num_versions == "all"
- version_list = versions.inject([]) do |res, version|
- res.push({
- :url => absolute_url(:cookbook_version, :cookbook_name => cookbook_name, :cookbook_version => version),
- :version => version
- })
- res
- end
- url = absolute_url(:cookbook, :cookbook_name => cookbook_name)
- {:url => url, :versions => version_list}
- end
-
- # validate and return the number of versions requested
- # by the user
- #
- # raises an exception if an invalid number is requested
- #
- # params:
- # - default: the number of versions to default to
- #
- # valid num_versions query parameter:
- # - an integer >= 0
- # - the string "all"
- def num_versions!(default="1")
- input = params[:num_versions]
- result = if input
- valid_input = (input == "all" || Integer(input) >= 0) rescue false
- raise BadRequest, "You have requested an invalid number of versions (x >= 0 || 'all')" unless valid_input
- input
- else
- default
- end
- end
- end
-end \ No newline at end of file
diff --git a/chef-server-api/app/helpers/tarball_helper.rb b/chef-server-api/app/helpers/tarball_helper.rb
deleted file mode 100644
index a3dff2a137..0000000000
--- a/chef-server-api/app/helpers/tarball_helper.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-#
-# Author:: Christopher Walters (<cw@opscode.com>)
-# Copyright:: Copyright (c) 2009 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-module Merb
- module TarballHelper
-
- class FileParameterException < StandardError ; end
-
- def validate_file_parameter(cookbook_name, file_param)
- raise FileParameterException, "missing required parameter: file" unless file_param
- raise FileParameterException, "invalid parameter: file must be a File" unless file_param.respond_to?(:has_key?) && file_param[:tempfile].respond_to?(:read)
- tarball_path = file_param[:tempfile].path
- raise FileParameterException, "invalid tarball: (try creating with 'tar czf cookbook.tar.gz cookbook/')" unless system("tar", "tzf", tarball_path)
- entry_roots = `tar tzf #{tarball_path}`.split("\n").map{|e|(e.split('/')-['.']).first}.uniq
- raise FileParameterException, "invalid tarball: tarball root must contain #{cookbook_name}" unless entry_roots.include?(cookbook_name)
- end
-
- def sandbox_base
- Chef::Config.sandbox_path
- end
-
- def sandbox_location(sandbox_guid)
- File.join(sandbox_base, sandbox_guid)
- end
-
- def sandbox_checksum_location(sandbox_guid, checksum)
- File.join(sandbox_location(sandbox_guid), checksum)
- end
-
- def cookbook_base
- [Chef::Config.cookbook_path].flatten.first
- end
-
- def cookbook_location(cookbook_name)
- File.join(cookbook_base, cookbook_name)
- end
-
- def cookbook_base
- [Chef::Config.cookbook_path].flatten.first
- end
-
- def cookbook_location(cookbook_name)
- File.join(cookbook_base, cookbook_name)
- end
-
- def cookbook_location(cookbook_name)
- File.join(cookbook_base, cookbook_name)
- end
-
- def get_or_create_cookbook_tarball_location(cookbook_name)
- tarball_location = cookbook_tarball_location(cookbook_name)
- unless File.exists? tarball_location
- args = ["tar", "-C", cookbook_base, "-czf", tarball_location, cookbook_name]
- Chef::Log.debug("Tarball for #{cookbook_name} not found, so creating at #{tarball_location} with '#{args.join(' ')}'")
- FileUtils.mkdir_p(Chef::Config.cookbook_tarball_path)
- system(*args)
- end
- tarball_location
- end
-
- def expand_tarball_and_put_in_repository(cookbook_name, file)
- # untar cookbook tarball into tempdir
- tempdir = File.join("#{file.path}.data")
- Chef::Log.debug("Creating #{tempdir} and untarring #{file.path} into it")
- FileUtils.mkdir_p(tempdir)
- raise "Could not untar file" unless system("tar", "xzf", file.path, "-C", tempdir)
-
- cookbook_path = cookbook_location(cookbook_name)
- tarball_path = cookbook_tarball_location(cookbook_name)
-
- # clear any existing cookbook components and move tempdir into the repository
- Chef::Log.debug("Moving #{tempdir} to #{cookbook_path}")
- FileUtils.rm_rf(cookbook_path)
- FileUtils.mkdir_p(cookbook_path)
- Dir[File.join(tempdir, cookbook_name, "*")].each{|e| FileUtils.mv(e, cookbook_path)}
-
- # clear the existing tarball (if exists) and move the downloaded tarball to the cache
- Chef::Log.debug("Moving #{file.path} to #{tarball_path}")
- FileUtils.mkdir_p(Chef::Config.cookbook_tarball_path)
- FileUtils.rm_f(tarball_path)
- FileUtils.mv(file.path, tarball_path)
- end
-
- end
-end
diff --git a/chef-server-api/app/models/sandbox_file.rb b/chef-server-api/app/models/sandbox_file.rb
deleted file mode 100644
index 43671acb34..0000000000
--- a/chef-server-api/app/models/sandbox_file.rb
+++ /dev/null
@@ -1,120 +0,0 @@
-#
-# Author:: Daniel DeLeo (<dan@opscode.com>)
-# Copyright:: Copyright (c) 2010 Opscode, Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require 'chef/sandbox'
-require 'chef/exceptions'
-require 'chef/checksum_cache'
-
-module ChefServerApi
- class SandboxFile
- attr_reader :sandbox_id
- attr_reader :expected_checksum
- attr_reader :error
-
- def initialize(input, params={})
- @input = input
- @sandbox_id = params[:sandbox_id]
- @expected_checksum = params[:checksum]
- @sandbox_loaded = false
- @error = nil
- end
-
- def resource_params
- {:sandbox_id => sandbox_id, :checksum => expected_checksum}
- end
-
- def sandbox
- unless @sandbox_loaded
- load_sandbox
- @sandbox_loaded = true
- end
- @sandbox
- end
-
- def commit_to(destination_file_path)
- if @input.respond_to?(:path) && @input.path
- commit_tempfile_to(destination_file_path)
- else
- commit_stringio_to(destination_file_path)
- end
- end
-
- def actual_checksum
- @actual_checksum ||= begin
- @input.rewind
- Chef::ChecksumCache.instance.generate_md5_checksum(@input)
- end
- end
-
- def invalid_file?
- if expected_checksum != actual_checksum
- @error = "Uploaded file is invalid: expected a md5 sum '#{expected_checksum}', but it was '#{actual_checksum}'"
- else
- false
- end
- end
-
- def invalid_params?
- if @sandbox_id.nil?
- @error = "Cannot upload file with checksum '#{expected_checksum}': you must provide a sandbox_id"
- elsif @expected_checksum.nil?
- @error = "Cannot upload file to sandbox '#{sandbox_id}': you must provide the file's checksum"
- else
- false
- end
- end
-
- def invalid_sandbox?
- if sandbox.nil?
- @error = "Cannot find sandbox with id '#{sandbox_id}' in the database"
- elsif !sandbox.member?(@expected_checksum)
- @error = "Cannot upload file: checksum '#{expected_checksum}' isn't a part of sandbox '#{sandbox_id}'"
- else
- false
- end
- end
-
- private
-
- def load_sandbox
- @sandbox = Chef::Sandbox.cdb_load(@sandbox_id)
- rescue Chef::Exceptions::CouchDBNotFound
- @sandbox = nil
- end
-
- def commit_stringio_to(destination_file_path)
- Tempfile.open("sandbox") do |src|
- @input.rewind
- while chunk = @input.read(8184)
- src.write(chunk)
- end
- src.close
- Chef::Log.info("upload_checksum: move #{src.path} to #{destination_file_path}")
- FileUtils.mv(src.path, destination_file_path)
- end
- end
-
- def commit_tempfile_to(destination_file_path)
- Chef::Log.debug("Sandbox file provided as tempfile: #{@input.inspect}")
- Chef::Log.info("upload_checksum: move #{@input.path} to #{destination_file_path}")
- FileUtils.mv(@input.path, destination_file_path)
- end
-
- end
-
-end
diff --git a/chef-server-api/app/views/exceptions/bad_request.json.erb b/chef-server-api/app/views/exceptions/bad_request.json.erb
deleted file mode 100644
index f266cf99b9..0000000000
--- a/chef-server-api/app/views/exceptions/bad_request.json.erb
+++ /dev/null
@@ -1 +0,0 @@
-<%= { :error => params[:exception], :code => 400 }.to_json %> \ No newline at end of file
diff --git a/chef-server-api/app/views/exceptions/internal_server_error.html.erb b/chef-server-api/app/views/exceptions/internal_server_error.html.erb
deleted file mode 100644
index aadbfad350..0000000000
--- a/chef-server-api/app/views/exceptions/internal_server_error.html.erb
+++ /dev/null
@@ -1,216 +0,0 @@
-<html>
-<head>
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
- <title><%= @exception_name %></title>
- <style type="text/css" media="screen">
- body {
- font-family:arial;
- font-size:11px;
- }
- h1 {
- font-size:48px;
- letter-spacing:-4px;
- margin:0;
- line-height:36px;
- color:#333;
- }
- h1 sup {
- font-size: 0.5em;
- }
- h1 sup.error_500, h1 sup.error_400 {
- color:#990E05;
- }
- h1 sup.error_100, h1 sup.error_200 {
- color:#00BF10;
- }
- h1 sup.error_300 {
- /* pretty sure you cant 'see' status 300
- errors but if you could I think they
- would be blue */
- color:#1B2099;
- }
- h2 {
- font-size:36px;
- letter-spacing:-3px;
- margin:0;
- line-height:28px;
- color:#444;
- }
- a, a:visited {
- color:#00BF10;
- }
- .internalError {
- width:800px;
- margin:50px auto;
- }
- .header {
- border-bottom:10px solid #333;
- margin-bottom:1px;
- background-image: url("data:image/gif;base64,R0lGODlhAwADAIAAAP///8zMzCH5BAAAAAAALAAAAAADAAMAAAIEBHIJBQA7");
- padding:20px;
- }
- table.trace {
- width:100%;
- font-family:courier, monospace;
- letter-spacing:-1px;
- border-collapse: collapse;
- border-spacing:0;
- }
- table.trace tr td{
- padding:0;
- height:26px;
- font-size:13px;
- vertical-align:middle;
- }
- table.trace tr.file{
- border-top:2px solid #fff;
- background-color:#F3F3F3;
- }
- table.trace tr.source {
- background-color:#F8F8F8;
- display:none;
- }
- table.trace .open tr.source {
- display:table-row;
- }
- table.trace tr.file td.expand {
- width:23px;
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAAXCAIAAABvSEP3AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAdVJREFUeNqMVL+TwUAYxaRIOlEhlZHGDAUzzOQ61+AqXMV1lJSU7q/QRqm8KFUcJTNn5qJkaPyoKKVz7y4mF8na5Kt29tt9+/Z97/u81+vVQ4r9frdarS6Xi7ETDIZisRjxMGPfmk4niNPpZE+xLAugbPaZ53nzvtfMBe/3+/3dbuehBrAKhZdUKkVAWa9Xsiybv0CPZDJZLr/qa5/BwgwRjYqOKIvFYjQa/aNommZh0Ww2K5UqzwfoQOPxaLPZ3FAmk0+7lplMpt1u53J5OpBOR0eZEE9wHJfP5zud93g88QhluwWbjW+5VOmKBgKBer3eaDTDYeGBQF8+x7rqIYoiPgixWJazpA6HA+MSxRArkUgMh0M409g8Ho8+9wYxxCqVSq1W26EDHGM2m4HOHQrEc38f/Yn7cLmlIRhBENzcx8cVRZnPZ/YUep2BWkjTIfA+PKVpZAXR5QxsjiqCKvGEqqp443w+0dvy17swqD0HB3S73V5PpkNg1qBqt8kwGCjmPkinM0QJbIoEa7U6UG6ToVgs4V9G2g0ESoP5Aoi7KYX5oCgf8IKbkvn9/mr1LRQKESamzgJy0g0tSZIuB3nuGqRU9Vv9C4sKkUhEkp4soxvxI8AAhWrrtXa3X8EAAAAASUVORK5CYII=);
- background-position:top left;
- background-repeat:no-repeat;
- }
- table.trace .open tr.file td.expand {
- width:19px;
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAB1CAIAAAAqdO2mAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAXZJREFUeNrslK1ywkAUhcMOBomEOiSdqLxEBJX0NaijOsjyHGGmCGyQQYaiiiw4gktkcOmZbpsuuzQ/M5XnqJ2d3S/n3nM3rTzPLUP7/Tt0+pLcGQwG3W53OLyHzPMtjYL7q9UqSRLrD4E1Gj1orCvKYuFHUWTVkOM44/HjDcp8/lL4r6NerzeZPMm1KFw0QkDn83m5fP2lHA4fNQvRtNvtjsfDd0WzmSfb2e/fdTqdOvdh/HLJZLOn0+d2HJ+KRGzbdl23EpFlmed5cp2maRzHQq1lvQ5KMi6EUZBGfup6E1pTfd+vrGW7jbQ2C9hTt9BpqNyIWaAwAy6xg2eBz5iRC/NomiZhGN5sqmnkauo0BUGgVQoBjQ80oCACgNQdZHfTYBkF2mxCtWWAqunWpahxIDUt3QYUxIFQpJHyIWpXjinabKbbwItMHT+NyjchrP8QKaSQQgoppJBCCimkkEIKKaSQQgoppJBCCimkkEIKKaSo+hRgAEFD17X08O2NAAAAAElFTkSuQmCC);
- background-position:top left;
- background-repeat:no-repeat;
- }
- table.trace tr.source td.collapse {
- width:19px;
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAB1CAIAAAAqdO2mAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAVxJREFUeNrs0zFygkAUBmBlUkgJHdABlQwVkVJKKUxBYWbkALTxMJwhltyDFkss03IF8pudIcwaDaDl/6pd2P327b7d+eHwMXs4lNkzggoVKlSoUKFChQoVKlSoUKFChQoVKlSoUKFChQqVEYqm6ft9+qiSJEkYho7jTlcw2fd9NOI4nq4gEdFwXXe1Cqco63VkWVbXRTqLhTpOwQRpF7quR1E0TgGhqvLKUFCyoQqG/rks3O6kZKW/eRFpevOCoGTXVTcMQ5EyxyDEkML1c5RzuZOICIyXqn7JBVez6282MWrx731HOv2qB8Hri2lamNk0DfpVVdV1Peodappmmua8bdvzuc7zfNprzrLMth1FnGh/X8MjCAIQv/cFz/+65PcDh7rbvYv2ZUfdj+PxsyzLgVl0hKwgTqeqKApx2LeOc7t98zyv/1FWOgvx9RPii23bmL9cetJ8Ed8CDAC6aFW8bCzFhwAAAABJRU5ErkJggg==);
- background-position:bottom left;
- background-repeat:no-repeat;
- background-color:#6F706F;
- }
- table.trace tr td.path {
- padding-left:10px;
- }
- table.trace tr td.code {
- padding-left:35px;
- white-space: pre;
- line-height:9px;
- padding-bottom:10px;
- }
- table.trace tr td.code em {
- font-weight:bold;
- color:#00BF10;
- }
- table.trace tr td.code a {
- width: 20px;
- float: left;
- }
- table.trace tr td.code .more {
- color:#666;
- }
- table.trace tr td.line {
- width:30px;
- text-align:right;
- padding-right:4px;
- }
- .footer {
- margin-top:5px;
- font-size:11px;
- color:#444;
- text-align:right;
- }
- </style>
-</head>
-<body>
- <div class="internalError">
-
- <div class="header">
- <h1><%= @exception_name %> <sup class="error_<%= @exception.class::STATUS %>"><%= @exception.class::STATUS %></sup></h1>
- <% if show_details = ::Merb::Config[:exception_details] -%>
- <h2><%= @exception.message %></h2>
- <% else -%>
- <h2>Sorry about that...</h2>
- <% end -%>
- <h3>Parameters</h3>
- <ul>
- <% params[:original_params].each do |param, value| %>
- <li><strong><%= param %>:</strong> <%= value.inspect %></li>
- <% end %>
- <%= "<li>None</li>" if params[:original_params].empty? %>
- </ul>
-
- <h3>Session</h3>
- <ul>
- <% params[:original_session].each do |param, value| %>
- <li><strong><%= param %>:</strong> <%= value.inspect %></li>
- <% end %>
- <%= "<li>None</li>" if params[:original_session].empty? %>
- </ul>
-
- <h3>Cookies</h3>
- <ul>
- <% params[:original_cookies].each do |param, value| %>
- <li><strong><%= param %>:</strong> <%= value.inspect %></li>
- <% end %>
- <%= "<li>None</li>" if params[:original_cookies].empty? %>
- </ul>
- </div>
-
- <% if show_details %>
- <table class="trace">
- <% @exception.backtrace.each_with_index do |line, index| %>
- <tbody class="close">
- <tr class="file">
- <td class="expand">
- </td>
- <td class="path">
- <%= (line.match(/^([^:]+)/)[1] rescue 'unknown').sub(/\/((opt|usr)\/local\/lib\/(ruby\/)?(gems\/)?(1.8\/)?(gems\/)?|.+\/app\/)/, '') %>
- <% unless line.match(/\.erb:/) %>
- in "<strong><%= line.match(/:in `(.+)'$/)[1] rescue '?' %></strong>"
- <% else %>
- (<strong>ERB Template</strong>)
- <% end %>
- </td>
- <td class="line">
- <a href="txmt://open?url=file://<%=file = (line.match(/^([^:]+)/)[1] rescue 'unknown')%>&amp;line=<%= lineno = line.match(/:([0-9]+):/)[1] rescue '?' %>"><%=lineno%></a>&nbsp;
- </td>
- </tr>
- <tr class="source">
- <td class="collapse">
- </td>
- <td class="code" colspan="2"><% (__caller_lines__(file, lineno, 5) rescue []).each do |llineno, lcode, lcurrent| %>
-<a href="txmt://open?url=file://<%=file%>&amp;line=<%=llineno%>"><%= llineno %></a><%='<em>' if llineno==lineno.to_i %><%= lcode.size > 90 ? CGI.escapeHTML(lcode[0..90])+'<span class="more">......</span>' : CGI.escapeHTML(lcode) %><%='</em>' if llineno==lineno.to_i %>
-<% end %>
-
-</td>
- </tr>
- </tbody>
- <% end %>
- </table>
- <script type="text/javascript" charset="utf-8">
- // swop the open & closed classes
- els = document.getElementsByTagName('td');
- for(i=0; i<els.length; i++){
- if(els[i].className=='expand' || els[i].className=='collapse'){
- els[i].onclick = function(e){
- tbody = this.parentNode.parentNode;
- if(tbody.className=='open'){
- tbody.className='closed';
- }else{
- tbody.className='open';
- }
- }
- }
- }
- </script>
- <% end %>
- <div class="footer">
- lots of love, from <a href="#">merb</a>
- </div>
- </div>
-</body>
-</html> \ No newline at end of file
diff --git a/chef-server-api/app/views/exceptions/not_acceptable.html.haml b/chef-server-api/app/views/exceptions/not_acceptable.html.haml
deleted file mode 100644
index b3e5b966c1..0000000000
--- a/chef-server-api/app/views/exceptions/not_acceptable.html.haml
+++ /dev/null
@@ -1,5 +0,0 @@
-.block#block-text
- .content
- %h2.title Content-Type Unacceptable.
- .inner
- The Chef Server's REST API only responds to requests for JSON data. Set the 'Accept' header on your request to 'application/json' and try again.
diff --git a/chef-server-api/app/views/exceptions/not_found.html.erb b/chef-server-api/app/views/exceptions/not_found.html.erb
deleted file mode 100644
index 388c72c31d..0000000000
--- a/chef-server-api/app/views/exceptions/not_found.html.erb
+++ /dev/null
@@ -1,47 +0,0 @@
-<div id="container">
- <div id="header-container">
- <img src="/images/merb.jpg" />
- <!-- <h1>Mongrel + Erb</h1> -->
- <h2>pocket rocket web framework</h2>
- <hr />
- </div>
-
- <div id="left-container">
- <h3>Exception:</h3>
- <p><%= params[:exception] %></p>
- </div>
-
- <div id="main-container">
- <h3>Welcome to Merb!</h3>
- <p>Merb is a light-weight MVC framework written in Ruby. We hope you enjoy it.</p>
-
- <h3>Where can I find help?</h3>
- <p>If you have any questions or if you can't figure something out, please take a
- look at our <a href="http://merbivore.com/"> project page</a>,
- feel free to come chat at irc.freenode.net, channel #merb,
- or post to <a href="http://groups.google.com/group/merb">merb mailing list</a>
- on Google Groups.</p>
-
- <h3>What if I've found a bug?</h3>
- <p>If you want to file a bug or make your own contribution to Merb,
- feel free to register and create a ticket at our
- <a href="http://merb.lighthouseapp.com/">project development page</a>
- on Lighthouse.</p>
-
- <h3>How do I edit this page?</h3>
- <p>You're seeing this page because you need to edit the following files:
- <ul>
- <li>config/router.rb <strong><em>(recommended)</em></strong></li>
- <li>app/views/exceptions/not_found.html.erb <strong><em>(recommended)</em></strong></li>
- <li>app/views/layout/application.html.erb <strong><em>(change this layout)</em></strong></li>
- </ul>
- </p>
- </div>
-
- <div id="footer-container">
- <hr />
- <div class="left"></div>
- <div class="right">&copy; 2007 the merb dev team</div>
- <p>&nbsp;</p>
- </div>
-</div>
diff --git a/chef-server-api/app/views/exceptions/standard_error.html.erb b/chef-server-api/app/views/exceptions/standard_error.html.erb
deleted file mode 100644
index edb45ddf90..0000000000
--- a/chef-server-api/app/views/exceptions/standard_error.html.erb
+++ /dev/null
@@ -1,217 +0,0 @@
-<html>
-<head>
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
- <title><%= @exception_name %></title>
- <style type="text/css" media="screen">
- body {
- font-family:arial;
- font-size:11px;
- }
- h1 {
- font-size:48px;
- letter-spacing:-4px;
- margin:0;
- line-height:36px;
- color:#333;
- }
- h1 sup {
- font-size: 0.5em;
- }
- h1 sup.error_500, h1 sup.error_400 {
- color:#990E05;
- }
- h1 sup.error_100, h1 sup.error_200 {
- color:#00BF10;
- }
- h1 sup.error_300 {
- /* pretty sure you cant 'see' status 300
- errors but if you could I think they
- would be blue */
- color:#1B2099;
- }
- h2 {
- font-size:36px;
- letter-spacing:-3px;
- margin:0;
- line-height:28px;
- color:#444;
- }
- a, a:visited {
- color:#00BF10;
- }
- .internalError {
- width:800px;
- margin:50px auto;
- }
- .header {
- border-bottom:10px solid #333;
- margin-bottom:1px;
- background-image: url("data:image/gif;base64,R0lGODlhAwADAIAAAP///8zMzCH5BAAAAAAALAAAAAADAAMAAAIEBHIJBQA7");
- padding:20px;
- }
- table.trace {
- width:100%;
- font-family:courier, monospace;
- letter-spacing:-1px;
- border-collapse: collapse;
- border-spacing:0;
- }
- table.trace tr td{
- padding:0;
- height:26px;
- font-size:13px;
- vertical-align:middle;
- }
- table.trace tr.file{
- border-top:2px solid #fff;
- background-color:#F3F3F3;
- }
- table.trace tr.source {
- background-color:#F8F8F8;
- display:none;
- }
- table.trace .open tr.source {
- display:table-row;
- }
- table.trace tr.file td.expand {
- width:23px;
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAAXCAIAAABvSEP3AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAdVJREFUeNqMVL+TwUAYxaRIOlEhlZHGDAUzzOQ61+AqXMV1lJSU7q/QRqm8KFUcJTNn5qJkaPyoKKVz7y4mF8na5Kt29tt9+/Z97/u81+vVQ4r9frdarS6Xi7ETDIZisRjxMGPfmk4niNPpZE+xLAugbPaZ53nzvtfMBe/3+/3dbuehBrAKhZdUKkVAWa9Xsiybv0CPZDJZLr/qa5/BwgwRjYqOKIvFYjQa/aNommZh0Ww2K5UqzwfoQOPxaLPZ3FAmk0+7lplMpt1u53J5OpBOR0eZEE9wHJfP5zud93g88QhluwWbjW+5VOmKBgKBer3eaDTDYeGBQF8+x7rqIYoiPgixWJazpA6HA+MSxRArkUgMh0M409g8Ho8+9wYxxCqVSq1W26EDHGM2m4HOHQrEc38f/Yn7cLmlIRhBENzcx8cVRZnPZ/YUep2BWkjTIfA+PKVpZAXR5QxsjiqCKvGEqqp443w+0dvy17swqD0HB3S73V5PpkNg1qBqt8kwGCjmPkinM0QJbIoEa7U6UG6ToVgs4V9G2g0ESoP5Aoi7KYX5oCgf8IKbkvn9/mr1LRQKESamzgJy0g0tSZIuB3nuGqRU9Vv9C4sKkUhEkp4soxvxI8AAhWrrtXa3X8EAAAAASUVORK5CYII=);
- background-position:top left;
- background-repeat:no-repeat;
- }
- table.trace .open tr.file td.expand {
- width:19px;
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAB1CAIAAAAqdO2mAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAXZJREFUeNrslK1ywkAUhcMOBomEOiSdqLxEBJX0NaijOsjyHGGmCGyQQYaiiiw4gktkcOmZbpsuuzQ/M5XnqJ2d3S/n3nM3rTzPLUP7/Tt0+pLcGQwG3W53OLyHzPMtjYL7q9UqSRLrD4E1Gj1orCvKYuFHUWTVkOM44/HjDcp8/lL4r6NerzeZPMm1KFw0QkDn83m5fP2lHA4fNQvRtNvtjsfDd0WzmSfb2e/fdTqdOvdh/HLJZLOn0+d2HJ+KRGzbdl23EpFlmed5cp2maRzHQq1lvQ5KMi6EUZBGfup6E1pTfd+vrGW7jbQ2C9hTt9BpqNyIWaAwAy6xg2eBz5iRC/NomiZhGN5sqmnkauo0BUGgVQoBjQ80oCACgNQdZHfTYBkF2mxCtWWAqunWpahxIDUt3QYUxIFQpJHyIWpXjinabKbbwItMHT+NyjchrP8QKaSQQgoppJBCCimkkEIKKaSQQgoppJBCCimkkEIKKaSo+hRgAEFD17X08O2NAAAAAElFTkSuQmCC);
- background-position:top left;
- background-repeat:no-repeat;
- }
- table.trace tr.source td.collapse {
- width:19px;
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAB1CAIAAAAqdO2mAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAVxJREFUeNrs0zFygkAUBmBlUkgJHdABlQwVkVJKKUxBYWbkALTxMJwhltyDFkss03IF8pudIcwaDaDl/6pd2P327b7d+eHwMXs4lNkzggoVKlSoUKFChQoVKlSoUKFChQoVKlSoUKFChQqVEYqm6ft9+qiSJEkYho7jTlcw2fd9NOI4nq4gEdFwXXe1Cqco63VkWVbXRTqLhTpOwQRpF7quR1E0TgGhqvLKUFCyoQqG/rks3O6kZKW/eRFpevOCoGTXVTcMQ5EyxyDEkML1c5RzuZOICIyXqn7JBVez6282MWrx731HOv2qB8Hri2lamNk0DfpVVdV1Peodappmmua8bdvzuc7zfNprzrLMth1FnGh/X8MjCAIQv/cFz/+65PcDh7rbvYv2ZUfdj+PxsyzLgVl0hKwgTqeqKApx2LeOc7t98zyv/1FWOgvx9RPii23bmL9cetJ8Ed8CDAC6aFW8bCzFhwAAAABJRU5ErkJggg==);
- background-position:bottom left;
- background-repeat:no-repeat;
- background-color:#6F706F;
- }
- table.trace tr td.path {
- padding-left:10px;
- }
- table.trace tr td.code {
- padding-left:35px;
- white-space: pre;
- line-height:9px;
- padding-bottom:10px;
- }
- table.trace tr td.code em {
- font-weight:bold;
- color:#00BF10;
- }
- table.trace tr td.code a {
- width: 20px;
- float: left;
- }
- table.trace tr td.code .more {
- color:#666;
- }
- table.trace tr td.line {
- width:30px;
- text-align:right;
- padding-right:4px;
- }
- .footer {
- margin-top:5px;
- font-size:11px;
- color:#444;
- text-align:right;
- }
- </style>
-</head>
-<body>
- <div class="internalError">
-
- <div class="header">
- <h1><%= @exception_name %> <sup class="error_<%= @exception.class::STATUS %>"><%= @exception.class::STATUS %></sup></h1>
- <% if show_details = ::Merb::Config[:exception_details] -%>
- <h2><%= @exception.message %></h2>
- <% else -%>
- <h2>Sorry about that...</h2>
- <% end -%>
- <h3>Parameters</h3>
- <ul>
- <% params[:original_params].each do |param, value| %>
- <li><strong><%= param %>:</strong> <%= value.inspect %></li>
- <% end %>
- <%= "<li>None</li>" if params[:original_params].empty? %>
- </ul>
-
- <h3>Session</h3>
- <ul>
- <% params[:original_session].each do |param, value| %>
- <li><strong><%= param %>:</strong> <%= value.inspect %></li>
- <% end %>
- <%= "<li>None</li>" if params[:original_session].empty? %>
- </ul>
-
- <h3>Cookies</h3>
- <ul>
- <% params[:original_cookies].each do |param, value| %>
- <li><strong><%= param %>:</strong> <%= value.inspect %></li>
- <% end %>
- <%= "<li>None</li>" if params[:original_cookies].empty? %>
- </ul>
- </div>
-
- <% if show_details %>
- <table class="trace">
- <% @exception.backtrace.each_with_index do |line, index| %>
- <tbody class="close">
- <tr class="file">
- <td class="expand">
- </td>
- <td class="path">
- <%= (line.match(/^([^:]+)/)[1] rescue 'unknown').sub(/\/((opt|usr)\/local\/lib\/(ruby\/)?(gems\/)?(1.8\/)?(gems\/)?|.+\/app\/)/, '') %>
- <% unless line.match(/\.erb:/) %>
- in "<strong><%= line.match(/:in `(.+)'$/)[1] rescue '?' %></strong>"
- <% else %>
- (<strong>ERB Template</strong>)
- <% end %>
- </td>
- <td class="line">
- <a href="txmt://open?url=file://<%=file = (line.match(/^([^:]+)/)[1] rescue 'unknown')%>&amp;line=<%= lineno = line.match(/:([0-9]+):/)[1] rescue '?' %>"><%=lineno%></a>&nbsp;
- </td>
- </tr>
- <tr class="source">
- <td class="collapse">
- </td>
- <td class="code" colspan="2"><% (__caller_lines__(file, lineno, 5) rescue []).each do |llineno, lcode, lcurrent| %>
-<a href="txmt://open?url=file://<%=file%>&amp;line=<%=llineno%>"><%= llineno %></a><%='<em>' if llineno==lineno.to_i %><%= lcode.size > 90 ? CGI.escapeHTML(lcode[0..90])+'<span class="more">......</span>' : CGI.escapeHTML(lcode) %><%='</em>' if llineno==lineno.to_i %>
-<% end %>
-
-</td>
- </tr>
- </tbody>
- <% end %>
- </table>
- <script type="text/javascript" charset="utf-8">
- // swop the open & closed classes
- els = document.getElementsByTagName('td');
- for(i=0; i<els.length; i++){
- if(els[i].className=='expand' || els[i].className=='collapse'){
- els[i].onclick = function(e){
- tbody = this.parentNode.parentNode;
- if(tbody.className=='open'){
- tbody.className='closed';
- }else{
- tbody.className='open';
- }
- }
- }
- }
- </script>
- <% end %>
- <div class="footer">
- lots of love, from <a href="#">merb</a>
- </div>
- </div>
-</body>
-</html>
-
diff --git a/chef-server-api/app/views/layout/application.html.erb b/chef-server-api/app/views/layout/application.html.erb
deleted file mode 100644
index e577a24e12..0000000000
--- a/chef-server-api/app/views/layout/application.html.erb
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version='1.0' encoding='utf-8' ?>
-<!DOCTYPE html>
-<html>
- <head>
- <meta content='text/html; charset=utf-8' http-equiv='content-type' />
- <title>Chef Server</title>
- <link href="/stylesheets/base.css" type="text/css" rel="Stylesheet" charset="utf-8" media="all" />
- <link href="/stylesheets/themes/djime-cerulean/style.css" type="text/css" rel="Stylesheet" charset="utf-8" media="all" />
- <link href="/stylesheets/chef.css" type="text/css" rel="Stylesheet" charset="utf-8" media="all" />
- </head>
- <body>
- <div id='container'>
- <div id='header'>
- <h1><a href="<%= absolute_url(:top) -%>">Chef REST API</a></h1>
- </div>
- <div id='main-navigation'>
- <div class='clear'></div>
- </div>
- <div id='wrapper'>
- <div id='main'>
- <div class='block' id='block-text'>
- <div class='content'>
- <h2 class='title'>The REST API</h2>
- <div class='inner'>
- This is the Chef API Server.
- <% if @webui_url %>
- <a href="<%= @webui_url -%>">Are you looking for the Web UI?</a>
- <% end %>
- </div>
- <div class='inner'>
- For more information about Chef, head on over to the <a href="http://wiki.opscode.com/">wiki.</a>
- </div>
- </div>
- </div>
- <div id='footer'>
- <div class='block'>
- <p>Copyright &copy; 2009-2011 Opscode, Inc.</p>
- </div>
- </div>
- </div>
- <div id='sidebar'>
- <div class='block notice' id='sidebar_block_notice'></div>
- <div class='block' id='sidebar_block'></div>
- </div>
- <div class='clear'></div>
- </div>
- </div>
- </body>
-</html>
diff --git a/chef-server-api/app/views/main/index.html.erb b/chef-server-api/app/views/main/index.html.erb
deleted file mode 100644
index e69de29bb2..0000000000
--- a/chef-server-api/app/views/main/index.html.erb
+++ /dev/null