/usr/lib/ruby/vendor_ruby/fog/compute/ecloud/requests/virtual_machine_edit_hardware_configuration.rb is in ruby-fog-ecloud 0.1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | 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 "MB"
xml.Value data[:memory]
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
class Mock
def virtual_machine_edit_hardware_configuration(vm_uri, data)
server_id = vm_uri.match(/(\d+)/)[1]
server = self.data[:servers][server_id.to_i]
task_id = Fog::Mock.random_numbers(10)
task = {
:id => task_id,
:href => "/cloudapi/ecloud/tasks/#{task_id}",
:type => "application/vnd.tmrk.cloud.task",
:Operation => "Configure Server",
:Status => "Complete",
:ImpactedItem => Fog::Ecloud.keep(server, :name, :href, :type),
:StartTime => Time.now.iso8601,
:CompletedTime => Time.now.iso8601,
:InitiatedBy => {},
}
self.data[:tasks][task_id] = task
response(:body => task)
end
end
end
end
end
|