Sha256: af8cb4a1fedc690ae277f2fb305b729be86cac8968ac8202e7a595c68fa721a3

Contents?: true

Size: 1.35 KB

Versions: 79

Compression:

Stored size: 1.35 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.has_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

79 entries across 79 versions & 12 rubygems

Version Path
fog-1.22.0 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-1.21.0 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-1.20.0 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-1.19.0 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/ecloud/requests/compute/virtual_machine_copy_identical.rb