Sha256: 2380fe9f24ff43943c2a43a3e43c5b606fbdf5ccbea55b135aa4422eef3cf20f

Contents?: true

Size: 1.72 KB

Versions: 9

Compression:

Stored size: 1.72 KB

Contents

#    This file is part of RestConnection 
#
#    RestConnection is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    RestConnection is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with RestConnection.  If not, see <http://www.gnu.org/licenses/>.

class Ec2ServerArray 
  include RightScale::Api::Base
  extend RightScale::Api::BaseExtend

#  Example:
#    right_script = @server_template.executables.first
#    result = @my_array.run_script_on_all(right_script, [@server_template.href])
  def run_script_on_all(script, server_template_hrefs, inputs=nil)
     serv_href = URI.parse(self.href)
     options = Hash.new
     options[:ec2_server_array] = Hash.new 
     options[:ec2_server_array][:right_script_href] = script.href
     options[:ec2_server_array][:parameters] = inputs unless inputs.nil?
     options[:ec2_server_array][:server_template_hrefs] = server_template_hrefs
# bug, this only returns work units if using xml, for json all we get is nil.  scripts still run though ..
     connection.post("#{serv_href.path}/run_script_on_all", options)
  end

  def instances
    serv_href = URI.parse(self.href)
    connection.get("#{serv_href.path}/instances")
  end 
  
  def terminate_all
    serv_href = URI.parse(self.href)
    connection.post("#{serv_href.path}/terminate_all")
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
rest_connection-0.0.18 lib/rest_connection/rightscale/ec2_server_array.rb
rest_connection-0.0.17 lib/rest_connection/rightscale/ec2_server_array.rb
rest_connection-0.0.16 lib/rest_connection/rightscale/ec2_server_array.rb
rest_connection-0.0.15 lib/rest_connection/rightscale/ec2_server_array.rb
rest_connection-0.0.14 lib/rest_connection/rightscale/ec2_server_array.rb
rest_connection-0.0.13 lib/rest_connection/rightscale/ec2_server_array.rb
rest_connection-0.0.12 lib/rest_connection/rightscale/ec2_server_array.rb
rest_connection-0.0.11 lib/rest_connection/rightscale/ec2_server_array.rb
rest_connection-0.0.10 lib/rest_connection/rightscale/ec2_server_array.rb