Module: Fog::ServicesMixin
- Included in:
- Account, Baremetal, Billing, CDN, Compute, DNS, Identity, Image, Introspection, Metering, Monitoring, NFV, Network, Orchestration, Storage, Support, VPN, Volume
- Defined in:
- lib/fog/core/services_mixin.rb
Constant Summary collapse
- E_SERVICE_PROVIDER_CONSTANT =
<<-EOS.gsub(/\s+/, " ").strip.freeze Falling back to deprecated constant Fog::%<service>s::%<provider>s. The preferred format of service provider constants has changed from service::provider to provider::service. Please update this service provider to use the preferred format. EOS
- E_SERVICE_PROVIDER_PATH =
<<-EOS.gsub(/\s+/, " ").strip.freeze Falling back to deprecated path fog/%<service>s/%<provider>s. The preferred file path format has changed from service/provider to provider/service. Please update this service provider to use the preferred format. EOS
Instance Method Summary collapse
Instance Method Details
#[](provider) ⇒ Object
16 17 18 |
# File 'lib/fog/core/services_mixin.rb', line 16 def [](provider) new(provider: provider) end |
#new(attributes) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/fog/core/services_mixin.rb', line 20 def new(attributes) attributes = attributes.dup # Prevent delete from having side effects provider = attributes.delete(:provider).to_s.downcase.to_sym provider_alias = check_provider_alias(provider) provider_name = Fog.providers[provider_alias] raise ArgumentError, "#{provider_alias} is not a recognized provider" unless providers.include?(provider) || providers.include?(provider_alias) require_service_provider_library(service_name.downcase, provider_alias) spc = service_provider_constant(service_name, provider_name) spc.new(attributes) rescue LoadError, NameError => e # Only rescue errors in finding the libraries, allow connection errors through to the caller Fog::Logger.warning("Error while loading provider #{provider_alias}: #{e.}") Fog::Logger.debug("backtrace: #{e.backtrace.join("\n")}") raise Fog::Service::NotFound, "#{provider_alias} has no #{service_name.downcase} service" end |