Sha256: fe59006ccf2792b87fcefcdfa5ebaf9a998a6f2354a2f19468a940a29742cff9

Contents?: true

Size: 1.86 KB

Versions: 2

Compression:

Stored size: 1.86 KB

Contents

require 'fog/joyent'

#   fog:Joyent:<joyent_url>
module ChefMetalFog
  module Providers
    class Joyent < ChefMetalFog::FogDriver

      ChefMetalFog::FogDriver.register_provider_class('Joyent', ChefMetalFog::Providers::Joyent)

      def creator
        compute_options[:joyent_username]
      end

      def bootstrap_options_for(action_handler, machine_spec, machine_options)
        bootstrap_options = symbolize_keys(machine_options[:bootstrap_options] || {})

        bootstrap_options[:tags] = default_tags(machine_spec, bootstrap_options[:tags] || {})

        bootstrap_options[:tags].each do |key, val|
          bootstrap_options["tag.#{key}"] = val
        end

        bootstrap_options[:name] ||= machine_spec.name

        bootstrap_options
      end

      def self.compute_options_for(provider, id, config)
        new_compute_options = {}
        new_compute_options[:provider] = provider
        new_config = { :driver_options => { :compute_options => new_compute_options }}
        new_defaults = {
          :driver_options => { :compute_options => {} },
          :machine_options => { :bootstrap_options => {} }
        }
        result = Cheffish::MergedConfig.new(new_config, config, new_defaults)

        new_compute_options[:joyent_url] = id if (id && id != '')
        credential = Fog.credentials

        new_compute_options[:joyent_username] ||= credential[:joyent_username]
        new_compute_options[:joyent_password] ||= credential[:joyent_password]
        new_compute_options[:joyent_keyname] ||= credential[:joyent_keyname]
        new_compute_options[:joyent_keyfile] ||= credential[:joyent_keyfile]
        new_compute_options[:joyent_url] ||= credential[:joyent_url]
        new_compute_options[:joyent_version] ||= credential[:joyent_version]

        id = result[:driver_options][:compute_options][:joyent_url]

        [result, id]
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chef-metal-fog-0.9 lib/chef_metal_fog/providers/joyent.rb
chef-metal-fog-0.8 lib/chef_metal_fog/providers/joyent.rb