def wait_until_ready(max_trials, wait_for_transactions = false, seconds_between_tries = 2)
      # pessimistically assume the server is not ready
      num_trials = 0
      begin
        self.refresh_details()

        has_os_reload = has_sl_property? :lastOperatingSystemReload
        has_active_transaction = has_sl_property? :activeTransaction

        reloading_os = has_active_transaction && has_os_reload && (self.last_operating_system_reload['id'] == self.active_transaction['id'])
        provisioned = has_sl_property?(:provisionDate) && ! self['provisionDate'].empty?

        # a server is ready when it is provisioned, not reloading the OS
        # (and if wait_for_transactions is true, when there are no active transactions).
        ready = provisioned && !reloading_os && (!wait_for_transactions || !has_active_transaction)

        num_trials = num_trials + 1

        yield ready if block_given?

        sleep(seconds_between_tries) if !ready && (num_trials <= max_trials)
      end until ready || (num_trials >= max_trials)

      ready
    end
def wait_until_ready(max_trials, wait_for_transactions = false, seconds_between_tries = 2)
      # pessimistically assume the server is not ready
      num_trials = 0
      begin
        self.refresh_details()

        has_os_reload = has_sl_property? :lastOperatingSystemReload
        has_active_transaction = has_sl_property? :activeTransaction

        reloading_os = has_active_transaction && has_os_reload && (self.last_operating_system_reload['id'] == self.active_transaction['id'])
        provisioned = has_sl_property?(:provisionDate) && ! self['provisionDate'].empty?

        # a server is ready when it is provisioned, not reloading the OS
        # (and if wait_for_transactions is true, when there are no active transactions).
        ready = provisioned && !reloading_os && (!wait_for_transactions || !has_active_transaction)

        num_trials = num_trials + 1

        yield ready if block_given?

        sleep(seconds_between_tries) if !ready && (num_trials <= max_trials)
      end until ready || (num_trials >= max_trials)

      ready
    end
Repeatedly polls the API to find out if this server is 'ready'.

 The server is ready when it is provisioned and any operating system reloads have completed.

 If wait_for_transactions is true, then the routine will poll until all transactions
 (not just an OS Reload) have completed on the server.

 max_trials is the maximum number of times the routine will poll the API
 seconds_between_tries is the polling interval (in seconds)

 The routine returns true if the server was found to be ready. If max_trials
 is exceeded and the server is still not ready, the routine returns false

 If a block is passed to this routine it will be called on each trial with
 a boolean argument representing whether or not the server is ready

 Calling this routine will (in essence) block the thread on which the request is made.