summaryrefslogtreecommitdiffstats
path: root/cloudmasterd
diff options
context:
space:
mode:
authorMatthew Hicks <mhicks@mhicks-host.usersys.redhat.com>2008-06-21 13:22:26 -0400
committerMatthew Hicks <mhicks@mhicks-host.usersys.redhat.com>2008-06-21 13:22:26 -0400
commita5937c0f25c462f14e915cce14b9ced7e4077497 (patch)
tree7a81b8061436a62a19f12e3a3ec034729cf80903 /cloudmasterd
parent783bea84b205c72d3714695aea6f77f1302ea0ea (diff)
downloadtools-a5937c0f25c462f14e915cce14b9ced7e4077497.tar.gz
tools-a5937c0f25c462f14e915cce14b9ced7e4077497.tar.xz
tools-a5937c0f25c462f14e915cce14b9ced7e4077497.zip
More work on the model
Diffstat (limited to 'cloudmasterd')
-rw-r--r--cloudmasterd/lib/cloudmasterd.rb29
1 files changed, 16 insertions, 13 deletions
diff --git a/cloudmasterd/lib/cloudmasterd.rb b/cloudmasterd/lib/cloudmasterd.rb
index ac091ad..90e8d8a 100644
--- a/cloudmasterd/lib/cloudmasterd.rb
+++ b/cloudmasterd/lib/cloudmasterd.rb
@@ -104,8 +104,7 @@ module Cloudmasterd::Controllers
return cobblerd.profile(cobbler_system["profile"])
end
- # Find the best host on which to create a VM that requires
- # the given "disk_size" and "ram"
+ # Find the best host on which to create a VM
def _get_best_host(disk_size, ram)
return `func-find-resources -m #{ram}`.chomp()
end
@@ -115,13 +114,11 @@ module Cloudmasterd::Controllers
def _koan(host, fqdn, repo)
# Run the koan process
func_cmd = "func \"#{host}\" call virt install #{repo} #{fqdn} True #{fqdn} /images"
- `#{func_cmd}`
- raise "Func installation failed for host #{host} against repo #{fqdn}" unless $?.success?
+ puts `#{func_cmd}`
# Make the new host autostart
- func_cmd = "func \"#{host}\" call command run \"ln -s /etc/xen/#{fqdn} /etc/xen/auto/\""
- `#{func_cmd}`
- raise "Symbolic link creation failed for host #{host} against repo #{fqdn}" unless $?.success?
+ func_cmd = "func \"#{host}\" call command run \"ln -s /etc/xen/#{fqdn.split('.')[0]} /etc/xen/auto/\""
+ puts `#{func_cmd}`
end
# POST /koan
@@ -141,7 +138,10 @@ module Cloudmasterd::Controllers
class Cloud < REST 'cloud'
def list
- @machines = Machine.find :all
+ @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}'")
+ end
render :cloud
end
end
@@ -170,13 +170,16 @@ module Cloudmasterd::Views
end
def cloud
- @machines.each do |m|
+ @machines.keys.each do |email|
div do
- h1 m.user_email
- p m.machine
- p m.destination
+ h1 email
+ ul do
+ @machines[email].each do |machine|
+ li "#{machine.destination}: #{machine.machine}"
+ end
+ end
end
- end
+ end
end
def _koan