Sha256: a1a4680e634f11e0cea4f4a129e9afd502e30e2dd82b66a08e0e8b00e0ed3a27

Contents?: true

Size: 1.51 KB

Versions: 12

Compression:

Stored size: 1.51 KB

Contents

# Copyright (c) 2012-2013 Stark & Wayne, LLC

require "fog"
module Bosh; module Bootstrap; module Helpers; end; end; end

# A collection of methods related to getting fog_compute
# credentials for creating the inception VM
# and to provide to the MicroBOSH for its uses.
#
# Attempts to look in +settings.fog_path+ to see if there is a .fog file.
module Bosh::Bootstrap::Helpers::FogSetup
  
  # fog connection object to Compute tasks (VMs, IP addresses)
  def fog_compute
    @fog_compute ||= begin
      # Fog::Compute.new requires Hash with keys that are symbols
      # but Settings converts all keys to strings
      # So create a version of settings.fog_credentials with symbol keys
      credentials_with_symbols = settings.fog_credentials.inject({}) do |creds, key_pair|
        key, value = key_pair
        creds[key.to_sym] = value
        creds
      end
      Fog::Compute.new(credentials_with_symbols)
    end
  end

  def reset_fog_compute
    @fog_compute = nil
    @provider = nil # in cli.rb - I don't like this; need one wrapper for all CPI/compute calls
    # or don't create fog_compute until we know all IaaS details
  end

  def fog_config
    @fog_config ||= begin
      if File.exists?(fog_config_path)
        say "Found infrastructure API credentials at #{fog_config_path} (override with --fog)"
        YAML.load_file(fog_config_path)
      else
        say "No existing #{fog_config_path} fog configuration file", :yellow
        {}
      end
    end
  end

  def fog_config_path
    settings.fog_path
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bosh-bootstrap-0.10.2 lib/bosh-bootstrap/helpers/fog_setup.rb
bosh-bootstrap-0.10.1 lib/bosh-bootstrap/helpers/fog_setup.rb
bosh-bootstrap-0.10.0 lib/bosh-bootstrap/helpers/fog_setup.rb
bosh-bootstrap-0.9.0 lib/bosh-bootstrap/helpers/fog_setup.rb
bosh-bootstrap-0.8.2 lib/bosh-bootstrap/helpers/fog_setup.rb
bosh-bootstrap-0.8.1 lib/bosh-bootstrap/helpers/fog_setup.rb
bosh-bootstrap-0.8.0 lib/bosh-bootstrap/helpers/fog_setup.rb
bosh-bootstrap-0.7.1 lib/bosh-bootstrap/helpers/fog_setup.rb
bosh-bootstrap-0.7.0 lib/bosh-bootstrap/helpers/fog_setup.rb
bosh-bootstrap-0.6.0 lib/bosh-bootstrap/helpers/fog_setup.rb
bosh-bootstrap-0.5.1 lib/bosh-bootstrap/helpers/fog_setup.rb
bosh-bootstrap-0.5.0 lib/bosh-bootstrap/helpers/fog_setup.rb