1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00
fog--fog/lib/fog/vcloud_director/requests/compute/put_cpu.rb

48 lines
2.3 KiB
Ruby
Raw Normal View History

2013-06-26 08:23:54 -04:00
module Fog
module Compute
2013-08-27 05:19:54 -04:00
class VcloudDirector
2013-06-26 08:23:54 -04:00
class Real
extend Fog::Deprecation
deprecate :put_vm_cpu, :put_cpu
# Update the RASD item that specifies CPU properties of a VM.
#
# This operation is asynchronous and returns a task that you can
# monitor to track the progress of the request.
#
# @param [String] id Object identifier of the VM.
# @param [Integer] num_cpus
# @return [Excon:Response]
# * body<~Hash>:
#
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/PUT-Cpu.html
# @since vCloud API version 0.9
def put_cpu(id, num_cpus)
2013-06-26 08:23:54 -04:00
data = <<EOF
<Item xmlns="http://www.vmware.com/vcloud/v1.5" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns12="http://www.vmware.com/vcloud/v1.5" ns12:href="#{end_point}vApp/#{id}/virtualHardwareSection/cpu" ns12:type="application/vnd.vmware.vcloud.rasdItem+xml" xsi:schemaLocation="http://www.vmware.com/vcloud/v1.5 http://10.194.1.65/api/v1.5/schema/master.xsd http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2.22.0/CIM_ResourceAllocationSettingData.xsd">
2013-06-26 08:23:54 -04:00
<rasd:AllocationUnits>hertz * 10^6</rasd:AllocationUnits>
<rasd:Description>Number of Virtual CPUs</rasd:Description>
<rasd:ElementName>#{num_cpus} virtual CPU(s)</rasd:ElementName>
<rasd:InstanceID>4</rasd:InstanceID>
<rasd:Reservation>0</rasd:Reservation>
<rasd:ResourceType>3</rasd:ResourceType>
<rasd:VirtualQuantity>#{num_cpus}</rasd:VirtualQuantity>
<rasd:Weight>0</rasd:Weight>
<Link rel="edit" type="application/vnd.vmware.vcloud.rasdItem+xml" href="#{end_point}vApp/#{id}/virtualHardwareSection/cpu"/>
2013-06-26 08:23:54 -04:00
</Item>
EOF
2013-09-16 13:13:09 -04:00
2013-06-26 08:23:54 -04:00
request(
2013-09-16 13:13:09 -04:00
:body => data,
:expects => 202,
:headers => {'Content-Type' => 'application/vnd.vmware.vcloud.rasdItem+xml'},
2013-09-16 13:13:09 -04:00
:method => 'PUT',
:parser => Fog::ToHashDocument.new,
:path => "vApp/#{id}/virtualHardwareSection/cpu"
2013-06-26 08:23:54 -04:00
)
end
end
end
end
end