Sha256: 4bfcb9cca4f6f921d58ef359def288f610fc8c1fd0429d72eacf6b9e808bd2f4

Contents?: true

Size: 1.66 KB

Versions: 6

Compression:

Stored size: 1.66 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/>.

#
# You must have Beta v1.5 API access to use these internal API calls.
#
class Task
  include RightScale::Api::Gateway
  extend RightScale::Api::GatewayExtend

  deny_methods :index, :create, :destroy, :update

  def self.parse_args(cloud_id, instance_id)
    "clouds/#{cloud_id}/instances/#{instance_id}/live/"
  end

  def show
    url = URI.parse(self.href)
    @params.merge! connection.get(url.path)#, 'view' => "extended")
  end

  def wait_for_state(state, timeout=900)
    while(timeout > 0)
      show
      return true if self.summary.include?(state)
      connection.logger("state is #{self.summary}, waiting for #{state}")
      raise "FATAL error:\n\n #{self.summary} \n\n" if self.summary.include?('failed') # TODO #{self.detail}
      sleep 30
      timeout -= 30
    end
    raise "FATAL: Timeout waiting for Executable to complete.  State was #{self.summary}" if timeout <= 0
  end

  def wait_for_completed(timeout=900)
    wait_for_state("completed", timeout)
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rest_connection-0.1.7 lib/rest_connection/rightscale/task.rb
rest_connection-0.1.6 lib/rest_connection/rightscale/task.rb
rest_connection-0.1.5 lib/rest_connection/rightscale/task.rb
rest_connection-0.1.4 lib/rest_connection/rightscale/task.rb
rest_connection-0.1.3 lib/rest_connection/rightscale/task.rb
rest_connection-0.1.2 lib/rest_connection/rightscale/task.rb