summaryrefslogtreecommitdiffstats
path: root/cloudmasterd
diff options
context:
space:
mode:
authorMatthew Hicks <mhicks@mhicks-host.usersys.redhat.com>2008-06-21 13:34:15 -0400
committerMatthew Hicks <mhicks@mhicks-host.usersys.redhat.com>2008-06-21 13:34:15 -0400
commit1bdfd2c9c90f08d8bfdd9aaebe8b558a09e08917 (patch)
tree056489c9c25ad7621f9664357e50fe59f2b763e0 /cloudmasterd
parenta5937c0f25c462f14e915cce14b9ced7e4077497 (diff)
downloadtools-1bdfd2c9c90f08d8bfdd9aaebe8b558a09e08917.tar.gz
tools-1bdfd2c9c90f08d8bfdd9aaebe8b558a09e08917.tar.xz
tools-1bdfd2c9c90f08d8bfdd9aaebe8b558a09e08917.zip
Adding a db primer (for testing)
More work around the model names and db structure
Diffstat (limited to 'cloudmasterd')
-rw-r--r--cloudmasterd/lib/cloudmasterd.rb14
-rwxr-xr-xcloudmasterd/primedb.rb24
2 files changed, 31 insertions, 7 deletions
diff --git a/cloudmasterd/lib/cloudmasterd.rb b/cloudmasterd/lib/cloudmasterd.rb
index 90e8d8a..fb761f0 100644
--- a/cloudmasterd/lib/cloudmasterd.rb
+++ b/cloudmasterd/lib/cloudmasterd.rb
@@ -84,9 +84,9 @@ module Cloudmasterd::Models
class CreateTheBasics < V 1.0
def self.up
create_table :cloudmasterd_machines do |t|
- t.column :user_email, :string, :null => false
- t.column :machine, :string, :limit => 255
- t.column :destination, :string, :limit => 255
+ t.column :name, :string, :limit => 255
+ t.column :email, :string, :null => false
+ t.column :cloud, :string, :limit => 255
end
end
def self.down
@@ -131,7 +131,7 @@ module Cloudmasterd::Controllers
@host = _get_best_host(cobbler_profile["virt_file_size"], cobbler_profile["virt_ram"])
_koan(@host, machine_fqdn, repo)
- Machine.create :user_email => email, :machine => machine_fqdn, :destination => @host
+ Machine.create :name => machine_fqdn, :email => email, :cloud => @host
render :_koan
end
end
@@ -139,8 +139,8 @@ module Cloudmasterd::Controllers
class Cloud < REST 'cloud'
def list
@machines = {}
- Machine.find(:all, :select => "distinct user_email").map{|x| x.user_email}.each do |email|
- @machines[email] = Machine.find(:all, :conditions => "user_email = '#{email}'")
+ Machine.find(:all, :select => "distinct email").map{|x| x.email}.each do |email|
+ @machines[email] = Machine.find(:all, :conditions => "email = '#{email}'")
end
render :cloud
end
@@ -175,7 +175,7 @@ module Cloudmasterd::Views
h1 email
ul do
@machines[email].each do |machine|
- li "#{machine.destination}: #{machine.machine}"
+ li "#{machine.name}: #{machine.cloud}"
end
end
end
diff --git a/cloudmasterd/primedb.rb b/cloudmasterd/primedb.rb
new file mode 100755
index 0000000..866b91d
--- /dev/null
+++ b/cloudmasterd/primedb.rb
@@ -0,0 +1,24 @@
+#!/usr/bin/ruby
+
+require 'rubygems'
+require 'sqlite3'
+require 'active_record'
+require 'pp'
+
+ActiveRecord::Base.logger = Logger.new(STDERR)
+ActiveRecord::Base.colorize_logging = false
+
+ActiveRecord::Base.establish_connection(
+ :adapter => "sqlite3",
+ :dbfile => "/var/lib/cloudmaster.db"
+)
+
+class Machine < ActiveRecord::Base
+ set_table_name "cloudmasterd_machines"
+end
+
+Machine.create(:name => "jboss-1.usersys.redhat.com", :email => "mhicks@redhat.com", :cloud => "cloud1.usersys.redhat.com")
+Machine.create(:name => "jboss-2.usersys.redhat.com", :email => "mhicks@redhat.com", :cloud => "cloud1.usersys.redhat.com")
+Machine.create(:name => "jboss-3.usersys.redhat.com", :email => "mhicks@redhat.com", :cloud => "cloud2.usersys.redhat.com")
+Machine.create(:name => "alien-jboss-1.usersys.redhat.com", :email => "calfonso@redhat.com", :cloud => "cloud3.usersys.redhat.com")
+Machine.create(:name => "alien-jboss-2.usersys.redhat.com", :email => "calfonso@redhat.com", :cloud => "cloud2.usersys.redhat.com")