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
|
2013-10-01 03:43:28 -04:00
|
|
|
extend Fog::Deprecation
|
|
|
|
deprecate :put_vm_cpu, :put_cpu
|
|
|
|
|
2013-09-27 11:32:49 -04:00
|
|
|
# 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.
|
|
|
|
#
|
2013-10-08 13:46:06 -04:00
|
|
|
# @param [String] id Object identifier of the VM.
|
2013-09-27 11:32:49 -04:00
|
|
|
# @param [Integer] num_cpus
|
|
|
|
# @return [Excon:Response]
|
|
|
|
# * body<~Hash>:
|
2013-10-13 15:23:24 -04:00
|
|
|
#
|
2013-09-27 11:32:49 -04:00
|
|
|
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/PUT-Cpu.html
|
2013-09-29 13:57:18 -04:00
|
|
|
# @since vCloud API version 0.9
|
2013-10-08 13:46:06 -04:00
|
|
|
def put_cpu(id, num_cpus)
|
2013-06-26 08:23:54 -04:00
|
|
|
data = <<EOF
|
2013-10-14 13:28:43 -04:00
|
|
|
<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>
|
2013-10-14 13:28:43 -04:00
|
|
|
<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,
|
2013-09-29 13:57:18 -04:00
|
|
|
:headers => {'Content-Type' => 'application/vnd.vmware.vcloud.rasdItem+xml'},
|
2013-09-16 13:13:09 -04:00
|
|
|
:method => 'PUT',
|
|
|
|
:parser => Fog::ToHashDocument.new,
|
2013-10-08 13:46:06 -04:00
|
|
|
:path => "vApp/#{id}/virtualHardwareSection/cpu"
|
2013-06-26 08:23:54 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|