lib/kytoon/providers/cloud_cue/server_group.rb in kytoon-1.4.1 vs lib/kytoon/providers/cloud_cue/server_group.rb in kytoon-1.4.2

- old
+ new

@@ -236,11 +236,11 @@ online = false count=0 until online or (count*20) >= timeout.to_i do count+=1 begin - sg=ServerGroup.get(:id => @id, :source => "remote") + sg=ServerGroup.get(:id => @id, :remote => true) online=true sg.servers.each do |server| if ["Pending", "Rebuilding"].include?(server.status) then online=false @@ -277,52 +277,48 @@ SshUtil.remove_known_hosts_ip(gateway_ip) end server_group.pretty_print end end - sg=ServerGroup.get(:id => sg.id, :source => "remote") + sg=ServerGroup.get(:id => sg.id, :remote => true) sg.cache_to_disk puts "Server group online." sg end # Get a server group. The following options are available: # # :id - The ID of the server group to get. Defaults to ENV['GROUP_ID'] - # :source - valid options are 'cache' and 'remote' + # :remote - true or false def self.get(options={}) - source = ENV['KYTOON_CLOUDCUE_SOURCE'] or options[:source] - source = 'cache' if source.nil? or source.empty? + remote = options[:remote] or false id = options[:id] if id.nil? then group = ServerGroup.most_recent raise "No recent server group files exist." if group.nil? id = group.id end - if source == "remote" then + if remote then xml=Connection.get("/server_groups/#{id}.xml") ServerGroup.from_xml(xml) - elsif source == "cache" then + else out_file = File.join(@@data_dir, "#{id}.xml") raise "No server group files exist." if not File.exists?(out_file) ServerGroup.from_xml(IO.read(out_file)) - else - raise "Invalid get :source specified." end end - # :source - valid options are 'remote' and 'cache' + # :remote - true or false def self.index(options={}) - source = ENV['KYTOON_CLOUDCUE_SOURCE'] or options[:source] - source = 'cache' if source.nil? or source.empty? + remote = options[:remote] or false server_groups=[] - if source == "remote" then + if 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