Class: VCloudCloud::Steps::ReconfigureVM
- Inherits:
-
VCloudCloud::Step
- Object
- VCloudCloud::Step
- VCloudCloud::Steps::ReconfigureVM
- Defined in:
- lib/cloud/vcloud/steps/reconfigure_vm.rb
Instance Attribute Summary
Attributes inherited from VCloudCloud::Step
Instance Method Summary collapse
Methods inherited from VCloudCloud::Step
#cleanup, #initialize, #rollback
Constructor Details
This class inherits a constructor from VCloudCloud::Step
Instance Method Details
#perform(name, description, resource_pool, networks, &block) ⇒ Object
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 |
# File 'lib/cloud/vcloud/steps/reconfigure_vm.rb', line 4 def perform(name, description, resource_pool, networks, &block) vapp = state[:vapp] = client.reload state[:vapp] vm = state[:vm] = client.reload state[:vm] vm.name = name unless name.nil? vm.description = description unless description.nil? unless resource_pool.nil? vm.change_cpu_count Integer(resource_pool['cpu']) vm.change_memory Integer(resource_pool['ram']) vm.add_hard_disk Integer(resource_pool['disk']) end unless networks.nil? vm.delete_nic *vm.hardware_section.nics networks.values.each_with_index do |network, nic_index| name = network['cloud_properties']['name'] vm.add_nic nic_index, name, VCloudSdk::Xml::IP_ADDRESSING_MODE[:MANUAL], network['ip'] vm.connect_nic nic_index, name, VCloudSdk::Xml::IP_ADDRESSING_MODE[:MANUAL], network['ip'] end end client.invoke_and_wait :post, vm.reconfigure_link, :payload => vm, :headers => { :content_type => VCloudSdk::Xml::MEDIA_TYPE[:VM] } state[:vm] = client.reload vm end |