summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorEzra Zygmuntowicz <ez@engineyard.com>2008-10-08 14:19:52 -0700
committerEzra Zygmuntowicz <ez@engineyard.com>2008-10-08 14:19:52 -0700
commitc5d33c1298834ce40b8fbf344f281045771b5371 (patch)
tree1f0d4c7eab1eb379b544282a7ce48052acf719a5 /lib
parent3d14601aea23dee3899d097324875274da419d84 (diff)
downloadchef-c5d33c1298834ce40b8fbf344f281045771b5371.tar.gz
big refactor of the repo layout. move to a chef gem and a chef-server gem all with proper deps
Diffstat (limited to 'lib')
-rw-r--r--lib/chef.rb29
-rw-r--r--lib/chef/client.rb277
-rw-r--r--lib/chef/compile.rb73
-rw-r--r--lib/chef/config.rb98
-rw-r--r--lib/chef/cookbook.rb111
-rw-r--r--lib/chef/cookbook_loader.rb147
-rw-r--r--lib/chef/couchdb.rb149
-rw-r--r--lib/chef/exceptions.rb30
-rw-r--r--lib/chef/file_cache.rb203
-rw-r--r--lib/chef/file_store.rb135
-rw-r--r--lib/chef/log.rb86
-rw-r--r--lib/chef/log/formatter.rb56
-rw-r--r--lib/chef/mixin/check_helper.rb31
-rw-r--r--lib/chef/mixin/checksum.rb36
-rw-r--r--lib/chef/mixin/command.rb206
-rw-r--r--lib/chef/mixin/create_path.rb56
-rw-r--r--lib/chef/mixin/from_file.rb36
-rw-r--r--lib/chef/mixin/generate_url.rb46
-rw-r--r--lib/chef/mixin/params_validate.rb197
-rw-r--r--lib/chef/mixin/template.rb39
-rw-r--r--lib/chef/node.rb260
-rw-r--r--lib/chef/openid_registration.rb175
-rw-r--r--lib/chef/platform.rb202
-rw-r--r--lib/chef/provider.rb40
-rw-r--r--lib/chef/provider/directory.rb68
-rw-r--r--lib/chef/provider/execute.rb55
-rw-r--r--lib/chef/provider/file.rb169
-rw-r--r--lib/chef/provider/link.rb71
-rw-r--r--lib/chef/provider/package.rb105
-rw-r--r--lib/chef/provider/package/apt.rb89
-rw-r--r--lib/chef/provider/package/portage.rb93
-rw-r--r--lib/chef/provider/package/rubygems.rb116
-rw-r--r--lib/chef/provider/remote_directory.rb78
-rw-r--r--lib/chef/provider/remote_file.rb80
-rw-r--r--lib/chef/provider/script.rb35
-rw-r--r--lib/chef/provider/service.rb86
-rw-r--r--lib/chef/provider/service/debian.rb53
-rw-r--r--lib/chef/provider/service/init.rb95
-rw-r--r--lib/chef/provider/sysctl.rb38
-rw-r--r--lib/chef/provider/template.rb69
-rw-r--r--lib/chef/provider/user.rb172
-rw-r--r--lib/chef/provider/user/useradd.rb88
-rw-r--r--lib/chef/queue.rb107
-rw-r--r--lib/chef/recipe.rb127
-rw-r--r--lib/chef/resource.rb172
-rw-r--r--lib/chef/resource/apt_package.rb33
-rw-r--r--lib/chef/resource/bash.rb33
-rw-r--r--lib/chef/resource/csh.rb33
-rw-r--r--lib/chef/resource/directory.rb74
-rw-r--r--lib/chef/resource/execute.rb133
-rw-r--r--lib/chef/resource/file.rb82
-rw-r--r--lib/chef/resource/gem_package.rb33
-rw-r--r--lib/chef/resource/link.rb60
-rw-r--r--lib/chef/resource/package.rb69
-rw-r--r--lib/chef/resource/perl.rb33
-rw-r--r--lib/chef/resource/portage_package.rb33
-rw-r--r--lib/chef/resource/python.rb33
-rw-r--r--lib/chef/resource/remote_directory.rb79
-rw-r--r--lib/chef/resource/remote_file.rb41
-rw-r--r--lib/chef/resource/ruby.rb33
-rw-r--r--lib/chef/resource/script.rb51
-rw-r--r--lib/chef/resource/service.rb113
-rw-r--r--lib/chef/resource/sysctl.rb42
-rw-r--r--lib/chef/resource/template.rb49
-rw-r--r--lib/chef/resource/user.rb96
-rw-r--r--lib/chef/resource_collection.rb174
-rw-r--r--lib/chef/resource_definition.rb67
-rw-r--r--lib/chef/rest.rb150
-rw-r--r--lib/chef/runner.rb100
-rw-r--r--lib/chef/search.rb74
-rw-r--r--lib/chef/search_index.rb80
-rw-r--r--lib/chef_server/controllers/application.rb147
-rw-r--r--lib/chef_server/controllers/cookbook_attributes.rb56
-rw-r--r--lib/chef_server/controllers/cookbook_definitions.rb57
-rw-r--r--lib/chef_server/controllers/cookbook_files.rb118
-rw-r--r--lib/chef_server/controllers/cookbook_recipes.rb57
-rw-r--r--lib/chef_server/controllers/cookbook_templates.rb77
-rw-r--r--lib/chef_server/controllers/cookbooks.rb50
-rw-r--r--lib/chef_server/controllers/exceptions.rb38
-rw-r--r--lib/chef_server/controllers/nodes.rb78
-rw-r--r--lib/chef_server/controllers/openid_consumer.rb117
-rw-r--r--lib/chef_server/controllers/openid_register.rb89
-rw-r--r--lib/chef_server/controllers/openid_server.rb236
-rw-r--r--lib/chef_server/controllers/search.rb71
-rw-r--r--lib/chef_server/controllers/search_entries.rb68
-rw-r--r--lib/chef_server/helpers/global_helpers.rb35
-rw-r--r--lib/chef_server/helpers/nodes_helper.rb37
-rw-r--r--lib/chef_server/helpers/openid_server_helpers.rb27
-rw-r--r--lib/chef_server/init.rb216
-rw-r--r--lib/chef_server/public/images/merb.jpgbin5815 -> 0 bytes
-rw-r--r--lib/chef_server/public/stylesheets/master.css292
-rw-r--r--lib/chef_server/views/cookbook_templates/index.html.haml8
-rw-r--r--lib/chef_server/views/cookbooks/_attribute_file.html.haml2
-rw-r--r--lib/chef_server/views/cookbooks/attribute_files.html.haml4
-rw-r--r--lib/chef_server/views/cookbooks/index.html.haml7
-rw-r--r--lib/chef_server/views/cookbooks/show.html.haml24
-rw-r--r--lib/chef_server/views/exceptions/bad_request.json.erb1
-rw-r--r--lib/chef_server/views/exceptions/internal_server_error.html.erb216
-rw-r--r--lib/chef_server/views/exceptions/not_acceptable.html.erb63
-rw-r--r--lib/chef_server/views/exceptions/not_found.html.erb47
-rw-r--r--lib/chef_server/views/layout/application.html.haml26
-rw-r--r--lib/chef_server/views/nodes/_action.html.haml13
-rw-r--r--lib/chef_server/views/nodes/_node.html.haml9
-rw-r--r--lib/chef_server/views/nodes/_resource.html.haml22
-rw-r--r--lib/chef_server/views/nodes/compile.html.haml5
-rw-r--r--lib/chef_server/views/nodes/index.html.haml9
-rw-r--r--lib/chef_server/views/nodes/show.html.haml1
-rw-r--r--lib/chef_server/views/openid_consumer/index.html.haml25
-rw-r--r--lib/chef_server/views/openid_consumer/start.html.haml4
-rw-r--r--lib/chef_server/views/openid_login/index.html.haml6
-rw-r--r--lib/chef_server/views/openid_register/index.html.haml15
-rw-r--r--lib/chef_server/views/openid_register/show.html.haml5
-rw-r--r--lib/chef_server/views/openid_server/decide.html.haml27
-rw-r--r--lib/chef_server/views/search/_search_form.html.haml6
-rw-r--r--lib/chef_server/views/search/index.html.haml9
-rw-r--r--lib/chef_server/views/search/show.html.haml13
-rw-r--r--lib/chef_server/views/search_entries/index.html.haml9
-rw-r--r--lib/chef_server/views/search_entries/show.html.haml8
118 files changed, 0 insertions, 8932 deletions
diff --git a/lib/chef.rb b/lib/chef.rb
deleted file mode 100644
index ac7f43adef..0000000000
--- a/lib/chef.rb
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 'rubygems'
-
-Dir[
- File.join(
- File.dirname(__FILE__),
- 'chef/**/*.rb'
- )].sort.each { |lib| require lib unless lib =~ /server/ }
-
-class Chef
- VERSION = '0.0.1'
-end
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
deleted file mode 100644
index fd7e263ce0..0000000000
--- a/lib/chef/client.rb
+++ /dev/null
@@ -1,277 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "mixin", "params_validate")
-require File.join(File.dirname(__FILE__), "mixin", "generate_url")
-require File.join(File.dirname(__FILE__), "mixin", "checksum")
-
-require 'rubygems'
-require 'facter'
-
-class Chef
- class Client
-
- include Chef::Mixin::GenerateURL
- include Chef::Mixin::Checksum
-
- attr_accessor :node, :registration, :safe_name
-
- # Creates a new Chef::Client.
- def initialize()
- @node = nil
- @safe_name = nil
- @registration = nil
- @rest = Chef::REST.new(Chef::Config[:registration_url])
- end
-
- # Do a full run for this Chef::Client. Calls:
- #
- # * build_node - Get the last known state, merge with local changes
- # * register - Make sure we have an openid
- # * authenticate - Authenticate with our openid
- # * sync_definitions - Populate the local cache with all the definitions
- # * sync_recipes - Populate the local cache with all the recipes
- # * do_attribute_files - Populate the local cache with all attributes, and execute them
- # * save_node - Store the new node configuration
- # * converge - Bring this system up to date, based on the local cache
- # * save_node - Store the node again, in case convergence altered future state
- #
- # === Returns
- # true:: Always returns true.
- def run
- build_node
- register
- authenticate
- sync_definitions
- sync_recipes
- do_attribute_files
- save_node
- converge
- save_node
- true
- end
-
- # Builds a new node object for this client. Starts with querying for the FQDN of the current
- # host (unless it is supplied), then merges in the facts from Facter.
- #
- # === Parameters
- # node_name<String>:: The name of the node to build - defaults to nil
- #
- # === Returns
- # node:: Returns the created node object, also stored in @node
- def build_node(node_name=nil)
- node_name ||= Facter["fqdn"].value ? Facter["fqdn"].value : Facter["hostname"].value
- @safe_name = node_name.gsub(/\./, '_')
- Chef::Log.debug("Building node object for #{@safe_name}")
- begin
- @node = @rest.get_rest("nodes/#{@safe_name}")
- rescue Net::HTTPServerException => e
- unless e.message =~ /^404/
- raise e
- end
- end
- unless @node
- @node ||= Chef::Node.new
- @node.name(node_name)
- end
- Facter.each do |field, value|
- @node[field] = value
- end
- @node
- end
-
- # If this node has been registered before, this method will fetch the current registration
- # data.
- #
- # If it has not, we register it by calling create_registration.
- #
- # === Returns
- # true:: Always returns true
- def register
- Chef::Log.debug("Registering #{@safe_name} for an openid")
- @registration = nil
- begin
- @registration = @rest.get_rest("registrations/#{@safe_name}")
- rescue Net::HTTPServerException => e
- unless e.message =~ /^404/
- raise e
- end
- end
-
- if @registration
- reg = Chef::FileStore.load("registration", @safe_name)
- @secret = reg["secret"]
- else
- create_registration
- end
- true
- end
-
- # Generates a random secret, stores it in the Chef::Filestore with the "registration" key,
- # and posts our nodes registration information to the server.
- #
- # === Returns
- # true:: Always returns true
- def create_registration
- @secret = random_password(500)
- Chef::FileStore.store("registration", @safe_name, { "secret" => @secret })
- @rest.post_rest("registrations", { :id => @safe_name, :password => @secret })
- true
- end
-
- # Authenticates the node via OpenID.
- #
- # === Returns
- # true:: Always returns true
- def authenticate
- Chef::Log.debug("Authenticating #{@safe_name} via openid")
- response = @rest.post_rest('openid/consumer/start', {
- "openid_identifier" => "#{Chef::Config[:openid_url]}/openid/server/node/#{@safe_name}",
- "submit" => "Verify"
- })
- @rest.post_rest(
- "#{Chef::Config[:openid_url]}#{response["action"]}",
- { "password" => @secret }
- )
- end
-
- # Update the file caches for a given cache segment. Takes a segment name
- # and a hash that matches one of the cookbooks/_attribute_files style
- # remote file listings.
- #
- # === Parameters
- # segment<String>:: The cache segment to update
- # remote_list<Hash>:: A cookbooks/_attribute_files style remote file listing
- def update_file_cache(segment, remote_list)
- # We need the list of known good attribute files, so we can delete any that are
- # just laying about.
- file_canonical = Hash.new
-
- remote_list.each do |rf|
- cache_file = File.join("cookbooks", rf['cookbook'], segment, rf['name'])
- file_canonical[cache_file] = true
-
- current_checksum = nil
- if Chef::FileCache.has_key?(cache_file)
- current_checksum = checksum(Chef::FileCache.load(cache_file, false))
- end
-
- rf_url = generate_cookbook_url(
- rf['name'],
- rf['cookbook'],
- segment,
- @node,
- current_checksum ? { 'checksum' => current_checksum } : nil
- )
- Chef::Log.debug(rf_url)
-
- changed = true
- begin
- raw_file = @rest.get_rest(rf_url, true)
- rescue Net::HTTPRetriableError => e
- if e.response.kind_of?(Net::HTTPNotModified)
- changed = false
- Chef::Log.debug("Cache file #{cache_file} is unchanged")
- else
- raise e
- end
- end
-
- if changed
- Chef::Log.info("Storing updated #{cache_file} in the cache.")
- Chef::FileCache.move_to(raw_file.path, cache_file)
- end
- end
-
- Chef::FileCache.list.each do |cache_file|
- if cache_file.match("cookbooks/.+?/#{segment}")
- unless file_canonical[cache_file]
- Chef::Log.info("Removing #{cache_file} from the cache; it is no longer on the server.")
- Chef::FileCache.delete(cache_file)
- end
- end
- end
-
- end
-
- # Gets all the attribute files included in all the cookbooks available on the server,
- # and executes them.
- #
- # === Returns
- # true:: Always returns true
- def do_attribute_files
- Chef::Log.debug("Synchronizing attributes")
- update_file_cache("attributes", @rest.get_rest('cookbooks/_attribute_files'))
- Chef::FileCache.list.each do |cache_file|
- if cache_file.match("cookbooks/.+?/attributes")
- Chef::Log.debug("Executing #{cache_file}")
- @node.from_file(Chef::FileCache.load(cache_file, false))
- end
- end
- true
- end
-
- def sync_definitions
- Chef::Log.debug("Synchronizing definitions")
- update_file_cache("definitions", @rest.get_rest('cookbooks/_definition_files'))
- end
-
- def sync_recipes
- Chef::Log.debug("Synchronizing attributes")
- update_file_cache("recipes", @rest.get_rest('cookbooks/_recipe_files'))
- end
-
- # Updates the current node configuration on the server.
- #
- # === Returns
- # true:: Always returns true
- def save_node
- Chef::Log.debug("Saving the current state of node #{@safe_name}")
- @node = @rest.put_rest("nodes/#{@safe_name}", @node)
- true
- end
-
- # Compiles the full list of recipes for the server, and passes it to an instance of
- # Chef::Runner.converge.
- #
- # === Returns
- # true:: Always returns true
- def converge
- Chef::Log.debug("Compiling recipes for node #{@safe_name}")
- Chef::Config[:cookbook_path] = File.join(Chef::Config[:file_cache_path], "cookbooks")
- compile = Chef::Compile.new()
- compile.node = @node
- compile.load_definitions
- compile.load_recipes
-
- Chef::Log.debug("Executing recipes for node #{@safe_name}")
- cr = Chef::Runner.new(@node, compile.collection)
- cr.converge
- true
- end
-
- protected
- # Generates a random password of "len" length.
- def random_password(len)
- chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
- newpass = ""
- 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] }
- newpass
- end
-
- end
-end
diff --git a/lib/chef/compile.rb b/lib/chef/compile.rb
deleted file mode 100644
index d5f38368ed..0000000000
--- a/lib/chef/compile.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Compile
-
- attr_accessor :node, :cookbook_loader, :collection, :definitions
-
- # Creates a new Chef::Compile object. This object gets used by the Chef Server to generate
- # a fully compiled recipe list for a node.
- def initialize()
- @node = nil
- @cookbook_loader = Chef::CookbookLoader.new
- @collection = Chef::ResourceCollection.new
- @definitions = Hash.new
- end
-
- # Looks up the node via the "name" argument, first from CouchDB, then by calling
- # Chef::Node.find_file(name)
- #
- # The first step in compiling the catalog. Results available via the node accessor.
- def load_node(name)
- Chef::Log.debug("Loading Chef Node #{name} from CouchDB")
- @node = Chef::Node.load(name)
- Chef::Log.debug("Loading Recipe for Chef Node #{name}")
- @node.find_file(name)
- @node
- end
-
- # Load all the definitions, from every cookbook, so they are available when we process
- # the recipes.
- #
- # Results available via the definitions accessor.
- def load_definitions()
- @cookbook_loader.each do |cookbook|
- hash = cookbook.load_definitions
- @definitions.merge!(hash)
- end
- end
-
- # Load all the recipes specified in the node data (loaded via load_node, above.)
- #
- # The results are available via the collection accessor (which returns a Chef::ResourceCollection
- # object)
- def load_recipes
- @node.recipes.each do |recipe|
- rmatch = recipe.match(/(.+?)::(.+)/)
- if rmatch
- cookbook = @cookbook_loader[rmatch[1]]
- cookbook.load_recipe(rmatch[2], @node, @collection, @definitions, @cookbook_loader)
- else
- cookbook = @cookbook_loader[recipe]
- cookbook.load_recipe("default", @node, @collection, @definitions, @cookbook_loader)
- end
- end
- end
-
- end
-end \ No newline at end of file
diff --git a/lib/chef/config.rb b/lib/chef/config.rb
deleted file mode 100644
index 573cf9dfb7..0000000000
--- a/lib/chef/config.rb
+++ /dev/null
@@ -1,98 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "mixin", "check_helper")
-require File.join(File.dirname(__FILE__), "mixin", "from_file")
-
-# Chef::Config[:variable]
-# @config = Chef::Config.new()
-#
-# Chef::ConfigFast << Chef::Config
-#
-# Chef::Config.from_file(foo)
-# Chef::Resource.from_file (NoMethodError)
-# Chef::Config[:cookbook_path]
-# Chef::Config.cookbook_path
-# Chef::Config.cookbook_path "one", "two"
-
-class Chef
- class Config
- include Chef::Mixin::CheckHelper
-
- @configuration = {
- :cookbook_path => [ "/etc/chef/site-cookbook", "/etc/chef/cookbook" ],
- :node_path => "/etc/chef/node",
- :file_store_path => "/var/chef/store",
- :search_index_path => "/var/chef/search_index",
- :log_level => :info,
- :log_location => STDOUT,
- :merb_log_path => "/var/log/chef/merb.log",
- :openid_providers => nil,
- :ssl_verify_mode => :verify_none,
- :rest_timeout => 60,
- :couchdb_url => "http://localhost:5984",
- :registration_url => "http://localhost:4000",
- :openid_url => "http://localhost:4001",
- :template_url => "http://localhost:4000",
- :remotefile_url => "http://localhost:4000",
- :search_url => "http://localhost:4000",
- :couchdb_database => "chef",
- :openid_store_path => "/var/chef/openid/db",
- :openid_cstore_path => "/var/chef/openid/cstore",
- :file_cache_path => "/var/chef/cache",
- :executable_path => ENV['PATH'] ? ENV['PATH'].split(File::PATH_SEPARATOR) : []
- }
-
- class << self
- include Chef::Mixin::FromFile
-
- def configure(&block)
- yield @configuration
- end
-
- def [](config_option)
- if @configuration.has_key?(config_option.to_sym)
- @configuration[config_option.to_sym]
- else
- raise ArgumentError, "Cannot find configuration option #{config_option.to_s}"
- end
- end
-
- def []=(config_option, value)
- @configuration[config_option.to_sym] = value
- end
-
- def has_key?(key)
- @configuration.has_key?(key.to_sym)
- end
-
- def method_missing(method_symbol, *args)
- if @configuration.has_key?(method_symbol)
- if args.length == 1
- @configuration[method_symbol] = args[0]
- elsif args.length > 1
- @configuration[method_symbol] = args
- end
- return @configuration[method_symbol]
- else
- raise ArgumentError, "Cannot find configuration option #{method_symbol.to_s}"
- end
- end
-
- end # class << self
- end
-end \ No newline at end of file
diff --git a/lib/chef/cookbook.rb b/lib/chef/cookbook.rb
deleted file mode 100644
index 46fc956d83..0000000000
--- a/lib/chef/cookbook.rb
+++ /dev/null
@@ -1,111 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Cookbook
-
- attr_accessor :attribute_files, :definition_files, :template_files, :remote_files, :name
- attr_reader :recipe_files
-
- def initialize(name)
- @name = name
- @attribute_files = Array.new
- @definition_files = Array.new
- @template_files = Array.new
- @remote_files = Array.new
- @recipe_files = Array.new
- @recipe_names = Hash.new
- @loaded_attributes = false
- end
-
- def load_attributes(node)
- unless node.kind_of?(Chef::Node)
- raise ArgumentError, "You must pass a Chef::Node to load_attributes!"
- end
- @attribute_files.each do |file|
- node.from_file(file)
- end
- @loaded_atributes = true
- node
- end
-
- def load_definitions
- results = Hash.new
- @definition_files.each do |file|
- Chef::Log.debug("Loading cookbook #{name}'s definitions from #{file}")
- resourcedef = Chef::ResourceDefinition.new
- resourcedef.from_file(file)
- results[resourcedef.name] = resourcedef
- end
- results
- end
-
- def recipe_files=(*args)
- @recipe_files = args.flatten
- @recipe_files.each_index do |i|
- file = @recipe_files[i]
- case file
- when /(.+\/)(.+).rb$/
- @recipe_names[$2] = i
- when /(.+).rb$/
- @recipe_names[$1] = i
- else
- @recipe_names[file] = i
- end
- end
- @recipe_files
- end
-
- def recipe?(name)
- lookup_name = name
- if name =~ /(.+)::(.+)/
- cookbook_name = $1
- lookup_name = $2
- return false unless cookbook_name == @name
- end
- @recipe_names.has_key?(lookup_name)
- end
-
- def recipes
- results = Array.new
- @recipe_names.each_key do |rname|
- results << "#{@name}::#{rname}"
- end
- results
- end
-
- def load_recipe(name, node, collection=nil, definitions=nil, cookbook_loader=nil)
- cookbook_name = @name
- recipe_name = nil
- nmatch = name.match(/^(.+?)::(.+)$/)
- recipe_name = nmatch ? nmatch[2] : name
-
- unless @recipe_names.has_key?(recipe_name)
- raise ArgumentError, "Cannot find a recipe matching #{recipe_name} in cookbook #{@name}"
- end
- Chef::Log.debug("Found recipe #{recipe_name} in cookbook #{cookbook_name}") if Chef::Log.debug?
- unless @loaded_attributes
- load_attributes(node)
- end
- recipe = Chef::Recipe.new(cookbook_name, recipe_name, node,
- collection, definitions, cookbook_loader)
- recipe.from_file(@recipe_files[@recipe_names[recipe_name]])
- recipe
- end
-
- end
-end \ No newline at end of file
diff --git a/lib/chef/cookbook_loader.rb b/lib/chef/cookbook_loader.rb
deleted file mode 100644
index 6f6c8d8010..0000000000
--- a/lib/chef/cookbook_loader.rb
+++ /dev/null
@@ -1,147 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class CookbookLoader
-
- attr_accessor :cookbook
-
- include Enumerable
-
- def initialize()
- @cookbook = Hash.new
- load_cookbooks
- end
-
- def load_cookbooks
- cookbook_settings = Hash.new
- Chef::Config.cookbook_path.each do |cb_path|
- Dir[File.join(cb_path, "*")].each do |cookbook|
- next unless File.directory?(cookbook)
- cookbook_name = File.basename(cookbook).to_sym
- unless cookbook_settings.has_key?(cookbook_name)
- cookbook_settings[cookbook_name] = {
- :ignore_regexes => Array.new,
- :attribute_files => Array.new,
- :definition_files => Array.new,
- :recipe_files => Array.new,
- :template_files => Array.new,
- :remote_files => Array.new,
- }
- end
- ignore_regexes = load_ignore_file(File.join(cookbook, "ignore"))
- cookbook_settings[cookbook_name][:ignore_regexes].concat(ignore_regexes)
- load_files_unless_basename(
- File.join(cookbook, "attributes", "*.rb"),
- cookbook_settings[cookbook_name][:attribute_files],
- cookbook_settings[cookbook_name][:ignore_regexes]
- )
- load_files_unless_basename(
- File.join(cookbook, "definitions", "*.rb"),
- cookbook_settings[cookbook_name][:definition_files],
- cookbook_settings[cookbook_name][:ignore_regexes]
- )
- load_files_unless_basename(
- File.join(cookbook, "recipes", "*.rb"),
- cookbook_settings[cookbook_name][:recipe_files],
- cookbook_settings[cookbook_name][:ignore_regexes]
- )
- load_cascading_files(
- File.join(cookbook, "templates", "**", "*.erb"),
- File.join(cookbook, "templates"),
- cookbook_settings[cookbook_name][:template_files],
- cookbook_settings[cookbook_name][:ignore_regexes]
- )
- load_cascading_files(
- File.join(cookbook, "files", "**", "*"),
- File.join(cookbook, "files"),
- cookbook_settings[cookbook_name][:remote_files],
- cookbook_settings[cookbook_name][:ignore_regexes]
- )
- end
- end
- cookbook_settings.each_key do |cookbook|
- @cookbook[cookbook] = Chef::Cookbook.new(cookbook)
- @cookbook[cookbook].attribute_files = cookbook_settings[cookbook][:attribute_files]
- @cookbook[cookbook].definition_files = cookbook_settings[cookbook][:definition_files]
- @cookbook[cookbook].recipe_files = cookbook_settings[cookbook][:recipe_files]
- @cookbook[cookbook].template_files = cookbook_settings[cookbook][:template_files]
- @cookbook[cookbook].remote_files = cookbook_settings[cookbook][:remote_files]
- end
- end
-
- def [](cookbook)
- if @cookbook.has_key?(cookbook.to_sym)
- @cookbook[cookbook.to_sym]
- else
- raise ArgumentError, "Cannot find a cookbook named #{cookbook.to_s}"
- end
- end
-
- def each
- @cookbook.each_value do |cobject|
- yield cobject
- end
- end
-
- private
-
- def load_ignore_file(ignore_file)
- results = Array.new
- if File.exists?(ignore_file) && File.readable?(ignore_file)
- IO.foreach(ignore_file) do |line|
- next if line =~ /^#/
- next if line =~ /^\w*$/
- line.chomp!
- results << Regexp.new(line)
- end
- end
- results
- end
-
- def load_cascading_files(file_glob, base_path, result_array, ignore_regexes)
- Dir[file_glob].each do |file|
- next if skip_file(file, ignore_regexes)
- file =~ /^#{base_path}\/(.+)$/
- singlecopy = $1
- unless result_array.detect { |f| f =~ /#{singlecopy}$/ }
- result_array << file
- end
- end
- end
-
- def load_files_unless_basename(file_glob, result_array, ignore_regexes)
- Dir[file_glob].each do |file|
- next if skip_file(file, ignore_regexes)
- file_basename = File.basename(file)
- # If we've seen a file with this basename before, skip it.
- unless result_array.detect { |f| File.basename(f) == file_basename }
- result_array << file
- end
- end
- end
-
- def skip_file(file, ignore_regexes)
- skip = false
- ignore_regexes.each do |exp|
- skip = true if exp.match(file)
- end
- skip
- end
-
- end
-end \ No newline at end of file
diff --git a/lib/chef/couchdb.rb b/lib/chef/couchdb.rb
deleted file mode 100644
index 22a651ca48..0000000000
--- a/lib/chef/couchdb.rb
+++ /dev/null
@@ -1,149 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "mixin", "params_validate")
-require 'digest/sha2'
-require 'json'
-
-class Chef
- class CouchDB
- include Chef::Mixin::ParamsValidate
-
- def initialize(url=nil)
- url ||= Chef::Config[:couchdb_url]
- @rest = Chef::REST.new(url)
- end
-
- def create_db
- @database_list = @rest.get_rest("_all_dbs")
- unless @database_list.detect { |db| db == Chef::Config[:couchdb_database] }
- response = @rest.put_rest(Chef::Config[:couchdb_database], Hash.new)
- end
- Chef::Config[:couchdb_database]
- end
-
- def create_design_document(name, data)
- to_update = true
- begin
- old_doc = @rest.get_rest("#{Chef::Config[:couchdb_database]}/_design%2F#{name}")
- if data["version"] != old_doc["version"]
- data["_rev"] = old_doc["_rev"]
- Chef::Log.debug("Updating #{name} views")
- else
- to_update = false
- end
- rescue
- Chef::Log.debug("Creating #{name} views for the first time")
- end
- if to_update
- @rest.put_rest("#{Chef::Config[:couchdb_database]}/_design%2F#{name}", data)
- end
- true
- end
-
- def store(obj_type, name, object)
- validate(
- {
- :obj_type => obj_type,
- :name => name,
- :object => object,
- },
- {
- :object => { :respond_to => :to_json },
- }
- )
- @rest.put_rest("#{Chef::Config[:couchdb_database]}/#{obj_type}_#{safe_name(name)}", object)
- end
-
- def load(obj_type, name)
- validate(
- {
- :obj_type => obj_type,
- :name => name,
- },
- {
- :obj_type => { :kind_of => String },
- :name => { :kind_of => String },
- }
- )
- @rest.get_rest("#{Chef::Config[:couchdb_database]}/#{obj_type}_#{safe_name(name)}")
- end
-
- def delete(obj_type, name, rev=nil)
- validate(
- {
- :obj_type => obj_type,
- :name => name,
- },
- {
- :obj_type => { :kind_of => String },
- :name => { :kind_of => String },
- }
- )
- unless rev
- last_obj = @rest.get_rest("#{Chef::Config[:couchdb_database]}/#{obj_type}_#{safe_name(name)}")
- if last_obj.respond_to?(:couchdb_rev)
- rev = last_obj.couchdb_rev
- else
- rev = last_obj['_rev']
- end
- end
- @rest.delete_rest("#{Chef::Config[:couchdb_database]}/#{obj_type}_#{safe_name(name)}?rev=#{rev}")
- end
-
- def list(view, inflate=false)
- validate(
- {
- :view => view,
- },
- {
- :view => { :kind_of => String }
- }
- )
- if inflate
- @rest.get_rest("#{Chef::Config[:couchdb_database]}/_view/#{view}/all")
- else
- @rest.get_rest("#{Chef::Config[:couchdb_database]}/_view/#{view}/all_id")
- end
- end
-
- def has_key?(obj_type, name)
- validate(
- {
- :obj_type => obj_type,
- :name => name,
- },
- {
- :obj_type => { :kind_of => String },
- :name => { :kind_of => String },
- }
- )
- begin
- @rest.get_rest("#{Chef::Config[:couchdb_database]}/#{obj_type}_#{safe_name(name)}")
- true
- rescue
- false
- end
- end
-
- private
- def safe_name(name)
- name.gsub(/\./, "_")
- end
-
- end
-end \ No newline at end of file
diff --git a/lib/chef/exceptions.rb b/lib/chef/exceptions.rb
deleted file mode 100644
index fa037a7f6c..0000000000
--- a/lib/chef/exceptions.rb
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Exception
- class Exec < RuntimeError; end
- class FileNotFound < RuntimeError; end
- class Package < RuntimeError; end
- class Service < RuntimeError; end
- class SearchIndex < RuntimeError; end
- class Override < RuntimeError; end
- class UnsupportedAction < RuntimeError; end
- class MissingLibrary < RuntimeError; end
- class User < RuntimeError; end
- end
-end
diff --git a/lib/chef/file_cache.rb b/lib/chef/file_cache.rb
deleted file mode 100644
index ea9e17fbb7..0000000000
--- a/lib/chef/file_cache.rb
+++ /dev/null
@@ -1,203 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "mixin", "params_validate")
-require File.join(File.dirname(__FILE__), "mixin", "create_path")
-require 'json'
-
-class Chef
- class FileCache
- class << self
- include Chef::Mixin::ParamsValidate
- include Chef::Mixin::CreatePath
-
- # Write a file to the File Cache.
- #
- # === Parameters
- # path<String>:: The path to the file you want to put in the cache - should
- # be relative to Chef::Config[:file_cache_path]
- # contents<String>:: A string with the contents you want written to the file
- #
- # === Returns
- # true
- def store(path, contents)
- validate(
- {
- :path => path,
- :contents => contents
- },
- {
- :path => { :kind_of => String },
- :contents => { :kind_of => String },
- }
- )
-
- file_path_array = File.split(path)
- file_name = file_path_array.pop
- cache_path = create_cache_path(File.join(file_path_array))
- io = File.open(File.join(cache_path, file_name), "w")
- io.print(contents)
- io.close
- true
- end
-
- # Move a file in to the cache. Useful with the REST raw file output.
- #
- # === Parameteres
- # file<String>:: The path to the file you want in the cache
- # path<String>:: The relative name you want the new file to use
- def move_to(file, path)
- validate(
- {
- :file => file,
- :path => path
- },
- {
- :file => { :kind_of => String },
- :path => { :kind_of => String },
- }
- )
-
- file_path_array = File.split(path)
- file_name = file_path_array.pop
- if File.exists?(file) && File.writable?(file)
- File.rename(
- file,
- File.join(create_cache_path(File.join(file_path_array), true), file_name)
- )
- else
- raise RuntimeError, "Cannot move #{file} to #{path}!"
- end
- end
-
- # Read a file from the File Cache
- #
- # === Parameters
- # path<String>:: The path to the file you want to load - should
- # be relative to Chef::Config[:file_cache_path]
- # read<True/False>:: Whether to return the file contents, or the path.
- # Defaults to true.
- #
- # === Returns
- # String:: A string with the file contents.
- #
- # === Raises
- # Chef::Exception::FileNotFound:: If it cannot find the file in the cache
- def load(path, read=true)
- validate(
- {
- :path => path
- },
- {
- :path => { :kind_of => String }
- }
- )
- cache_path = create_cache_path(path, false)
- raise Chef::Exception::FileNotFound, "Cannot find #{cache_path} for #{path}!" unless File.exists?(cache_path)
- if read
- File.read(cache_path)
- else
- cache_path
- end
- end
-
- # Delete a file from the File Cache
- #
- # === Parameters
- # path<String>:: The path to the file you want to delete - should
- # be relative to Chef::Config[:file_cache_path]
- #
- # === Returns
- # true
- def delete(path)
- validate(
- {
- :path => path
- },
- {
- :path => { :kind_of => String },
- }
- )
- cache_path = create_cache_path(path, false)
- if File.exists?(cache_path)
- File.unlink(cache_path)
- end
- true
- end
-
- # List all the files in the Cache
- #
- # === Returns
- # Array:: An array of files in the cache, suitable for use with load, delete and store
- def list()
- keys = Array.new
- Dir[File.join(Chef::Config[:file_cache_path], '**', '*')].each do |f|
- if File.file?(f)
- path = f.match("^#{Chef::Config[:file_cache_path]}\/(.+)")[1]
- keys << path
- end
- end
- keys
- end
-
- # Whether or not this file exists in the Cache
- #
- # === Parameters
- # path:: The path to the file you want to check - is relative
- # to Chef::Config[:file_cache_path]
- #
- # === Returns
- # True:: If the file exists
- # False:: If it does not
- def has_key?(path)
- validate(
- {
- :path => path
- },
- {
- :path => { :kind_of => String },
- }
- )
- full_path = create_cache_path(path, false)
- if File.exists?(full_path)
- true
- else
- false
- end
- end
-
- # Create a full path to a given file in the cache. By default,
- # also creates the path if it does not exist.
- #
- # === Parameters
- # path:: The path to create, relative to Chef::Config[:file_cache_path]
- # create_if_missing:: True by default - whether to create the path if it does not exist
- #
- # === Returns
- # String:: The fully expanded path
- def create_cache_path(path, create_if_missing=true)
- cache_dir = File.expand_path(File.join(Chef::Config[:file_cache_path], path))
- if create_if_missing
- create_path(cache_dir)
- else
- cache_dir
- end
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/file_store.rb b/lib/chef/file_store.rb
deleted file mode 100644
index 6fe13e5ad6..0000000000
--- a/lib/chef/file_store.rb
+++ /dev/null
@@ -1,135 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "mixin", "params_validate")
-require File.join(File.dirname(__FILE__), "mixin", "create_path")
-require 'digest/sha2'
-require 'json'
-
-class Chef
- class FileStore
- class << self
- include Chef::Mixin::ParamsValidate
- include Chef::Mixin::CreatePath
-
- def store(obj_type, name, object)
- validate(
- {
- :obj_type => obj_type,
- :name => name,
- :object => object,
- },
- {
- :object => { :respond_to => :to_json },
- }
- )
-
- store_path = create_store_path(obj_type, name)
- io = File.open(store_path, "w")
- io.puts object.to_json
- io.close
- end
-
- def load(obj_type, name)
- validate(
- {
- :obj_type => obj_type,
- :name => name,
- },
- {
- :obj_type => { :kind_of => String },
- :name => { :kind_of => String },
- }
- )
- store_path = create_store_path(obj_type, name)
- raise "Cannot find #{store_path} for #{obj_type} #{name}!" unless File.exists?(store_path)
- object = JSON.parse(IO.read(store_path))
- end
-
- def delete(obj_type, name)
- validate(
- {
- :obj_type => obj_type,
- :name => name,
- },
- {
- :obj_type => { :kind_of => String },
- :name => { :kind_of => String },
- }
- )
- store_path = create_store_path(obj_type, name)
- if File.exists?(store_path)
- File.unlink(store_path)
- end
- end
-
- def list(obj_type, inflate=false)
- validate(
- {
- :obj_type => obj_type,
- },
- {
- :obj_type => { :kind_of => String }
- }
- )
- keys = Array.new
- Dir[File.join(Chef::Config[:file_store_path], obj_type, '**', '*')].each do |f|
- if File.file?(f)
- if inflate
- keys << load(obj_type, File.basename(f))
- else
- keys << File.basename(f)
- end
- end
- end
- keys
- end
-
- def has_key?(obj_type, name)
- validate(
- {
- :obj_type => obj_type,
- :name => name,
- },
- {
- :obj_type => { :kind_of => String },
- :name => { :kind_of => String },
- }
- )
- Dir[File.join(Chef::Config[:file_store_path], obj_type, '**', '*')].each do |f|
- if File.file?(f)
- return true if File.basename(f) == name
- end
- end
- return false
- end
-
- def create_store_path(obj_type, key)
- shadigest = Digest::SHA2.hexdigest("#{obj_type}#{key}")
-
- file_path = [
- Chef::Config[:file_store_path],
- obj_type,
- shadigest[0,1],
- shadigest[1,3]
- ]
- File.join(create_path(file_path), key)
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/log.rb b/lib/chef/log.rb
deleted file mode 100644
index ff98cc9dff..0000000000
--- a/lib/chef/log.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 'logger'
-
-class Chef
- class Log
-
- @logger = nil
-
- class << self
- attr_reader :logger #:nodoc
-
- # Use Chef::Logger.init when you want to set up the logger manually. Arguments to this method
- # get passed directly to Logger.new, so check out the documentation for the standard Logger class
- # to understand what to do here.
- #
- # If this method is called with no arguments, it will log to STDOUT at the :info level.
- #
- # It also configures the Logger instance it creates to use the custom Chef::Log::Formatter class.
- def init(*opts)
- if opts.length == 0
- @logger = Logger.new(STDOUT)
- else
- @logger = Logger.new(*opts)
- end
- @logger.formatter = Chef::Log::Formatter.new()
- level(Chef::Config.log_level)
- end
-
- # Sets the level for the Logger object by symbol. Valid arguments are:
- #
- # :debug
- # :info
- # :warn
- # :error
- # :fatal
- #
- # Throws an ArgumentError if you feed it a bogus log level.
- def level(loglevel)
- init() unless @logger
- case loglevel
- when :debug
- @logger.level = Logger::DEBUG
- when :info
- @logger.level = Logger::INFO
- when :warn
- @logger.level = Logger::WARN
- when :error
- @logger.level = Logger::ERROR
- when :fatal
- @logger.level = Logger::FATAL
- else
- raise ArgumentError, "Log level must be one of :debug, :info, :warn, :error, or :fatal"
- end
- end
-
- # Passes any other method calls on directly to the underlying Logger object created with init. If
- # this method gets hit before a call to Chef::Logger.init has been made, it will call
- # Chef::Logger.init() with no arguments.
- def method_missing(method_symbol, *args)
- init() unless @logger
- if args.length > 0
- @logger.send(method_symbol, *args)
- else
- @logger.send(method_symbol)
- end
- end
-
- end # class << self
- end
-end \ No newline at end of file
diff --git a/lib/chef/log/formatter.rb b/lib/chef/log/formatter.rb
deleted file mode 100644
index 9f758178f5..0000000000
--- a/lib/chef/log/formatter.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 'logger'
-require 'time'
-
-class Chef
- class Log
- class Formatter < Logger::Formatter
- @@show_time = true
-
- def self.show_time=(show=false)
- @@show_time = show
- end
-
- # Prints a log message as '[time] severity: message' if Chef::Log::Formatter.show_time == true.
- # Otherwise, doesn't print the time.
- def call(severity, time, progname, msg)
- if @@show_time
- sprintf("[%s] %s: %s\n", time.rfc2822(), severity, msg2str(msg))
- else
- sprintf("%s: %s\n", severity, msg2str(msg))
- end
- end
-
- # Converts some argument to a Logger.severity() call to a string. Regular strings pass through like
- # normal, Exceptions get formatted as "message (class)\nbacktrace", and other random stuff gets
- # put through "object.inspect"
- def msg2str(msg)
- case msg
- when ::String
- msg
- when ::Exception
- "#{ msg.message } (#{ msg.class })\n" <<
- (msg.backtrace || []).join("\n")
- else
- msg.inspect
- end
- end
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/mixin/check_helper.rb b/lib/chef/mixin/check_helper.rb
deleted file mode 100644
index 959b57cbb7..0000000000
--- a/lib/chef/mixin/check_helper.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- module Mixin
- module CheckHelper
- def set_if_args(thing, arguments)
- raise ArgumentError, "Must call set_if_args with a block!" unless Kernel.block_given?
- if arguments != nil
- yield(arguments)
- else
- thing
- end
- end
- end
- end
-end
diff --git a/lib/chef/mixin/checksum.rb b/lib/chef/mixin/checksum.rb
deleted file mode 100644
index 5a7eed4165..0000000000
--- a/lib/chef/mixin/checksum.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 'digest/md5'
-
-class Chef
- module Mixin
- module Checksum
-
- def checksum(file)
- digest = Digest::MD5.new
- fh = ::File.open(file)
- fh.each do |line|
- digest.update(line)
- end
- digest.hexdigest
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/mixin/command.rb b/lib/chef/mixin/command.rb
deleted file mode 100644
index 08344148a5..0000000000
--- a/lib/chef/mixin/command.rb
+++ /dev/null
@@ -1,206 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 'tmpdir'
-require 'fcntl'
-require 'etc'
-
-class Chef
- module Mixin
- module Command
-
- def run_command(args={})
- if args.has_key?(:creates)
- if File.exists?(args[:creates])
- Chef::Log.debug("Skipping #{args[:command_string]} - creates #{args[:creates]} exists.")
- return false
- end
- end
-
- if args.has_key?(:onlyif)
- status = popen4(args[:onlyif]) { |p, i, o, e| }
- if status.exitstatus != 0
- Chef::Log.debug("Skipping #{args[:command_string]} - onlyif #{args[:onlyif]} returned #{status.exitstatus}")
- return false
- end
- end
-
- if args.has_key?(:not_if)
- status = popen4(args[:not_if]) { |p, i, o, e| }
- if status.exitstatus == 0
- Chef::Log.debug("Skipping #{args[:command_string]} - unless #{args[:not_if]} returned #{status.exitstatus}")
- return false
- end
- end
-
- exec_processing_block = lambda do |pid, stdin, stdout, stderr|
- stdin.close
-
- stdout_string = stdout.gets(nil)
- if stdout_string
- Chef::Log.debug("---- Begin #{args[:command_string]} STDOUT ----")
- Chef::Log.debug(stdout_string.strip)
- Chef::Log.debug("---- End #{args[:command_string]} STDOUT ----")
- end
- stderr_string = stderr.gets(nil)
- if stderr_string
- Chef::Log.debug("---- Begin #{args[:command_string]} STDERR ----")
- Chef::Log.debug(stderr_string.strip)
- Chef::Log.debug("---- End #{args[:command_string]} STDERR ----")
- end
- end
-
- args[:cwd] ||= Dir.tmpdir
- unless File.directory?(args[:cwd])
- raise Chef::Exception::Exec, "#{args[:cwd]} does not exist or is not a directory"
- end
-
- status = nil
- Dir.chdir(args[:cwd]) do
- if args[:timeout]
- begin
- Timeout.timeout(args[:timeout]) do
- status = popen4(args[:command], args, &exec_processing_block)
- end
- rescue Exception => e
- Chef::Log.error("#{args[:command_string]} exceeded timeout #{args[:timeout]}")
- raise(e)
- end
- else
- status = popen4(args[:command], args, &exec_processing_block)
- end
-
- args[:returns] ||= 0
- if status.exitstatus != args[:returns]
- raise Chef::Exception::Exec, "#{args[:command_string]} returned #{status.exitstatus}, expected #{args[:returns]}"
- else
- Chef::Log.debug("Ran #{args[:command_string]} (#{args[:command]}) returned #{status.exitstatus}")
- end
- end
- status
- end
-
- module_function :run_command
-
- # This is taken directly from Ara T Howard's Open4 library, and then
- # modified to suit the needs of Chef. Any bugs here are most likely
- # my own, and not Ara's.
- #
- # The original appears in external/open4.rb in it's unmodified form.
- #
- # Thanks, Ara.
- def popen4(cmd, args={}, &b)
-
- args[:user] ||= nil
- unless args[:user].kind_of?(Integer)
- args[:user] = Etc.getpwnam(args[:user]).uid if args[:user]
- end
- args[:group] ||= nil
- unless args[:group].kind_of?(Integer)
- args[:group] = Etc.getgrnam(args[:group]).gid if args[:group]
- end
- args[:environment] ||= nil
-
- pw, pr, pe, ps = IO.pipe, IO.pipe, IO.pipe, IO.pipe
-
- verbose = $VERBOSE
- begin
- $VERBOSE = nil
- ps.last.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
-
- cid = fork {
- pw.last.close
- STDIN.reopen pw.first
- pw.first.close
-
- pr.first.close
- STDOUT.reopen pr.last
- pr.last.close
-
- pe.first.close
- STDERR.reopen pe.last
- pe.last.close
-
- STDOUT.sync = STDERR.sync = true
-
- if args[:user]
- Process.euid = args[:user]
- Process.uid = args[:user]
- end
-
- if args[:group]
- Process.egid = args[:group]
- Process.gid = args[:group]
- end
-
- if args[:environment]
- args[:environment].each do |key,value|
- ENV[key] = value
- end
- end
-
- begin
- if cmd.kind_of?(Array)
- exec(*cmd)
- else
- exec(cmd)
- end
- raise 'forty-two'
- rescue Exception => e
- Marshal.dump(e, ps.last)
- ps.last.flush
- end
- ps.last.close unless (ps.last.closed?)
- exit!
- }
- ensure
- $VERBOSE = verbose
- end
-
- [pw.first, pr.last, pe.last, ps.last].each{|fd| fd.close}
-
- begin
- e = Marshal.load ps.first
- raise(Exception === e ? e : "unknown failure!")
- rescue EOFError # If we get an EOF error, then the exec was successful
- 42
- ensure
- ps.first.close
- end
-
- pw.last.sync = true
-
- pi = [pw.last, pr.first, pe.first]
-
- if b
- begin
- b[cid, *pi]
- Process.waitpid2(cid).last
- ensure
- pi.each{|fd| fd.close unless fd.closed?}
- end
- else
- [cid, pw.last, pr.first, pe.first]
- end
- end
-
- module_function :popen4
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/mixin/create_path.rb b/lib/chef/mixin/create_path.rb
deleted file mode 100644
index dc9200eaf5..0000000000
--- a/lib/chef/mixin/create_path.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- module Mixin
- module CreatePath
-
- # Creates a given path, including all directories that lead up to it.
- # Like mkdir_p, but without the leaking.
- #
- # === Parameters
- # file_path<String, Array>:: A string that represents the path to create,
- # or an Array with the path-parts.
- #
- # === Returns
- # The created file_path.
- def create_path(file_path)
- unless file_path.kind_of?(String) || file_path.kind_of?(Array)
- raise ArgumentError, "file_path must be a string or an array!"
- end
-
- if file_path.kind_of?(String)
- file_path = File.expand_path(file_path).split(File::SEPARATOR)
- file_path.shift if file_path[0] = ''
- unless file_path[0].match("^#{File::SEPARATOR}")
- file_path[0] = "#{File::SEPARATOR}#{file_path[0]}"
- end
- end
-
- file_path.each_index do |i|
- create_path = File.join(file_path[0, i + 1])
- unless File.directory?(create_path)
- Chef::Log.debug("Creating directory #{create_path}")
- Dir.mkdir(create_path)
- end
- end
- File.expand_path(File.join(file_path))
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/mixin/from_file.rb b/lib/chef/mixin/from_file.rb
deleted file mode 100644
index 05f7fe8e8b..0000000000
--- a/lib/chef/mixin/from_file.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- module Mixin
- module FromFile
-
- # Loads a given ruby file, and runs instance_eval against it in the context of the current
- # object.
- #
- # Raises an IOError if the file cannot be found, or is not readable.
- def from_file(filename)
- if File.exists?(filename) && File.readable?(filename)
- self.instance_eval(IO.read(filename), filename, 1)
- else
- raise IOError, "Cannot open or read #{filename}!"
- end
- end
- end
- end
-end
diff --git a/lib/chef/mixin/generate_url.rb b/lib/chef/mixin/generate_url.rb
deleted file mode 100644
index 3eb8c4f70d..0000000000
--- a/lib/chef/mixin/generate_url.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- module Mixin
- module GenerateURL
-
- def generate_cookbook_url(url, cookbook, type, node, args=nil)
- new_url = nil
- if url =~ /^http/
- new_url = url
- else
- new_url = "cookbooks/#{cookbook}/#{type}?"
- new_url += "id=#{url}"
- platform, version = Chef::Platform.find_platform_and_version(node)
- if type == "files" || type == "templates"
- new_url += "&platform=#{platform}&version=#{version}&fqdn=#{node[:fqdn]}"
- end
- if args
- args.each do |key, value|
- new_url += "&#{key}=#{value}"
- end
- end
- end
-
- return new_url
- end
-
- end
- end
-end
diff --git a/lib/chef/mixin/params_validate.rb b/lib/chef/mixin/params_validate.rb
deleted file mode 100644
index 4d8ddb74c3..0000000000
--- a/lib/chef/mixin/params_validate.rb
+++ /dev/null
@@ -1,197 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- module Mixin
- module ParamsValidate
-
- # Takes a hash of options, along with a map to validate them. Returns the original
- # options hash, plus any changes that might have been made (through things like setting
- # default values in the validation map)
- #
- # For example:
- #
- # validate({ :one => "neat" }, { :one => { :kind_of => String }})
- #
- # Would raise an exception if the value of :one above is not a kind_of? string. Valid
- # map options are:
- #
- # :default:: Sets the default value for this parameter.
- # :callbacks:: Takes a hash of Procs, which should return true if the argument is valid.
- # The key will be inserted into the error message if the Proc does not return true:
- # "Option #{key}'s value #{value} #{message}!"
- # :kind_of:: Ensure that the value is a kind_of?(Whatever). If passed an array, it will ensure
- # that the value is one of those types.
- # :respond_to:: Ensure that the value has a given method. Takes one method name or an array of
- # method names.
- # :required:: Raise an exception if this parameter is missing. Valid values are true or false,
- # by default, options are not required.
- # :regex:: Match the value of the paramater against a regular expression.
- # :equal_to:: Match the value of the paramater with ==. An array means it can be equal to any
- # of the values.
- def validate(opts, map)
- #--
- # validate works by taking the keys in the validation map, assuming it's a hash, and
- # looking for _pv_:symbol as methods. Assuming it find them, it calls the right
- # one.
- #++
- raise ArgumentError, "Options must be a hash" unless opts.kind_of?(Hash)
- raise ArgumentError, "Validation Map must be a hash" unless map.kind_of?(Hash)
-
- map.each do |key, validation|
- unless key.kind_of?(Symbol) || key.kind_of?(String)
- raise ArgumentError, "Validation map keys must be symbols or strings!"
- end
- case validation
- when true
- _pv_required(opts, key)
- when false
- true
- when Hash
- validation.each do |check, carg|
- check_method = "_pv_#{check.to_s}"
- if self.respond_to?(check_method, true)
- self.send(check_method, opts, key, carg)
- else
- raise ArgumentError, "Validation map has unknown check: #{check}"
- end
- end
- end
- end
- opts
- end
-
- def set_or_return(symbol, arg, validation)
- iv_symbol = "@#{symbol.to_s}".to_sym
- map = {
- symbol => validation
- }
- if arg == nil
- self.instance_variable_get(iv_symbol)
- else
- validate({ symbol => arg }, { symbol => validation })
- self.instance_variable_set(iv_symbol, arg)
- end
- end
-
- private
-
- # Return the value of a parameter, or nil if it doesn't exist.
- def _pv_opts_lookup(opts, key)
- if opts.has_key?(key.to_s)
- opts[key.to_s]
- elsif opts.has_key?(key.to_sym)
- opts[key.to_sym]
- else
- nil
- end
- end
-
- # Raise an exception if the parameter is not found.
- def _pv_required(opts, key, is_required=true)
- if is_required
- if opts.has_key?(key.to_s) || opts.has_key?(key.to_sym)
- true
- else
- raise ArgumentError, "Required argument #{key} is missing!"
- end
- end
- end
-
- def _pv_equal_to(opts, key, to_be)
- value = _pv_opts_lookup(opts, key)
- if value != nil
- passes = false
- [ to_be ].flatten.each do |tb|
- if value == tb
- passes = true
- end
- end
- unless passes
- raise ArgumentError, "Option #{key} must be equal to one of: #{to_be.join(", ")}! You passed #{value.inspect}."
- end
- end
- end
-
- # Raise an exception if the parameter is not a kind_of?(to_be)
- def _pv_kind_of(opts, key, to_be)
- value = _pv_opts_lookup(opts, key)
- if value != nil
- passes = false
- [ to_be ].flatten.each do |tb|
- if value.kind_of?(tb)
- passes = true
- end
- end
- unless passes
- raise ArgumentError, "Option #{key} must be a kind of #{to_be}! You passed #{value.inspect}."
- end
- end
- end
-
- # Raise an exception if the parameter does not respond to a given set of methods.
- def _pv_respond_to(opts, key, method_name_list)
- value = _pv_opts_lookup(opts, key)
- if value != nil
- [ method_name_list ].flatten.each do |method_name|
- unless value.respond_to?(method_name)
- raise ArgumentError, "Option #{key} must have a #{method_name} method!"
- end
- end
- end
- end
-
- # Assign a default value to a parameter.
- def _pv_default(opts, key, default_value)
- value = _pv_opts_lookup(opts, key)
- if value == nil
- opts[key] = default_value
- end
- end
-
- # Check a parameter against a regular expression.
- def _pv_regex(opts, key, regex)
- value = _pv_opts_lookup(opts, key)
- passes = false
- [ regex ].flatten.each do |r|
- if value != nil
- if r.match(value.to_s)
- passes = true
- end
- end
- end
- unless passes
- raise ArgumentError, "Option #{key}'s value #{value} does not match regular expression #{regex.to_s}"
- end
- end
-
- # Check a parameter against a hash of proc's.
- def _pv_callbacks(opts, key, callbacks)
- raise ArgumentError, "Callback list must be a hash!" unless callbacks.kind_of?(Hash)
- value = _pv_opts_lookup(opts, key)
- if value != nil
- callbacks.each do |message, zeproc|
- if zeproc.call(value) != true
- raise ArgumentError, "Option #{key}'s value #{value} #{message}!"
- end
- end
- end
- end
- end
- end
-end
-
diff --git a/lib/chef/mixin/template.rb b/lib/chef/mixin/template.rb
deleted file mode 100644
index f3980922a1..0000000000
--- a/lib/chef/mixin/template.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 'tempfile'
-require 'erubis'
-
-class Chef
- module Mixin
- module Template
-
- # Render a template with Erubis. Takes a template as a string, and a
- # context hash.
- def render_template(template, context)
- eruby = Erubis::Eruby.new(template)
- output = eruby.evaluate(context)
- final_tempfile = Tempfile.new("chef-rendered-template")
- final_tempfile.print(output)
- final_tempfile.close
- final_tempfile
- end
-
- end
- end
-end
diff --git a/lib/chef/node.rb b/lib/chef/node.rb
deleted file mode 100644
index e1c8ef2d9a..0000000000
--- a/lib/chef/node.rb
+++ /dev/null
@@ -1,260 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "mixin", "check_helper")
-require File.join(File.dirname(__FILE__), "mixin", "params_validate")
-require File.join(File.dirname(__FILE__), "mixin", "from_file")
-
-require 'extlib'
-require 'rubygems'
-require 'json'
-
-class Chef
- class Node
-
- attr_accessor :attribute, :recipe_list, :couchdb_rev
-
- include Chef::Mixin::CheckHelper
- include Chef::Mixin::FromFile
- include Chef::Mixin::ParamsValidate
-
- DESIGN_DOCUMENT = {
- "version" => 3,
- "language" => "javascript",
- "views" => {
- "all" => {
- "map" => <<-EOJS
- function(doc) {
- if (doc.chef_type == "node") {
- emit(doc.name, doc);
- }
- }
- EOJS
- },
- "all_id" => {
- "map" => <<-EOJS
- function(doc) {
- if (doc.chef_type == "node") {
- emit(doc.name, doc.name);
- }
- }
- EOJS
- },
- },
- }
-
- # Create a new Chef::Node object.
- def initialize()
- @name = nil
- @attribute = Mash.new
- @recipe_list = Array.new
- @couchdb_rev = nil
- @couchdb = Chef::CouchDB.new
- end
-
- # Find a recipe for this Chef::Node by fqdn. Will search first for
- # Chef::Config["node_path"]/fqdn.rb, then hostname.rb, then default.rb.
- #
- # Returns a new Chef::Node object.
- #
- # Raises an ArgumentError if it cannot find the node.
- def find_file(fqdn)
- node_file = nil
- host_parts = fqdn.split(".")
- hostname = host_parts[0]
-
- if File.exists?(File.join(Chef::Config[:node_path], "#{fqdn}.rb"))
- node_file = File.join(Chef::Config[:node_path], "#{fqdn}.rb")
- elsif File.exists?(File.join(Chef::Config[:node_path], "#{hostname}.rb"))
- node_file = File.join(Chef::Config[:node_path], "#{hostname}.rb")
- elsif File.exists?(File.join(Chef::Config[:node_path], "default.rb"))
- node_file = File.join(Chef::Config[:node_path], "default.rb")
- end
- unless node_file
- raise ArgumentError, "Cannot find a node matching #{fqdn}, not even with default.rb!"
- end
- self.from_file(node_file)
- end
-
- # Set the name of this Node, or return the current name.
- def name(arg=nil)
- if arg != nil
- validate(
- { :name => arg },
- {
- :name => {
- :kind_of => String
- }
- }
- )
- @name = arg
- else
- @name
- end
- end
-
- # Return an attribute of this node. Returns nil if the attribute is not found.
- def [](attrib)
- if @attribute.has_key?(attrib)
- @attribute[attrib]
- elsif @attribute.has_key?(attrib.to_s)
- @attribute[attrib.to_s]
- else
- nil
- end
- end
-
- # Set an attribute of this node
- def []=(attrib, value)
- @attribute[attrib] = value
- end
-
- # Yield each key to the block
- def each(&block)
- @attribute.each_key do |k|
- yield(k)
- end
- end
-
- # Iterates over each attribute, passing the attribute and value to the block.
- def each_attribute(&block)
- @attribute.each do |k,v|
- yield(k, v)
- end
- end
-
- # Return true if this Node has a given attribute, false if not. Takes either a symbol or
- # a string.
- def attribute?(attrib)
- result = false
- result = @attribute.has_key?(attrib)
- return result if result
- return @attribute.has_key?(attrib.to_sym)
- end
-
- # Returns true if this Node expects a given recipe, false if not.
- def recipe?(recipe_name)
- @recipe_list.detect { |r| r == recipe_name } ? true : false
- end
-
- # Returns an Array of recipes. If you call it with arguments, they will become the new
- # list of recipes.
- def recipes(*args)
- if args.length > 0
- @recipe_list = args.flatten
- else
- @recipe_list
- end
- end
-
- # Set an attribute based on the missing method. If you pass an argument, we'll use that
- # to set the attribute values. Otherwise, we'll wind up just returning the attributes
- # value.
- def method_missing(symbol, *args)
- if args.length != 0
- @attribute[symbol] = args.length == 1 ? args[0] : args
- else
- if @attribute.has_key?(symbol)
- @attribute[symbol]
- else
- raise ArgumentError, "Attribute #{symbol.to_s} is not defined!"
- end
- end
- end
-
- def to_index
- index_hash = {
- :index_name => "node",
- :id => "node_#{@name}",
- :name => @name,
- }
- @attribute.each do |key, value|
- index_hash[key] = value
- end
- index_hash[:recipe] = @recipe_list if @recipe_list.length > 0
- index_hash
- end
-
- # Serialize this object as a hash
- def to_json(*a)
- result = {
- "name" => @name,
- 'json_class' => self.class.name,
- "attributes" => @attribute,
- "chef_type" => "node",
- "recipes" => @recipe_list,
- }
- result["_rev"] = @couchdb_rev if @couchdb_rev
- result.to_json(*a)
- end
-
- # Create a Chef::Node from JSON
- def self.json_create(o)
- node = new
- node.name(o["name"])
- o["attributes"].each do |k,v|
- node[k] = v
- end
- o["recipes"].each do |r|
- node.recipes << r
- end
- node.couchdb_rev = o["_rev"] if o.has_key?("_rev")
- node
- end
-
- # List all the Chef::Node objects in the CouchDB. If inflate is set to true, you will get
- # the full list of all Nodes, fully inflated.
- def self.list(inflate=false)
- rs = Chef::CouchDB.new.list("nodes", inflate)
- if inflate
- rs["rows"].collect { |r| r["value"] }
- else
- rs["rows"].collect { |r| r["key"] }
- end
- end
-
- # Load a node by name from CouchDB
- def self.load(name)
- Chef::CouchDB.new.load("node", name)
- end
-
- # Remove this node from the CouchDB
- def destroy
- Chef::Queue.send_msg(:queue, :remove, self)
- @couchdb.delete("node", @name, @couchdb_rev)
- end
-
- # Save this node to the CouchDB
- def save
- Chef::Queue.send_msg(:queue, :index, self)
- results = @couchdb.store("node", @name, self)
- @couchdb_rev = results["rev"]
- end
-
- # Set up our CouchDB design document
- def self.create_design_document
- Chef::CouchDB.new.create_design_document("nodes", DESIGN_DOCUMENT)
- end
-
- # As a string
- def to_s
- "node[#{@name}]"
- end
-
- end
-end
diff --git a/lib/chef/openid_registration.rb b/lib/chef/openid_registration.rb
deleted file mode 100644
index 748c865097..0000000000
--- a/lib/chef/openid_registration.rb
+++ /dev/null
@@ -1,175 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 'rubygems'
-require 'json'
-
-class Chef
- class OpenIDRegistration
-
- attr_accessor :name, :salt, :validated, :password, :couchdb_rev
-
- include Chef::Mixin::ParamsValidate
-
- DESIGN_DOCUMENT = {
- "version" => 3,
- "language" => "javascript",
- "views" => {
- "all" => {
- "map" => <<-EOJS
- function(doc) {
- if (doc.chef_type == "openid_registration") {
- emit(doc.name, doc);
- }
- }
- EOJS
- },
- "all_id" => {
- "map" => <<-EOJS
- function(doc) {
- if (doc.chef_type == "openid_registration") {
- emit(doc.name, doc.name);
- }
- }
- EOJS
- },
- "validated" => {
- "map" => <<-EOJS
- function(doc) {
- if (doc.chef_type == "openid_registration") {
- if (doc.validated == true) {
- emit(doc.name, doc);
- }
- }
- }
- EOJS
- },
- "unvalidated" => {
- "map" => <<-EOJS
- function(doc) {
- if (doc.chef_type == "openid_registration") {
- if (doc.validated == false) {
- emit(doc.name, doc);
- }
- }
- }
- EOJS
- },
- },
- }
-
- # Create a new Chef::OpenIDRegistration object.
- def initialize()
- @name = nil
- @salt = nil
- @password = nil
- @validated = false
- @couchdb_rev = nil
- @couchdb = Chef::CouchDB.new
- end
-
- def name=(n)
- @name = n.gsub(/\./, '_')
- end
-
- # Set the password for this object.
- def set_password(password)
- @salt = generate_salt
- @password = encrypt_password(@salt, password)
- end
-
- # Serialize this object as a hash
- def to_json(*a)
- attributes = Hash.new
- recipes = Array.new
- result = {
- 'name' => @name,
- 'json_class' => self.class.name,
- 'salt' => @salt,
- 'password' => @password,
- 'validated' => @validated,
- 'chef_type' => 'openid_registration',
- }
- result["_rev"] = @couchdb_rev if @couchdb_rev
- result.to_json(*a)
- end
-
- # Create a Chef::Node from JSON
- def self.json_create(o)
- me = new
- me.name = o["name"]
- me.salt = o["salt"]
- me.password = o["password"]
- me.validated = o["validated"]
- me.couchdb_rev = o["_rev"] if o.has_key?("_rev")
- me
- end
-
- # List all the Chef::OpenIDRegistration objects in the CouchDB. If inflate is set to true, you will get
- # the full list of all registration objects. Otherwise, you'll just get the IDs
- def self.list(inflate=false)
- rs = Chef::CouchDB.new.list("registrations", inflate)
- if inflate
- rs["rows"].collect { |r| r["value"] }
- else
- rs["rows"].collect { |r| r["key"] }
- end
- end
-
- # Load an OpenIDRegistration by name from CouchDB
- def self.load(name)
- Chef::CouchDB.new.load("openid_registration", name)
- end
-
- # Whether or not there is an OpenID Registration with this key.
- def self.has_key?(name)
- Chef::CouchDB.new.has_key?("openid_registration", name)
- end
-
- # Remove this node from the CouchDB
- def destroy
- @couchdb.delete("openid_registration", @name, @couchdb_rev)
- end
-
- # Save this node to the CouchDB
- def save
- results = @couchdb.store("openid_registration", @name, self)
- @couchdb_rev = results["rev"]
- end
-
- # Set up our CouchDB design document
- def self.create_design_document
- Chef::CouchDB.new.create_design_document("registrations", DESIGN_DOCUMENT)
- end
-
- protected
-
- def generate_salt
- salt = Time.now.to_s
- chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a
- 1.upto(30) { |i| salt << chars[rand(chars.size-1)] }
- salt
- end
-
- def encrypt_password(salt, password)
- Digest::SHA1.hexdigest("--#{salt}--#{password}--")
- end
-
- end
-end \ No newline at end of file
diff --git a/lib/chef/platform.rb b/lib/chef/platform.rb
deleted file mode 100644
index c7a7be1236..0000000000
--- a/lib/chef/platform.rb
+++ /dev/null
@@ -1,202 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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.
-#
-
-Dir[File.join(File.dirname(__FILE__), 'provider/**/*.rb')].sort.each { |lib| require lib }
-require File.join(File.dirname(__FILE__), 'mixin', 'params_validate')
-
-class Chef
- class Platform
-
- @platforms = {
- :mac_os_x => {},
- :ubuntu => {
- :default => {
- :package => Chef::Provider::Package::Apt,
- :service => Chef::Provider::Service::Debian,
- }
- },
- :centos => {},
- :redhat => {},
- :gentoo => {
- :default => {
- :package => Chef::Provider::Package::Portage
- }
- },
- :solaris => {},
- :default => {
- :file => Chef::Provider::File,
- :directory => Chef::Provider::Directory,
- :link => Chef::Provider::Link,
- :template => Chef::Provider::Template,
- :remote_file => Chef::Provider::RemoteFile,
- :remote_directory => Chef::Provider::RemoteDirectory,
- :sysctl => Chef::Provider::Sysctl,
- :execute => Chef::Provider::Execute,
- :script => Chef::Provider::Script,
- :service => Chef::Provider::Service::Init,
- :perl => Chef::Provider::Script,
- :python => Chef::Provider::Script,
- :ruby => Chef::Provider::Script,
- :bash => Chef::Provider::Script,
- :csh => Chef::Provider::Script,
- :user => Chef::Provider::User::Useradd,
- }
- }
-
- class << self
- attr_accessor :platforms
-
- include Chef::Mixin::ParamsValidate
-
- def find(name, version)
- provider_map = @platforms[:default].clone
-
- name_sym = name
- if name.kind_of?(String)
- name.downcase!
- name.gsub!(/\s/, "_")
- name_sym = name.to_sym
- end
-
- if @platforms.has_key?(name_sym)
- if @platforms[name_sym].has_key?(version)
- Chef::Log.debug("Platform #{name.to_s} version #{version} found")
- if @platforms[name_sym].has_key?(:default)
- provider_map.merge!(@platforms[name_sym][:default])
- end
- provider_map.merge!(@platforms[name_sym][version])
- elsif @platforms[name_sym].has_key?(:default)
- provider_map.merge!(@platforms[name_sym][:default])
- end
- else
- Chef::Log.debug("Platform #{name} not found, using all defaults. (Unsupported platform?)")
- end
- provider_map
- end
-
- def find_provider(platform, version, resource_type)
- pmap = Chef::Platform.find(platform, version)
- rtkey = resource_type
- if resource_type.kind_of?(Chef::Resource)
- rtkey = resource_type.resource_name.to_sym
- end
- if pmap.has_key?(rtkey)
- pmap[rtkey]
- else
- Chef::Log.error("#{rtkey.inspect} #{pmap.inspect}")
- raise(
- ArgumentError,
- "Cannot find a provider for #{resource_type} on #{platform} version #{version}"
- )
- end
- end
-
- def find_platform_and_version(node)
- platform = nil
- version = nil
- if node.attribute?("lsbdistid")
- platform = node[:lsbdistid]
- elsif node.attribute?("macosx_productname")
- platform = node[:macosx_productname]
- elsif node.attribute?("operatingsystem")
- platform = node[:operatingsystem]
- end
- raise ArgumentError, "Cannot find a platform for #{node}" unless platform
-
- if node.attribute?("lsbdistrelease")
- version = node[:lsbdistrelease]
- elsif node.attribute?("macosx_productversion")
- version = node[:macosx_productversion]
- elsif node.attribute?("operatingsystemversion")
- version = node[:operatingsystemversion]
- elsif node.attribute?("operatingsystemrelease")
- version = node[:operatingsystemrelease]
- end
- raise ArgumentError, "Cannot find a version for #{node}" unless version
-
- return platform, version
- end
-
- def find_provider_for_node(node, resource_type)
- platform, version = find_platform_and_version(node)
- provider = find_provider(platform, version, resource_type)
- end
-
- def set(args)
- validate(
- args,
- {
- :platform => {
- :kind_of => Symbol,
- :required => false,
- },
- :version => {
- :kind_of => String,
- :required => false,
- },
- :resource => {
- :kind_of => Symbol,
- },
- :provider => {
- :kind_of => [ String, Symbol, Class ],
- }
- }
- )
- if args.has_key?(:platform)
- if args.has_key?(:version)
- if @platforms.has_key?(args[:platform])
- if @platforms[args[:platform]].has_key?(args[:version])
- @platforms[args[:platform]][args[:version]][args[:resource].to_sym] = args[:provider]
- else
- @platforms[args[:platform]][args[:version]] = {
- args[:resource].to_sym => args[:provider]
- }
- end
- else
- @platforms[args[:platform]] = {
- args[:version] => {
- args[:resource].to_sym => args[:provider]
- }
- }
- end
- else
- if @platforms.has_key?(args[:platform])
- @platforms[args[:platform]][:default][args[:resource].to_sym] = args[:provider]
- else
- @platforms[args[:platform]] = {
- :default => {
- args[:resource].to_sym => args[:provider]
- }
- }
- end
- end
- else
- if @platforms.has_key?(:default)
- @platforms[:default][args[:resource].to_sym] = args[:provider]
- else
- @platforms[:default] = {
- args[:resource].to_sym => args[:provider]
- }
- end
- end
- end
-
- end
-
- end
-end
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb
deleted file mode 100644
index 3251693cb3..0000000000
--- a/lib/chef/provider.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Provider
-
- attr_accessor :node, :new_resource, :current_resource
-
- def initialize(node, new_resource)
- @node = node
- @new_resource = new_resource
- @current_resource = nil
- end
-
- def load_current_resource
- raise Chef::Exception::Override, "You must override load_current_resource in #{self.to_s}"
- end
-
- def action_nothing
- Chef::Log.debug("Doing nothing for #{@new_resource.to_s}")
- true
- end
-
- end
-end \ No newline at end of file
diff --git a/lib/chef/provider/directory.rb b/lib/chef/provider/directory.rb
deleted file mode 100644
index d042b6a8eb..0000000000
--- a/lib/chef/provider/directory.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "file")
-require "fileutils"
-
-class Chef
- class Provider
- class Directory < Chef::Provider::File
- def load_current_resource
- @current_resource = Chef::Resource::Directory.new(@new_resource.name)
- @current_resource.path(@new_resource.path)
- if ::File.exist?(@current_resource.path) && ::File.directory?(@current_resource.path)
- cstats = ::File.stat(@current_resource.path)
- @current_resource.owner(cstats.uid)
- @current_resource.group(cstats.gid)
- @current_resource.mode("%o" % (cstats.mode & 007777))
- end
- @current_resource
- end
-
- def action_create
- unless ::File.exists?(@new_resource.path)
- Chef::Log.info("Creating #{@new_resource} at #{@new_resource.path}")
- if @new_resource.recursive == true
- ::FileUtils.mkdir_p(@new_resource.path)
- else
- ::Dir.mkdir(@new_resource.path)
- end
- @new_resource.updated = true
- end
- set_owner if @new_resource.owner != nil
- set_group if @new_resource.group != nil
- set_mode if @new_resource.mode != nil
- end
-
- def action_delete
- if ::File.exists?(@new_resource.path) && ::File.writable?(@new_resource.path)
- if @new_resource.recursive == true
- Chef::Log.info("Deleting #{@new_resource} recursively at #{@new_resource.path}")
- FileUtils.rm_rf(@new_resource.path)
- else
- Chef::Log.info("Deleting #{@new_resource} at #{@new_resource.path}")
- ::Dir.delete(@new_resource.path)
- end
- @new_resource.updated = true
- else
- raise RuntimeError, "Cannot delete #{@new_resource} at #{@new_resource_path}!" if ::File.exists?(@new_resource.path)
- end
- end
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/provider/execute.rb b/lib/chef/provider/execute.rb
deleted file mode 100644
index 67a706e4f1..0000000000
--- a/lib/chef/provider/execute.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "..", "mixin", "command")
-
-class Chef
- class Provider
- class Execute < Chef::Provider
-
- include Chef::Mixin::Command
-
- def load_current_resource
- true
- end
-
- def action_run
- command_args = {
- :command => @new_resource.command,
- :command_string => @new_resource.to_s,
- }
- command_args[:creates] = @new_resource.creates if @new_resource.creates
- command_args[:onlyif] = @new_resource.onlyif if @new_resource.onlyif
- command_args[:not_if] = @new_resource.not_if if @new_resource.not_if
- command_args[:timeout] = @new_resource.timeout if @new_resource.timeout
- command_args[:returns] = @new_resource.returns if @new_resource.returns
- command_args[:environment] = @new_resource.environment if @new_resource.environment
- command_args[:user] = @new_resource.user if @new_resource.user
- command_args[:group] = @new_resource.group if @new_resource.group
- command_args[:cwd] = @new_resource.cwd if @new_resource.cwd
-
- status = run_command(command_args)
- if status
- @new_resource.updated = true
- Chef::Log.info("Ran #{@new_resource} successfully")
- end
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb
deleted file mode 100644
index d25e5decca..0000000000
--- a/lib/chef/provider/file.rb
+++ /dev/null
@@ -1,169 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 'etc'
-require 'fileutils'
-require File.join(File.dirname(__FILE__), "..", "mixin", "checksum")
-require File.join(File.dirname(__FILE__), "..", "mixin", "generate_url")
-
-class Chef
- class Provider
- class File < Chef::Provider
- include Chef::Mixin::Checksum
- include Chef::Mixin::GenerateURL
-
- def load_current_resource
- @current_resource = Chef::Resource::File.new(@new_resource.name)
- @current_resource.path(@new_resource.path)
- if ::File.exist?(@current_resource.path) && ::File.readable?(@current_resource.path)
- cstats = ::File.stat(@current_resource.path)
- @current_resource.owner(cstats.uid)
- @current_resource.group(cstats.gid)
- @current_resource.mode("%o" % (cstats.mode & 007777))
- @current_resource.checksum(checksum(@current_resource.path))
- end
- @current_resource
- end
-
- # Compare the ownership of a file. Returns true if they are the same, false if they are not.
- def compare_owner
- if @new_resource.owner != nil
- case @new_resource.owner
- when /^\d+$/, Integer
- @set_user_id = @new_resource.owner.to_i
- @set_user_id == @current_resource.owner
- else
- # This raises an ArugmentError if you can't find the user
- user_info = Etc.getpwnam(@new_resource.owner)
- @set_user_id = user_info.uid
- @set_user_id == @current_resource.owner
- end
- end
- end
-
- # Set the ownership on the file, assuming it is not set correctly already.
- def set_owner
- unless compare_owner
- Chef::Log.info("Setting owner to #{@set_user_id} for #{@new_resource}")
- ::File.chown(@set_user_id, nil, @new_resource.path)
- @new_resource.updated = true
- end
- end
-
- # Compares the group of a file. Returns true if they are the same, false if they are not.
- def compare_group
- if @new_resource.group != nil
- case @new_resource.group
- when /^\d+$/, Integer
- @set_group_id = @new_resource.group.to_i
- @set_group_id == @current_resource.group
- else
- group_info = Etc.getgrnam(@new_resource.group)
- @set_group_id = group_info.gid
- @set_group_id == @current_resource.group
- end
- end
- end
-
- def set_group
- unless compare_group
- Chef::Log.info("Setting group to #{@set_group_id} for #{@new_resource}")
- ::File.chown(nil, @set_group_id, @new_resource.path)
- @new_resource.updated = true
- end
- end
-
- def compare_mode
- if @new_resource.mode != nil
- case @new_resource.mode
- when /^\d+$/, Integer
- real_mode = sprintf("%o" % (@new_resource.mode & 007777))
- real_mode.to_i == @current_resource.mode.to_i
- end
- end
- end
-
- def set_mode
- unless compare_mode && @new_resource.mode != nil
- Chef::Log.info("Setting mode to #{sprintf("%o" % (@new_resource.mode & 007777))
- } for #{@new_resource}")
- ::File.chmod(@new_resource.mode.to_i, @new_resource.path)
- @new_resource.updated = true
- end
- end
-
- def action_create
- unless ::File.exists?(@new_resource.path)
- Chef::Log.info("Creating #{@new_resource} at #{@new_resource.path}")
- ::File.open(@new_resource.path, "w+") { |f| }
- @new_resource.updated = true
- end
- set_owner if @new_resource.owner != nil
- set_group if @new_resource.group != nil
- set_mode if @new_resource.mode != nil
- end
-
- def action_delete
- if ::File.exists?(@new_resource.path) && ::File.writable?(@new_resource.path)
- backup
- Chef::Log.info("Deleting #{@new_resource} at #{@new_resource.path}")
- ::File.delete(@new_resource.path)
- @new_resource.updated = true
- else
- raise "Cannot delete #{@new_resource} at #{@new_resource_path}!"
- end
- end
-
- def action_touch
- action_create
- time = Time.now
- Chef::Log.info("Updating #{@new_resource} with new atime/mtime of #{time}")
- ::File.utime(time, time, @new_resource.path)
- @new_resource.updated = true
- end
-
- def backup(file=nil)
- file ||= @new_resource.path
- if @new_resource.backup && ::File.exist?(file)
- time = Time.now
- savetime = time.strftime("%Y%m%d%H%M%S")
- backup_filename = "#{@new_resource.path}.chef-#{savetime}"
- Chef::Log.info("Backing up #{@new_resource} to #{backup_filename}")
- FileUtils.cp(file, backup_filename)
-
- # Clean up after the number of backups
- slice_number = @new_resource.backup - 1
- backup_files = Dir["#{@new_resource.path}.chef-*"].sort { |a,b| b <=> a }
- if backup_files.length >= @new_resource.backup
- remainder = backup_files.slice(slice_number..-1)
- remainder.each do |backup_to_delete|
- Chef::Log.info("Removing backup of #{@new_resource} at #{backup_to_delete}")
- FileUtils.rm(backup_to_delete)
- end
- end
-
- end
- end
-
- def generate_url(url, type, args=nil)
- generate_cookbook_url(url, @new_resource.cookbook_name, type, @node, args)
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/provider/link.rb b/lib/chef/provider/link.rb
deleted file mode 100644
index 843a4ad009..0000000000
--- a/lib/chef/provider/link.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Provider
- class Link < Chef::Provider
- def load_current_resource
- @current_resource = Chef::Resource::Link.new(@new_resource.name)
- @current_resource.target_file(@new_resource.target_file)
- @current_resource.link_type(@new_resource.link_type)
- if @new_resource.link_type == :symbolic
- if ::File.exists?(@current_resource.target_file) && ::File.symlink?(@current_resource.target_file)
- @current_resource.source_file(
- ::File.expand_path(::File.readlink(@current_resource.target_file))
- )
- else
- @current_resource.source_file("")
- end
- elsif @new_resource.link_type == :hard
- if ::File.exists?(@current_resource.target_file) && ::File.exists?(@new_resource.source_file)
- if ::File.stat(@current_resource.target_file).ino == ::File.stat(@new_resource.source_file).ino
- @current_resource.source_file(@new_resource.source_file)
- else
- @current_resource.source_file("")
- end
- else
- @current_resource.source_file("")
- end
- end
- @current_resource
- end
-
- def action_create
- if @current_resource.source_file != @new_resource.source_file
- Chef::Log.info("Creating a #{@new_resource.link_type} link from #{@new_resource.source_file} -> #{@new_resource.target_file} for #{@new_resource}")
- if @new_resource.link_type == :symbolic
- ::File.symlink(@new_resource.source_file, @new_resource.target_file)
- elsif @new_resource.link_type == :hard
- ::File.link(@new_resource.source_file, @new_resource.target_file)
- end
- @new_resource.updated = true
- end
- end
-
- def action_delete
- if ::File.exists?(@new_resource.target_file) && ::File.writable?(@new_resource.target_file)
- Chef::Log.info("Deleting #{@new_resource} at #{@new_resource.target_file}")
- ::File.delete(@new_resource.target_file)
- @new_resource.updated = true
- else
- raise "Cannot delete #{@new_resource} at #{@new_resource_path}!"
- end
- end
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
deleted file mode 100644
index a68c2e88f2..0000000000
--- a/lib/chef/provider/package.rb
+++ /dev/null
@@ -1,105 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "..", "mixin", "command")
-
-class Chef
- class Provider
- class Package < Chef::Provider
-
- include Chef::Mixin::Command
-
- def initialize(node, new_resource)
- super(node, new_resource)
- @candidate_version = nil
- end
-
- def action_install
- # First, select what version we should be using
- install_version = @new_resource.version
- install_version ||= @candidate_version
-
- unless install_version
- raise(Chef::Exception::Package, "No version specified, and no candidate version available!")
- end
-
- do_package = false
- # If it's not installed at all, install it
- if @current_resource.version == nil
- do_package = true
- # If we specified a version, and it's not the current version, move to the current version
- elsif @new_resource.version != nil
- if @new_resource.version != @current_resource.version
- do_package = true
- end
- end
-
- if do_package
- Chef::Log.info("Installing #{@new_resource} version #{install_version} successfully")
- status = install_package(@new_resource.package_name, install_version)
- if status
- @new_resource.updated = true
- end
- end
- end
-
- def action_upgrade
- if @current_resource.version != @candidate_version
- Chef::Log.info("Upgrading #{@new_resource} version from #{@current_resource.version} to #{@candidate_version} successfully")
- status = install_package(@new_resource.package_name, @candidate_version)
- if status
- @new_resource.updated = true
- end
- end
- end
-
- def action_remove
- if @current_resource.version != nil
- Chef::Log.info("Removing #{@new_resource} successfully")
- remove_package(@new_resource.package_name, @new_resource.version)
- @new_resource.updated = true
- end
- end
-
- def action_purge
- if @current_resource.version != nil
- Chef::Log.info("Purging #{@new_resource} successfully")
- purge_package(@new_resource.package_name, @new_resource.version)
- @new_resource.updated = true
- end
- end
-
- def install_package(name, version)
- raise Chef::Exception::UnsupportedAction, "#{self.to_s} does not support :install"
- end
-
- def upgrade_package(name, version)
- raise Chef::Exception::UnsupportedAction, "#{self.to_s} does not support :upgrade"
- end
-
- def remove_package(name, version)
- raise Chef::Exception::UnsupportedAction, "#{self.to_s} does not support :remove"
- end
-
- def purge_package(name, version)
- raise Chef::Exception::UnsupportedAction, "#{self.to_s} does not support :purge"
- end
-
- end
- end
-end
diff --git a/lib/chef/provider/package/apt.rb b/lib/chef/provider/package/apt.rb
deleted file mode 100644
index a2e9bd68a2..0000000000
--- a/lib/chef/provider/package/apt.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "..", "package")
-require File.join(File.dirname(__FILE__), "..", "..", "mixin", "command")
-
-class Chef
- class Provider
- class Package
- class Apt < Chef::Provider::Package
-
- def load_current_resource
- @current_resource = Chef::Resource::Package.new(@new_resource.name)
- @current_resource.package_name(@new_resource.package_name)
-
- status = popen4("apt-cache policy #{@new_resource.package_name}") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- case line
- when /^\s{2}Installed: (.+)$/
- installed_version = $1
- if installed_version == '(none)'
- @current_resource.version(nil)
- else
- @current_resource.version(installed_version)
- end
- when /^\s{2}Candidate: (.+)$/
- @candidate_version = $1
- end
- end
- end
-
- unless status.exitstatus == 0
- raise Chef::Exception::Package, "apt-cache failed - #{status.inspect}!"
- end
-
- @current_resource
- end
-
- def install_package(name, version)
- run_command(
- :command => "apt-get -q -y install #{name}=#{version}",
- :environment => {
- "DEBIAN_FRONTEND" => "noninteractive"
- }
- )
- end
-
- def upgrade_package(name, version)
- install_package(name, version)
- end
-
- def remove_package(name, version)
- run_command(
- :command => "apt-get -q -y remove #{@new_resource.package_name}",
- :environment => {
- "DEBIAN_FRONTEND" => "noninteractive"
- }
- )
- end
-
- def purge_package(name, version)
- run_command(
- :command => "apt-get -q -y purge #{@new_resource.package_name}",
- :environment => {
- "DEBIAN_FRONTEND" => "noninteractive"
- }
- )
- end
-
- end
- end
- end
-end
diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb
deleted file mode 100644
index 8981a386bc..0000000000
--- a/lib/chef/provider/package/portage.rb
+++ /dev/null
@@ -1,93 +0,0 @@
-#
-# Author:: Ezra Zygmuntowicz (<ezra@engineyard.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "..", "package")
-require File.join(File.dirname(__FILE__), "..", "..", "mixin", "command")
-
-class Chef
- class Provider
- class Package
- class Portage < Chef::Provider::Package
-
- def load_current_resource
- @current_resource = Chef::Resource::Package.new(@new_resource.name)
- @current_resource.package_name(@new_resource.package_name)
-
- status = popen4("emerge --color n --nospinner --search #{@new_resource.package_name}") do |pid, stdin, stdout, stderr|
- stdin.close
-
- available, installed = parse_emerge(@new_resource.package_name, stdout.read)
-
- if installed == "[ Not Installed ]"
- @current_resource.version(nil)
- else
- @current_resource.version(installed)
- end
- @candidate_version = available
- end
-
- unless status.exitstatus == 0
- raise Chef::Exception::Package, "emerge --search failed - #{status.inspect}!"
- end
-
- @current_resource
- end
-
-
- def parse_emerge(package, txt)
- available, installed, pkg = nil
- txt.each do |line|
- if line =~ /\*(.*)/
- pkg = $1.strip.split('/').last
- end
- if pkg == package
- if line =~ /Latest version available: (.*)/
- available = $1
- elsif line =~ /Latest version installed: (.*)/
- installed = $1
- end
- end
- end
- [available, installed]
- end
-
-
- def install_package(name, version)
- run_command(
- :command => "emerge -g --color n --nospinner --quiet =#{name}-#{version}"
- )
- end
-
- def upgrade_package(name, version)
- install_package(name, version)
- end
-
- def remove_package(name, version)
- run_command(
- :command => "emerge --unmerge --color n --nospinner --quiet #{@new_resource.package_name}"
- )
- end
-
- def purge_package(name, version)
- remove_package(name, version)
- end
-
- end
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
deleted file mode 100644
index 69459ffef4..0000000000
--- a/lib/chef/provider/package/rubygems.rb
+++ /dev/null
@@ -1,116 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "..", "package")
-require File.join(File.dirname(__FILE__), "..", "..", "mixin", "command")
-
-class Chef
- class Provider
- class Package
- class Rubygems < Chef::Provider::Package
-
- def gem_list_parse(line)
- installed_versions = Array.new
- if line.match("^#{@new_resource.package_name} \\((.+?)\\)$")
- installed_versions = $1.split(/, /)
- installed_versions
- else
- nil
- end
- end
-
- def load_current_resource
- @current_resource = Chef::Resource::Package.new(@new_resource.name)
- @current_resource.package_name(@new_resource.package_name)
- @current_resource.version(nil)
-
- # First, we need to look up whether we have the local gem installed or not
- status = popen4("gem list --local #{@new_resource.package_name}") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- installed_versions = gem_list_parse(line)
- next unless installed_versions
- # If the version we are asking for is installed, make that our current
- # version. Otherwise, go ahead and use the highest one, which
- # happens to come first in the array.
- if installed_versions.detect { |v| v == @new_resource.version }
- Chef::Log.debug("#{@new_resource.package_name} at version #{@new_resource.version}")
- @current_resource.version(@new_resource.version)
- else
- iv = installed_versions.first
- Chef::Log.debug("#{@new_resource.package_name} at version #{iv}")
- @current_resource.version(iv)
- end
- end
- end
-
- unless status.exitstatus == 0
- raise Chef::Exception::Package, "gem list --local failed - #{status.inspect}!"
- end
-
- status = popen4("gem list --remote #{@new_resource.package_name}") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.each do |line|
- installed_versions = gem_list_parse(line)
- next unless installed_versions
- Chef::Log.debug("I have #{installed_versions.inspect}")
-
- if installed_versions.length >= 1
- Chef::Log.debug("Setting candidate version")
- @candidate_version = installed_versions.first
- end
- end
- end
-
- unless status.exitstatus == 0
- raise Chef::Exception::Package, "gem list --remote failed - #{status.inspect}!"
- end
-
- @current_resource
- end
-
- def install_package(name, version)
- run_command(
- :command => "gem install #{name} -q --no-rdoc --no-ri -v #{version}"
- )
- end
-
- def upgrade_package(name, version)
- install_package(name, version)
- end
-
- def remove_package(name, version)
- if version
- run_command(
- :command => "gem uninstall #{name} -q -v #{version}"
- )
- else
- run_command(
- :command => "gem uninstall #{name} -q -a"
- )
- end
- end
-
- def purge_package(name, version)
- remove_package(name, version)
- end
-
- end
- end
- end
-end
diff --git a/lib/chef/provider/remote_directory.rb b/lib/chef/provider/remote_directory.rb
deleted file mode 100644
index 47d62b6308..0000000000
--- a/lib/chef/provider/remote_directory.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "file")
-require 'uri'
-require 'tempfile'
-require 'net/https'
-
-class Chef
- class Provider
- class RemoteDirectory < Chef::Provider::Directory
-
- def action_create
- super
-
- @remote_file_list = Hash.new
- do_recursive
- end
-
- def do_recursive
- Chef::Log.debug("Doing a recursive directory transfer for #{@new_resource}")
-
- r = Chef::REST.new(Chef::Config[:remotefile_url])
-
- files_to_transfer = r.get_rest(generate_url(@new_resource.source, "files", { :recursive => "true" }))
-
- files_to_transfer.each do |remote_file_source|
- full_path = ::File.join(@new_resource.path, remote_file_source)
- full_dir = ::File.dirname(full_path)
- unless ::File.directory?(full_dir)
- new_dir = Chef::Resource::Directory.new(full_dir, nil, @node)
- new_dir.cookbook_name = @new_resource.cookbook_name
- new_dir.mode(@new_resource.mode)
- new_dir.group(@new_resource.group)
- new_dir.owner(@new_resource.owner)
- new_dir.recursive(true)
-
- d_provider_class = Chef::Platform.find_provider_for_node(@node, new_dir)
- d_provider = d_provider_class.new(@node, new_dir)
- d_provider.load_current_resource
- d_provider.action_create
- @new_resource.updated = true if d_provider.new_resource.updated
- end
-
- remote_file = Chef::Resource::RemoteFile.new(full_path, nil, @node)
- remote_file.cookbook_name = @new_resource.cookbook_name
- remote_file.source(::File.join(@new_resource.source, remote_file_source))
- remote_file.mode(@new_resource.files_mode) if @new_resource.files_mode
- remote_file.group(@new_resource.files_group) if @new_resource.files_group
- remote_file.owner(@new_resource.files_owner) if @new_resource.files_owner
- remote_file.backup(@new_resource.files_backup) if @new_resource.files_backup
-
- rf_provider_class = Chef::Platform.find_provider_for_node(@node, remote_file)
- rf_provider = rf_provider_class.new(@node, remote_file)
- rf_provider.load_current_resource
- rf_provider.action_create
- @new_resource.updated = true if rf_provider.new_resource.updated
- end
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/provider/remote_file.rb b/lib/chef/provider/remote_file.rb
deleted file mode 100644
index cc0812346e..0000000000
--- a/lib/chef/provider/remote_file.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "file")
-require 'uri'
-require 'tempfile'
-require 'net/https'
-
-class Chef
- class Provider
- class RemoteFile < Chef::Provider::File
-
- def action_create
- Chef::Log.debug("Checking #{@new_resource} for changes")
- do_remote_file(@new_resource.source, @current_resource.path)
- end
-
- def do_remote_file(source, path)
- r = Chef::REST.new(Chef::Config[:remotefile_url])
-
- current_checksum = nil
- current_checksum = self.checksum(path) if ::File.exists?(path)
-
- url = generate_url(
- source,
- "files",
- {
- :checksum => current_checksum
- }
- )
-
- raw_file = nil
- begin
- raw_file = r.get_rest(url, true)
- rescue Net::HTTPRetriableError => e
- if e.response.kind_of?(Net::HTTPNotModified)
- Chef::Log.debug("File #{path} is unchanged")
- return false
- else
- raise e
- end
- end
-
- raw_file_checksum = self.checksum(raw_file.path)
-
- if ::File.exists?(path)
- Chef::Log.debug("#{path} changed from #{current_checksum} to #{raw_file_checksum}")
- Chef::Log.info("Updating file for #{@new_resource} at #{path}")
- else
- Chef::Log.info("Creating file for #{@new_resource} at #{path}")
- end
-
- backup(path)
- FileUtils.cp(raw_file.path, path)
- @new_resource.updated = true
-
- set_owner if @new_resource.owner != nil
- set_group if @new_resource.group != nil
- set_mode if @new_resource.mode != nil
- return true
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/provider/script.rb b/lib/chef/provider/script.rb
deleted file mode 100644
index 4669361142..0000000000
--- a/lib/chef/provider/script.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 'tempfile'
-
-class Chef
- class Provider
- class Script < Chef::Provider::Execute
-
- def action_run
- tf = Tempfile.new("chef-script")
- tf.puts(@new_resource.code)
- tf.close
- @new_resource.command("#{@new_resource.interpreter} #{tf.path}")
- super
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb
deleted file mode 100644
index 5ac53478e3..0000000000
--- a/lib/chef/provider/service.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-#
-# Author:: AJ Christensen (<aj@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "..", "mixin", "command")
-
-class Chef
- class Provider
- class Service < Chef::Provider
-
- include Chef::Mixin::Command
-
- def initialize(node, new_resource)
- super(node, new_resource)
- @enabled = nil
- end
-
- def action_enable
- if @current_resource.enabled == false
- Chef::Log.debug("#{@new_resource}: attempting to enable")
- status = enable_service(@new_resource.service_name)
- if status
- @new_resource.enabled == true
- Chef::Log.info("#{@new_resource}: enabled succesfully")
- end
- else
- Chef::Log.debug("#{@new_resource}: not enabling, already enabled")
- end
- end
-
- def action_disable
- if @current_resource.enabled == true
- Chef::Log.debug("#{@new_resource}: attempting to disable")
- status = disable_service(@new_resource.service_name)
- if status
- @new_resource.enabled == false
- Chef::Log.info("#{@new_resource}: disabled succesfully")
- end
- else
- Chef::Log.debug("#{@new_resource}: not disabling, already disabled")
- end
- end
-
- def action_start
- if @current_resource.running == false
- Chef::Log.debug("#{@new_resource}: attempting to start")
- status = start_service(@new_resource.service_name)
- if status
- @new_resource.running == true
- Chef::Log.info("Started service #{@new_resource} succesfully")
- end
- else
- Chef::Log.debug("#{@new_resource}: not starting, already running")
- end
- end
-
- def action_stop
- if @current_resource.running == true
- Chef::Log.debug("#{@new_resource}: attempting to stop")
- status = stop_service(@new_resource.service_name)
- if status
- @new_resource.running == false
- Chef::Log.info("#{@new_resource}: stopped succesfully")
- end
- else
- Chef::Log.debug("#{@new_resource}: not stopping, already stopped")
- end
- end
-
- end
- end
-end
diff --git a/lib/chef/provider/service/debian.rb b/lib/chef/provider/service/debian.rb
deleted file mode 100644
index 21f166ba6a..0000000000
--- a/lib/chef/provider/service/debian.rb
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-# Author:: AJ Christensen (<aj@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "..", "service")
-require File.join(File.dirname(__FILE__), "init")
-require File.join(File.dirname(__FILE__), "..", "..", "mixin", "command")
-
-class Chef
- class Provider
- class Service
- class Debian < Chef::Provider::Service::Init
- def load_current_resource
- super
-
- status = popen4("update-rc.d -n -f #{@current_resource.service_name} remove") do |pid, stdin, stdout, stderr|
- stdin.close
- stdout.gets(nil) =~ /etc\/rc[\dS].d\/S|not installed/i ? @current_resource.enabled(true) : @current_resource.enabled(false)
- end
-
- unless status.exitstatus == 0
- raise Chef::Exception::Service, "update-rc.d -n -f #{@current_resource.service_name} failed - #{status.inspect}"
- end
-
- @current_resource
- end
-
- def enable_service(name)
- run_command(:command => "update-rc.d #{name} defaults")
- end
-
- def disable_service(name)
- run_command(:command => "update-rc.d -f #{name} remove")
- end
-
- end
- end
- end
-end
diff --git a/lib/chef/provider/service/init.rb b/lib/chef/provider/service/init.rb
deleted file mode 100644
index 0ccfc232d8..0000000000
--- a/lib/chef/provider/service/init.rb
+++ /dev/null
@@ -1,95 +0,0 @@
-#
-# Author:: AJ Christensen (<aj@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "..", "service")
-require File.join(File.dirname(__FILE__), "..", "..", "mixin", "command")
-
-class Chef
- class Provider
- class Service
- class Init < Chef::Provider::Service
-
- def load_current_resource
- @current_resource = Chef::Resource::Service.new(@new_resource.name)
- @current_resource.service_name(@new_resource.service_name)
- process_running = false
- if @new_resource.supports[:status]
- run_command(:command => "/etc/init.d/#{@current_resource.service_name} status") == 0 ? process_running = true : process_running = false
- elsif @new_resource.status_command
- run_command(:command => @new_resource.status_command) == 0 ? process_running = true : process_running = false
- else
- Chef::Log.debug("#{@new_resource} does not support status and you have not specified a status command, falling back to process table inspection")
- if @new_resource.pattern == @new_resource.service_name
- Chef::Log.debug("#{@new_resource} defaulting pattern to #{Regex.new(@new_resource.pattern)}")
- elsif @node[:ps] == ""
- raise Chef::Exception::Service, "#{@new_resource}: Facter could not determine how to call `ps` on your system (#{Facter["ps"].value})"
- end
-
- process_pid = nil
- status = popen4(@node[:ps]) do |pid, stdin, stdout, stderr|
- stdin.close
- r = Regexp.new(@new_resource.pattern)
- Chef::Log.debug("#{@new_resource}: attempting to match #{@new_resource.pattern} (#{r}) against process table")
- stdout.each_line do |line|
- if r.match(line)
- process_pid = line.sub(/^\s+/, '').split(/\s+/)[1]
- end
- end
- end
- unless status.exitstatus == 0
- raise Chef::Exception::Service, "Command #{@node[:ps]} failed"
- else
- process_pid ? process_running = true : process_running = false
- Chef::Log.debug("#{@new_resource}: #{@node[:ps]} exited succesfully, process_running: #{process_running}")
- end
- end
- @current_resource.running process_running
- @current_resource
- end
-
- def start_service(name)
- if @new_resource.start_command
- run_command(:command => @new_resource.start_command)
- else
- run_command(:command => "/etc/init.d/#{name} start")
- end
- end
-
- def stop_service(name)
- if @new_resource.stop_command
- run_command(:command => @new_resource.stop_command)
- else
- run_command(:command => "/etc/init.d/#{name} stop")
- end
- end
-
- def restart_service(name)
- if @new_resource.supports[:restart]
- run_command(:command => "/etc/init.d/#{name} restart")
- elsif @new_resource.restart_command
- run_command(:command => @new_resource.restart_command)
- else
- stop_service
- start_service
- end
- end
-
- end
- end
- end
-end
diff --git a/lib/chef/provider/sysctl.rb b/lib/chef/provider/sysctl.rb
deleted file mode 100644
index 09b5942f5e..0000000000
--- a/lib/chef/provider/sysctl.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "file")
-require "fileutils"
-
-class Chef
- class Provider
- class Sysctl < Chef::Provider
- def load_current_resource
- @current_resource = Chef::Resource::Sysctl.new(@new_resource.name)
- @current_resource.value(`/sbin/sysctl #{@new_resource.name}`.chomp)
- @current_resource
- end
-
- def action_set
- if @current_resource.value != @new_resource.value
- system("/sbin/sysctl #{@new_resource.name}=#{@new_resource.value}")
- end
- end
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/provider/template.rb b/lib/chef/provider/template.rb
deleted file mode 100644
index 550a1388bf..0000000000
--- a/lib/chef/provider/template.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "file")
-require File.join(File.dirname(__FILE__), "..", "mixin", "template")
-require 'uri'
-require 'tempfile'
-
-class Chef
- class Provider
- class Template < Chef::Provider::File
-
- include Chef::Mixin::Template
-
- def action_create
- r = Chef::REST.new(Chef::Config[:template_url])
-
- template_url = generate_url(@new_resource.source, "templates")
- raw_template_file = r.get_rest(template_url, true)
-
- context = @new_resource.variables
- context[:node] = @node
- template_file = render_template(::File.read(raw_template_file.path), context)
-
- update = false
-
- if ::File.exists?(@new_resource.path)
- @new_resource.checksum(self.checksum(template_file.path))
- if @new_resource.checksum != @current_resource.checksum
- Chef::Log.debug("#{@new_resource} changed from #{@current_resource.checksum} to #{@new_resource.checksum}")
- Chef::Log.info("Updating #{@new_resource} at #{@new_resource.path}")
- update = true
- end
- else
- Chef::Log.info("Creating #{@new_resource} at #{@new_resource.path}")
- update = true
- end
-
- if update
- backup
- FileUtils.cp(template_file.path, @new_resource.path)
- @new_resource.updated = true
- else
- Chef::Log.debug("#{@new_resource} is unchanged")
- end
-
- set_owner if @new_resource.owner != nil
- set_group if @new_resource.group != nil
- set_mode if @new_resource.mode != nil
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb
deleted file mode 100644
index a3de68d93c..0000000000
--- a/lib/chef/provider/user.rb
+++ /dev/null
@@ -1,172 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "..", "provider")
-require File.join(File.dirname(__FILE__), "..", "mixin", "command")
-require 'etc'
-
-class Chef
- class Provider
- class User < Chef::Provider
-
- include Chef::Mixin::Command
-
- def initialize(node, new_resource)
- super(node, new_resource)
- @user_exists = true
- @locked = nil
- end
-
- def load_current_resource
- @current_resource = Chef::Resource::User.new(@new_resource.name)
- @current_resource.username(@new_resource.username)
-
- user_info = nil
- begin
- user_info = Etc.getpwnam(@new_resource.username)
- rescue ArgumentError => e
- @user_exists = false
- Chef::Log.debug("User #{@new_resource.username} does not exist")
- end
-
- if user_info
- @current_resource.uid(user_info.uid)
- @current_resource.gid(user_info.gid)
- @current_resource.comment(user_info.gecos)
- @current_resource.home(user_info.dir)
- @current_resource.shell(user_info.shell)
-
- if @new_resource.password
- begin
- require 'shadow'
- rescue Exception => e
- Chef::Log.error("You must have ruby-shadow installed for password support!")
- raise Chef::Exception::MissingLibrary, "You must have ruby-shadow installed for password support!"
- end
- shadow_info = Shadow::Passwd.getspnam(@new_resource.username)
- @current_resource.password(shadow_info.sp_pwdp)
- end
- end
-
- @current_resource
- end
-
- def compare_user
- change_required = false
- change_required = true if @new_resource.uid != @current_resource.uid
- change_required = true if @new_resource.gid != @current_resource.gid
- change_required = true if @new_resource.comment != @current_resource.comment
- change_required = true if @new_resource.home != @current_resource.home
- change_required = true if @new_resource.shell != @current_resource.shell
- change_required = true if @new_resource.password != @current_resource.password
- change_required
- end
-
- def action_create
- case @user_exists
- when false
- create_user
- Chef::Log.info("Created #{@new_resource}")
- @new_resource.updated = true
- else
- if compare_user
- manage_user
- Chef::Log.info("Altered #{@new_resource}")
- @new_resource.updated = true
- end
- end
- end
-
- def action_remove
- if @user_exists
- remove_user
- @new_resource.updated = true
- Chef::Log.info("Removed #{@new_resource}")
- end
- end
-
- def action_manage
- if @user_exists && compare_user
- manage_user
- @new_resource.updated = true
- Chef::Log.info("Managed #{@new_resource}")
- end
- end
-
- def action_modify
- if @user_exists && compare_user
- manage_user
- @new_resource.updated = true
- Chef::Log.info("Modified #{@new_resource}")
- else
- raise Chef::Exception::User, "Cannot modify #{@new_resource} - user does not exist!"
- end
- end
-
- def check_lock
- status = popen4("passwd -S #{@new_resource.username}") do |pid, stdin, stdout, stderr|
- stdin.close
- status_line = stdout.gets.split(' ')
- case status_line[1]
- when /^P/
- @locked = false
- when /^N/
- @locked = false
- when /^L/
- @locked = true
- end
- end
-
- unless status.exitstatus == 0
- raise Chef::Exception::User, "Cannot determine if #{@new_resource} is locked!"
- end
-
- @locked
- end
-
- def action_lock
- if @user_exists
- if check_lock() == false
- lock_user
- @new_resource.updated = true
- Chef::Log.info("Locked #{@new_resource}")
- else
- Chef::Log.debug("No need to lock #{@new_resource}")
- end
- else
- raise Chef::Exception::User, "Cannot lock #{@new_resource} - user does not exist!"
- end
- end
-
- def action_unlock
- if @user_exists
- if check_lock() == true
- unlock_user
- @new_resource.updated = true
- Chef::Log.info("Unlocked #{@new_resource}")
- else
- Chef::Log.debug("No need to unlock #{@new_resource}")
- end
- else
- raise Chef::Exception::User, "Cannot unlock #{@new_resource} - user does not exist!"
- end
- end
-
- end
- end
-end
diff --git a/lib/chef/provider/user/useradd.rb b/lib/chef/provider/user/useradd.rb
deleted file mode 100644
index 96736a27a8..0000000000
--- a/lib/chef/provider/user/useradd.rb
+++ /dev/null
@@ -1,88 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "..", "user")
-
-class Chef
- class Provider
- class User
- class Useradd < Chef::Provider::User
- def create_user
- command = "useradd"
- command << set_options
- run_command(:command => command)
- end
-
- def manage_user
- command = "usermod"
- command << set_options
- run_command(:command => command)
- end
-
- def remove_user
- command = "userdel"
- command << " -r" if @new_resource.supports[:manage_home]
- command << " #{@new_resource.username}"
- run_command(:command => command)
- end
-
- def lock_user
- run_command(:command => "usermod -L #{@new_resource.username}")
- end
-
- def unlock_user
- run_command(:command => "usermod -U #{@new_resource.username}")
- end
-
- def set_options
- opts = ''
-
- field_list = {
- 'comment' => "-c",
- 'home' => "-d",
- 'gid' => "-g",
- 'uid' => "-u",
- 'shell' => "-s",
- 'password' => "-p"
- }
- field_list.each do |field, option|
- field_symbol = field.to_sym
- if @current_resource.send(field_symbol) != @new_resource.send(field_symbol)
- if @new_resource.send(field_symbol)
- Chef::Log.debug("Setting #{@new_resource} #{field} to #{@new_resource.send(field_symbol)}")
- opts << " #{option} '#{@new_resource.send(field_symbol)}'"
- end
- end
- end
- if @new_resource.supports[:manage_home]
- Chef::Log.debug("Managing the home directory for #{@new_resource}")
- case @node[:operatingsystem]
- when "Fedora","RedHat","CentOS"
- opts << " -M"
- else
- opts << " -m"
- end
- end
- opts << " #{@new_resource.username}"
- opts
- end
-
- end
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/queue.rb b/lib/chef/queue.rb
deleted file mode 100644
index 86eb7df257..0000000000
--- a/lib/chef/queue.rb
+++ /dev/null
@@ -1,107 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "mixin", "params_validate")
-
-class Chef
- class Queue
- require 'stomp'
-
- @client = nil
-
- class << self
- include Chef::Mixin::ParamsValidate
-
- def connect
- @client = Stomp::Connection.open(
- Chef::Config.has_key?(:queue_user) ? Chef::Config[:queue_user] : "",
- Chef::Config.has_key?(:queue_password) ? Chef::Config[:queue_password] : "",
- Chef::Config.has_key?(:queue_host) ? Chef::Config[:queue_host] : "localhost",
- Chef::Config.has_key?(:queue_port) ? Chef::Config[:queue_port] : 61613,
- false
- )
- end
-
- def make_url(type, name)
- validate(
- {
- :queue_type => type.to_sym,
- :queue_name => name.to_sym,
- },
- {
- :queue_type => {
- :equal_to => [ :topic, :queue ],
- },
- :queue_name => {
- :kind_of => [ String, Symbol ],
- }
- }
- )
- queue_url = "/#{type}/chef/#{name}"
- end
-
- def subscribe(type, name)
- queue_url = make_url(type, name)
- Chef::Log.debug("Subscribing to #{queue_url}")
- connect if @client == nil
- @client.subscribe(queue_url)
- end
-
- def send_msg(type, name, msg)
- validate(
- {
- :message => msg,
- },
- {
- :message => {
- :respond_to => :to_json
- }
- }
- )
- queue_url = make_url(type, name)
- json = msg.to_json
- connect if @client == nil
- Chef::Log.debug("Sending to #{queue_url}: #{json}")
- @client.send(queue_url, json)
- end
-
- def receive_msg
- connect if @client == nil
- raw_msg = @client.receive()
- Chef::Log.debug("Received Message from #{raw_msg.headers["destination"]} containing: #{raw_msg.body}")
- msg = JSON.parse(raw_msg.body)
- return msg, raw_msg.headers
- end
-
- def poll_msg
- connect if @client == nil
- raw_msg = @client.poll()
- if raw_msg
- msg = JSON.parse(raw_msg.body)
- else
- nil
- end
- end
-
- def disconnect
- raise ArgumentError, "You must call connect before you can disconnect!" unless @client
- @client.disconnect
- end
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/recipe.rb b/lib/chef/recipe.rb
deleted file mode 100644
index e2e20640f7..0000000000
--- a/lib/chef/recipe.rb
+++ /dev/null
@@ -1,127 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "mixin", "from_file")
-
-class Chef
- class Recipe
-
- include Chef::Mixin::FromFile
-
- attr_accessor :cookbook_name, :recipe_name, :recipe, :node, :collection,
- :definitions, :params, :cookbook_loader
-
- def initialize(cookbook_name, recipe_name, node, collection=nil, definitions=nil, cookbook_loader=nil)
- @cookbook_name = cookbook_name
- @recipe_name = recipe_name
- @node = node
-
- if collection
- @collection = collection
- else
- @collection = Chef::ResourceCollection.new()
- end
-
- if definitions
- @definitions = definitions
- else
- @definitions = Hash.new
- end
-
- if cookbook_loader
- @cookbook_loader = cookbook_loader
- else
- @cookbook_loader = Chef::CookbookLoader.new()
- end
-
- @params = Hash.new
- end
-
- def require_recipe(*args)
- args.flatten.each do |recipe|
- rmatch = recipe.match(/(.+?)::(.+)/)
- if rmatch
- cookbook = @cookbook_loader[rmatch[1]]
- cookbook.load_recipe(rmatch[2], @node, @collection, @definitions, @cookbook_loader)
- else
- cookbook = @cookbook_loader[recipe]
- cookbook.load_recipe("default", @node, @collection, @definitions, @cookbook_loader)
- end
- end
- end
-
- def resources(*args)
- @collection.resources(*args)
- end
-
- def search(type, query, &block)
- Chef::Log.debug("Searching #{type} index with #{query}")
- r = Chef::REST.new(Chef::Config[:search_url])
- results = r.get_rest("search/#{type}?q=#{query}")
- Chef::Log.debug("Searching #{type} index with #{query} returned #{results.length} entries")
- results.each do |sr|
- block.call(sr)
- end
- end
-
- def method_missing(method_symbol, *args, &block)
- resource = nil
- # If we have a definition that matches, we want to use that instead. This should
- # let you do some really crazy over-riding of "native" types, if you really want
- # to.
- if @definitions.has_key?(method_symbol)
- new_def = @definitions[method_symbol].dup
- new_def.instance_eval(&block) if block
- new_recipe = Chef::Recipe.new(@cookbook_name, @recipe_name, @node, @collection, @definitions, @cookbook_loader)
- new_recipe.params = new_def.params
- new_recipe.params[:name] = args[0]
- new_recipe.instance_eval(&new_def.recipe)
- else
- method_name = method_symbol.to_s
- # Otherwise, we're rocking the regular resource call route.
- rname = nil
- mn = method_name.match(/^(.+)_(.+)$/)
- if mn
- rname = "Chef::Resource::#{mn[1].capitalize}#{mn[2].capitalize}"
- else
- short_match = method_name.match(/^(.+)$/)
- if short_match
- rname = "Chef::Resource::#{short_match[1].capitalize}"
- end
- end
- begin
- args << @collection
- args << @node
- resource = eval(rname).new(*args)
- resource.cookbook_name = @cookbook_name
- resource.recipe_name = @recipe_name
- resource.params = @params
- resource.instance_eval(&block) if block
- rescue Exception => e
- if e.kind_of?(NameError) && e.to_s =~ /Chef::Resource/
- raise NameError, "Cannot find #{rname} for #{method_name}\nOriginal: #{e.to_s}"
- else
- raise e
- end
- end
- @collection << resource
- resource
- end
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
deleted file mode 100644
index 75349a7927..0000000000
--- a/lib/chef/resource.rb
+++ /dev/null
@@ -1,172 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "mixin", "params_validate")
-require File.join(File.dirname(__FILE__), "mixin", "check_helper")
-
-class Chef
- class Resource
-
- include Chef::Mixin::CheckHelper
- include Chef::Mixin::ParamsValidate
-
- attr_accessor :actions, :params, :provider, :updated, :allowed_actions, :collection, :cookbook_name, :recipe_name, :supports
- attr_reader :resource_name, :source_line, :node
-
- def initialize(name, collection=nil, node=nil)
- @name = name
- if collection
- @collection = collection
- else
- @collection = Chef::ResourceCollection.new()
- end
- @node = node ? node : Chef::Node.new
- @noop = nil
- @before = nil
- @actions = Hash.new
- @params = Hash.new
- @provider = nil
- @allowed_actions = [ :nothing ]
- @action = :nothing
- @updated = false
- @supports = {}
- @source_line = caller(4).shift.gsub!(/^(.+):(.+):.+$/, '\1 line \2')
- @source_line = ::File.expand_path(@source_line) if @source_line
- end
-
- def provider(arg=nil)
- set_or_return(
- :provider,
- arg,
- :kind_of => [ Class ]
- )
- end
-
- def action(arg=nil)
- if arg
- action_list = arg.kind_of?(Array) ? arg : [ arg ]
- action_list.each do |action|
- validate(
- {
- :action => action,
- },
- {
- :object => { :equal_to => @allowed_actions },
- }
- )
- end
- @action = action_list
- else
- @action
- end
- end
-
- def name(name=nil)
- set_if_args(@name, name) do
- raise ArgumentError, "name must be a string!" unless name.kind_of?(String)
- @name = name
- end
- end
-
- def noop(tf=nil)
- set_if_args(@noop, tf) do
- raise ArgumentError, "noop must be true or false!" unless tf == true || tf == false
- @noop = tf
- end
- end
-
- def notifies(action, resources, timing=:delayed)
- timing = check_timing(timing)
- rarray = resources.kind_of?(Array) ? resources : [ resources ]
- rarray.each do |resource|
- action_sym = action.to_sym
- if @actions.has_key?(action_sym)
- @actions[action_sym][timing] << resource
- else
- @actions[action_sym] = Hash.new
- @actions[action_sym][:delayed] = Array.new
- @actions[action_sym][:immediate] = Array.new
- @actions[action_sym][timing] << resource
- end
- end
- true
- end
-
- def resources(*args)
- @collection.resources(*args)
- end
-
- def subscribes(action, resources, timing=:delayed)
- timing = check_timing(timing)
- rarray = resources.kind_of?(Array) ? resources : [ resources ]
- rarray.each do |resource|
- action_sym = action.to_sym
- if resource.actions.has_key?(action_sym)
- resource.actions[action_sym][timing] << self
- else
- resource.actions[action_sym] = Hash.new
- resource.actions[action_sym][:delayed] = Array.new
- resource.actions[action_sym][:immediate] = Array.new
- resource.actions[action_sym][timing] << self
- end
- end
- true
- end
-
- def is(*args)
- return *args
- end
-
- def to_s
- "#{@resource_name}[#{@name}]"
- end
-
- # Serialize this object as a hash
- def to_json(*a)
- instance_vars = Hash.new
- self.instance_variables.each do |iv|
- instance_vars[iv] = self.instance_variable_get(iv) unless iv == "@collection"
- end
- results = {
- 'json_class' => self.class.name,
- 'instance_vars' => instance_vars
- }
- results.to_json(*a)
- end
-
- def self.json_create(o)
- resource = self.new(o["instance_vars"]["@name"])
- o["instance_vars"].each do |k,v|
- resource.instance_variable_set(k.to_sym, v)
- end
- resource
- end
-
- private
-
- def check_timing(timing)
- unless timing == :delayed || timing == :immediate || timing == :immediately
- raise ArgumentError, "Timing must be :delayed or :immediate(ly), you said #{timing}"
- end
- if timing == :immediately
- timing = :immediate
- end
- timing
- end
- end
-end
diff --git a/lib/chef/resource/apt_package.rb b/lib/chef/resource/apt_package.rb
deleted file mode 100644
index 58e8b14edc..0000000000
--- a/lib/chef/resource/apt_package.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "package")
-
-class Chef
- class Resource
- class AptPackage < Chef::Resource::Package
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :apt_package
- @provider = Chef::Provider::Package::Apt
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/bash.rb b/lib/chef/resource/bash.rb
deleted file mode 100644
index 7af5f9756a..0000000000
--- a/lib/chef/resource/bash.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "script")
-
-class Chef
- class Resource
- class Bash < Chef::Resource::Script
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :bash
- @interpreter = "bash"
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/csh.rb b/lib/chef/resource/csh.rb
deleted file mode 100644
index 29de9777b9..0000000000
--- a/lib/chef/resource/csh.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "script")
-
-class Chef
- class Resource
- class Csh < Chef::Resource::Script
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :csh
- @interpreter = "csh"
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/directory.rb b/lib/chef/resource/directory.rb
deleted file mode 100644
index 7e8944f5fc..0000000000
--- a/lib/chef/resource/directory.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Resource
- class Directory < Chef::Resource
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :directory
- @path = name
- @action = :create
- @recursive = false
- @allowed_actions.push(:create, :delete)
- end
-
- def recursive(arg=nil)
- set_or_return(
- :recursive,
- arg,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
-
- def group(arg=nil)
- set_or_return(
- :group,
- arg,
- :regex => [ /^([a-z]|[A-Z]|[0-9]|_|-)+$/, /^\d+$/ ]
- )
- end
-
- def mode(arg=nil)
- set_or_return(
- :mode,
- arg,
- :regex => /^\d{3,4}$/
- )
- end
-
- def owner(arg=nil)
- set_or_return(
- :owner,
- arg,
- :regex => [ /^([a-z]|[A-Z]|[0-9]|_|-)+$/, /^\d+$/ ]
- )
- end
-
- def path(arg=nil)
- set_or_return(
- :path,
- arg,
- :kind_of => String
- )
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/execute.rb b/lib/chef/resource/execute.rb
deleted file mode 100644
index 232cfe4d64..0000000000
--- a/lib/chef/resource/execute.rb
+++ /dev/null
@@ -1,133 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Resource
- class Execute < Chef::Resource
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :execute
- @command = name
- @backup = 5
- @action = "run"
- @creates = nil
- @cwd = nil
- @environment = nil
- @group = nil
- @onlyif = nil
- @path = nil
- @notify_only = false
- @returns = 0
- @timeout = nil
- @not_if = nil
- @user = nil
- @allowed_actions.push(:run)
- end
-
- def command(arg=nil)
- set_or_return(
- :command,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def creates(arg=nil)
- set_or_return(
- :creates,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def cwd(arg=nil)
- set_or_return(
- :cwd,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def environment(arg=nil)
- set_or_return(
- :environment,
- arg,
- :kind_of => [ Hash ]
- )
- end
-
- def group(arg=nil)
- set_or_return(
- :group,
- arg,
- :kind_of => [ String, Integer ]
- )
- end
-
- def onlyif(arg=nil)
- set_or_return(
- :onlyif,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def path(arg=nil)
- set_or_return(
- :path,
- arg,
- :kind_of => [ Array ]
- )
- end
-
- def returns(arg=nil)
- set_or_return(
- :returns,
- arg,
- :kind_of => [ Integer ]
- )
- end
-
- def timeout(arg=nil)
- set_or_return(
- :timeout,
- arg,
- :kind_of => [ Integer ]
- )
- end
-
- def not_if(arg=nil)
- set_or_return(
- :not_if,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def user(arg=nil)
- set_or_return(
- :user,
- arg,
- :kind_of => [ String, Integer ]
- )
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb
deleted file mode 100644
index 099bd76591..0000000000
--- a/lib/chef/resource/file.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Resource
- class File < Chef::Resource
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :file
- @path = name
- @backup = 5
- @action = "create"
- @allowed_actions.push(:create, :delete, :touch)
- end
-
- def backup(arg=nil)
- set_or_return(
- :backup,
- arg,
- :kind_of => [ Integer, FalseClass ]
- )
- end
-
- def checksum(arg=nil)
- set_or_return(
- :checksum,
- arg,
- :regex => /^[a-zA-Z0-9]{32}$/
- )
- end
-
- def group(arg=nil)
- set_or_return(
- :group,
- arg,
- :regex => [ /^([a-z]|[A-Z]|[0-9]|_|-)+$/, /^\d+$/ ]
- )
- end
-
- def mode(arg=nil)
- set_or_return(
- :mode,
- arg,
- :regex => /^\d{3,4}$/
- )
- end
-
- def owner(arg=nil)
- set_or_return(
- :owner,
- arg,
- :regex => [ /^([a-z]|[A-Z]|[0-9]|_|-)+$/, /^\d+$/ ]
- )
- end
-
- def path(arg=nil)
- set_or_return(
- :path,
- arg,
- :kind_of => String
- )
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/gem_package.rb b/lib/chef/resource/gem_package.rb
deleted file mode 100644
index 1ec9463337..0000000000
--- a/lib/chef/resource/gem_package.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "package")
-
-class Chef
- class Resource
- class GemPackage < Chef::Resource::Package
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :gem_package
- @provider = Chef::Provider::Package::Rubygems
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/link.rb b/lib/chef/resource/link.rb
deleted file mode 100644
index 46b5793b0f..0000000000
--- a/lib/chef/resource/link.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Resource
- class Link < Chef::Resource
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :link
- @source_file = name
- @action = :create
- @link_type = :symbolic
- @target_file = nil
- @allowed_actions.push(:create, :delete)
- end
-
- def source_file(arg=nil)
- set_or_return(
- :source_file,
- arg,
- :kind_of => String
- )
- end
-
- def target_file(arg=nil)
- set_or_return(
- :target_file,
- arg,
- :kind_of => String
- )
- end
-
- def link_type(arg=nil)
- real_arg = arg.kind_of?(String) ? arg.to_sym : arg
- set_or_return(
- :link_type,
- real_arg,
- :equal_to => [ :symbolic, :hard ]
- )
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/package.rb b/lib/chef/resource/package.rb
deleted file mode 100644
index f5f1c8418e..0000000000
--- a/lib/chef/resource/package.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Resource
- class Package < Chef::Resource
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :package
- @package_name = name
- @version = nil
- @candidate_version = nil
- @response_file = nil
- @source = nil
- @action = "install"
- @allowed_actions.push(:install, :upgrade, :remove, :purge)
- end
-
- def package_name(arg=nil)
- set_or_return(
- :package_name,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def version(arg=nil)
- set_or_return(
- :version,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def response_file(arg=nil)
- set_or_return(
- :response_file,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def source(arg=nil)
- set_or_return(
- :source,
- arg,
- :kind_of => [ String ]
- )
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/perl.rb b/lib/chef/resource/perl.rb
deleted file mode 100644
index a9b891ed5c..0000000000
--- a/lib/chef/resource/perl.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "script")
-
-class Chef
- class Resource
- class Perl < Chef::Resource::Script
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :perl
- @interpreter = "perl"
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/portage_package.rb b/lib/chef/resource/portage_package.rb
deleted file mode 100644
index 0e300da7a3..0000000000
--- a/lib/chef/resource/portage_package.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "package")
-
-class Chef
- class Resource
- class PortagePackage < Chef::Resource::Package
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :portage_package
- @provider = Chef::Provider::Package::Apt
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/python.rb b/lib/chef/resource/python.rb
deleted file mode 100644
index ac2b27c00f..0000000000
--- a/lib/chef/resource/python.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "script")
-
-class Chef
- class Resource
- class Python < Chef::Resource::Script
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :python
- @interpreter = "python"
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/remote_directory.rb b/lib/chef/resource/remote_directory.rb
deleted file mode 100644
index a23b39d42c..0000000000
--- a/lib/chef/resource/remote_directory.rb
+++ /dev/null
@@ -1,79 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Resource
- class RemoteDirectory < Chef::Resource::Directory
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :remote_directory
- @path = name
- @delete = false
- @action = :create
- @recursive = true
- @files_backup = 5
- @files_owner = nil
- @files_group = nil
- @files_mode = 0644
- @allowed_actions.push(:create, :delete)
- end
-
- def source(args=nil)
- set_or_return(
- :source,
- args,
- :kind_of => String
- )
- end
-
- def files_backup(arg=nil)
- set_or_return(
- :files_backup,
- arg,
- :kind_of => [ Integer, FalseClass ]
- )
- end
-
- def files_group(arg=nil)
- set_or_return(
- :files_group,
- arg,
- :regex => [ /^([a-z]|[A-Z]|[0-9]|_|-)+$/, /^\d+$/ ]
- )
- end
-
- def files_mode(arg=nil)
- set_or_return(
- :files_mode,
- arg,
- :regex => /^\d{3,4}$/
- )
- end
-
- def files_owner(arg=nil)
- set_or_return(
- :files_owner,
- arg,
- :regex => [ /^([a-z]|[A-Z]|[0-9]|_|-)+$/, /^\d+$/ ]
- )
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/remote_file.rb b/lib/chef/resource/remote_file.rb
deleted file mode 100644
index dace234398..0000000000
--- a/lib/chef/resource/remote_file.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Resource
- class RemoteFile < Chef::Resource::File
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :remote_file
- @action = "create"
- @source = nil
- @variables = Hash.new
- end
-
- def source(args=nil)
- set_or_return(
- :source,
- args,
- :kind_of => String
- )
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/ruby.rb b/lib/chef/resource/ruby.rb
deleted file mode 100644
index 591f1a658b..0000000000
--- a/lib/chef/resource/ruby.rb
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "script")
-
-class Chef
- class Resource
- class Ruby < Chef::Resource::Script
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :ruby
- @interpreter = "ruby"
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/script.rb b/lib/chef/resource/script.rb
deleted file mode 100644
index d59882ab9c..0000000000
--- a/lib/chef/resource/script.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "execute")
-
-class Chef
- class Resource
- class Script < Chef::Resource::Execute
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :script
- @command = name
- @code = nil
- @interpreter = nil
- end
-
- def code(arg=nil)
- set_or_return(
- :code,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def interpreter(arg=nil)
- set_or_return(
- :interpreter,
- arg,
- :kind_of => [ String ]
- )
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/service.rb b/lib/chef/resource/service.rb
deleted file mode 100644
index 1c9a784745..0000000000
--- a/lib/chef/resource/service.rb
+++ /dev/null
@@ -1,113 +0,0 @@
-#
-# Author:: AJ Christensen (<aj@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Resource
- class Service < Chef::Resource
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :service
- @service_name = name
- @enabled = nil
- @running = nil
- @pattern = service_name
- @start_command = nil
- @stop_command = nil
- @status_command = nil
- @restart_command = nil
- @action = "none"
- @supports = { :restart => false, :status => false }
- @allowed_actions.push(:enable, :disable, :start, :stop)
- end
-
- def service_name(arg=nil)
- set_or_return(
- :service_name,
- arg,
- :kind_of => [ String ]
- )
- end
-
- # regex for match against ps -ef when !supports[:has_status] && status == nil
- def pattern(arg=nil)
- set_or_return(
- :pattern,
- arg,
- :kind_of => [ String ]
- )
- end
-
- # command to call to start service
- def start_command(arg=nil)
- set_or_return(
- :start_command,
- arg,
- :kind_of => [ String ]
- )
- end
-
- # command to call to stop service
- def stop_command(arg=nil)
- set_or_return(
- :stop_command,
- arg,
- :kind_of => [ String ]
- )
- end
-
- # command to call to get status of service
- def status_command(arg=nil)
- set_or_return(
- :status_command,
- arg,
- :kind_of => [ String ]
- )
- end
-
- # command to call to restart service
- def restart_command(arg=nil)
- set_or_return(
- :restart_command,
- arg,
- :kind_of => [ String ]
- )
- end
-
- # if the service is enabled or not
- def enabled(arg=nil)
- set_or_return(
- :enabled,
- arg,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
-
- # if the service is running or not
- def running(arg=nil)
- set_or_return(
- :running,
- arg,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
-
-
- end
- end
-end
diff --git a/lib/chef/resource/sysctl.rb b/lib/chef/resource/sysctl.rb
deleted file mode 100644
index 203ad72425..0000000000
--- a/lib/chef/resource/sysctl.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Resource
- class Sysctl < Chef::Resource
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :sysctl
- @action = "set"
- @name = name
- @value = nil
- @variables = Hash.new
- end
-
- def value(args=nil)
- set_or_return(
- :value,
- args,
- :kind_of => String
- )
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/template.rb b/lib/chef/resource/template.rb
deleted file mode 100644
index 5f2512a274..0000000000
--- a/lib/chef/resource/template.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Resource
- class Template < Chef::Resource::File
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :template
- @action = "create"
- @source = nil
- @variables = Hash.new
- end
-
- def source(file=nil)
- set_or_return(
- :source,
- file,
- :kind_of => [ String ]
- )
- end
-
- def variables(args=nil)
- set_or_return(
- :variables,
- args,
- :kind_of => [ Hash ]
- )
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource/user.rb b/lib/chef/resource/user.rb
deleted file mode 100644
index 1702753408..0000000000
--- a/lib/chef/resource/user.rb
+++ /dev/null
@@ -1,96 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class Resource
- class User < Chef::Resource
-
- def initialize(name, collection=nil, node=nil)
- super(name, collection, node)
- @resource_name = :user
- @username = name
- @comment = nil
- @uid = nil
- @gid = nil
- @home = nil
- @shell = nil
- @password = nil
- @action = :create
- @supports = { :manage_home => false }
- @allowed_actions.push(:create, :remove, :modify, :manage, :lock, :unlock)
- end
-
- def username(arg=nil)
- set_or_return(
- :username,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def comment(arg=nil)
- set_or_return(
- :comment,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def uid(arg=nil)
- set_or_return(
- :uid,
- arg,
- :kind_of => [ String, Integer ]
- )
- end
-
- def gid(arg=nil)
- set_or_return(
- :gid,
- arg,
- :kind_of => [ String, Integer ]
- )
- end
-
- def home(arg=nil)
- set_or_return(
- :home,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def shell(arg=nil)
- set_or_return(
- :shell,
- arg,
- :kind_of => [ String ]
- )
- end
-
- def password(arg=nil)
- set_or_return(
- :password,
- arg,
- :kind_of => [ String ]
- )
- end
-
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource_collection.rb b/lib/chef/resource_collection.rb
deleted file mode 100644
index 5278b15c72..0000000000
--- a/lib/chef/resource_collection.rb
+++ /dev/null
@@ -1,174 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Chef
- class ResourceCollection
- include Enumerable
-
- def initialize
- @resources = Array.new
- @resources_by_name = Hash.new
- end
-
- def [](index)
- @resources[index]
- end
-
- def []=(index, arg)
- is_chef_resource(arg)
- @resources[index] = arg
- @resources_by_name[arg.to_s] = index
- end
-
- def <<(*args)
- args.flatten.each do |a|
- is_chef_resource(a)
- @resources << a
- @resources_by_name[a.to_s] = @resources.length - 1
- end
- end
-
- def push(*args)
- args.flatten.each do |a|
- is_chef_resource(a)
- @resources.push(a)
- @resources_by_name[a.to_s] = @resources.length - 1
- end
- end
-
- def each
- @resources.each do |r|
- yield r
- end
- end
-
- def each_index
- @resources.each_index do |i|
- yield i
- end
- end
-
- def lookup(resource)
- lookup_by = nil
- if resource.kind_of?(Chef::Resource)
- lookup_by = resource.to_s
- elsif resource.kind_of?(String)
- lookup_by = resource
- else
- raise ArgumentError, "Must pass a Chef::Resource or String to lookup"
- end
- res = @resources_by_name[lookup_by]
- unless res
- raise ArgumentError, "Cannot find a resource matching #{lookup_by} (did you define it first?)"
- end
- @resources[res]
- end
-
- # Find existing resources by searching the list of existing resources. Possible
- # forms are:
- #
- # resources(:file => "foobar")
- # resources(:file => [ "foobar", "baz" ])
- # resources("file[foobar]", "file[baz]")
- # resources("file[foobar,baz]")
- #
- # Returns the matching resource, or an Array of matching resources.
- #
- # Raises an ArgumentError if you feed it bad lookup information
- # Raises a Runtime Error if it can't find the resources you are looking for.
- def resources(*args)
- results = Array.new
- args.each do |arg|
- case arg
- when Hash
- results << find_resource_by_hash(arg)
- when String
- results << find_resource_by_string(arg)
- else
- raise ArgumentError, "resources takes arguments as a hash or strings!"
- end
- end
- flat_results = results.flatten
- flat_results.length == 1 ? flat_results[0] : flat_results
- end
-
- # Serialize this object as a hash
- def to_json(*a)
- instance_vars = Hash.new
- self.instance_variables.each do |iv|
- instance_vars[iv] = self.instance_variable_get(iv)
- end
- results = {
- 'json_class' => self.class.name,
- 'instance_vars' => instance_vars
- }
- results.to_json(*a)
- end
-
- def self.json_create(o)
- collection = self.new()
- o["instance_vars"].each do |k,v|
- collection.instance_variable_set(k.to_sym, v)
- end
- collection
- end
-
- private
-
- def find_resource_by_hash(arg)
- results = Array.new
- arg.each do |resource_name, name_list|
- names = name_list.kind_of?(Array) ? name_list : [ name_list ]
- names.each do |name|
- res_name = "#{resource_name.to_s}[#{name}]"
- results << lookup(res_name)
- end
- end
- return results
- end
-
- def find_resource_by_string(arg)
- results = Array.new
- case arg
- when /^(.+)\[(.+?),(.+)\]$/
- resource_type = $1
- arg =~ /^.+\[(.+)\]$/
- resource_list = $1
- resource_list.split(",").each do |name|
- resource_name = "#{resource_type}[#{name}]"
- results << lookup(resource_name)
- end
- when /^(.+)\[(.+)\]$/
- resource_type = $1
- name = $2
- resource_name = "#{resource_type}[#{name}]"
- results << lookup(resource_name)
- else
- raise ArgumentError, "You must have a string like resource_type[name]!"
- end
- return results
- end
-
- def is_chef_resource(arg)
- unless arg.kind_of?(Chef::Resource)
- raise ArgumentError, "Members must be Chef::Resource's"
- end
- true
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/resource_definition.rb b/lib/chef/resource_definition.rb
deleted file mode 100644
index 9a0a9cb09a..0000000000
--- a/lib/chef/resource_definition.rb
+++ /dev/null
@@ -1,67 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "mixin", "from_file")
-require File.join(File.dirname(__FILE__), "mixin", "params_validate")
-
-
-class Chef
- class ResourceDefinition
-
- include Chef::Mixin::FromFile
- include Chef::Mixin::ParamsValidate
-
- attr_accessor :name, :params, :recipe
-
- def initialize
- @name = nil
- @params = Hash.new
- @recipe = nil
- end
-
- def define(resource_name, prototype_params=nil, &block)
- unless resource_name.kind_of?(Symbol)
- raise ArgumentError, "You must use a symbol when defining a new resource!"
- end
- @name = resource_name
- if prototype_params
- unless prototype_params.kind_of?(Hash)
- raise ArgumentError, "You must pass a hash as the prototype parameters for a definition."
- end
- @params = prototype_params
- end
- if Kernel.block_given?
- @recipe = block
- else
- raise ArgumentError, "You must pass a block to a definition."
- end
- true
- end
-
- # When we do the resource definition, we're really just setting new values for
- # the paramaters we prototyped at the top. This method missing is as simple as
- # it gets.
- def method_missing(symbol, *args)
- @params[symbol] = args.length == 1 ? args[0] : args
- end
-
- def to_s
- "#{name.to_s}"
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/rest.rb b/lib/chef/rest.rb
deleted file mode 100644
index b78df6c35f..0000000000
--- a/lib/chef/rest.rb
+++ /dev/null
@@ -1,150 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "mixin", "params_validate")
-require 'net/https'
-require 'uri'
-require 'json'
-require 'tempfile'
-
-class Chef
- class REST
-
- def initialize(url)
- @url = url
- @cookies = Hash.new
- end
-
- # Send an HTTP GET request to the path
- #
- # === Parameters
- # path:: The path to GET
- # raw:: Whether you want the raw body returned, or JSON inflated. Defaults
- # to JSON inflated.
- def get_rest(path, raw=false)
- run_request(:GET, create_url(path), false, 10, raw)
- end
-
- # Send an HTTP DELETE request to the path
- def delete_rest(path)
- run_request(:DELETE, create_url(path))
- end
-
- # Send an HTTP POST request to the path
- def post_rest(path, json)
- run_request(:POST, create_url(path), json)
- end
-
- # Send an HTTP PUT request to the path
- def put_rest(path, json)
- run_request(:PUT, create_url(path), json)
- end
-
- def create_url(path)
- if path =~ /^(http|https):\/\//
- URI.parse(path)
- else
- URI.parse("#{@url}/#{path}")
- end
- end
-
- # Actually run an HTTP request. First argument is the HTTP method,
- # which should be one of :GET, :PUT, :POST or :DELETE. Next is the
- # URL, then an object to include in the body (which will be converted with
- # .to_json) and finally, the limit of HTTP Redirects to follow (10).
- #
- # Typically, you won't use this method -- instead, you'll use one of
- # the helper methods (get_rest, post_rest, etc.)
- #
- # Will return the body of the response on success.
- def run_request(method, url, data=false, limit=10, raw=false)
- raise ArgumentError, 'HTTP redirect too deep' if limit == 0
-
- http = Net::HTTP.new(url.host, url.port)
- if url.scheme == "https"
- http.use_ssl = true
- if Chef::Config[:ssl_verify_mode] == :verify_none
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
- end
- end
- http.read_timeout = Chef::Config[:rest_timeout]
- headers = Hash.new
- unless raw
- headers = {
- 'Accept' => "application/json",
- }
- end
- if @cookies["#{url.host}:#{url.port}"]
- headers['Cookie'] = @cookies["#{url.host}:#{url.port}"]
- end
- req = nil
- case method
- when :GET
- req_path = "#{url.path}"
- req_path << "?#{url.query}" if url.query
- req = Net::HTTP::Get.new(req_path, headers)
- when :POST
- headers["Content-Type"] = 'application/json' if data
- req = Net::HTTP::Post.new(url.path, headers)
- req.body = data.to_json if data
- when :PUT
- headers["Content-Type"] = 'application/json' if data
- req = Net::HTTP::Put.new(url.path, headers)
- req.body = data.to_json if data
- when :DELETE
- req_path = "#{url.path}"
- req_path << "?#{url.query}" if url.query
- req = Net::HTTP::Delete.new(req_path, headers)
- else
- raise ArgumentError, "You must provide :GET, :PUT, :POST or :DELETE as the method"
- end
- Chef::Log.debug("Sending HTTP Request via #{req.method} to #{req.path}")
- res = http.request(req)
-
- Chef::Log.debug("HTTP request headers: #{req.to_hash.inspect} ")
-
- Chef::Log.debug("HTTP response headers: #{res.to_hash.inspect} ")
-
- if res.kind_of?(Net::HTTPSuccess)
- if res['set-cookie']
- @cookies["#{url.host}:#{url.port}"] = res['set-cookie']
- end
- if res['content-type'] =~ /json/
- JSON.parse(res.body)
- else
- if raw
- tf = Tempfile.new("chef-rest")
- tf.print(res.body)
- tf.close
- tf
- else
- res.body
- end
- end
- elsif res.kind_of?(Net::HTTPFound)
- if res['set-cookie']
- @cookies["#{url.host}:#{url.port}"] = res['set-cookie']
- end
- run_request(:GET, create_url(res['location']), false, limit - 1, raw)
- else
- res.error!
- end
- end
-
- end
-end
diff --git a/lib/chef/runner.rb b/lib/chef/runner.rb
deleted file mode 100644
index b943ef5ec4..0000000000
--- a/lib/chef/runner.rb
+++ /dev/null
@@ -1,100 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "mixin", "params_validate")
-
-class Chef
- class Runner
-
- include Chef::Mixin::ParamsValidate
-
- def initialize(node, collection)
- validate(
- {
- :node => node,
- :collection => collection,
- },
- {
- :node => {
- :kind_of => Chef::Node,
- },
- :collection => {
- :kind_of => Chef::ResourceCollection,
- },
- }
- )
- @node = node
- @collection = collection
- end
-
- def build_provider(resource)
- provider_klass = resource.provider
- if provider_klass == nil
- provider_klass = Chef::Platform.find_provider_for_node(@node, resource)
- end
- Chef::Log.debug("#{resource} using #{provider_klass.to_s}")
- provider = provider_klass.new(@node, resource)
- provider.load_current_resource
- provider
- end
-
- def converge
- start_time = Time.now
- Chef::Log.info("Starting Chef Run")
- delayed_actions = Array.new
-
- @collection.each do |resource|
- begin
- Chef::Log.debug("Processing #{resource}")
- action_list = resource.action.kind_of?(Array) ? resource.action : [ resource.action ]
- action_list.each do |ra|
- provider = build_provider(resource)
- provider.send("action_#{ra}")
- if resource.updated
- resource.actions.each_key do |action|
- if resource.actions[action].has_key?(:immediate)
- resource.actions[action][:immediate].each do |r|
- Chef::Log.info("#{resource} sending #{action} action to #{r} (immediate)")
- build_provider(r).send("action_#{action}")
- end
- end
- if resource.actions[action].has_key?(:delayed)
- resource.actions[action][:delayed].each do |r|
- delayed_actions << lambda {
- Chef::Log.info("#{resource} sending #{action} action to #{r} (delayed)")
- build_provider(r).send("action_#{action}")
- }
- end
- end
- end
- end
- end
- rescue => e
- Chef::Log.error("#{resource} (#{resource.source_line}) had an error:")
- raise
- end
- end
-
- # Run all our :delayed actions
- delayed_actions.each { |da| da.call }
- end_time = Time.now
- Chef::Log.info("Chef Run complete in #{end_time - start_time} seconds")
- true
- end
- end
-end
diff --git a/lib/chef/search.rb b/lib/chef/search.rb
deleted file mode 100644
index 229f738399..0000000000
--- a/lib/chef/search.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "mixin", "params_validate")
-require 'ferret'
-
-class Chef
- class Search
-
- attr_reader :index
-
- def initialize
- @index = Ferret::Index::Index.new(:path => Chef::Config[:search_index_path])
- end
-
- def search(type, query, &block)
- search_query = build_search_query(type, query)
- start_time = Time.now
- result = Array.new
-
- if Kernel.block_given?
- result = @index.search_each(search_query, :limit => :all) do |id, score|
- block.call(build_hash(@index.doc(id)))
- end
- else
- @index.search_each(search_query, :limit => :all) do |id, score|
- result << build_hash(@index.doc(id))
- end
- end
- Chef::Log.debug("Search #{search_query} complete in #{Time.now - start_time} seconds")
- result
- end
-
- def list_indexes
- indexes = Hash.new
- @index.search_each("index_name:*", :limit => :all) do |id, score|
- indexes[@index.doc(id)["index_name"]] = true
- end
- indexes.keys
- end
-
- def has_index?(index)
- list_indexes.detect { |i| i == index }
- end
-
- private
- def build_search_query(type, query)
- "index_name:#{type} AND (#{query})"
- end
-
- def build_hash(doc)
- result = Hash.new
- doc.fields.each do |f|
- result[f] = doc[f]
- end
- result
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef/search_index.rb b/lib/chef/search_index.rb
deleted file mode 100644
index 932a451999..0000000000
--- a/lib/chef/search_index.rb
+++ /dev/null
@@ -1,80 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "mixin", "params_validate")
-require 'ferret'
-
-class Chef
- class SearchIndex
-
- attr_reader :index
-
- def initialize
- @index = Ferret::Index::Index.new(
- :path => Chef::Config[:search_index_path],
- :key => [ :id ]
- )
- end
-
- def add(new_object)
- index_hash = create_index_object(new_object)
- Chef::Log.debug("Indexing #{index_hash[:index_name]} with #{index_hash.inspect}")
- @index.add_document(index_hash)
- end
-
- def create_index_object(new_object)
- index_hash = nil
-
- if new_object.respond_to?(:to_index)
- index_hash = new_object.to_index
- elsif new_object.kind_of?(Hash)
- index_hash = new_object
- else
- raise Chef::Exception::SearchIndex, "Cannot transform argument to a Hash!"
- end
-
- unless index_hash.has_key?(:index_name) || index_hash.has_key?("index_name")
- raise Chef::Exception::SearchIndex, "Cannot index without an index_name key: #{index_hash.inspect}"
- end
-
- unless index_hash.has_key?(:id) || index_hash.has_key?("id")
- raise Chef::Exception::SearchIndex, "Cannot index without an id key: #{index_hash.inspect}"
- end
-
- index_hash.each do |k,v|
- unless k.kind_of?(Symbol)
- index_hash[k.to_sym] = v
- index_hash.delete(k)
- end
- end
-
- index_hash
- end
-
- def delete(index_obj)
- to_delete = create_index_object(index_obj)
- Chef::Log.debug("Removing #{to_delete.inspect} from the #{to_delete[:index_name]} index")
- @index.delete(to_delete[:id])
- end
-
- def commit
- @index.commit
- end
-
- end
-end
diff --git a/lib/chef_server/controllers/application.rb b/lib/chef_server/controllers/application.rb
deleted file mode 100644
index d98492d3ad..0000000000
--- a/lib/chef_server/controllers/application.rb
+++ /dev/null
@@ -1,147 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Application < Merb::Controller
-
- def fix_up_node_id
- if params.has_key?(:id)
- params[:id].gsub!(/_/, '.')
- end
- end
-
- def escape_node_id
- if params.has_key?(:id)
- params[:id].gsub(/_/, '.')
- end
- end
-
- def login_required
- if session[:openid]
- return session[:openid]
- else
- self.store_location
- throw(:halt, :access_denied)
- end
- end
-
- def authorized_node
- if session[:level] == :admin
- Chef::Log.debug("Authorized as Administrator")
- true
- elsif session[:level] == :node
- Chef::Log.debug("Authorized as node")
- if session[:node_name] == params[:id].gsub(/\./, '_')
- true
- else
- raise(
- Unauthorized,
- "You are not the correct node for this action: #{session[:node_name]} instead of #{params[:id]}"
- )
- end
- else
- Chef::Log.debug("Unauthorized")
- raise Unauthorized, "You are not allowed to take this action."
- 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
- case content_type
- when :html
- store_location
- redirect url(:openid_consumer)
- else
- raise Unauthorized, "You must authenticate first!"
- end
- end
-
- # Load a cookbook and return a hash with a list of all the files of a
- # given segment (attributes, recipes, definitions, libraries)
- #
- # === Parameters
- # cookbook_id<String>:: The cookbook to load
- # segment<Symbol>:: :attributes, :recipes, :definitions, :libraries
- #
- # === Returns
- # <Hash>:: A hash consisting of the short name of the file in :name, and the full path
- # to the file in :file.
- def load_cookbook_segment(cookbook_id, segment)
- cl = Chef::CookbookLoader.new
- cookbook = cl[cookbook_id]
- raise NotFound unless cookbook
-
- files_list = segment_files(segment, cookbook)
-
- files = Hash.new
- files_list.each do |f|
- full = File.expand_path(f)
- name = File.basename(full)
- files[name] = {
- :name => name,
- :file => full,
- }
- end
- files
- end
-
- def segment_files(segment, cookbook)
- files_list = nil
- case segment
- when :attributes
- files_list = cookbook.attribute_files
- when :recipes
- files_list = cookbook.recipe_files
- when :definitions
- files_list = cookbook.definition_files
- when :libraries
- files_list = cookbook.library_files
- else
- raise ArgumentError, "segment must be one of :attributes, :recipes, :definitions or :libraries"
- end
- files_list
- end
-
- def load_all_files(segment)
- cl = Chef::CookbookLoader.new
- files = Array.new
- cl.each do |cookbook|
- segment_files(segment, cookbook).each do |sf|
- files << {
- :cookbook => cookbook.name,
- :name => File.basename(sf)
- }
- end
- end
- files
- end
-
-end \ No newline at end of file
diff --git a/lib/chef_server/controllers/cookbook_attributes.rb b/lib/chef_server/controllers/cookbook_attributes.rb
deleted file mode 100644
index 5dd2b44802..0000000000
--- a/lib/chef_server/controllers/cookbook_attributes.rb
+++ /dev/null
@@ -1,56 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "..", "..", "chef", "mixin", "checksum")
-
-class CookbookAttributes < Application
-
- provides :html, :json
-
- include Chef::Mixin::Checksum
-
- def load_cookbook_attributes()
- @attribute_files = load_cookbook_segment(params[:cookbook_id], :attributes)
- end
-
- def index
- if params[:id]
- show
- else
- load_cookbook_attributes()
- display @attribute_files
- end
- end
-
- def show
- only_provides :json
- load_cookbook_attributes
- raise NotFound, "Cannot find a suitable attribute file!" unless @attribute_files.has_key?(params[:id])
- to_send = @attribute_files[params[:id]][:file]
- current_checksum = checksum(to_send)
- Chef::Log.debug("old sum: #{params[:checksum]}, new sum: #{current_checksum}")
- if current_checksum == params[:checksum]
- display "File #{to_send} has not changed", :status => 304
- else
- send_file(to_send)
- end
- end
-
-end
-
-
diff --git a/lib/chef_server/controllers/cookbook_definitions.rb b/lib/chef_server/controllers/cookbook_definitions.rb
deleted file mode 100644
index 07135371af..0000000000
--- a/lib/chef_server/controllers/cookbook_definitions.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "..", "..", "chef", "mixin", "checksum")
-
-class CookbookDefinitions < Application
-
- provides :html, :json
-
- include Chef::Mixin::Checksum
-
- def load_cookbook_definitions()
- @definition_files = load_cookbook_segment(params[:cookbook_id], :definitions)
- end
-
- def index
- if params[:id]
- show
- else
- load_cookbook_definitions()
- display @definition_files
- end
- end
-
- def show
- only_provides :json
- load_cookbook_definitions
- raise NotFound, "Cannot find a suitable definition file!" unless @definition_files.has_key?(params[:id])
-
- to_send = @definition_files[params[:id]][:file]
- current_checksum = checksum(to_send)
- Chef::Log.debug("Old sum: #{params[:checksum]}, New sum: #{current_checksum}")
- if current_checksum == params[:checksum]
- display "File #{to_send} has not changed", :status => 304
- else
- send_file(to_send)
- end
- end
-
-end
-
-
diff --git a/lib/chef_server/controllers/cookbook_files.rb b/lib/chef_server/controllers/cookbook_files.rb
deleted file mode 100644
index 30b0dead65..0000000000
--- a/lib/chef_server/controllers/cookbook_files.rb
+++ /dev/null
@@ -1,118 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "..", "..", "chef", "mixin", "checksum")
-
-class CookbookFiles < Application
-
- provides :html, :json
-
- include Chef::Mixin::Checksum
-
- layout nil
-
- def load_cookbook_files()
- @cl = Chef::CookbookLoader.new
- @cookbook = @cl[params[:cookbook_id]]
- raise NotFound unless @cookbook
-
- @remote_files = Hash.new
- @cookbook.remote_files.each do |rf|
- full = File.expand_path(rf)
- name = File.basename(full)
- rf =~ /^.+#{params[:cookbook_id]}[\\|\/]files[\\|\/](.+?)[\\|\/]#{name}/
- singlecopy = $1
- @remote_files[full] = {
- :name => name,
- :singlecopy => singlecopy,
- :file => full,
- }
- end
- @remote_files
- end
-
- def index
- if params[:id]
- if params[:recursive] == "true"
- show_directory
- else
- show
- end
- else
- load_cookbook_files()
- display @remote_files
- end
- end
-
- def show
- only_provides :json
- to_send = find_preferred_file
- raise NotFound, "Cannot find a suitable file!" unless to_send
- current_checksum = checksum(to_send)
- Chef::Log.debug("old sum: #{params[:checksum]}, new sum: #{current_checksum}")
- if current_checksum == params[:checksum]
- display "File #{to_send} has not changed", :status => 304
- else
- send_file(to_send)
- end
- end
-
- def show_directory
- Chef::Log.info("totally rocking hte show_directory")
- dir_to_send = find_preferred_file
- unless (dir_to_send && File.directory?(dir_to_send))
- raise NotFound, "Cannot find a suitable directory"
- end
-
- @directory_listing = Array.new
- Dir[::File.join(dir_to_send, '**', '*')].sort { |a,b| b <=> a }.each do |file_to_send|
- next if File.directory?(file_to_send)
- file_to_send =~ /^#{dir_to_send}\/(.+)$/
- @directory_listing << $1
- end
-
- display @directory_listing
- end
-
- protected
-
- def find_preferred_file
- load_cookbook_files()
- preferences = [
- File.join("host-#{params[:fqdn]}", "#{params[:id]}"),
- File.join("#{params[:platform]}-#{params[:version]}", "#{params[:id]}"),
- File.join("#{params[:platform]}", "#{params[:id]}"),
- File.join("default", "#{params[:id]}")
- ]
- to_send = nil
- @remote_files.each_key do |file|
- Chef::Log.debug("Looking at #{file}")
- preferences.each do |pref|
- Chef::Log.debug("Compared to #{pref}")
- if file =~ /#{pref}$/
- Chef::Log.debug("Matched #{pref} for #{file}!")
- to_send = file
- break
- end
- end
- break if to_send
- end
- to_send
- end
-
-end
diff --git a/lib/chef_server/controllers/cookbook_recipes.rb b/lib/chef_server/controllers/cookbook_recipes.rb
deleted file mode 100644
index 6c27ddadd6..0000000000
--- a/lib/chef_server/controllers/cookbook_recipes.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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(File.dirname(__FILE__), "..", "..", "chef", "mixin", "checksum")
-
-class CookbookRecipes < Application
-
- provides :html, :json
-
- include Chef::Mixin::Checksum
-
- def load_cookbook_recipes()
- @recipe_files = load_cookbook_segment(params[:cookbook_id], :recipes)
- end
-
- def index
- if params[:id]
- show
- else
- load_cookbook_recipes()
- display @recipe_files
- end
- end
-
- def show
- only_provides :json
- load_cookbook_recipes
- raise NotFound, "Cannot find a suitable recipe file!" unless @recipe_files.has_key?(params[:id])
-
- to_send = @recipe_files[params[:id]][:file]
- current_checksum = checksum(to_send)
- Chef::Log.debug("old sum: #{params[:checksum]}, new sum: #{current_checksum}")
- if current_checksum == params[:checksum]
- display "File #{to_send} has not changed", :status => 304
- else
- send_file(to_send)
- end
- end
-
-end
-
-
diff --git a/lib/chef_server/controllers/cookbook_templates.rb b/lib/chef_server/controllers/cookbook_templates.rb
deleted file mode 100644
index 4cb5e4622c..0000000000
--- a/lib/chef_server/controllers/cookbook_templates.rb
+++ /dev/null
@@ -1,77 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 CookbookTemplates < Application
-
- provides :html, :json
-
- def load_cookbook_templates()
- @cl = Chef::CookbookLoader.new
- @cookbook = @cl[params[:cookbook_id]]
- raise NotFound unless @cookbook
-
- @templates = Hash.new
- @cookbook.template_files.each do |tf|
- full = File.expand_path(tf)
- name = File.basename(full)
- tf =~ /^.+#{params[:cookbook_id]}[\\|\/]templates[\\|\/](.+?)[\\|\/]#{name}/
- singlecopy = $1
- @templates[full] = {
- :name => name,
- :singlecopy => singlecopy,
- :file => full,
- }
- end
- @templates
- end
-
- def index
- if params[:id]
- show
- else
- load_cookbook_templates()
- display @templates
- end
- end
-
- def show
- load_cookbook_templates()
- preferences = [
- File.join("host-#{params[:fqdn]}", "#{params[:id]}"),
- File.join("#{params[:platform]}-#{params[:version]}", "#{params[:id]}"),
- File.join("#{params[:platform]}", "#{params[:id]}"),
- File.join("default", "#{params[:id]}")
- ]
- to_send = nil
- @templates.each_key do |file|
- Chef::Log.debug("Looking at #{file}")
- preferences.each do |pref|
- Chef::Log.debug("Compared to #{pref}")
- if file =~ /#{pref}/
- Chef::Log.debug("Matched #{pref} for #{file}!")
- to_send = file
- break
- end
- end
- break if to_send
- end
- raise NotFound, "Cannot find a suitable template!" unless to_send
- send_file(to_send)
- end
-
-end
diff --git a/lib/chef_server/controllers/cookbooks.rb b/lib/chef_server/controllers/cookbooks.rb
deleted file mode 100644
index e2a9d7f319..0000000000
--- a/lib/chef_server/controllers/cookbooks.rb
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Cookbooks < Application
-
- provides :html, :json
-
- def index
- @cl = Chef::CookbookLoader.new
- display @cl
- end
-
- def show
- @cl = Chef::CookbookLoader.new
- @cookbook = @cl[params[:id]]
- raise NotFound unless @cookbook
- display @cookbook
- end
-
- def recipe_files
- @recipe_files = load_all_files(:recipes)
- display @recipe_files
- end
-
- def attribute_files
- @attribute_files = load_all_files(:attributes)
- display @attribute_files
- end
-
- def definition_files
- @definition_files = load_all_files(:definitions)
- display @definition_files
- end
-
-end
diff --git a/lib/chef_server/controllers/exceptions.rb b/lib/chef_server/controllers/exceptions.rb
deleted file mode 100644
index d8f7307637..0000000000
--- a/lib/chef_server/controllers/exceptions.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 :html, :json
-
- # handle NotFound exceptions (404)
- def not_found
- display params
- end
-
- # handle NotAcceptable exceptions (406)
- def not_acceptable
- display params
- end
-
- # handle BadRequest exceptions (400)
- def bad_request
- display params
- end
-
-end \ No newline at end of file
diff --git a/lib/chef_server/controllers/nodes.rb b/lib/chef_server/controllers/nodes.rb
deleted file mode 100644
index 655b264862..0000000000
--- a/lib/chef_server/controllers/nodes.rb
+++ /dev/null
@@ -1,78 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Nodes < Application
-
- provides :html, :json
-
- before :fix_up_node_id
- before :login_required, :only => [ :create, :update, :destroy ]
- before :authorized_node, :only => [ :update, :destroy ]
-
- def index
- @node_list = Chef::Node.list
- display @node_list
- end
-
- def show
- begin
- @node = Chef::Node.load(params[:id])
- rescue Net::HTTPServerException => e
- raise NotFound, "Cannot load node #{params[:id]}"
- end
- display @node
- end
-
- def create
- @node = params.has_key?("inflated_object") ? params["inflated_object"] : nil
- if @node
- @status = 202
- @node.save
- display @node
- else
- raise BadRequest, "You must provide a Node to create"
- end
- end
-
- def update
- @node = params.has_key?("inflated_object") ? params["inflated_object"] : nil
- if @node
- @status = 202
- @node.save
- display @node
- else
- raise NotFound, "You must provide a Node to update"
- end
- end
-
- def destroy
- begin
- @node = Chef::Node.load(params[:id])
- rescue RuntimeError => e
- raise BadRequest, "Node #{params[:id]} does not exist to destroy!"
- end
- @status = 202
- @node.destroy
- if content_type == :html
- redirect url(:nodes)
- else
- display @node
- end
- end
-
-end
diff --git a/lib/chef_server/controllers/openid_consumer.rb b/lib/chef_server/controllers/openid_consumer.rb
deleted file mode 100644
index 4e3980ce3d..0000000000
--- a/lib/chef_server/controllers/openid_consumer.rb
+++ /dev/null
@@ -1,117 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 'pathname'
-
-require "openid"
-require 'openid/store/filesystem'
-
-class OpenidConsumer < Application
-
- provides :html, :json
-
- def index
- render
- end
-
- def start
- check_valid_openid_provider(params[:openid_identifier])
- begin
- oidreq = consumer.begin(params[:openid_identifier])
- rescue OpenID::OpenIDError => e
- raise BadRequest, "Discovery failed for #{params[:openid_identifier]}: #{e}"
- end
- return_to = absolute_url(:openid_consumer_complete)
- realm = absolute_url(:openid_consumer)
-
- if oidreq.send_redirect?(realm, return_to, params[:immediate])
- return redirect(oidreq.redirect_url(realm, return_to, params[:immediate]))
- else
- @form_text = oidreq.form_markup(realm, return_to, params[:immediate], {'id' => 'openid_form'})
- render
- end
- end
-
- def complete
- # FIXME - url_for some action is not necessarily the current URL.
- current_url = absolute_url(:openid_consumer_complete)
- parameters = params.reject{|k,v| k == "controller" || k == "action"}
- oidresp = consumer.complete(parameters, current_url)
- case oidresp.status
- when OpenID::Consumer::FAILURE
- if oidresp.display_identifier
- raise BadRequest, "Verification of #{oidresp.display_identifier} failed: #{oidresp.message}"
- else
- raise BadRequest, "Verification failed: #{oidresp.message}"
- end
- when OpenID::Consumer::SUCCESS
- session[:openid] = oidresp.identity_url
- if oidresp.display_identifier =~ /openid\/server\/node\/(.+)$/
- session[:level] = :node
- session[:node_name] = $1
- else
- session[:level] = :admin
- end
- redirect_back_or_default(absolute_url(:nodes))
- return "Verification of #{oidresp.display_identifier} succeeded."
- when OpenID::Consumer::SETUP_NEEDED
- return "Immediate request failed - Setup Needed"
- when OpenID::Consumer::CANCEL
- return "OpenID transaction cancelled."
- else
- end
- redirect absolute_url(:openid_consumer)
- end
-
- def logout
- session[:openid] = nil if session.has_key?(:openid)
- session[:level] = nil if session.has_key?(:level)
- session[:node_name] = nil if session.has_key?(:node_name)
- redirect url(:top)
- end
-
- private
-
- # Returns true if the openid is at a valid provider, based on whether :openid_providers is
- # defined. Raises an exception if it is not an allowed provider.
- def check_valid_openid_provider(openid)
- if Chef::Config[:openid_providers]
- fp = Chef::Config[:openid_providers].detect do |p|
- case openid
- when /^http:\/\/#{p}/, /^#{p}/
- true
- else
- false
- end
- end
- unless fp
- raise Unauthorized, "Sorry, #{openid} is not an allowed OpenID Provider."
- end
- end
- true
- end
-
- def consumer
- if @consumer.nil?
- dir = Chef::Config[:openid_cstore_path]
- store = OpenID::Store::Filesystem.new(dir)
- @consumer = OpenID::Consumer.new(session, store)
- end
- return @consumer
- end
-end
diff --git a/lib/chef_server/controllers/openid_register.rb b/lib/chef_server/controllers/openid_register.rb
deleted file mode 100644
index f5113ef267..0000000000
--- a/lib/chef_server/controllers/openid_register.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 'openid'
-
-class OpenidRegister < Application
-
- provides :html, :json
-
- before :fix_up_node_id
-
- def index
- @headers['X-XRDS-Location'] = absolute_url(:protocol => "http", :controller => "openid_server", :action => "idp_xrds")
- @registered_nodes = Chef::OpenIDRegistration.list(true)
- Chef::Log.debug(@registered_nodes.inspect)
- display @registered_nodes
- end
-
- def show
- begin
- @registered_node = Chef::OpenIDRegistration.load(params[:id])
- rescue Net::HTTPServerException => e
- if e.message =~ /^404/
- raise NotFound, "Cannot load node registration for #{params[:id]}"
- else
- raise e
- end
- end
- Merb.logger.debug(@registered_node.inspect)
- display @registered_node
- end
-
- def create
- params.has_key?(:id) or raise BadRequest, "You must provide an id to register"
- params.has_key?(:password) or raise BadRequest, "You must provide a password to register"
- if Chef::OpenIDRegistration.has_key?(params[:id])
- raise BadRequest, "You cannot re-register #{params[:id]}!"
- end
- @registered_node = Chef::OpenIDRegistration.new
- @registered_node.name = params[:id]
- @registered_node.set_password(params[:password])
- @registered_node.save
- display @registered_node
- end
-
- def update
- raise BadRequest, "You cannot update your registration -- delete #{params[:id]} and re-register"
- end
-
- def destroy
- begin
- r = Chef::OpenIDRegistration.load(params[:id])
- rescue Exception => e
- raise BadRequest, "Cannot find the registration for #{params[:id]}"
- end
- r.destroy
- if content_type == :html
- redirect url(:registrations)
- else
- display({ :message => "Deleted registration for #{params[:id]}"})
- end
- end
-
- def validate
- begin
- r = Chef::OpenIDRegistration.load(params[:id])
- rescue Exception => e
- raise BadRequest, "Cannot find the registration for #{params[:id]}"
- end
- r.validated = r.validated ? false : true
- r.save
- redirect url(:registrations)
- end
-end
diff --git a/lib/chef_server/controllers/openid_server.rb b/lib/chef_server/controllers/openid_server.rb
deleted file mode 100644
index 4cdaf67adb..0000000000
--- a/lib/chef_server/controllers/openid_server.rb
+++ /dev/null
@@ -1,236 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 'pathname'
-
-# load the openid library, first trying rubygems
-#begin
-# require "rubygems"
-# require_gem "ruby-openid", ">= 1.0"
-#rescue LoadError
-require "openid"
-require "openid/consumer/discovery"
-require 'openid/store/filesystem'
-require 'json'
-#end
-
-class OpenidServer < Application
-
- provides :html, :json
-
- include Merb::OpenidServerHelper
- include OpenID::Server
-
- layout nil
-
- before :fix_up_node_id
-
- def index
-
- oidreq = server.decode_request(params.reject{|k,v| k == "controller" || k == "action"})
-
- # no openid.mode was given
- unless oidreq
- return "This is the Chef OpenID server endpoint."
- end
-
- oidresp = nil
-
- if oidreq.kind_of?(CheckIDRequest)
- identity = oidreq.identity
-
- if oidresp
- nil
- elsif self.is_authorized(identity, oidreq.trust_root)
- oidresp = oidreq.answer(true, nil, identity)
- elsif oidreq.immediate
- server_url = url :openid_server
- oidresp = oidreq.answer(false, server_url)
- else
- if content_type != 'application/json'
- session[:last_oidreq] = oidreq
- response = { :action => url(:openid_server_decision) }
- return response.to_json
- else
- return show_decision_page(oidreq)
- end
- end
- else
- oidresp = server.handle_request(oidreq)
- end
-
- self.render_response(oidresp)
- end
-
- def show_decision_page(oidreq, message="Do you trust this site with your identity?")
- session[:last_oidreq] = oidreq
- @oidreq = oidreq
-
- if message
- session[:notice] = message
- end
-
- render :template => 'openid_server/decide'
- end
-
- def node_page
- unless Chef::OpenIDRegistration.has_key?(params[:id])
- raise NotFound, "Cannot find registration for #{params[:id]}"
- end
-
- # Yadis content-negotiation: we want to return the xrds if asked for.
- accept = request.env['HTTP_ACCEPT']
-
- # This is not technically correct, and should eventually be updated
- # to do real Accept header parsing and logic. Though I expect it will work
- # 99% of the time.
- if accept and accept.include?('application/xrds+xml')
- return node_xrds
- end
-
- # content negotiation failed, so just render the user page
- xrds_url = absolute_url(:openid_node_xrds, :id => params[:id])
- identity_page = <<EOS
-<html><head>
-<meta http-equiv="X-XRDS-Location" content="#{xrds_url}" />
-<link rel="openid.server" href="#{absolute_url(:openid_node, :id => params[:id])}" />
-</head><body><p>OpenID identity page for registration #{params[:id]}</p>
-</body></html>
-EOS
-
- # Also add the Yadis location header, so that they don't have
- # to parse the html unless absolutely necessary.
- @headers['X-XRDS-Location'] = xrds_url
- render identity_page
- end
-
- def node_xrds
- types = [
- OpenID::OPENID_2_0_TYPE,
- OpenID::OPENID_1_0_TYPE
- ]
-
- render_xrds(types)
- end
-
- def idp_xrds
- types = [
- OpenID::OPENID_IDP_2_0_TYPE,
- ]
-
- render_xrds(types)
- end
-
- def decision
- oidreq = session[:last_oidreq]
- session[:last_oidreq] = nil
-
- if params.has_key?(:cancel)
- Merb.logger.info("Cancelling OpenID Authentication")
- return(redirect(oidreq.cancel_url))
- else
- identity = oidreq.identity
- identity =~ /node\/(.+)$/
- openid_node = Chef::OpenIDRegistration.load($1)
- unless openid_node.validated
- raise Unauthorized, "This nodes registration has not been validated"
- end
- if openid_node.password == encrypt_password(openid_node.salt, params[:password])
- if session[:approvals]
- session[:approvals] << oidreq.trust_root
- else
- session[:approvals] = [oidreq.trust_root]
- end
- oidresp = oidreq.answer(true, nil, identity)
- return self.render_response(oidresp)
- else
- raise Unauthorized, "Invalid credentials"
- end
- end
- end
-
- protected
-
- def encrypt_password(salt, password)
- Digest::SHA1.hexdigest("--#{salt}--#{password}--")
- end
-
- def server
- if @server.nil?
- server_url = absolute_url(:openid_server)
- dir = Chef::Config[:openid_store_path]
- store = OpenID::Store::Filesystem.new(dir)
- @server = Server.new(store, server_url)
- end
- return @server
- end
-
- def approved(trust_root)
- return false if session[:approvals].nil?
- return session[:approvals].member?(trust_root)
- end
-
- def is_authorized(identity_url, trust_root)
- return (session[:username] and (identity_url == url_for_user) and self.approved(trust_root))
- end
-
- def render_xrds(types)
- type_str = ""
-
- types.each { |uri|
- type_str += "<Type>#{uri}</Type>\n "
- }
-
- yadis = <<EOS
-<?xml version="1.0" encoding="UTF-8"?>
-<xrds:XRDS
- xmlns:xrds="xri://$xrds"
- xmlns="xri://$xrd*($v*2.0)">
- <XRD>
- <Service priority="0">
- #{type_str}
- <URI>#{absolute_url(:openid_server)}</URI>
- </Service>
- </XRD>
-</xrds:XRDS>
-EOS
-
- @headers['content-type'] = 'application/xrds+xml'
- render yadis
- end
-
- def render_response(oidresp)
- if oidresp.needs_signing
- signed_response = server.signatory.sign(oidresp)
- end
- web_response = server.encode_response(oidresp)
-
- case web_response.code
- when HTTP_OK
- @status = 200
- render web_response.body
- when HTTP_REDIRECT
- redirect web_response.headers['location']
- else
- @status = 400
- render web_response.body
- end
- end
-
-
-end
diff --git a/lib/chef_server/controllers/search.rb b/lib/chef_server/controllers/search.rb
deleted file mode 100644
index 0abbf352b8..0000000000
--- a/lib/chef_server/controllers/search.rb
+++ /dev/null
@@ -1,71 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 Search < Application
-
- provides :html, :json
-
- def index
- @s = Chef::Search.new
- @search_indexes = @s.list_indexes
- display @search_indexes
- end
-
- def show
- @s = Chef::Search.new
- @results = nil
- if params[:q]
- @results = @s.search(params[:id], params[:q] == "" ? "?*" : params[:q])
- else
- @results = @s.search(params[:id], "?*")
- end
- # Boy, this should move to the search function
- if params[:a]
- attributes = params[:a].split(",").collect { |a| a.to_sym }
- unless attributes.length == 0
- @results = @results.collect do |r|
- nr = Hash.new
- nr[:index_name] = r[:index_name]
- nr[:id] = r[:id]
- attributes.each do |attrib|
- if r.has_key?(attrib)
- nr[attrib] = r[attrib]
- end
- end
- nr
- end
- end
- end
- display @results
- end
-
- def destroy
- @s = Chef::Search.new
- @entries = @s.search(params[:id], "?*")
- @entries.each do |entry|
- Chef::Queue.send_msg(:queue, :remove, entry)
- end
- @status = 202
- if content_type == :html
- redirect url(:search)
- else
- display @entries
- end
- end
-
-end
diff --git a/lib/chef_server/controllers/search_entries.rb b/lib/chef_server/controllers/search_entries.rb
deleted file mode 100644
index c93add3dc5..0000000000
--- a/lib/chef_server/controllers/search_entries.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 SearchEntries < Application
-
- provides :html, :json
-
- def index
- @s = Chef::Search.new
- @entries = @s.search(params[:search_id], "?*")
- display @entries
- end
-
- def show
- @s = Chef::Search.new
- @entry = @s.search(params[:search_id], "id:'#{params[:search_id]}_#{params[:id]}'").first
- display @entry
- end
-
- def create
- @to_index = params
- @to_index.delete(:controller)
- @to_index["index_name"] = params[:search_id]
- @to_index["id"] = "#{params[:search_id]}_#{params[:id]}"
- @to_index.delete(:search_id)
- Chef::Queue.send_msg(:queue, :index, @to_index)
- if content_type == :html
- redirect url(:search)
- else
- @status = 202
- display @to_index
- end
- end
-
- def update
- create
- end
-
- def destroy
- @s = Chef::Search.new
- @entries = @s.search(params[:id], "?*")
- @entries.each do |entry|
- Chef::Queue.send_msg(:queue, :remove, entry)
- end
- @status = 202
- if content_type == :html
- redirect url(:search)
- else
- display @entries
- end
- end
-
-end
diff --git a/lib/chef_server/helpers/global_helpers.rb b/lib/chef_server/helpers/global_helpers.rb
deleted file mode 100644
index f3b15129a8..0000000000
--- a/lib/chef_server/helpers/global_helpers.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 GlobalHelpers
- # helpers defined here available to all views.
- def resource_collection(collection)
- html = "<ul>"
- collection.each do |resource|
- html << "<li><b>#{resource.class}</b></li>"
- end
- html << "</ul>"
- html
- end
-
- def node_escape(node)
- node.gsub(/\./, '_')
- end
- end
-end
diff --git a/lib/chef_server/helpers/nodes_helper.rb b/lib/chef_server/helpers/nodes_helper.rb
deleted file mode 100644
index 44a190a7c6..0000000000
--- a/lib/chef_server/helpers/nodes_helper.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 NodesHelper
- def recipe_list(node)
- response = ""
- node.recipes.each do |recipe|
- response << "<li>#{recipe}</li>"
- end
- response
- end
-
- def attribute_list(node)
- response = ""
- node.each_attribute do |k,v|
- response << "<li><b>#{k}</b>: #{v}</li>"
- end
- response
- end
- end
-end \ No newline at end of file
diff --git a/lib/chef_server/helpers/openid_server_helpers.rb b/lib/chef_server/helpers/openid_server_helpers.rb
deleted file mode 100644
index dc56d2742f..0000000000
--- a/lib/chef_server/helpers/openid_server_helpers.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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 OpenidServerHelper
-
- def url_for_user
- url(:openid_node, :username => session[:username])
- end
-
- end
-end
diff --git a/lib/chef_server/init.rb b/lib/chef_server/init.rb
deleted file mode 100644
index e88c478426..0000000000
--- a/lib/chef_server/init.rb
+++ /dev/null
@@ -1,216 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@hjksolutions.com>)
-# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
-# 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.
-#
-
-Merb.root = File.join(File.dirname(__FILE__))
-
-#
-# ==== Structure of Merb initializer
-#
-# 1. Load paths.
-# 2. Dependencies configuration.
-# 3. Libraries (ORM, testing tool, etc) you use.
-# 4. Application-specific configuration.
-
-#
-# ==== Set up load paths
-#
-
-# Make the app's "gems" directory a place where gems are loaded from.
-# Note that gems directory must have a structure RubyGems uses for
-# directories under which gems are kept.
-#
-# To conveniently set it up use gem install -i <merb_app_root/gems>
-# when installing gems. This will set up the structure under /gems
-# automagically.
-#
-# An example:
-#
-# You want to bundle ActiveRecord and ActiveSupport with your Merb
-# application to be deployment environment independent. To do so,
-# install gems into merb_app_root/gems directory like this:
-#
-# gem install -i ~/dev/merbapp/gems activesupport-post-2.0.2gem activerecord-post-2.0.2.gem
-#
-# Since RubyGems will search merb_app_root/gems for dependencies, order
-# in statement above is important: we need to install ActiveSupport which
-# ActiveRecord depends on first.
-#
-# Remember that bundling of dependencies as gems with your application
-# makes it independent of the environment it runs in and is a very
-# good, encouraged practice to follow.
-Gem.clear_paths
-Gem.path.unshift(Merb.root / "gems")
-
-# If you want modules and classes from libraries organized like
-# merbapp/lib/magicwand/lib/magicwand.rb to autoload,
-# uncomment this.
-
-
-# Merb.push_path(:lib, Merb.root / "lib") # uses **/*.rb as path glob.
-
-
-# disable the ActiveSupport json annoying stuff, as it breaks our to_json
-Merb.disable :json
-
-# ==== Dependencies
-
-# These are some examples of how you might specify dependencies.
-# Dependencies load is delayed to one of later Merb app
-# boot stages. It may be important when
-# later part of your configuration relies on libraries specified
-# here.
-#
-# dependencies "RedCloth", "merb_helpers"
-# OR
-# dependency "RedCloth", "> 3.0"
-# OR
-# dependencies "RedCloth" => "> 3.0", "ruby-aes-cext" => "= 1.0"
-Merb::BootLoader.after_app_loads do
- # Add dependencies here that must load after the application loads:
- if File.exists?(File.join(File.dirname(__FILE__), "..", "..", "config", "server.rb"))
- Chef::Config.from_file(
- File.join(File.dirname(__FILE__), "..", "..", "config", "server.rb")
- )
- else
- Chef::Config.from_file(
- File.join("/etc", "chef", "server.rb")
- )
- end
- Chef::Queue.connect
-
- # create the couch design docs for nodes and openid registrations
- Chef::Node.create_design_document
- Chef::OpenIDRegistration.create_design_document
-
- # dependency "magic_admin" # this gem uses the app's model classes
-end
-
-#
-# ==== Set up your ORM of choice
-#
-
-# Merb doesn't come with database support by default. You need
-# an ORM plugin. Install one, and uncomment one of the following lines,
-# if you need a database.
-
-# Uncomment for DataMapper ORM
-# use_orm :datamapper
-
-# Uncomment for ActiveRecord ORM
-# use_orm :activerecord
-
-# Uncomment for Sequel ORM
-# use_orm :sequel
-
-Merb.push_path(:lib, File.join(File.dirname(__FILE__), "..", "chef"))
-Merb.push_path(:controller, File.join(File.dirname(__FILE__), "controllers"))
-Merb.push_path(:model, File.join(File.dirname(__FILE__), "models"))
-Merb.push_path(:view, File.join(File.dirname(__FILE__), "views"))
-Merb.push_path(:helper, File.join(File.dirname(__FILE__), "helpers"))
-Merb.push_path(:public, File.join(File.dirname(__FILE__), "public"))
-
-require 'merb-haml'
-require 'uv'
-
-
-#
-# ==== Pick what you test with
-#
-
-# This defines which test framework the generators will use
-# rspec is turned on by default
-#
-# Note that you need to install the merb_rspec if you want to ue
-# rspec and merb_test_unit if you want to use test_unit.
-# merb_rspec is installed by default if you did gem install
-# merb.
-#
-# use_test :test_unit
-use_test :rspec
-
-
-#
-# ==== Set up your basic configuration
-#
-Merb::Config.use do |c|
- # Sets up a custom session id key, if you want to piggyback sessions of other applications
- # with the cookie session store. If not specified, defaults to '_session_id'.
- c[:session_id_key] = '_chef_server_session_id'
- c[:session_secret_key] = '0992ea491c30ec76c98367c1ca53b18c1e7c5b30'
- c[:session_store] = 'cookie'
- c[:exception_details] = true
- c[:reload_classes] = true
- c[:log_level] = :debug
- c[:log_file] = "/var/log/chef-server.log"
-end
-
-Merb.logger.info("Compiling routes...")
-Merb::Router.prepare do |r|
- # RESTful routes
- # r.resources :posts
-
- # This is the default route for /:controller/:action/:id
- # This is fine for most cases. If you're heavily using resource-based
- # routes, you may want to comment/remove this line to prevent
- # clients from calling your create or destroy actions with a GET
-
- resources :nodes
- resources :searches, :path => "search", :controller => "search" do
- resources :entries, :controller => "search_entries"
- end
-
- match("/cookbooks/_attribute_files").to(:controller => "cookbooks", :action => "attribute_files")
- match("/cookbooks/_recipe_files").to(:controller => "cookbooks", :action => "recipe_files")
- match("/cookbooks/_definition_files").to(:controller => "cookbooks", :action => "definition_files")
-
-# r.match("/cookbooks/:cookbook_id/templates").to(:controller => "cookbook_templates", :action => "index")
-
- resources :cookbooks do
- resources :templates, :controller => "cookbook_templates"
- resources :files, :controller => "cookbook_files"
- resources :recipes, :controller => "cookbook_recipes"
- resources :attributes, :controller => "cookbook_attributes"
- resources :definitions, :controller => "cookbook_definitions"
- end
-
- #r.resources :openid do |res|
- # res.resources :register, :controller => "openid_register"
- # res.resources :server, :controller => "openid_server"
- #end
-
- resources :registrations, :controller => "openid_register"
- resources :registrations, :controller => "openid_register", :member => { :validate => :post }
- match("/openid/server").to(:controller => "openid_server", :action => "index").name(:openid_server)
- match("/openid/server/server/xrds").
- to(:controller => "openid_server", :action => 'idp_xrds').name(:openid_server_xrds)
- match("/openid/server/node/:id").
- to(:controller => "openid_server", :action => 'node_page').name(:openid_node)
- match('/openid/server/node/:id/xrds').
- to(:controller => 'openid_server', :action => 'node_xrds').name(:openid_node_xrds)
- match('/openid/server/decision').to(:controller => "openid_server", :action => "decision").name(:openid_server_decision)
- match('/openid/consumer').to(:controller => 'openid_consumer', :action => 'index').name(:openid_consumer)
- match('/openid/consumer/start').to(:controller => 'openid_consumer', :action => 'start').name(:openid_consumer_start)
- match('/openid/consumer/complete').to(:controller => 'openid_consumer', :action => 'complete').name(:openid_consumer_complete)
- match('/openid/consumer/logout').to(:controller => 'openid_consumer', :action => 'logout').name(:openid_consumer_logout)
-
- #r.default_routes
-
- # Change this for your home page to be available at /
- match('/').to(:controller => 'nodes', :action =>'index').name(:top)
-end
-
diff --git a/lib/chef_server/public/images/merb.jpg b/lib/chef_server/public/images/merb.jpg
deleted file mode 100644
index a19dcf4048..0000000000
--- a/lib/chef_server/public/images/merb.jpg
+++ /dev/null
Binary files differ
diff --git a/lib/chef_server/public/stylesheets/master.css b/lib/chef_server/public/stylesheets/master.css
deleted file mode 100644
index 13bdffbe1b..0000000000
--- a/lib/chef_server/public/stylesheets/master.css
+++ /dev/null
@@ -1,292 +0,0 @@
-/* body {
- font-family: Arial, Verdana, sans-serif;
- font-size: 12px;
- background-color: #fff;
- margin: ;
-}
-html {
- height: 100%;
- margin-bottom: 1px;
-}
-#container {
- width: 80%;
- text-align: left;
- background-color: #fff;
- margin-right: auto;
- margin-left: auto;
-}
-#header-container {
- width: 100%;
- padding-top: 15px;
-}
-#header-container h1, #header-container h2 {
- margin-left: 6px;
- margin-bottom: 6px;
-}
-.spacer {
- width: 100%;
- height: 15px;
-}
-hr {
- border: 0px;
- color: #ccc;
- background-color: #cdcdcd;
- height: 1px;
- width: 100%;
- text-align: left;
-}
-h1 {
- font-size: 28px;
- color: #c55;
- background-color: #fff;
- font-family: Arial, Verdana, sans-serif;
- font-weight: 300;
-}
-h2 {
- font-size: 15px;
- color: #999;
- font-family: Arial, Verdana, sans-serif;
- font-weight: 300;
- background-color: #fff;
-}
-h3 {
- color: #4d9b12;
- font-size: 15px;
- text-align: left;
- font-weight: 300;
- padding: 5px;
- margin-top: 5px;
-}
-
-#left-container {
- float: left;
- width: 250px;
- background-color: #FFFFFF;
- color: black;
-}
-
-#left-container h3 {
- color: #c55;
-}
-
-#main-container {
- margin: 5px 5px 5px 260px;
- padding: 15px;
- border-left: 1px solid silver;
- min-height: 400px;
-}
-p {
- color: #000;
- background-color: #fff;
- line-height: 20px;
- padding: 5px;
-}
-a {
- color: #4d9b12;
- background-color: #fff;
- text-decoration: none;
-}
-a:hover {
- color: #4d9b12;
- background-color: #fff;
- text-decoration: underline;
-}
-#footer-container {
- clear: both;
- font-size: 12px;
- font-family: Verdana, Arial, sans-serif;
-}
-.right {
- float: right;
- font-size: 100%;
- margin-top: 5px;
- color: #999;
- background-color: #fff;
-}
-.left {
- float: left;
- font-size: 100%;
- margin-top: 5px;
- color: #999;
- background-color: #fff;
-}
-#main-container ul {
- margin-left: 3.0em;
-}
-
-div.resource_collection {
- border: 1px solid #999;
- float: left;
- clear: both;
- margin: 10px;
- padding: 5px;
-}
-
-div.resource {
- border-top: 1px solid #999;
- float: left;
- clear: both;
-}
-
-div.attr_group {
- float: left;
- clear: both;
-}
-
-td.attr_name {
- font-weight: bold;
- margin-right: 10px;
- border-right: 1px solid #999;
-}
-
-td.attr_value {
- padding-left: 5px;
- border-top: 1px solid #999;
-}
-
-div.node {
- float: left;
- clear: both;
- margin: 10px;
- padding: 5px;
- border: 1px solid #999;
-}
-*/
-
-pre.twilight .DiffInserted {
- background-color: #253B22;
- color: #F8F8F8;
-}
-pre.twilight .DiffHeader {
- background-color: #0E2231;
- color: #F8F8F8;
- font-style: italic;
-}
-pre.twilight .CssPropertyValue {
- color: #F9EE98;
-}
-pre.twilight .CCCPreprocessorDirective {
- color: #AFC4DB;
-}
-pre.twilight .Constant {
- color: #CF6A4C;
-}
-pre.twilight .DiffChanged {
- background-color: #4A410D;
- color: #F8F8F8;
-}
-pre.twilight .EmbeddedSource {
- background-color: #A3A6AD;
-}
-pre.twilight .Support {
- color: #9B859D;
-}
-pre.twilight .MarkupList {
- color: #F9EE98;
-}
-pre.twilight .CssConstructorArgument {
- color: #8F9D6A;
-}
-pre.twilight .Storage {
- color: #F9EE98;
-}
-pre.twilight .line-numbers {
- background-color: #DDF0FF;
- color: #000000;
-}
-pre.twilight .CssClass {
- color: #9B703F;
-}
-pre.twilight .StringConstant {
- color: #DDF2A4;
-}
-pre.twilight .CssAtRule {
- color: #8693A5;
-}
-pre.twilight .MetaTagInline {
- color: #E0C589;
-}
-pre.twilight .MarkupHeading {
- color: #CF6A4C;
-}
-pre.twilight .CssTagName {
- color: #CDA869;
-}
-pre.twilight .SupportConstant {
- color: #CF6A4C;
-}
-pre.twilight .DiffDeleted {
- background-color: #420E09;
- color: #F8F8F8;
-}
-pre.twilight .CCCPreprocessorLine {
- color: #8996A8;
-}
-pre.twilight .StringRegexpSpecial {
- color: #CF7D34;
-}
-pre.twilight .EmbeddedSourceBright {
- background-color: #9C9EA4;
-}
-pre.twilight .InvalidIllegal {
- background-color: #241A24;
- color: #F8F8F8;
-}
-pre.twilight .SupportFunction {
- color: #DAD085;
-}
-pre.twilight .CssAdditionalConstants {
- color: #CA7840;
-}
-pre.twilight .MetaTagAll {
- color: #AC885B;
-}
-pre.twilight .StringRegexp {
- color: #E9C062;
-}
-pre.twilight .StringEmbeddedSource {
- color: #DAEFA3;
-}
-pre.twilight .EntityInheritedClass {
- color: #9B5C2E;
- font-style: italic;
-}
-pre.twilight .CssId {
- color: #8B98AB;
-}
-pre.twilight .CssPseudoClass {
- color: #8F9D6A;
-}
-pre.twilight .StringVariable {
- color: #8A9A95;
-}
-pre.twilight .String {
- color: #8F9D6A;
-}
-pre.twilight .Keyword {
- color: #CDA869;
-}
-pre.twilight {
- background-color: #141414;
- color: #F8F8F8;
-}
-pre.twilight .CssPropertyName {
- color: #C5AF75;
-}
-pre.twilight .DoctypeXmlProcessing {
- color: #494949;
-}
-pre.twilight .InvalidDeprecated {
- color: #D2A8A1;
- font-style: italic;
-}
-pre.twilight .Variable {
- color: #7587A6;
-}
-pre.twilight .Entity {
- color: #9B703F;
-}
-pre.twilight .Comment {
- color: #5F5A60;
- font-style: italic;
-}
diff --git a/lib/chef_server/views/cookbook_templates/index.html.haml b/lib/chef_server/views/cookbook_templates/index.html.haml
deleted file mode 100644
index 307aefd812..0000000000
--- a/lib/chef_server/views/cookbook_templates/index.html.haml
+++ /dev/null
@@ -1,8 +0,0 @@
-%h1 Cookbook Templates
-- @templates.each do |template, data|
- .index
- %table
- %tr
- %td
- %a{ :href => url(:cookbook_template, { :cookbook_id => params[:cookbook_id], :id => data[:link_name], :version => data[:version] }) }
- = "#{data[:version]} - #{data[:name]}"
diff --git a/lib/chef_server/views/cookbooks/_attribute_file.html.haml b/lib/chef_server/views/cookbooks/_attribute_file.html.haml
deleted file mode 100644
index af859d5ff3..0000000000
--- a/lib/chef_server/views/cookbooks/_attribute_file.html.haml
+++ /dev/null
@@ -1,2 +0,0 @@
-%h3= name
-= ::Uv.parse(contents, "xhtml", "ruby", true, "twilight") \ No newline at end of file
diff --git a/lib/chef_server/views/cookbooks/attribute_files.html.haml b/lib/chef_server/views/cookbooks/attribute_files.html.haml
deleted file mode 100644
index 56fdcf7bee..0000000000
--- a/lib/chef_server/views/cookbooks/attribute_files.html.haml
+++ /dev/null
@@ -1,4 +0,0 @@
-%h1 All Attribute Files
-- @attribute_files.each do |af_hash|
- %h2= "#{af_hash[:cookbook]}"
- = partial(:attribute_file, :name => af_hash[:name], :contents => af_hash[:contents]) \ No newline at end of file
diff --git a/lib/chef_server/views/cookbooks/index.html.haml b/lib/chef_server/views/cookbooks/index.html.haml
deleted file mode 100644
index 008f74765c..0000000000
--- a/lib/chef_server/views/cookbooks/index.html.haml
+++ /dev/null
@@ -1,7 +0,0 @@
-%h1 Cookbooks
-- @cl.each do |cookbook|
- .index
- %table
- %tr
- %td
- %a{ :href => url(:cookbook, { :id => cookbook.name }) }= cookbook.name
diff --git a/lib/chef_server/views/cookbooks/show.html.haml b/lib/chef_server/views/cookbooks/show.html.haml
deleted file mode 100644
index 1b6557e012..0000000000
--- a/lib/chef_server/views/cookbooks/show.html.haml
+++ /dev/null
@@ -1,24 +0,0 @@
-%h1= "Cookbook #{h @cookbook.name}"
-.cookbook
-- if @cookbook.attribute_files.length > 0
- %h2 Attribute Files
- - @cookbook.attribute_files.each do |af|
- = partial(:attribute_file, :name => File.basename(af), :contents => File.read(af))
-
-- if @cookbook.definition_files.length > 0
- - @cookbook.definition_files.each do |df|
- %h2 Definition Files
- %h3= File.basename(df)
- = ::Uv.parse(File.read(df), "xhtml", "ruby", true, "twilight")
-
-- if @cookbook.recipe_files.length > 0
- - @cookbook.recipe_files.each do |rf|
- %h2 Recipe Files
- %h3= File.basename(rf)
- = ::Uv.parse(File.read(rf), "xhtml", "ruby", true, "twilight")
-
-- if @cookbook.template_files.length > 0
- - @cookbook.template_files.each do |tf|
- %h2 Template Files
- %h3= File.basename(tf)
- = ::Uv.parse(File.read(tf), "xhtml", "html_rails", true, "twilight")
diff --git a/lib/chef_server/views/exceptions/bad_request.json.erb b/lib/chef_server/views/exceptions/bad_request.json.erb
deleted file mode 100644
index f266cf99b9..0000000000
--- a/lib/chef_server/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/lib/chef_server/views/exceptions/internal_server_error.html.erb b/lib/chef_server/views/exceptions/internal_server_error.html.erb
deleted file mode 100644
index aadbfad350..0000000000
--- a/lib/chef_server/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/lib/chef_server/views/exceptions/not_acceptable.html.erb b/lib/chef_server/views/exceptions/not_acceptable.html.erb
deleted file mode 100644
index f632712bb2..0000000000
--- a/lib/chef_server/views/exceptions/not_acceptable.html.erb
+++ /dev/null
@@ -1,63 +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>Why am I seeing this page?</h3>
- <p>Merb couldn't find an appropriate content_type to return,
- based on what you said was available via provides() and
- what the client requested.</p>
-
- <h3>How to add a mime-type</h3>
- <pre><code>
- Merb.add_mime_type :pdf, :to_pdf, %w[application/pdf], &quot;Content-Encoding&quot; =&gt; &quot;gzip&quot;
- </code></pre>
- <h3>What this means is:</h3>
- <ul>
- <li>Add a mime-type for :pdf</li>
- <li>Register the method for converting objects to PDF as <code>#to_pdf</code>.</li>
- <li>Register the incoming mime-type "Accept" header as <code>application/pdf</code>.</li>
- <li>Specify a new header for PDF types so it will set <code>Content-Encoding</code> to gzip.</li>
- </ul>
-
- <h3>You can then do:</h3>
- <pre><code>
- class Foo &lt; Application
- provides :pdf
- end
- </code></pre>
-
- <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 can change what people see when this happens by editing <tt>app/views/exceptions/not_acceptable.html.erb</tt>.</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/lib/chef_server/views/exceptions/not_found.html.erb b/lib/chef_server/views/exceptions/not_found.html.erb
deleted file mode 100644
index 388c72c31d..0000000000
--- a/lib/chef_server/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/lib/chef_server/views/layout/application.html.haml b/lib/chef_server/views/layout/application.html.haml
deleted file mode 100644
index 2be4097d29..0000000000
--- a/lib/chef_server/views/layout/application.html.haml
+++ /dev/null
@@ -1,26 +0,0 @@
-!!! XML
-!!!
-%html
- %head
- %title Chef Server
- %meta{"http-equiv" => "content-type", :content => "text/html; charset=utf-8" }
- %link{:rel => "stylesheet", :href => "/stylesheets/master.css", :type => "text/css", :media => "screen", :charset => "utf-8" }
- %body
- .header
- %a{:href => url(:searches) } Search
- |
- %a{:href => url(:nodes) } Nodes
- |
- %a{:href => url(:cookbooks) } Cookbooks
- |
- %a{:href => url(:registrations)} Registrations
- - if session[:openid]
- |
- %a{:href => url(:openid_consumer_logout)}= "Logout #{h session[:openid]}"
- = "(#{session[:level].to_s})"
- - else
- |
- %a{:href => url(:openid_consumer)} Login
- = catch_content :for_layout
-
- \ No newline at end of file
diff --git a/lib/chef_server/views/nodes/_action.html.haml b/lib/chef_server/views/nodes/_action.html.haml
deleted file mode 100644
index 8adb39338d..0000000000
--- a/lib/chef_server/views/nodes/_action.html.haml
+++ /dev/null
@@ -1,13 +0,0 @@
-%table
- - actions.each do |action, resource_hash|
- %tr
- %td.action_name= action.to_s
- %td.action_resources
- %table
- - resource_hash.keys.sort{ |a,b| a.to_s <=> b.to_s }.each do |rk|
- %tr
- %td.action_when= rk.to_s
- %td
- - resource_hash[rk].each do |resource|
- = partial(:resource, :resource => resource)
- \ No newline at end of file
diff --git a/lib/chef_server/views/nodes/_node.html.haml b/lib/chef_server/views/nodes/_node.html.haml
deleted file mode 100644
index 24b1f2816b..0000000000
--- a/lib/chef_server/views/nodes/_node.html.haml
+++ /dev/null
@@ -1,9 +0,0 @@
-.node
- %h1
- = "Node #{h node.name}"
- %h2 Recipes
- %ol
- = recipe_list(node)
- %h2 Attributes
- %ol
- = attribute_list(node)
diff --git a/lib/chef_server/views/nodes/_resource.html.haml b/lib/chef_server/views/nodes/_resource.html.haml
deleted file mode 100644
index 7b9776b816..0000000000
--- a/lib/chef_server/views/nodes/_resource.html.haml
+++ /dev/null
@@ -1,22 +0,0 @@
-.resource
- %h3= "#{h resource.to_s} (#{resource.class})"
- %table
- - resource.instance_variables.sort.each do |v|
- - attr_name = v.gsub(/\@/, "")
- - unless attr_name == "collection"
- %tr.attr_group
- %td.attr_name
- = "#{h attr_name}"
- %td.attr_value
- - value = resource.instance_variable_get(v)
- - if value.kind_of?(String)
- = "#{h value}"
- - elsif value.kind_of?(Array)
- = "#{h value.join(", ")}"
- - elsif value.kind_of?(Symbol)
- = "#{h value.to_s}"
- - elsif attr_name == "actions"
- = partial(:action, :actions => value)
- - else
- = "#{h value.inspect}"
-
diff --git a/lib/chef_server/views/nodes/compile.html.haml b/lib/chef_server/views/nodes/compile.html.haml
deleted file mode 100644
index 5656447ea8..0000000000
--- a/lib/chef_server/views/nodes/compile.html.haml
+++ /dev/null
@@ -1,5 +0,0 @@
-= partial(:node, :node => @output[:node])
-.resource_collection
- %h1 Resource Collection
- - @output[:collection].each do |resource|
- = partial(:resource, :resource => resource)
diff --git a/lib/chef_server/views/nodes/index.html.haml b/lib/chef_server/views/nodes/index.html.haml
deleted file mode 100644
index 667e1c7317..0000000000
--- a/lib/chef_server/views/nodes/index.html.haml
+++ /dev/null
@@ -1,9 +0,0 @@
-%h1 Node List
-- @node_list.each do |node|
- .node
- %a{ :href => url(:node, { :id => node.gsub(/\./, "_") }) }
- = node
- %form{ :method => "post", :action => url(:node, { :id => node.gsub(/\./, "_") })}
- %input{ :type => "hidden", :name => "_method", :value => "delete" }
- %input{ :type => "submit", :name => "Delete", :value => "Delete" }
- \ No newline at end of file
diff --git a/lib/chef_server/views/nodes/show.html.haml b/lib/chef_server/views/nodes/show.html.haml
deleted file mode 100644
index 94708af6d3..0000000000
--- a/lib/chef_server/views/nodes/show.html.haml
+++ /dev/null
@@ -1 +0,0 @@
-= partial(:node, :node => @node) \ No newline at end of file
diff --git a/lib/chef_server/views/openid_consumer/index.html.haml b/lib/chef_server/views/openid_consumer/index.html.haml
deleted file mode 100644
index 576ef8d787..0000000000
--- a/lib/chef_server/views/openid_consumer/index.html.haml
+++ /dev/null
@@ -1,25 +0,0 @@
-%h1 OpenID Relying Party
--if session[:alert]
- .alert= h session[:alert]
--if session[:error]
- .error= h session[:error]
--if session[:success]
- .success= h session[:success]
-#verify-form
- %form{ :method => "get", "accept-charset" => "UTF-8", :action => url(:openid_consumer_start) }
- Identifier:
- %input.openid{ :type => "text", :name => "openid_identifier" }/
- %input{ :type => "submit", :value => "Verify"}/
- %br
- %input#immediate{ :name => "immediate", :type => "checkbox" }/
- %label{:for => "immediate"} Use immediate mode
- %br
- %input#immediate{ :name => "use_sreg", :type => "checkbox" }/
- %label{:for => "use_sreg"} Request registration data
- %br
- %input#immediate{ :name => "use_pape", :type => "checkbox" }/
- %label{:for => "use_pape"} Request phishing-resistent auth policy
- %br
- %input#immediate{ :name => "force_post", :type => "checkbox" }/
- %label{:for => "force_post"} Force the transaction to POST
- %br
diff --git a/lib/chef_server/views/openid_consumer/start.html.haml b/lib/chef_server/views/openid_consumer/start.html.haml
deleted file mode 100644
index 75ed9a9257..0000000000
--- a/lib/chef_server/views/openid_consumer/start.html.haml
+++ /dev/null
@@ -1,4 +0,0 @@
-<%= @form_text %>
-<script type="text/javascript">
-document.getElementById('openid_form').submit();
-</script> \ No newline at end of file
diff --git a/lib/chef_server/views/openid_login/index.html.haml b/lib/chef_server/views/openid_login/index.html.haml
deleted file mode 100644
index 17ae69017a..0000000000
--- a/lib/chef_server/views/openid_login/index.html.haml
+++ /dev/null
@@ -1,6 +0,0 @@
-%h1 Login
-#login-form
- %form{ :method => "get", :action => url(:openid_login_submit) }
- %input{ :type => "text", :name => "username" }/
- %input{ :type => "submit", :value => "Log In"}/
- \ No newline at end of file
diff --git a/lib/chef_server/views/openid_register/index.html.haml b/lib/chef_server/views/openid_register/index.html.haml
deleted file mode 100644
index fe4798c59d..0000000000
--- a/lib/chef_server/views/openid_register/index.html.haml
+++ /dev/null
@@ -1,15 +0,0 @@
-%h1 Registered OpenID Nodes List
-%table
-- @registered_nodes.each do |node|
- %tr
- %td
- %a{ :href => url(:registration, { :id => node.name }) }
- = h node.name
- %td
- - if session[:level] == :admin
- %form{ :method => "post", :action => url(:validate_registration, { :id => node.name })}
- - submit_name = node.validated ? "Invalidate" : "Validate"
- %input{ :type => "submit", :name => submit_name, :value => submit_name }
- %form{ :method => "post", :action => url(:registration, { :id => node.name })}
- %input{ :type => "hidden", :name => "_method", :value => "delete" }
- %input{ :type => "submit", :name => "Delete", :value => "Delete" }
diff --git a/lib/chef_server/views/openid_register/show.html.haml b/lib/chef_server/views/openid_register/show.html.haml
deleted file mode 100644
index cfd38e8963..0000000000
--- a/lib/chef_server/views/openid_register/show.html.haml
+++ /dev/null
@@ -1,5 +0,0 @@
-%h1= "Registered OpenID Node #{@registered_node.name}"
-%ol
- %li
- %a{ :href => url(:openid_node , { :id => @registered_node.name.gsub(/\./, "_") }) } OpenID URL
- %li= "Validated: #{@registered_node.validated}"
diff --git a/lib/chef_server/views/openid_server/decide.html.haml b/lib/chef_server/views/openid_server/decide.html.haml
deleted file mode 100644
index 8082a5068d..0000000000
--- a/lib/chef_server/views/openid_server/decide.html.haml
+++ /dev/null
@@ -1,27 +0,0 @@
-%form{:method => "post", :action => url(:openid_server_decision)}
- %table
- %tr
- %td Site:
- %td= @oidreq.trust_root
- - if @oidreq.id_select
- %tr
- %td{:colspan => "2"}
- You entered the server identifier at the relying party.
- You will need to send an identifier of your choosing.
- Enter a username and password below.
- %tr
- %td Identity to send:
- %td
- %input{:type => "text", :name => "id_to_send", :size => "25"}
- - else
- %tr
- %td Identity:
- %td= @oidreq.identity
- %tr
- %td
- %label{:for => "password"} Password:
- %td
- %input{:type => "password", :name => "password"}
- %input{:type => "submit", :name => "submit", :value => "Authenticate"}
- %input{:type => "submit", :name => "cancel", :value => "Cancel"}
-
diff --git a/lib/chef_server/views/search/_search_form.html.haml b/lib/chef_server/views/search/_search_form.html.haml
deleted file mode 100644
index 99303e1714..0000000000
--- a/lib/chef_server/views/search/_search_form.html.haml
+++ /dev/null
@@ -1,6 +0,0 @@
-%form{ :method => "get", :action => url(:search, { :id => index_name }) }
- Q:
- %input{ :type => "text", :name => "q" }
- A:
- %input{ :type => "text", :name => "a" }
- %input{ :type => "submit", :value => "Search #{index_name}" }
diff --git a/lib/chef_server/views/search/index.html.haml b/lib/chef_server/views/search/index.html.haml
deleted file mode 100644
index 742c1110b0..0000000000
--- a/lib/chef_server/views/search/index.html.haml
+++ /dev/null
@@ -1,9 +0,0 @@
-%h1 Search Indexes
-- @search_indexes.each do |index|
- .index
- %table
- %tr
- %td
- %a{ :href => url(:search, { :id => index }) }= index
- %td
- = partial(:search_form, :index_name => index)
diff --git a/lib/chef_server/views/search/show.html.haml b/lib/chef_server/views/search/show.html.haml
deleted file mode 100644
index 5380a7477a..0000000000
--- a/lib/chef_server/views/search/show.html.haml
+++ /dev/null
@@ -1,13 +0,0 @@
-%h1 Search Results
-.search
- = partial(:search_form, :index_name => params[:id])
-.query
- %h2= "Search Query was #{params[:q] ? params[:q] : '*'}"
-- @results.each do |result|
- .search_result
- %h3= "#{h result[:index_name]} (#{h result[:id]})"
- %table
- - result.each do |k, v|
- %tr.attr_group
- %td.attr_name= k
- %td.attr_value= v.kind_of?(Array) ? v.join(",") : v \ No newline at end of file
diff --git a/lib/chef_server/views/search_entries/index.html.haml b/lib/chef_server/views/search_entries/index.html.haml
deleted file mode 100644
index 77d140242e..0000000000
--- a/lib/chef_server/views/search_entries/index.html.haml
+++ /dev/null
@@ -1,9 +0,0 @@
-%h1= "Search Index #{h params[:search_id]}"
-- @entries.each do |result|
- .search_result
- %h3= "#{h result[:index_name]} (#{h result[:id]})"
- %table
- - result.each do |k, v|
- %tr.attr_group
- %td.attr_name= k
- %td.attr_value= v.kind_of?(Array) ? v.join(",") : v \ No newline at end of file
diff --git a/lib/chef_server/views/search_entries/show.html.haml b/lib/chef_server/views/search_entries/show.html.haml
deleted file mode 100644
index 7ca34b32ab..0000000000
--- a/lib/chef_server/views/search_entries/show.html.haml
+++ /dev/null
@@ -1,8 +0,0 @@
-%h1= "Search Index #{h params[:search_id]} entry #{h params[:id]}"
-.search_result
- %h3= "#{h @entry[:index_name]} (#{h @entry[:id]})"
- %table
- - @entry.each do |k, v|
- %tr.attr_group
- %td.attr_name= k
- %td.attr_value= v.kind_of?(Array) ? v.join(",") : v \ No newline at end of file