Sha256: 2066ccd88443c3ec4471adc06246d218d1767aa0935ee194fb4e795089d2d25a

Contents?: true

Size: 1.34 KB

Versions: 17

Compression:

Stored size: 1.34 KB

Contents

module Fog
  module Compute
    class Ecloud
      module Shared
        def validate_create_server_options_identical(template_uri, options)
          required_opts = [:name, :row, :group, :source]
          unless required_opts.all? { |opt| options.key?(opt) }
            raise ArgumentError.new("Required data missing: #{(required_opts - options.keys).map(&:inspect).join(", ")}")
          end

          options
        end

        def build_request_body_identical(options)
          xml = Builder::XmlMarkup.new
          xml.CopyIdenticalVirtualMachine(:name => options[:name]) do
            xml.Source(:href => options[:source], :type => "application/vnd.tmrk.cloud.virtualMachine")
            xml.Layout do
              xml.NewRow options[:row]
              xml.NewGroup options[:group]
            end
            xml.Description options[:description]
          end
        end
      end

      class Real
        def virtual_machine_copy_identical(template_uri, options)
          options = validate_create_server_options_identical(template_uri, options)
          body = build_request_body_identical(options)
          request(
            :expects => 201,
            :method => 'POST',
            :headers => {},
            :body => body,
            :uri => template_uri,
            :parse => true
          )
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 5 rubygems

Version Path
vagrant-cloudstack-1.1.0 vendor/bundle/gems/fog-1.22.1/lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-ecloud-0.0.2 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-ecloud-0.0.1 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-1.25.0 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
nsidc-fog-1.24.1 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-1.24.0 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
ns-fog-1.22.11 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
ns-fog-1.22.10 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
ns-fog-1.22.9 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
ns-fog-1.22.8 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
ns-fog-1.22.7 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
ns-fog-1.22.6 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-1.23.0 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
ns-fog-1.22.4 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
ns-fog-1.22.3 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
ns-fog-1.22.2 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-1.22.1 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb