/usr/lib/ruby/vendor_ruby/fog/compute/ecloud/requests/virtual_machine_detach_disk.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 | module Fog
module Compute
class Ecloud
module Shared
def build_request_body_detach_disk(options)
xml = Builder::XmlMarkup.new
xml.DetachDisk(:name => options[:name]) do
xml.Description options[:description]
xml.Disk do
xml.Index options[:disk][:Index]
end
end
end
end
class Real
def virtual_machine_detach_disk(href, options)
body = build_request_body_detach_disk(options)
request(
:expects => 201,
:method => "POST",
:headers => {},
:body => body,
:uri => href,
:parse => true
)
end
end
class Mock
def virtual_machine_detach_disk(href, options)
server_id = href.match(/(\d+)/)[1].to_i
server = self.data[:servers][server_id]
compute_pool_id = server[:compute_pool_id]
compute_pool = self.data[:compute_pools][compute_pool_id]
detached_disk_id = Fog::Mock.random_numbers(6).to_i
detached_disk = {
:id => detached_disk_id,
:href => "/cloudapi/ecloud/detacheddisks/#{detached_disk_id}",
:name => options[:name],
:type => "application/vnd.tmrk.cloud.detachedDisk",
:Links => {
:Link => [
Fog::Ecloud.keep(compute_pool, :href, :name, :type),
],
},
:Description => options[:description],
:LastKnownVirtualMachineConfiguration => Fog::Ecloud.keep(server, :name, :ProcessorCount, :Memory, :OperatingSystem),
:Type => "Data",
:Size => {
:Unit => "GB",
:Value => options[:disk][:Size][:Value],
},
:Status => "Available",
}
server[:HardwareConfiguration][:Disks][:Disk].delete_if { |disk| disk[:Index] == options[:disk][:Index] }
detached_disk_response = response(:body => detached_disk)
detached_disk.merge!(:compute_pool_id => compute_pool_id)
self.data[:detached_disks][detached_disk_id] = detached_disk
detached_disk_response
end
end
end
end
end
|