Module: NexusSW::LXD
- Defined in:
- lib/nexussw/lxd.rb,
lib/nexussw/lxd/driver.rb,
lib/nexussw/lxd/version.rb,
lib/nexussw/lxd/rest_api.rb,
lib/nexussw/lxd/transport.rb,
lib/nexussw/lxd/driver/cli.rb,
lib/nexussw/lxd/driver/rest.rb,
lib/nexussw/lxd/transport/cli.rb,
lib/nexussw/lxd/transport/rest.rb,
lib/nexussw/lxd/transport/local.rb,
lib/nexussw/lxd/driver/mixins/cli.rb,
lib/nexussw/lxd/driver/mixins/rest.rb,
lib/nexussw/lxd/rest_api/connection.rb,
lib/nexussw/lxd/transport/mixins/cli.rb,
lib/nexussw/lxd/transport/mixins/rest.rb,
lib/nexussw/lxd/transport/mixins/local.rb,
lib/nexussw/lxd/driver/mixins/helpers/wait.rb,
lib/nexussw/lxd/transport/mixins/helpers/users.rb,
lib/nexussw/lxd/transport/mixins/helpers/execute.rb,
lib/nexussw/lxd/transport/mixins/helpers/folder_txfr.rb
Defined Under Namespace
Classes: Driver, RestAPI, Transport
Constant Summary collapse
- VERSION =
"0.9.9".freeze
Class Method Summary collapse
- .symbolize_keys(hash) ⇒ Object
-
.with_timeout_and_retries(options = {}) ⇒ Object
Must specify :retry_interval in order to receive retries And if so, then either :timeout or :retry_count must be specified :timeout == 0 without :retry_count is valid in this case, saying to retry forever If nothing is specified, then this function is ineffectual and runs indefinitely.
Class Method Details
.symbolize_keys(hash) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/nexussw/lxd.rb', line 32 def self.symbolize_keys(hash) {}.tap do |retval| hash.each do |k, v| if %w{config expanded_config}.include? k retval[k.to_sym] = v next elsif v.is_a?(Array) v.map! do |a| a.is_a?(Hash) ? symbolize_keys(a) : a end end retval[k.to_sym] = v.is_a?(Hash) ? symbolize_keys(v) : v end end end |
.with_timeout_and_retries(options = {}) ⇒ Object
Must specify :retry_interval in order to receive retries And if so, then either :timeout or :retry_count must be specified
:timeout == 0 without :retry_count is valid in this case, to retry forever
If nothing is specified, then this function is ineffectual and runs indefinitely
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/nexussw/lxd.rb', line 14 def self.with_timeout_and_retries( = {}) Timeout.timeout([:timeout] || 0) do tries = 0 loop do begin Timeout.timeout([:retry_interval] || 0, Timeout::Retry) do tries += 1 return yield end rescue Timeout::Retry next if [:retry_count] && (tries <= [:retry_count]) next if [:timeout] raise end end end end |