Sha256: 56f8aed43abcf8c5a99b5bdc29b91e61caaa9bea8fb4ca39f35df0e60852de84

Contents?: true

Size: 1.55 KB

Versions: 14

Compression:

Stored size: 1.55 KB

Contents

module Fog
  module Compute
    class Ecloud
      class Real

        def virtual_machine_edit_hardware_configuration(vm_uri, data)
          validate_data([:cpus, :memory, :disks, :nics], data)
          body = build_request_body_edit_hardware_configuration(data)
          request(
            :expects => 202,
            :method => 'PUT',
            :headers => {},
            :body => body,
            :uri => vm_uri,
            :parse => true
          )
        end

        def build_request_body_edit_hardware_configuration(data)
          xml = Builder::XmlMarkup.new
          xml.HardwareConfiguration do
            xml.ProcessorCount data[:cpus]
            xml.Memory do
              xml.Unit data[:memory][:Unit]
              xml.Value data[:memory][:Value]
            end
            xml.Disks do
              data[:disks].each do |disk|
                xml.Disk do
                  xml.Index disk[:Index]
                  xml.Size do
                    xml.Unit "GB"
                    xml.Value disk[:Size][:Value]
                  end
                end
              end
            end
            xml.Nics do
              data[:nics].each do |nic|
                xml.Nic do
                  xml.UnitNumber nic[:UnitNumber]
                  xml.MacAddress nic[:MacAddress]
                  xml.Network(:href => nic[:Network][:href], :name => nic[:Network][:name], :type => "application/vnd.tmrk.cloud.network") do
                  end
                end
              end
            end
          end    
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 8 rubygems

Version Path
fog-nirvanix-1.8.2 lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb
fog-nirvanix-1.8.1 lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb
fog-parser-fix-1.6.1 lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb
fog-test-again-1.6.0 lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb
fog-parser-fix-1.6.0 lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb
ey-vendored-backup-3.0.27 vendor/gems/fog/lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb
fog-sgonyea-1.8.1 lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb
fog-1.8.0 lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb
fog-maestrodev-1.7.0.20121114190951 lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb
fog-1.7.0 lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb
fog-1.6.0 lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb
fog-1.5.0 lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb
rackspace-fog-1.4.2 lib/rackspace-fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb
fog-1.4.0 lib/fog/ecloud/requests/compute/virtual_machine_edit_hardware_configuration.rb