Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
moved to Rails 3
Browse files Browse the repository at this point in the history
  • Loading branch information
goldmann committed Dec 1, 2010
1 parent fb016a6 commit 550e634
Show file tree
Hide file tree
Showing 61 changed files with 4,127 additions and 2,437 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ boxgrinder.log
.idea
log
jboss-appliance.log
.bundle
db/*.sqlite3
vendor
public/data/
Expand All @@ -10,4 +11,6 @@ rpms-cache
build
boxgrinder.log
config/boxgrinder.yml
log/*.log
tmp/**/*

9 changes: 0 additions & 9 deletions .gitmodules

This file was deleted.

12 changes: 12 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
source 'http://rubygems.org'

group :torquebox do
gem "org.torquebox.rake-support"
gem "org.torquebox.torquebox-messaging-client"
gem "org.torquebox.vfs"
end

gem 'rails', '3.0.3'
gem 'jdbc-sqlite3'
gem "activerecord-jdbcpostgresql-adapter"
gem "boxgrinder-core"
93 changes: 93 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.3)
actionpack (= 3.0.3)
mail (~> 2.2.9)
actionpack (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.6)
tzinfo (~> 0.3.23)
activemodel (3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activerecord-jdbc-adapter (1.0.3-java)
activerecord-jdbcpostgresql-adapter (1.0.3-java)
activerecord-jdbc-adapter (= 1.0.3)
jdbc-postgres (~> 8.4.0)
activeresource (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
arel (2.0.5)
boxgrinder-core (0.1.3)
hashery (>= 1.3.0)
open4 (>= 1.0.0)
builder (2.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
hashery (1.3.0)
i18n (0.5.0)
jdbc-postgres (8.4.702-java)
jdbc-sqlite3 (3.6.14.2.056-java)
mail (2.2.11)
activesupport (>= 2.3.6)
i18n (~> 0.5.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
open4 (1.0.1)
org.torquebox.rake-support (1.0.0.Beta23)
org.torquebox.torquebox-messaging-client (1.0.0.Beta23-java)
org.torquebox.torquebox-naming-client (= 1.0.0.Beta23)
org.torquebox.torquebox-naming-client (1.0.0.Beta23-java)
org.torquebox.vfs (1.0.0.Beta23)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.6)
rack (>= 1.0)
rails (3.0.3)
actionmailer (= 3.0.3)
actionpack (= 3.0.3)
activerecord (= 3.0.3)
activeresource (= 3.0.3)
activesupport (= 3.0.3)
bundler (~> 1.0)
railties (= 3.0.3)
railties (3.0.3)
actionpack (= 3.0.3)
activesupport (= 3.0.3)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.23)

PLATFORMS
java

DEPENDENCIES
activerecord-jdbcpostgresql-adapter
boxgrinder-core
jdbc-sqlite3
org.torquebox.rake-support
org.torquebox.torquebox-messaging-client
org.torquebox.vfs
rails (= 3.0.3)
1 change: 0 additions & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Homepage:

http://www.jboss.org/boxgrinder/rest.html
Expand Down
9 changes: 2 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

require(File.join(File.dirname(__FILE__), 'config', 'boot'))

require File.expand_path('../config/application', __FILE__)
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

require 'tasks/rails'

require 'torquebox/tasks'
BoxgrinderRest::Application.load_tasks
13 changes: 9 additions & 4 deletions app/helpers/appliances_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,13 @@
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
# 02110-1301 USA, or see the FSF site: http://www.fsf.org.

require 'boxgrinder-core/helpers/appliance-helper'
require 'boxgrinder-core/validators/appliance-config-validator'
load '/home/goldmann/torquebox-current/jruby/lib/ruby/gems/1.8/gems/boxgrinder-core-0.1.3/lib/boxgrinder-core/helpers/appliance-helper.rb'
load '/home/goldmann/torquebox-current/jruby/lib/ruby/gems/1.8/gems/boxgrinder-core-0.1.3/lib/boxgrinder-core/validators/appliance-config-validator.rb'

#require 'boxgrinder-core/helpers/appliance-helper'
#require 'boxgrinder-core/validators/appliance-config-validator'

require 'rest-config'

module AppliancesHelper
include BaseHelper
Expand All @@ -35,10 +40,10 @@ def validate_appliance_definition_file
end

begin
appliance_configs = BoxGrinder::ApplianceHelper.new( :log => logger ).read_definitions( definition_file.path, definition_file.content_type )
appliance_configs, appliance_config = BoxGrinder::ApplianceHelper.new( :log => logger ).read_definitions( definition_file.path, definition_file.content_type )
appliance_config_helper = BoxGrinder::ApplianceConfigHelper.new( appliance_configs )

@appliance_config = appliance_config_helper.merge(appliance_configs.values.first.clone)
@appliance_config = appliance_config_helper.merge(appliance_config.clone)
rescue => e
render_error( Error.new( "Could not read definition file", e) )
return
Expand Down
12 changes: 6 additions & 6 deletions app/models/appliance.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class Appliance < ActiveRecord::Base
ACTIONS = { :create => 'CREATE', :destroy => 'DESTROY' }
STATUSES = { :new => 'NEW', :created => 'CREATED', :error => 'ERROR', :removed => 'REMOVED', :removing => 'REMOVING'}
ACTIONS = {:create => 'CREATE', :destroy => 'DESTROY'}
STATUSES = {:new => 'NEW', :created => 'CREATED', :error => 'ERROR', :removed => 'REMOVED', :removing => 'REMOVING'}

has_many :images

Expand All @@ -13,14 +13,14 @@ def self.definitions
@@definitions
end

def self.add_definition( name, definition )
def self.add_definition(name, definition)
@@definitions[name] = definition
end

def after_initialize
after_initialize do
if self.status.nil?
self.status = STATUSES[:new]
self.status = STATUSES[:new]
self.created_at = self.updated_at = Time.now
end
end
end
end
10 changes: 5 additions & 5 deletions app/models/image.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
class Image < ActiveRecord::Base
ACTIONS = { :build => 'BUILD', :package => 'PACKAGE', :convert => 'CONVERT', :remove => 'REMOVE' }
STATUSES = { :new => 'NEW', :building => 'BUILDING', :converting => 'CONVERTING', :built => 'BUILT', :converted => 'CONVERTED', :removing => 'REMOVING', :error => 'ERROR', :delivering => 'DELIVERING', :delivered => 'DELIVERED' }
FORMATS = { :raw => 'RAW', :vmware => 'VMWARE', :ec2 => 'EC2' }
ACTIONS = {:build => 'BUILD', :package => 'PACKAGE', :convert => 'CONVERT', :remove => 'REMOVE'}
STATUSES = {:new => 'NEW', :building => 'BUILDING', :converting => 'CONVERTING', :built => 'BUILT', :converted => 'CONVERTED', :removing => 'REMOVING', :error => 'ERROR', :delivering => 'DELIVERING', :delivered => 'DELIVERED'}
FORMATS = {:raw => 'RAW', :vmware => 'VMWARE', :ec2 => 'EC2'}

validates_presence_of :status, :summary
belongs_to :appliance
belongs_to :node
has_many :images, :foreign_key => "parent_id", :dependent => :destroy
belongs_to :parent, :class_name => "Image"

def after_initialize
after_initialize do
if self.status.nil?
self.status = STATUSES[:new]
self.status = STATUSES[:new]
self.created_at = self.updated_at = Time.now
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/appliances/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@
</li>
<% end %>
<% end %>
<li><%= link_to "Destroy", {:action => :destroy, :id => @appliance.id}, :method => :delete, :confirm => "Are you sure?" %> </li>
<li><%= button_to "Destroy", {:action => :destroy, :id => @appliance.id}, :method => :delete, :confirm => "Are you sure?" %> </li>
</ul>
3 changes: 2 additions & 1 deletion app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<head>
<title><%= api_name %> API v<%= api_version %></title>
<%= stylesheet_link_tag 'main.css' %>
<%= javascript_include_tag :defaults %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
Expand All @@ -20,7 +21,7 @@

<hr/>

<%= bread_crumb -%>
<!-- <%= bread_crumb -%> -->
</div>

<%= yield %>
Expand Down
31 changes: 31 additions & 0 deletions bin/appliance_initialization.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh

SU_CMD=$(which su)

BOXGRINDER_REST_DEPLOYMENT="/opt/jboss-as/server/all/deploy/boxgrinder-rest-rails.yml"
if [ ! -e $BOXGRINDER_REST_DEPLOYMENT ]; then
echo "Creating BoxGrinder REST deployment file..."
echo -e '---\napplication:\n RAILS_ROOT: /opt/boxgrinder-rest\n RAILS_ENV: production\nweb:\n context: /\n' > $BOXGRINDER_REST_DEPLOYMENT
fi

BOXGRINDER_DB_USER=$(echo '\du' | $SU_CMD postgres -c psql | grep boxgrinder | cut -d' ' -f2)
if [ $BOXGRINDER_DB_USER. != 'boxgrinder.' ]; then
echo "Creating BoxGrinder database user..."
$SU_CMD postgres -c "/usr/bin/createuser -SDR boxgrinder"
echo "ALTER USER boxgrinder WITH PASSWORD 'boxgrinder';" | $SU_CMD postgres -c /usr/bin/psql
fi

BOXGRINDER_DB_NAME=$(echo '\l' | $SU_CMD postgres -c psql | grep boxgrinder_production | cut -d' ' -f2)
if [ $BOXGRINDER_DB_NAME. != 'boxgrinder_production.' ]; then
echo "Creating BoxGrinder database..."
$SU_CMD postgres -c "/usr/bin/createdb boxgrinder_production -O boxgrinder"
echo "GRANT ALL ON DATABASE boxgrinder_production TO boxgrinder" | $SU_CMD postgres -c /usr/bin/psql
fi

STEAMCANNON_SCHEMA=$(echo '\dt' | $SU_CMD postgres -c 'psql boxgrinder_production' | grep schema_migrations | cut -d' ' -f4)
if [ $STEAMCANNON_SCHEMA. != 'schema_migrations.' ]; then
echo "Initializing and seeding BoxGrinder database schema..."
cd /opt/boxgrinder
export RAILS_ENV=production
$SU_CMD jboss-as6 -c '/opt/jruby/bin/jruby -S rake db:setup'
fi
4 changes: 4 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
run BoxgrinderRest::Application
42 changes: 42 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require File.expand_path('../boot', __FILE__)

require 'rails/all'

# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)

module BoxgrinderRest
class Application < Rails::Application
# 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.

# Custom directories with classes and modules you want to be autoloadable.
# config.autoload_paths += %W(#{config.root}/extras)

# 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 ]

# 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. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'

# 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}').to_s]
# config.i18n.default_locale = :de

# JavaScript files you want as :defaults (application.js is always included).
# config.action_view.javascript_expansions[:defaults] = %w(jquery rails)

# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
end
end
Loading

0 comments on commit 550e634

Please sign in to comment.