mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[vcloud|compute] memory reconfiguration
This commit is contained in:
parent
fe8ee15310
commit
01ace6c62f
4 changed files with 67 additions and 2 deletions
|
@ -112,10 +112,12 @@ module Fog
|
|||
|
||||
def memory=(amount)
|
||||
@changed = true
|
||||
memory_mess[:VirtualQuantity] = amount.to_s
|
||||
@update_memory_value = amount
|
||||
amount
|
||||
end
|
||||
|
||||
def disks
|
||||
pp disk_mess
|
||||
disk_mess.map do |dm|
|
||||
{ :number => dm[:"rasd:AddressOnParent"], :size => dm[:"rasd:VirtualQuantity"].to_i, :resource => dm[:"rasd:HostResource"] }
|
||||
end
|
||||
|
@ -162,9 +164,14 @@ module Fog
|
|||
raise RuntimeError, "Can't save cpu, name or memory changes while the VM is on."
|
||||
end
|
||||
end
|
||||
connection.configure_vapp( href, _compose_vapp_data )
|
||||
if @update_memory_value
|
||||
memory_mess[:"rasd:VirtualQuantity"] = @update_memory_value.to_s
|
||||
connection.configure_vm_memory(memory_mess)
|
||||
end
|
||||
#connection.configure_vapp( href, _compose_vapp_data )
|
||||
end
|
||||
reset_tracking
|
||||
true
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
@ -183,6 +190,7 @@ module Fog
|
|||
def reset_tracking
|
||||
@disk_change = false
|
||||
@changed = false
|
||||
@update_memory_value = nil
|
||||
end
|
||||
|
||||
def _compose_vapp_data
|
||||
|
|
39
lib/fog/compute/requests/vcloud/configure_vm_memory.rb
Normal file
39
lib/fog/compute/requests/vcloud/configure_vm_memory.rb
Normal file
|
@ -0,0 +1,39 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
module Fog
|
||||
module Vcloud
|
||||
class Compute
|
||||
class Real
|
||||
|
||||
def configure_vm_memory(vm_data)
|
||||
edit_uri = vm_data.select {|k,v| k == :Link && v[:rel] == 'edit'}[:Link][:href]
|
||||
|
||||
body = <<EOF
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Item xmlns="http://www.vmware.com/vcloud/v1" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vcloud="http://www.vmware.com/vcloud/v1" vcloud:href="https://vcd01.esx.dev.int.realestate.com.au/api/v1.0/vApp/vm-329805878/virtualHardwareSection/memory" vcloud:type="application/vnd.vmware.vcloud.rasdItem+xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="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 http://www.vmware.com/vcloud/v1 http://vcd01.esx.dev.int.realestate.com.au/api/v1.0/schema/master.xsd">
|
||||
<rasd:AllocationUnits>byte * 2^20</rasd:AllocationUnits>
|
||||
<rasd:Description>Memory Size</rasd:Description>
|
||||
<rasd:ElementName>#{vm_data[:'rasd:VirtualQuantity']} MB of memory</rasd:ElementName>
|
||||
<rasd:InstanceID>5</rasd:InstanceID>
|
||||
<rasd:Reservation>0</rasd:Reservation>
|
||||
<rasd:ResourceType>4</rasd:ResourceType>
|
||||
<rasd:VirtualQuantity>#{vm_data[:'rasd:VirtualQuantity']}</rasd:VirtualQuantity>
|
||||
<rasd:Weight>5120</rasd:Weight>
|
||||
<Link rel="edit" type="application/vnd.vmware.vcloud.rasdItem+xml" href="https://vcd01.esx.dev.int.realestate.com.au/api/v1.0/vApp/vm-329805878/virtualHardwareSection/memory"/>
|
||||
</Item>
|
||||
EOF
|
||||
|
||||
request(
|
||||
:body => body,
|
||||
:expects => 202,
|
||||
:headers => {'Content-Type' => vm_data[:"vcloud_type"] },
|
||||
:method => 'PUT',
|
||||
:uri => edit_uri,
|
||||
:parse => true
|
||||
)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
16
lib/fog/compute/requests/vcloud/get_vm_memory.rb
Normal file
16
lib/fog/compute/requests/vcloud/get_vm_memory.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module Fog
|
||||
module Vcloud
|
||||
class Compute
|
||||
|
||||
class Real
|
||||
def get_vm_memory(href, parse = true)
|
||||
request(
|
||||
:expects => 200,
|
||||
:uri => href,
|
||||
:parse => parse
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -89,6 +89,7 @@ module Fog
|
|||
request :configure_network
|
||||
request :configure_network_ip
|
||||
request :configure_vapp
|
||||
request :configure_vm_memory
|
||||
request :delete_vapp
|
||||
request :get_catalog
|
||||
request :get_catalog_item
|
||||
|
@ -102,6 +103,7 @@ module Fog
|
|||
request :get_task_list
|
||||
request :get_vapp
|
||||
request :get_vapp_template
|
||||
request :get_vm_memory
|
||||
request :get_vdc
|
||||
request :instantiate_vapp_template
|
||||
request :login
|
||||
|
|
Loading…
Add table
Reference in a new issue