Sha256: aa8ef57a760f6698a302475628a609ac35e5c75f07258a5bd273040924ac04c1

Contents?: true

Size: 1.21 KB

Versions: 10

Compression:

Stored size: 1.21 KB

Contents

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

        def build_request_body_edit(options)
          xml = Builder::XmlMarkup.new
          xml.VirtualMachine(:name => options[:name]) do
            if options[:description]
              xml.Description options[:description]
            end
            if options[:tags]
              xml.Tags do
                options[:tags].each do |tag|
                  xml.Tag tag
                end
              end
            end
          end
        end
      end

      class Real
        def virtual_machine_edit(vm_uri, options)
          validate_edit_server_options(options)
          body = build_request_body_edit(options)
          request(
            :expects => [202,204],
            :method => "PUT",
            :headers => {},
            :body => body,
            :uri => vm_uri,
            :parse => true
          )
        end
      end
    end
  end
end

Version data entries

10 entries across 8 versions & 3 rubygems

Version Path
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/requests/virtual_machine_edit.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/requests/virtual_machine_edit.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-ecloud-0.3.0/lib/fog/compute/ecloud/requests/virtual_machine_edit.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-ecloud-0.1.1/lib/fog/compute/ecloud/requests/virtual_machine_edit.rb
fog-ecloud-0.3.0 lib/fog/compute/ecloud/requests/virtual_machine_edit.rb
fog-ecloud-0.2.0 lib/fog/compute/ecloud/requests/virtual_machine_edit.rb
fog-ecloud-0.1.3 lib/fog/compute/ecloud/requests/virtual_machine_edit.rb
fog-ecloud-0.1.2 lib/fog/compute/ecloud/requests/virtual_machine_edit.rb
fog-ecloud-0.1.1 lib/fog/compute/ecloud/requests/virtual_machine_edit.rb
fog-ecloud-0.1.0 lib/fog/compute/ecloud/requests/virtual_machine_edit.rb