summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrenton Leanhardt <bleanhar@redhat.com>2008-07-02 09:27:59 -0400
committerBrenton Leanhardt <bleanhar@redhat.com>2008-07-02 09:29:34 -0400
commit80d99bf16f937fa3da7a20dfa0fc436d416ba405 (patch)
tree5bfa49429e11d0dbb9c41284b0d928caed4a5037
parent1b8d211e10918e7f4f3f7aedaa816a7a880b888b (diff)
downloadtools-80d99bf16f937fa3da7a20dfa0fc436d416ba405.tar.gz
tools-80d99bf16f937fa3da7a20dfa0fc436d416ba405.tar.xz
tools-80d99bf16f937fa3da7a20dfa0fc436d416ba405.zip
Workaround for Restr "feature"
See comment on the method "restr_get" for more info.
-rw-r--r--everest-bootstrap/extra/everest-bootstrap.spec2
-rw-r--r--everest-bootstrap/lib/everest-bootstrap/core.rb23
2 files changed, 20 insertions, 5 deletions
diff --git a/everest-bootstrap/extra/everest-bootstrap.spec b/everest-bootstrap/extra/everest-bootstrap.spec
index 705395d..3aab3c7 100644
--- a/everest-bootstrap/extra/everest-bootstrap.spec
+++ b/everest-bootstrap/extra/everest-bootstrap.spec
@@ -7,7 +7,7 @@ Summary: Tool for provisioning virtual machines
Name: rubygem-%{gemname}
Version: 1.0.0
-Release: 1%{?dist}
+Release: 2%{?dist}
Group: Development/Languages
License: Ruby License/GPL
Source0: %{gemname}-%{version}.gem
diff --git a/everest-bootstrap/lib/everest-bootstrap/core.rb b/everest-bootstrap/lib/everest-bootstrap/core.rb
index 07e6b9e..ed5e7f2 100644
--- a/everest-bootstrap/lib/everest-bootstrap/core.rb
+++ b/everest-bootstrap/lib/everest-bootstrap/core.rb
@@ -44,7 +44,7 @@ module EverestBootstrap
def facts_for(type, machine_name)
# Don't want to pull in the everest lib. See below fore more detail.
- facts = Restr.get("#{@everestd}/machine_types/#{type}.xml")["fact"]
+ facts = restr_get("#{@everestd}/machine_types/#{type}.xml", "fact")
return facts.map do |f|
def f.name
self["name"]
@@ -67,7 +67,7 @@ module EverestBootstrap
end
def classes_for(type)
- Restr.get("#{@everestd}/machine_types/#{type}.xml")["class"]
+ restr_get("#{@everestd}/machine_types/#{type}.xml", "class")
end
def fetch_data
@@ -75,7 +75,8 @@ module EverestBootstrap
# lib. That lib has lots of funky metaprogramming stuff in it and it
# might need to be changed in the future. The fewer tools relying on it
# the better.
- machine_types = Restr.get("#{@everestd}/machine_types.xml")["machine_type"]
+ machine_types = restr_get("#{@everestd}/machine_types.xml", "machine_type")
+
return machine_types.map do |m|
def m.name
self["name"]
@@ -116,7 +117,7 @@ module EverestBootstrap
# Retrive information form the /var/log/cobbler/install.log
def get_installed_systems
- systems = Restr.get("#{@everestd}/systems.xml")
+ systems = restr_get("#{@everestd}/systems.xml")
return systems["system"].map do |system|
def system.name
self["name"].to_s
@@ -147,6 +148,20 @@ module EverestBootstrap
def register_dns_entry(ip, name)
end
+
+ # This is a workaround for a Restr "feature". If only one element it is
+ # returned as a Hash instead of an Array. The way we use Restr assumes that it
+ # will always return an Array.
+ def restr_get(url, xml_node=nil)
+ data = xml_node ? Restr.get(url)[xml_node] : Restr.get(url)
+
+ return case data
+ when Hash
+ Array.new << data
+ when Array
+ data
+ end
+ end
end
class CloudController