Hi,
These patches will remove unused or obsolete code from 'core'. Also this patch fixes RAILS_ROOT variable usage and removing some unused/obsolete helpers). Some of deltacloud includes (drivers.rb, deltacloud.rb) movedinto lib/deltacloud directory, so root directory is now cleaner.
- Michal
--- server/Rakefile | 44 +++----------------------------------------- 1 files changed, 3 insertions(+), 41 deletions(-)
diff --git a/server/Rakefile b/server/Rakefile index 72b7af6..06c649d 100644 --- a/server/Rakefile +++ b/server/Rakefile @@ -54,45 +54,7 @@ Rake::GemPackageTask.new(@spec) do |pkg| pkg.need_tar = true end
-desc "Install API" -task :install, [:install_dir, :bin_dir] do |t, args| - - require 'fileutils' - require 'pp' - - files = FileList[ - Dir["config/**/**"], - Dir["features/**/**"], - Dir["lib/**/**"], - Dir["public/**/**"], - Dir["views/**/**"], - "config.ru", - "COPYING", - "README", - "*.rb" - ] - - INSTALL_DIR=args.install_dir || "/usr/local/share/deltacloud-core" - BIN_DIR=args.bin_dir || "/usr/local/bin" - - exit(1) unless FileUtils.mkdir_p(INSTALL_DIR) - exit(1) unless FileUtils.mkdir_p(BIN_DIR) - - files.each do |f| - install_path = "#{INSTALL_DIR}/#{File.dirname(f)}" - unless File.directory?(install_path) - FileUtils.mkdir_p(install_path, :mode => 0755, :verbose => true) - end - next if File.directory?(f) - FileUtils.install(f, "#{INSTALL_DIR}/#{File.dirname(f)}", :verbose => true) - end - - FileUtils.install('bin/deltacloudd', BIN_DIR, :verbose => true, :mode => 0755) -end - -desc "Uninstall API" -task :uninstall do - require 'fileutils' - INSTALL_DIR="/usr/share/deltacloud-core" - FileUtils.rm_rf(INSTALL_DIR) +desc "Generate CSS" +task :compass do + puts exec('compass -q') end
--- server/app/controllers/api_controller.rb | 39 ------- server/app/controllers/application_controller.rb | 47 -------- server/app/controllers/flavors_controller.rb | 48 --------- .../controllers/hardware_profiles_controller.rb | 16 --- server/app/controllers/images_controller.rb | 52 --------- .../app/controllers/instance_states_controller.rb | 49 --------- server/app/controllers/instances_controller.rb | 109 ------------------- server/app/controllers/realms_controller.rb | 48 --------- server/app/controllers/root_controller.rb | 23 ---- .../controllers/storage_snapshots_controller.rb | 47 -------- .../app/controllers/storage_volumes_controller.rb | 47 -------- server/config/boot.rb | 110 ------------------- server/config/compass.config | 2 +- server/config/database.yml | 22 ---- server/config/environment.rb | 111 -------------------- server/config/environments/development.rb | 17 --- server/config/environments/production.rb | 28 ----- server/config/environments/test.rb | 28 ----- server/config/initializers/backtrace_silencers.rb | 7 -- server/config/initializers/compass.rb | 5 - server/config/initializers/inflections.rb | 10 -- server/config/initializers/mime_types.rb | 10 -- server/config/initializers/new_rails_defaults.rb | 19 ---- server/config/initializers/session_store.rb | 15 --- server/config/locales/en.yml | 2 - server/config/routes.rb | 49 --------- server/deltacloud.rb | 14 --- server/drivers.rb | 39 ------- server/lib/deltacloud/deltacloud.rb | 10 ++ server/lib/deltacloud/drivers.rb | 38 +++++++ server/lib/deltacloud/helpers.rb | 3 +- server/lib/deltacloud/helpers/root_helper.rb | 19 ---- server/lib/deltacloud/helpers/url_helper.rb | 5 - server/server.rb | 6 +- server/views/layout.html.haml | 2 +- 35 files changed, 54 insertions(+), 1042 deletions(-) delete mode 100644 server/app/controllers/api_controller.rb delete mode 100644 server/app/controllers/application_controller.rb delete mode 100644 server/app/controllers/flavors_controller.rb delete mode 100644 server/app/controllers/hardware_profiles_controller.rb delete mode 100644 server/app/controllers/images_controller.rb delete mode 100644 server/app/controllers/instance_states_controller.rb delete mode 100644 server/app/controllers/instances_controller.rb delete mode 100644 server/app/controllers/realms_controller.rb delete mode 100644 server/app/controllers/root_controller.rb delete mode 100644 server/app/controllers/storage_snapshots_controller.rb delete mode 100644 server/app/controllers/storage_volumes_controller.rb delete mode 100644 server/config/boot.rb delete mode 100644 server/config/database.yml delete mode 100644 server/config/environment.rb delete mode 100644 server/config/environments/development.rb delete mode 100644 server/config/environments/production.rb delete mode 100644 server/config/environments/test.rb delete mode 100644 server/config/initializers/backtrace_silencers.rb delete mode 100644 server/config/initializers/compass.rb delete mode 100644 server/config/initializers/inflections.rb delete mode 100644 server/config/initializers/mime_types.rb delete mode 100644 server/config/initializers/new_rails_defaults.rb delete mode 100644 server/config/initializers/session_store.rb delete mode 100644 server/config/locales/en.yml delete mode 100644 server/config/routes.rb delete mode 100644 server/deltacloud.rb delete mode 100644 server/drivers.rb create mode 100644 server/lib/deltacloud/deltacloud.rb create mode 100644 server/lib/deltacloud/drivers.rb delete mode 100644 server/lib/deltacloud/helpers/root_helper.rb delete mode 100644 server/lib/deltacloud/helpers/url_helper.rb
diff --git a/server/app/controllers/api_controller.rb b/server/app/controllers/api_controller.rb deleted file mode 100644 index dd201eb..0000000 --- a/server/app/controllers/api_controller.rb +++ /dev/null @@ -1,39 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -class ApiController < ApplicationController - - def show - @version = 1.0 - @entry_points = [ - [ :flavors, flavors_url ], - [ :hardware_profiles, hardware_profiles_url ], - [ :instance_states, instance_states_url ], - [ :realms, realms_url ], - [ :images, images_url ], - [ :instances, instances_url ], - [ :storage_volumes, storage_volumes_url ], - [ :storage_snapshots, storage_snapshots_url ], - ] - respond_to do |format| - format.html - format.json - format.xml - end - end - -end diff --git a/server/app/controllers/application_controller.rb b/server/app/controllers/application_controller.rb deleted file mode 100644 index 618a833..0000000 --- a/server/app/controllers/application_controller.rb +++ /dev/null @@ -1,47 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -# -# Filters added to this controller apply to all controllers in the application. -# Likewise, all the methods added will be available for all controllers. - -class ApplicationController < ActionController::Base - helper :all # include all helpers, all the time - #protect_from_forgery # See ActionController::RequestForgeryProtection for details - - # Scrub sensitive parameters from your log - # filter_parameter_logging :password - - - protected - - def credentials - creds = {} - authenticate_with_http_basic do |name,password| - creds[:name] = name - creds[:password] = password - end - creds - end - - def build_filter(param_name) - if ( params[param_name] ) - @filter ||= {} - @filter[param_name] = params[param_name] - end - end - -end diff --git a/server/app/controllers/flavors_controller.rb b/server/app/controllers/flavors_controller.rb deleted file mode 100644 index 6176f2a..0000000 --- a/server/app/controllers/flavors_controller.rb +++ /dev/null @@ -1,48 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -class FlavorsController < ApplicationController - - include DriverHelper - include ConversionHelper - - around_filter :catch_auth - - def index - build_filter( :id ) - build_filter( :architecture ) - @flavors = driver.flavors( credentials, @filter ) - respond_to do |format| - format.html - format.xml { - render :xml=>convert_to_xml( :flavor, @flavors ) - } - end - end - - def show - @flavor = driver.flavor( credentials, :id => params[:id] ) - respond_to do |format| - format.html - format.json - format.xml { - render :xml=>convert_to_xml( :flavor, @flavor ) - } - end - end - -end diff --git a/server/app/controllers/hardware_profiles_controller.rb b/server/app/controllers/hardware_profiles_controller.rb deleted file mode 100644 index 1b2215b..0000000 --- a/server/app/controllers/hardware_profiles_controller.rb +++ /dev/null @@ -1,16 +0,0 @@ -class HardwareProfilesController < ApplicationController - - include DriverHelper - include ConversionHelper - - around_filter :catch_auth - - def index - @profiles = driver().hardware_profiles - end - - def show - @profile = driver().hardware_profile(params[:id]) - end - -end diff --git a/server/app/controllers/images_controller.rb b/server/app/controllers/images_controller.rb deleted file mode 100644 index 92fe73f..0000000 --- a/server/app/controllers/images_controller.rb +++ /dev/null @@ -1,52 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -class ImagesController < ApplicationController - - include DriverHelper - include ConversionHelper - - around_filter :catch_auth - - def index - build_filter( :id ) - build_filter( :owner_id ) - build_filter( :architecture ) - @images = driver.images( credentials, @filter ) - - respond_to do |format| - format.html - format.json - format.xml { - render :xml=>convert_to_xml( :image, @images ) - } - end - end - - def show - @image = driver.image( credentials, :id => params[:id] ) - - respond_to do |format| - format.html - format.json - format.xml { - render :xml=>convert_to_xml( :image, @image ) - } - end - end - -end diff --git a/server/app/controllers/instance_states_controller.rb b/server/app/controllers/instance_states_controller.rb deleted file mode 100644 index b860b50..0000000 --- a/server/app/controllers/instance_states_controller.rb +++ /dev/null @@ -1,49 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -require 'open3' - -class InstanceStatesController < ApplicationController - - include DriverHelper - include ConversionHelper - - around_filter :catch_auth - - def show - #@states = driver.instance_states() - @machine = driver.instance_state_machine() - respond_to do |format| - format.html - format.json - format.xml - format.gv - format.png { - gv = render_to_string( :file=>'instance_states/show.gv.erb' ) - png = '' - cmd = 'dot -Kdot -Gpad="0.2,0.2" -Gsize="5.0,8.0" -Gdpi="180" -Tpng' - Open3.popen3( cmd ) do |stdin, stdout, stderr| - stdin.write( gv ) - stdin.close() - png = stdout.read - end - render :text=>png, :content_type=>'image/png' - } - end - end - -end diff --git a/server/app/controllers/instances_controller.rb b/server/app/controllers/instances_controller.rb deleted file mode 100644 index abcc1ed..0000000 --- a/server/app/controllers/instances_controller.rb +++ /dev/null @@ -1,109 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -class InstancesController < ApplicationController - - include DriverHelper - include ConversionHelper - - around_filter :catch_auth - - def states - @states = driver.instance_states() - respond_to do |format| - format.html - format.json - format.xml - end - end - - def index - build_filter( :id ) - @instances = driver.instances( credentials, @filter ) - @id = params[:id] - - respond_to do |format| - format.html - format.json - format.xml { - render :xml=>convert_to_xml( :instance, @instances ) - } - end - end - - def show - @instance = driver.instance( credentials, :id=>params[:id] ) - - respond_to do |format| - format.html { - render :text=>'resource not found', :status=>404 and return unless @instance - } - format.json - format.xml { - render :nothing=>true, :status=>404 and return unless @instance - render :xml=>convert_to_xml( :instance, @instance ) - } - end - end - - def new - @instance = Instance.new( { - :id=>params[:id], - :image_id=>params[:image_id], - } ) - @image = driver.image( credentials, :id => params[:image_id] ) - @flavors = driver.flavors( credentials, { :architecture=>@image.architecture } ) - @realms = driver.realms(credentials) - end - - def create - @image = driver.image( credentials, :id=>params[:image_id] ) - respond_to do |format| - format.html { - instance = driver.create_instance( credentials, @image.id, params ) - redirect_to instance_url( instance.id ) - } - format.xml { - instance = driver.create_instance( credentials, @image.id, params ) - render :xml=>convert_to_xml( :instance, instance), :status=>:created, :location=>instance_url( instance.id ) - } - end - end - - ## - - def start - driver.start_instance(credentials, params[:id]) - redirect_to :action=>:show - end - - def stop - driver.stop_instance(credentials, params[:id]) - redirect_to :action=>:show - end - - def destroy - driver.destroy_instance( credentials, params[:id] ) - redirect_to :action=>:show - end - - def reboot - driver.reboot_instance( credentials, params[:id] ) - redirect_to :action=>:show - end - -end diff --git a/server/app/controllers/realms_controller.rb b/server/app/controllers/realms_controller.rb deleted file mode 100644 index 492b850..0000000 --- a/server/app/controllers/realms_controller.rb +++ /dev/null @@ -1,48 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -class RealmsController < ApplicationController - - include DriverHelper - include ConversionHelper - - around_filter :catch_auth - - def index - build_filter( :id ) - build_filter( :architecture ) - @realms = driver.realms( credentials, @filter ) - respond_to do |format| - format.html - format.xml { - render :xml=>convert_to_xml( :realm, @realms ) - } - end - end - - def show - @realm = driver.realm( credentials, :id => params[:id] ) - respond_to do |format| - format.html - format.json - format.xml { - render :xml=>convert_to_xml( :realm, @realm ) - } - end - end - -end diff --git a/server/app/controllers/root_controller.rb b/server/app/controllers/root_controller.rb deleted file mode 100644 index a616740..0000000 --- a/server/app/controllers/root_controller.rb +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -class RootController < ApplicationController - - def index - end - -end diff --git a/server/app/controllers/storage_snapshots_controller.rb b/server/app/controllers/storage_snapshots_controller.rb deleted file mode 100644 index 7b5a074..0000000 --- a/server/app/controllers/storage_snapshots_controller.rb +++ /dev/null @@ -1,47 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -class StorageSnapshotsController < ApplicationController - - include DriverHelper - include ConversionHelper - - around_filter :catch_auth - - def index - @snapshots = driver.storage_snapshots( credentials, :id=>params[:id] ) - respond_to do |format| - format.html - format.json - format.xml { - render :xml=>convert_to_xml( :storage_snapshot, @snapshots ) - } - end - end - - def show - @snapshot = driver.storage_snapshot( credentials, :id=>params[:id] ) - respond_to do |format| - format.html - format.json - format.xml { - render :xml=>convert_to_xml( :storage_snapshot, @snapshot ) - } - end - end - -end diff --git a/server/app/controllers/storage_volumes_controller.rb b/server/app/controllers/storage_volumes_controller.rb deleted file mode 100644 index 128796e..0000000 --- a/server/app/controllers/storage_volumes_controller.rb +++ /dev/null @@ -1,47 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -class StorageVolumesController < ApplicationController - - include DriverHelper - include ConversionHelper - - around_filter :catch_auth - - def index - @volumes = driver.storage_volumes( credentials, :id=>params[:id] ) - respond_to do |format| - format.html - format.json - format.xml { - render :xml=>convert_to_xml( :storage_volume, @volumes ) - } - end - end - - def show - @volume = driver.storage_volume( credentials, :id => params[:id] ) - respond_to do |format| - format.html - format.json - format.xml { - render :xml=>convert_to_xml( :storage_volume, @volume ) - } - end - end - -end diff --git a/server/config/boot.rb b/server/config/boot.rb deleted file mode 100644 index 0ad0f78..0000000 --- a/server/config/boot.rb +++ /dev/null @@ -1,110 +0,0 @@ -# Don't change this file! -# Configure your app in config/environment.rb and config/environments/*.rb - -RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) - -module Rails - class << self - def boot! - unless booted? - preinitialize - pick_boot.run - end - end - - def booted? - defined? Rails::Initializer - end - - def pick_boot - (vendor_rails? ? VendorBoot : GemBoot).new - end - - def vendor_rails? - File.exist?("#{RAILS_ROOT}/vendor/rails") - end - - def preinitialize - load(preinitializer_path) if File.exist?(preinitializer_path) - end - - def preinitializer_path - "#{RAILS_ROOT}/config/preinitializer.rb" - end - end - - class Boot - def run - load_initializer - Rails::Initializer.run(:set_load_path) - end - end - - class VendorBoot < Boot - def load_initializer - require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" - Rails::Initializer.run(:install_gem_spec_stubs) - Rails::GemDependency.add_frozen_gem_path - end - end - - class GemBoot < Boot - def load_initializer - self.class.load_rubygems - load_rails_gem - require 'initializer' - end - - def load_rails_gem - if version = self.class.gem_version - gem 'rails', version - else - gem 'rails' - end - rescue Gem::LoadError => load_error - $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.) - exit 1 - end - - class << self - def rubygems_version - Gem::RubyGemsVersion rescue nil - end - - def gem_version - if defined? RAILS_GEM_VERSION - RAILS_GEM_VERSION - elsif ENV.include?('RAILS_GEM_VERSION') - ENV['RAILS_GEM_VERSION'] - else - parse_gem_version(read_environment_rb) - end - end - - def load_rubygems - require 'rubygems' - min_version = '1.3.1' - unless rubygems_version >= min_version - $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) - exit 1 - end - - rescue LoadError - $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) - exit 1 - end - - def parse_gem_version(text) - $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ - end - - private - def read_environment_rb - File.read("#{RAILS_ROOT}/config/environment.rb") - end - end - end -end - -# All that for this: -Rails.boot! diff --git a/server/config/compass.config b/server/config/compass.config index ace247a..3c3f5d9 100644 --- a/server/config/compass.config +++ b/server/config/compass.config @@ -1,6 +1,6 @@ # Require any additional compass plugins here. project_type = :rails -project_path = RAILS_ROOT if defined?(RAILS_ROOT) +project_path = '.' # Set this to the root of your project when deployed: http_path = "/" css_dir = "public/stylesheets/compiled" diff --git a/server/config/database.yml b/server/config/database.yml deleted file mode 100644 index 025d62a..0000000 --- a/server/config/database.yml +++ /dev/null @@ -1,22 +0,0 @@ -# SQLite version 3.x -# gem install sqlite3-ruby (not necessary on OS X Leopard) -development: - adapter: sqlite3 - database: db/development.sqlite3 - pool: 5 - timeout: 5000 - -# Warning: The database defined as "test" will be erased and -# re-generated from your development database when you run "rake". -# Do not set this db to the same as development or production. -test: - adapter: sqlite3 - database: db/test.sqlite3 - pool: 5 - timeout: 5000 - -production: - adapter: sqlite3 - database: db/production.sqlite3 - pool: 5 - timeout: 5000 diff --git a/server/config/environment.rb b/server/config/environment.rb deleted file mode 100644 index 5d967f3..0000000 --- a/server/config/environment.rb +++ /dev/null @@ -1,111 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -# Be sure to restart your server when you modify this file - -# Specifies gem version of Rails to use when vendor/rails is not present -RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION - -# Bootstrap the Rails environment, frameworks, and default configuration -require File.join(File.dirname(__FILE__), 'boot') - -Rails::Initializer.run do |config| - # Settings in config/environments/* take precedence over those specified here. - # Application configuration should go into files in config/initializers - # -- all .rb files in that directory are automatically loaded. - - # Add additional load paths for your own custom dirs - # config.load_paths += %W( #{RAILS_ROOT}/extras ) - - # Specify gems that this application depends on and have them installed with rake gems:install - # config.gem "bj" - # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" - # config.gem "sqlite3-ruby", :lib => "sqlite3" - # config.gem "aws-s3", :lib => "aws/s3" - - - #config.gem "activerecord-jdbc-adapter", - #:lib=>'jdbc_adapter' - - #config.gem "torquebox-gem" - - #config.gem "torquebox-rails" - #config.gem "right_aws" - - # Only load the plugins named here, in the order given (default is alphabetical). - # :all can be used as a placeholder for all plugins not explicitly named - # config.plugins = [ :exception_notification, :ssl_requirement, :all ] - - # Skip frameworks you're not going to use. To use Rails without a database, - # you must remove the Active Record framework. - # config.frameworks -= [ :active_record, :active_resource, :action_mailer ] - config.frameworks -= [ :active_record ] - - # Activate observers that should always be running - # config.active_record.observers = :cacher, :garbage_collector, :forum_observer - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. - config.time_zone = 'UTC' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] - # config.i18n.default_locale = :de -end - -#DEFAULT_DRIVER=:ec2 -DEFAULT_DRIVER=:mock -#DEFAULT_DRIVER=:rhevm - - -unless defined?( DRIVER ) - driver_env = ENV['DRIVER'] - ( driver_env = driver_env.to_sym ) if ( driver_env ) - DRIVER=driver_env if driver_env -end - -unless defined?( DRIVER ) - if ( defined?( DEFAULT_DRIVER ) ) - DRIVER=DEFAULT_DRIVER - else - raise Exception.new( "DRIVER must be defined through environment variable or DEFAULT_DRIVER through config/environment.rb" ) - end -end - - -DRIVER_ROOT = File.dirname( __FILE__ ) + "/../../driver-#{DRIVER}" -$: << DRIVER_ROOT+'/lib' - -case DRIVER - when :mock - DRIVER_CLASS_NAME = "Deltacloud::Drivers::Mock::MockDriver" - mock_storage_root = File.dirname( __FILE__ ) + "/../../client/specs/data" - puts "Using mock storage root of #{mock_storage_root}" - MOCK_STORAGE_ROOT = mock_storage_root - when :ec2 - DRIVER_CLASS_NAME = "Deltacloud::Drivers::EC2::EC2Driver" - when :rackspace - DRIVER_CLASS_NAME = "Deltacloud::Drivers::Rackspace::RackspaceDriver" - when :rhevm - DRIVER_CLASS_NAME = "Deltacloud::Drivers::RHEVM::RHEVMDriver" - when :rimu - DRIVER_CLASS_NAME = "Deltacloud::Drivers::Rimu::RimuHostingDriver" - when :opennebula - DRIVER_CLASS_NAME = "Deltacloud::Drivers::Opennebula::OpennebulaDriver" - else - raise Exception.new( "Unknown driver #{DRIVER}" ) -end diff --git a/server/config/environments/development.rb b/server/config/environments/development.rb deleted file mode 100644 index 85c9a60..0000000 --- a/server/config/environments/development.rb +++ /dev/null @@ -1,17 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# In the development environment your application's code is reloaded on -# every request. This slows down response time but is perfect for development -# since you don't have to restart the webserver when you make code changes. -config.cache_classes = false - -# Log error messages when you accidentally call methods on nil. -config.whiny_nils = true - -# Show full error reports and disable caching -config.action_controller.consider_all_requests_local = true -config.action_view.debug_rjs = true -config.action_controller.perform_caching = false - -# Don't care if the mailer can't send -config.action_mailer.raise_delivery_errors = false \ No newline at end of file diff --git a/server/config/environments/production.rb b/server/config/environments/production.rb deleted file mode 100644 index 27119d2..0000000 --- a/server/config/environments/production.rb +++ /dev/null @@ -1,28 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# The production environment is meant for finished, "live" apps. -# Code is not reloaded between requests -config.cache_classes = true - -# Full error reports are disabled and caching is turned on -config.action_controller.consider_all_requests_local = false -config.action_controller.perform_caching = true -config.action_view.cache_template_loading = true - -# See everything in the log (default is :info) -# config.log_level = :debug - -# Use a different logger for distributed setups -# config.logger = SyslogLogger.new - -# Use a different cache store in production -# config.cache_store = :mem_cache_store - -# Enable serving of images, stylesheets, and javascripts from an asset server -# config.action_controller.asset_host = "http://assets.example.com" - -# Disable delivery errors, bad email addresses will be ignored -# config.action_mailer.raise_delivery_errors = false - -# Enable threaded mode -# config.threadsafe! \ No newline at end of file diff --git a/server/config/environments/test.rb b/server/config/environments/test.rb deleted file mode 100644 index d6f80a4..0000000 --- a/server/config/environments/test.rb +++ /dev/null @@ -1,28 +0,0 @@ -# Settings specified here will take precedence over those in config/environment.rb - -# The test environment is used exclusively to run your application's -# test suite. You never need to work with it otherwise. Remember that -# your test database is "scratch space" for the test suite and is wiped -# and recreated between test runs. Don't rely on the data there! -config.cache_classes = true - -# Log error messages when you accidentally call methods on nil. -config.whiny_nils = true - -# Show full error reports and disable caching -config.action_controller.consider_all_requests_local = true -config.action_controller.perform_caching = false -config.action_view.cache_template_loading = true - -# Disable request forgery protection in test environment -config.action_controller.allow_forgery_protection = false - -# Tell Action Mailer not to deliver emails to the real world. -# The :test delivery method accumulates sent emails in the -# ActionMailer::Base.deliveries array. -config.action_mailer.delivery_method = :test - -# Use SQL instead of Active Record's schema dumper when creating the test database. -# This is necessary if your schema can't be completely dumped by the schema dumper, -# like if you have constraints or database-specific column types -# config.active_record.schema_format = :sql \ No newline at end of file diff --git a/server/config/initializers/backtrace_silencers.rb b/server/config/initializers/backtrace_silencers.rb deleted file mode 100644 index c2169ed..0000000 --- a/server/config/initializers/backtrace_silencers.rb +++ /dev/null @@ -1,7 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. -# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } - -# You can also remove all the silencers if you're trying do debug a problem that might steem from framework code. -# Rails.backtrace_cleaner.remove_silencers! \ No newline at end of file diff --git a/server/config/initializers/compass.rb b/server/config/initializers/compass.rb deleted file mode 100644 index 9862fac..0000000 --- a/server/config/initializers/compass.rb +++ /dev/null @@ -1,5 +0,0 @@ -require 'compass' -# If you have any compass plugins, require them here. -Compass.configuration.parse(File.join(RAILS_ROOT, "config", "compass.config")) -Compass.configuration.environment = RAILS_ENV.to_sym -Compass.configure_sass_plugin! diff --git a/server/config/initializers/inflections.rb b/server/config/initializers/inflections.rb deleted file mode 100644 index 9e8b013..0000000 --- a/server/config/initializers/inflections.rb +++ /dev/null @@ -1,10 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new inflection rules using the following format -# (all these examples are active by default): -# ActiveSupport::Inflector.inflections do |inflect| -# inflect.plural /^(ox)$/i, '\1en' -# inflect.singular /^(ox)en/i, '\1' -# inflect.irregular 'person', 'people' -# inflect.uncountable %w( fish sheep ) -# end diff --git a/server/config/initializers/mime_types.rb b/server/config/initializers/mime_types.rb deleted file mode 100644 index 30829f7..0000000 --- a/server/config/initializers/mime_types.rb +++ /dev/null @@ -1,10 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Add new mime types for use in respond_to blocks: -# Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone - -#Mime::Type.register 'text/vnd.graphviz', :gv -Mime::Type.register_alias 'text/plain', :gv - -Mime::Type.register 'image/png', :png diff --git a/server/config/initializers/new_rails_defaults.rb b/server/config/initializers/new_rails_defaults.rb deleted file mode 100644 index 8ec3186..0000000 --- a/server/config/initializers/new_rails_defaults.rb +++ /dev/null @@ -1,19 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# These settings change the behavior of Rails 2 apps and will be defaults -# for Rails 3. You can remove this initializer when Rails 3 is released. - -if defined?(ActiveRecord) - # Include Active Record class name as root for JSON serialized output. - ActiveRecord::Base.include_root_in_json = true - - # Store the full class name (including module namespace) in STI type column. - ActiveRecord::Base.store_full_sti_class = true -end - -# Use ISO 8601 format for JSON serialized times and dates. -ActiveSupport.use_standard_json_time_format = true - -# Don't escape HTML entities in JSON, leave that for the #json_escape helper. -# if you're including raw json in an HTML page. -ActiveSupport.escape_html_entities_in_json = false \ No newline at end of file diff --git a/server/config/initializers/session_store.rb b/server/config/initializers/session_store.rb deleted file mode 100644 index 9450644..0000000 --- a/server/config/initializers/session_store.rb +++ /dev/null @@ -1,15 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key for verifying cookie session data integrity. -# If you change this key, all old sessions will become invalid! -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -ActionController::Base.session = { - :key => '_deltacloud-framework_session', - :secret => '2f8c7e1de10186f37efa57c9dd816eb2abb7f780fba8844ef73b3e6745101da849e30e54dcf6e4078fc43fce76ead4d7e0d1d06d40646d876f338186810cae18' -} - -# Use the database for sessions instead of the cookie-based default, -# which shouldn't be used to store highly confidential information -# (create the session table with "rake db:sessions:create") -# ActionController::Base.session_store = :active_record_store diff --git a/server/config/locales/en.yml b/server/config/locales/en.yml deleted file mode 100644 index ae09dd9..0000000 --- a/server/config/locales/en.yml +++ /dev/null @@ -1,2 +0,0 @@ -en: - hello: "Hello world" \ No newline at end of file diff --git a/server/config/routes.rb b/server/config/routes.rb deleted file mode 100644 index ea747a0..0000000 --- a/server/config/routes.rb +++ /dev/null @@ -1,49 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -ActionController::Routing::Routes.draw do |map| - - map.root :controller=>'root' - - map.resource :api, :controller=>'Api' - - map.resources :flavors, :path_prefix=>'api' - map.resources :hardware_profiles, :path_prefix=>'api', - :as=>'hardware-profiles', - :only=>[ :index, :show ] - - map.resources :realms, :path_prefix=>'api' - map.resources :images, :path_prefix=>'api' - - map.resource :instance_states, :path_prefix=>'api', - :as=>'instance-states', - :only=>[ :show ] - - map.resources :instances, :path_prefix=>'api', - :member=>{ - :destroy=>:post, - :stop=>:post, - :start=>:post, - :reboot=>:post, - } - - map.resource :storage, :path_prefix=>'api' do |s| - s.resources :volumes, :controller=>'StorageVolumes' - s.resources :snapshots, :controller=>'StorageSnapshots' - end - -end diff --git a/server/deltacloud.rb b/server/deltacloud.rb deleted file mode 100644 index c879316..0000000 --- a/server/deltacloud.rb +++ /dev/null @@ -1,14 +0,0 @@ -# Add ./lib into load path -$:.unshift File.join(File.dirname(__FILE__), 'lib') - -require 'deltacloud/base_driver' -require 'deltacloud/hardware_profile' -require 'deltacloud/state_machine' - -require 'deltacloud/models/base_model' -require 'deltacloud/models/flavor' -require 'deltacloud/models/realm' -require 'deltacloud/models/image' -require 'deltacloud/models/instance' -require 'deltacloud/models/storage_snapshot' -require 'deltacloud/models/storage_volume' diff --git a/server/drivers.rb b/server/drivers.rb deleted file mode 100644 index d87c685..0000000 --- a/server/drivers.rb +++ /dev/null @@ -1,39 +0,0 @@ - -DRIVERS = { - :ec2 => { :name => "EC2" }, - :rackspace => { :name => "Rackspace" }, - :gogrid => { :name => "Gogrid" }, - :rhevm => { :name => "RHEVM" }, - :rimu => { :name => "Rimu", :class => "RimuHostingDriver"}, - :opennebula => { :name => "Opennebula", :class => "OpennebulaDriver" }, - :mock => { :name => "Mock" } -} - -def driver_name - DRIVERS[DRIVER][:name] -end - -def driver_class_name - basename = DRIVERS[DRIVER][:class] || "#{driver_name}Driver" - "Deltacloud::Drivers::#{driver_name}::#{basename}" -end - -def driver_source_name - "deltacloud/drivers/#{DRIVER}/#{DRIVER}_driver.rb" -end - -def driver_mock_source_name - return "deltacloud/drivers/#{DRIVER}/#{DRIVER}_driver.rb" if driver_name.eql? 'Mock' - "deltacloud/drivers/#{DRIVER}/#{DRIVER}_mock_driver.rb" -end - -def driver - require driver_source_name - - if Sinatra::Application.environment.eql? :test - require driver_mock_source_name - end - - @driver ||= eval( driver_class_name ).new -end - diff --git a/server/lib/deltacloud/deltacloud.rb b/server/lib/deltacloud/deltacloud.rb new file mode 100644 index 0000000..32f76ee --- /dev/null +++ b/server/lib/deltacloud/deltacloud.rb @@ -0,0 +1,10 @@ +require 'deltacloud/base_driver' +require 'deltacloud/hardware_profile' +require 'deltacloud/state_machine' +require 'deltacloud/models/base_model' +require 'deltacloud/models/flavor' +require 'deltacloud/models/realm' +require 'deltacloud/models/image' +require 'deltacloud/models/instance' +require 'deltacloud/models/storage_snapshot' +require 'deltacloud/models/storage_volume' diff --git a/server/lib/deltacloud/drivers.rb b/server/lib/deltacloud/drivers.rb new file mode 100644 index 0000000..72873c6 --- /dev/null +++ b/server/lib/deltacloud/drivers.rb @@ -0,0 +1,38 @@ + +DRIVERS = { + :ec2 => { :name => "EC2" }, + :rackspace => { :name => "Rackspace" }, + :gogrid => { :name => "Gogrid" }, + :rhevm => { :name => "RHEVM" }, + :rimu => { :name => "Rimu", :class => "RimuHostingDriver"}, + :opennebula => { :name => "Opennebula", :class => "OpennebulaDriver" }, + :mock => { :name => "Mock" } +} + +def driver_name + DRIVERS[DRIVER][:name] +end + +def driver_class_name + basename = DRIVERS[DRIVER][:class] || "#{driver_name}Driver" + "Deltacloud::Drivers::#{driver_name}::#{basename}" +end + +def driver_source_name + "deltacloud/drivers/#{DRIVER}/#{DRIVER}_driver.rb" +end + +def driver_mock_source_name + return "deltacloud/drivers/#{DRIVER}/#{DRIVER}_driver.rb" if driver_name.eql? 'Mock' + "deltacloud/drivers/#{DRIVER}/#{DRIVER}_mock_driver.rb" +end + +def driver + require driver_source_name + + if Sinatra::Application.environment.eql? :test + require driver_mock_source_name + end + + @driver ||= eval( driver_class_name ).new +end diff --git a/server/lib/deltacloud/helpers.rb b/server/lib/deltacloud/helpers.rb index c12c11d..184c107 100644 --- a/server/lib/deltacloud/helpers.rb +++ b/server/lib/deltacloud/helpers.rb @@ -1,6 +1,5 @@ require 'deltacloud/helpers/application_helper' -require 'deltacloud/helpers/url_helper' require 'deltacloud/helpers/driver_helper' require 'deltacloud/helpers/hardware_profiles_helper'
-helpers ApplicationHelper, URLHelper, DriverHelper, HardwareProfilesHelper +helpers ApplicationHelper, DriverHelper, HardwareProfilesHelper diff --git a/server/lib/deltacloud/helpers/root_helper.rb b/server/lib/deltacloud/helpers/root_helper.rb deleted file mode 100644 index 7a45cfa..0000000 --- a/server/lib/deltacloud/helpers/root_helper.rb +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright (C) 2009 Red Hat, Inc. -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License, or (at your option) any later version. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -module RootHelper -end diff --git a/server/lib/deltacloud/helpers/url_helper.rb b/server/lib/deltacloud/helpers/url_helper.rb deleted file mode 100644 index cd7f1d5..0000000 --- a/server/lib/deltacloud/helpers/url_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -module URLHelper - def root_url - url_for "/" - end -end diff --git a/server/server.rb b/server/server.rb index 67590d0..8126375 100644 --- a/server/server.rb +++ b/server/server.rb @@ -1,15 +1,15 @@ -require 'rubygems' -require 'deltacloud' +$:.unshift File.join(File.dirname(__FILE__), 'lib') +require 'deltacloud/deltacloud' require 'sinatra' require 'sinatra/respond_to' require 'erb' require 'haml' require 'open3' require 'builder' -require 'drivers' require 'sinatra/static_assets' require 'sinatra/rabbit' require 'sinatra/lazy_auth' +require 'deltacloud/drivers' require 'deltacloud/validation' require 'deltacloud/helpers'
diff --git a/server/views/layout.html.haml b/server/views/layout.html.haml index a932caa..a785a19 100644 --- a/server/views/layout.html.haml +++ b/server/views/layout.html.haml @@ -11,7 +11,7 @@ %body #wrapper #header - = link_to image_tag( "/images/logo-wide.png" ), root_url + = link_to image_tag( "/images/logo-wide.png" ), '/' = bread_crumb #content = yield
--- .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb index e40558d..dc2ff31 100644 --- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb @@ -25,7 +25,7 @@ module Deltacloud class RHEVMDriver < Deltacloud::BaseDriver
SCRIPT_DIR = File.dirname(__FILE__) + '/../scripts' - CONFIG = YAML.load_file(RAILS_ROOT + '/config/rhevm_config.yml') + CONFIG = YAML.load_file('config/rhevm_config.yml') SCRIPT_DIR_ARG = '"' + SCRIPT_DIR + '"' DELIM_BEGIN="<_OUTPUT>" DELIM_END="</_OUTPUT>"
deltacloud-devel@lists.fedorahosted.org