summaryrefslogtreecommitdiffstats
path: root/cloudmasterd/lib
diff options
context:
space:
mode:
authorMatt Hicks <mhicks@localhost.localdomain>2008-07-15 18:46:32 -0400
committerMatt Hicks <mhicks@localhost.localdomain>2008-07-15 18:53:01 -0400
commit13e8c8d7635723cea7f85fa73734008a401b290a (patch)
tree8ae8326eb8ed1072ff6bab7648075ff417b99d1a /cloudmasterd/lib
parent261c795941003f9b4ba333b0c7927d497698f73f (diff)
downloadtools-13e8c8d7635723cea7f85fa73734008a401b290a.tar.gz
tools-13e8c8d7635723cea7f85fa73734008a401b290a.tar.xz
tools-13e8c8d7635723cea7f85fa73734008a401b290a.zip
Update for the new func format
Diffstat (limited to 'cloudmasterd/lib')
-rw-r--r--cloudmasterd/lib/cloudmasterd/syncer.rb32
1 files changed, 6 insertions, 26 deletions
diff --git a/cloudmasterd/lib/cloudmasterd/syncer.rb b/cloudmasterd/lib/cloudmasterd/syncer.rb
index b3e2e89..bb191a6 100644
--- a/cloudmasterd/lib/cloudmasterd/syncer.rb
+++ b/cloudmasterd/lib/cloudmasterd/syncer.rb
@@ -21,6 +21,7 @@ require 'open3'
require 'sqlite3'
require 'active_record'
require 'date'
+require 'yaml'
# This is needed to let a 'kill PID' command cleanly
# kill the process without requiring -9
@@ -66,27 +67,11 @@ class Syncer
end
end
- def parse_hosts(func_stderr)
- hosts = []
- func_stderr.split("\n").each do |host_line|
- # Handle a remote exception coming from a disconnected host
- if host_line.index("remote exception") then
- hosts.pop()
- else
- hosts << host_line.split(":")[1][2..-1]
- end
- end
- return hosts
- end
-
def sync_memory
current_state = {}
Open3.popen3("func '*' call virt freemem") do |stdin, stdout, stderr|
- hosts = parse_hosts(stderr.read)
-
- # Parse out the machines that belong to each host and zip them together in a hash
- stdout.read.split("\n").each_with_index do |memory, index|
- current_state[hosts[index]] = memory
+ YAML.load(stdout.read).each do |host, value|
+ current_state[host] = value
end
end
@@ -104,14 +89,9 @@ class Syncer
def sync_state
current_state = {}
Open3.popen3("func '*' call virt state") do |stdin, stdout, stderr|
- hosts = parse_hosts(stderr.read)
-
- # Parse out the machines that belong to each host and zip them together in a hash
- stdout.read.split("\n").each_with_index do |host, index|
- host[1..-2].split(", ").each do |machine|
- name, state = machine[1..-2].split(" ")
- current_state[name] = {:state => state, :cloud => hosts[index]} unless name == "Domain-0"
- end
+ YAML.load(stdout.read).each do |host, value|
+ name, state = value[0].split(" ")
+ current_state[name] = {:state => state, :cloud => host} unless name == "Domain-0"
end
end