diff options
author | Matt Hicks <mhicks@localhost.localdomain> | 2008-07-17 19:24:22 -0400 |
---|---|---|
committer | Matt Hicks <mhicks@localhost.localdomain> | 2008-07-17 19:24:22 -0400 |
commit | 1905e258c2d06f2b42f56a83c0d6e7263cd6b6bb (patch) | |
tree | c0e056668b1365e869ac3ba0d491d64e6b82dbc0 | |
parent | 1df1cfc147a659c18909523ff01775e2a677c279 (diff) | |
download | tools-1905e258c2d06f2b42f56a83c0d6e7263cd6b6bb.tar.gz tools-1905e258c2d06f2b42f56a83c0d6e7263cd6b6bb.tar.xz tools-1905e258c2d06f2b42f56a83c0d6e7263cd6b6bb.zip |
Adding output for the type of cloud machine (Xen, KVM)
-rw-r--r-- | cloudmasterd/extra/cloudmasterd.spec | 2 | ||||
-rw-r--r-- | cloudmasterd/lib/cloudmasterd.rb | 13 | ||||
-rw-r--r-- | cloudmasterd/lib/cloudmasterd/syncer.rb | 12 |
3 files changed, 21 insertions, 6 deletions
diff --git a/cloudmasterd/extra/cloudmasterd.spec b/cloudmasterd/extra/cloudmasterd.spec index 50575b8..b137129 100644 --- a/cloudmasterd/extra/cloudmasterd.spec +++ b/cloudmasterd/extra/cloudmasterd.spec @@ -6,7 +6,7 @@ Summary: Genome library and web application for managing cloud machines Name: rubygem-%{gemname} Version: 1.0.0 -Release: 9%{?dist} +Release: 10%{?dist} Group: Applications/System License: GPLv2 URL: https://fedorahosted.org/genome diff --git a/cloudmasterd/lib/cloudmasterd.rb b/cloudmasterd/lib/cloudmasterd.rb index fe94972..89a2e1e 100644 --- a/cloudmasterd/lib/cloudmasterd.rb +++ b/cloudmasterd/lib/cloudmasterd.rb @@ -100,6 +100,7 @@ module Cloudmasterd::Models def self.up create_table :cloudmasterd_cloud do |t| t.column :name, :string, :null => false, :limit => 255 + t.column :virttype, :string, :limit => 255 t.column :memory, :integer, :null => false t.column :added_date, :datetime, :null => true end @@ -216,6 +217,14 @@ module Cloudmasterd::Controllers @memory = Cloud.sum('memory') @cloud_machines = Cloud.find(:all) + @cloud_names = {} + @cloud_machines.each do |machine| + printed_name = machine.name + if machine.type + printed_name += (machine.type == "Xen") ? " (Xen)": " (KVM)" + end + @cloud_names[machine.name] = printed_name + end render :status end @@ -262,7 +271,7 @@ module Cloudmasterd::Views end @cloud_machines.each do |machine| tr do - td machine.name + td @cloud_names[machine.name] td machine.memory unless machine.added_date == nil then td machine.added_date.strftime("%m/%d/%Y") @@ -296,7 +305,7 @@ module Cloudmasterd::Views a name end end - td machine.cloud + td @cloud_names[machine.cloud] td machine.state unless machine.created_date == nil then td machine.created_date.strftime("%m/%d/%Y") diff --git a/cloudmasterd/lib/cloudmasterd/syncer.rb b/cloudmasterd/lib/cloudmasterd/syncer.rb index 4bda1a5..1ab72eb 100644 --- a/cloudmasterd/lib/cloudmasterd/syncer.rb +++ b/cloudmasterd/lib/cloudmasterd/syncer.rb @@ -71,7 +71,13 @@ class Syncer current_state = {} Open3.popen3("func '*' call virt freemem") do |stdin, stdout, stderr| YAML.load(stdout.read).each do |host, value| - current_state[host] = value + current_state[host] = { :memory => value } + end + end + + Open3.popen3("func '*' call virt virttype") do |stdin, stdout, stderr| + YAML.load(stdout.read).each do |host, type| + current_state[host][:virttype] = type end end @@ -80,8 +86,8 @@ class Syncer Cloud.delete_all # Create the current entries - current_state.each do |host, memory| - Cloud.create :name => host, :memory => memory, :added_date => DateTime.now() + current_state.each do |host, attrs| + Cloud.create :name => host, :memory => attrs[:memory], :virttype => attrs[:virttype], :added_date => DateTime.now() end end end |