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