Sha256: 3d2d4c17903894c44cfefcdb823ad51b644ff04eb314ddfcec9271709a5577d3

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

module Fog
  module Models
    module ProfitBricks
      class Base < Fog::Model
        def wait_for(timeout = Fog.timeout, interval = Fog.interval, &block)
          reload_has_succeeded = false
          duration = Fog.wait_for(timeout, interval) do # Note that duration = false if it times out
            if ready?
              reload_has_succeeded = true
              instance_eval(&block)
            else
              false
            end
          end
          if reload_has_succeeded
            return duration # false if timeout; otherwise {:duration => elapsed time }
          else
            raise Fog::Errors::Error, "Reload failed, #{self.class} #{identity} not present."
          end
        end

        def request_status(request_id)
          request = service.requests.get_status(request_id)
          request.status
        end

        def ready?
          request_status(request_id) == 'DONE'
        end

        def failed?
          request_status(request_id) == 'FAILED'
        end
      end
    end
  end
end

Version data entries

8 entries across 6 versions & 2 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-profitbricks-4.1.1/lib/fog/profitbricks/models/base.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-profitbricks-4.1.1/lib/fog/profitbricks/models/base.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-profitbricks-4.1.1/lib/fog/profitbricks/models/base.rb
fog-profitbricks-4.1.1 lib/fog/profitbricks/models/base.rb
fog-profitbricks-4.1.0 lib/fog/profitbricks/models/base.rb
fog-profitbricks-4.0.0 lib/fog/profitbricks/models/base.rb
fog-profitbricks-3.0.0 lib/fog/profitbricks/models/base.rb
fog-profitbricks-2.0.1 lib/fog/profitbricks/models/base.rb