lib/kytoon/providers/cloud_cue/server_group.rb in kytoon-1.4.0 vs lib/kytoon/providers/cloud_cue/server_group.rb in kytoon-1.4.1
- old
+ new
@@ -290,11 +290,12 @@
#
# :id - The ID of the server group to get. Defaults to ENV['GROUP_ID']
# :source - valid options are 'cache' and 'remote'
def self.get(options={})
- source = options[:source] or source = "cache"
+ source = ENV['KYTOON_CLOUDCUE_SOURCE'] or options[:source]
+ source = 'cache' if source.nil? or source.empty?
id = options[:id]
if id.nil? then
group = ServerGroup.most_recent
raise "No recent server group files exist." if group.nil?
id = group.id
@@ -314,13 +315,23 @@
end
# :source - valid options are 'remote' and 'cache'
def self.index(options={})
- source = options[:source] or source = "cache"
+ source = ENV['KYTOON_CLOUDCUE_SOURCE'] or options[:source]
+ source = 'cache' if source.nil? or source.empty?
server_groups=[]
- Dir[File.join(ServerGroup.data_dir, '*.xml')].each do |file|
- server_groups << ServerGroup.from_xml(IO.read(file))
+
+ if source == "remote" then
+ xml=Connection.get("/server_groups.xml")
+ dom = REXML::Document.new(xml)
+ REXML::XPath.each(dom, "//server-group") do |group_xml|
+ server_groups << ServerGroup.from_xml(group_xml.to_s)
+ end
+ else
+ Dir[File.join(ServerGroup.data_dir, '*.xml')].each do |file|
+ server_groups << ServerGroup.from_xml(IO.read(file))
+ end
end
server_groups
end