Sha256: f8054e014c8d7126156ff9149395a0e179b62e03bef929e356e01b654917cdca

Contents?: true

Size: 1.53 KB

Versions: 4

Compression:

Stored size: 1.53 KB

Contents

module ChefMetalFog
  module Providers
    class CloudStack < ChefMetalFog::FogDriver

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

      def creator
        ''
      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)

        if id && id != ''
          cloudstack_uri = URI.parse(id)
          new_compute_options[:cloudstack_scheme] = cloudstack_uri.scheme
          new_compute_options[:cloudstack_host]   = cloudstack_uri.host
          new_compute_options[:cloudstack_port]   = cloudstack_uri.port
          new_compute_options[:cloudstack_path]   = cloudstack_uri.path
        end

        host   = result[:driver_options][:compute_options][:cloudstack_host]
        path   = result[:driver_options][:compute_options][:cloudstack_path]    || '/client/api'
        port   = result[:driver_options][:compute_options][:cloudstack_port]    || 443
        scheme = result[:driver_options][:compute_options][:cloudstack_scheme]  || 'https'
        id = URI.scheme_list[scheme.upcase].build(:host => host, :port => port, :path => path).to_s

        [result, id]
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
chef-metal-fog-0.9 lib/chef_metal_fog/providers/cloudstack.rb
chef-metal-fog-0.8 lib/chef_metal_fog/providers/cloudstack.rb
chef-metal-fog-0.7.1 lib/chef_metal_fog/providers/cloudstack.rb
chef-metal-fog-0.7 lib/chef_metal_fog/providers/cloudstack.rb