Module: Fog
- Defined in:
- lib/fog/test_helpers/types_helper.rb,
lib/fog/cdn.rb,
lib/fog/dns.rb,
lib/fog/nfv.rb,
lib/fog/vpn.rb,
lib/fog/image.rb,
lib/fog/volume.rb,
lib/fog/account.rb,
lib/fog/billing.rb,
lib/fog/compute.rb,
lib/fog/network.rb,
lib/fog/storage.rb,
lib/fog/support.rb,
lib/fog/core/scp.rb,
lib/fog/core/ssh.rb,
lib/fog/identity.rb,
lib/fog/metering.rb,
lib/fog/baremetal.rb,
lib/fog/core/hmac.rb,
lib/fog/core/mock.rb,
lib/fog/core/time.rb,
lib/fog/core/uuid.rb,
lib/fog/core/cache.rb,
lib/fog/core/model.rb,
lib/fog/core/utils.rb,
lib/fog/formatador.rb,
lib/fog/monitoring.rb,
lib/fog/core/errors.rb,
lib/fog/core/logger.rb,
lib/tasks/test_task.rb,
lib/fog/core/service.rb,
lib/fog/core/version.rb,
lib/fog/core/provider.rb,
lib/fog/core/wait_for.rb,
lib/fog/introspection.rb,
lib/fog/orchestration.rb,
lib/fog/core/attributes.rb,
lib/fog/core/collection.rb,
lib/fog/core/connection.rb,
lib/fog/core/association.rb,
lib/fog/core/credentials.rb,
lib/fog/core/deprecation.rb,
lib/fog/core/services_mixin.rb,
lib/fog/core/stringify_keys.rb,
lib/fog/core/whitelist_keys.rb,
lib/fog/core/attributes/time.rb,
lib/fog/core/current_machine.rb,
lib/fog/compute/models/server.rb,
lib/fog/core/attributes/array.rb,
lib/fog/core/attributes/float.rb,
lib/fog/schema/data_validator.rb,
lib/fog/core/attributes/string.rb,
lib/fog/core/wait_for_defaults.rb,
lib/fog/core/attributes/boolean.rb,
lib/fog/core/attributes/default.rb,
lib/fog/core/attributes/integer.rb,
lib/fog/core/associations/default.rb,
lib/fog/core/attributes/timestamp.rb,
lib/fog/core/associations/one_model.rb,
lib/fog/core/associations/many_models.rb,
lib/fog/core/associations/one_identity.rb,
lib/fog/core/associations/many_identities.rb,
lib/fog/core/deprecated_connection_accessors.rb
Overview
Format related hackery allows both true.is_a?(Fog::Boolean) and false.is_a?(Fog::Boolean) allows both nil.is_a?(Fog::Nullable::String) and ”.is_a?(Fog::Nullable::String)
Defined Under Namespace
Modules: Account, Associations, Attributes, Baremetal, Billing, Boolean, CDN, Compute, Core, DNS, Deprecation, Errors, Formatador, Identity, Image, Introspection, Metering, Mock, Monitoring, NFV, Network, Nullable, Orchestration, Provider, Rake, SCP, SSH, Schema, ServicesMixin, Storage, StringifyKeys, Support, VPN, Volume, WhitelistKeys Classes: Association, Cache, Collection, CurrentMachine, HMAC, Logger, Model, PagedCollection, Service, Time, UUID
Class Attribute Summary collapse
-
.credentials ⇒ Hash
The credentials pulled from the configuration file.
-
.interval ⇒ Object
Returns the value of attribute interval.
-
.max_interval ⇒ Object
Returns the value of attribute max_interval.
-
.mocking ⇒ Object
(also: mock?, mocking?)
readonly
Returns the value of attribute mocking.
- .providers ⇒ Object
-
.timeout ⇒ Object
Returns the value of attribute timeout.
Class Method Summary collapse
-
.credential ⇒ Symbol
This is the named credential from amongst the configuration file being used or
:default
. -
.credential=(new_credential) ⇒ Symbol
Assign a new credential to use from configuration file.
-
.credentials_path ⇒ String
This returns the path to the configuration file being used globally to look for sets of credentials.
-
.credentials_path=(new_credentials_path) ⇒ String
The new path for credentials file.
- .mock! ⇒ Object
- .services ⇒ Object
-
.symbolize_credential?(key) ⇒ true
deprecated
Deprecated.
Don’t use!
-
.symbolize_credentials(hash) ⇒ Object
deprecated
Deprecated.
Use Core::Utils.prepare_service_settings instead
- .unmock! ⇒ Object
- .wait_for(timeout = Fog.timeout, interval = Fog.interval, &_block) ⇒ Object
Class Attribute Details
.credentials ⇒ Hash
Returns The credentials pulled from the configuration file.
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/fog/core/credentials.rb', line 67 def self.credentials @credentials ||= begin if credentials_path && File.exist?(credentials_path) credentials = Fog::Core::Utils.prepare_service_settings(YAML.load_file(credentials_path)) (credentials && credentials[credential]) || Fog::Errors.missing_credentials else {} end end end |
.interval ⇒ Object
Returns the value of attribute interval.
5 6 7 |
# File 'lib/fog/core/wait_for_defaults.rb', line 5 def interval @interval end |
.max_interval ⇒ Object
Returns the value of attribute max_interval.
31 32 33 |
# File 'lib/fog/core/wait_for_defaults.rb', line 31 def max_interval @max_interval end |
.mocking ⇒ Object (readonly) Also known as: mock?, mocking?
Returns the value of attribute mocking.
13 14 15 |
# File 'lib/fog/core/mock.rb', line 13 def mocking @mocking end |
.providers ⇒ Object
6 7 8 |
# File 'lib/fog/core/provider.rb', line 6 def self.providers @providers ||= {} end |
.timeout ⇒ Object
Returns the value of attribute timeout.
20 21 22 |
# File 'lib/fog/core/wait_for_defaults.rb', line 20 def timeout @timeout end |
Class Method Details
.credential ⇒ Symbol
This can be set using the FOG_CREDENTIAL
environment variable
This is the named credential from amongst the configuration file being used or :default
40 41 42 |
# File 'lib/fog/core/credentials.rb', line 40 def self.credential @credential ||= (ENV["FOG_CREDENTIAL"] && ENV["FOG_CREDENTIAL"].to_sym) || :default end |
.credential=(new_credential) ⇒ Symbol
Assign a new credential to use from configuration file
30 31 32 33 |
# File 'lib/fog/core/credentials.rb', line 30 def self.credential=(new_credential) @credentials = nil @credential = new_credential && new_credential.to_sym end |
.credentials_path ⇒ String
This can be set using the FOG_RC
environment variable or defaults to $HOME/.fog
This returns the path to the configuration file being used globally to look for sets of credentials
50 51 52 53 54 55 56 57 |
# File 'lib/fog/core/credentials.rb', line 50 def self.credentials_path @credential_path ||= begin path = ENV["FOG_RC"] || (ENV["HOME"] && File.directory?(ENV["HOME"]) && "~/.fog") File.(path) if path rescue nil end end |
.credentials_path=(new_credentials_path) ⇒ String
Returns The new path for credentials file.
60 61 62 63 |
# File 'lib/fog/core/credentials.rb', line 60 def self.credentials_path=(new_credentials_path) @credentials = nil @credential_path = new_credentials_path end |
.mock! ⇒ Object
4 5 6 |
# File 'lib/fog/core/mock.rb', line 4 def self.mock! @mocking = true end |
.services ⇒ Object
4 5 6 |
# File 'lib/fog/core/service.rb', line 4 def self.services @services ||= {} end |
.symbolize_credential?(key) ⇒ true
Don’t use!
Returns if key == :headers.
81 82 83 |
# File 'lib/fog/core/credentials.rb', line 81 def self.symbolize_credential?(key) ![:headers].include?(key) end |
.symbolize_credentials(hash) ⇒ Object
Use Fog::Core::Utils.prepare_service_settings instead
86 87 88 |
# File 'lib/fog/core/credentials.rb', line 86 def self.symbolize_credentials(hash) Fog::Core::Utils.prepare_service_settings(hash) end |
.unmock! ⇒ Object
8 9 10 |
# File 'lib/fog/core/mock.rb', line 8 def self.unmock! @mocking = false end |
.wait_for(timeout = Fog.timeout, interval = Fog.interval, &_block) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/fog/core/wait_for.rb', line 2 def self.wait_for(timeout = Fog.timeout, interval = Fog.interval, &_block) duration = 0 start = Time.now retries = 0 loop do break if yield if duration > timeout raise Errors::TimeoutError, "The specified wait_for timeout (#{timeout} seconds) was exceeded" end sleep(interval.respond_to?(:call) ? interval.call(retries += 1).to_f : interval.to_f) duration = Time.now - start end { :duration => duration } end |