Class: VCloudCloud::Steps::DeleteUnusedNetworks

Inherits:
VCloudCloud::Step show all
Defined in:
lib/cloud/vcloud/steps/delete_unused_networks.rb

Instance Attribute Summary

Attributes inherited from VCloudCloud::Step

#client, #state

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(network_names_in_use, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/cloud/vcloud/steps/delete_unused_networks.rb', line 4

def perform(network_names_in_use, &block)
  vapp = client.reload state[:vapp]
  networks = vapp.network_config_section.network_configs.map { |n| n.network_name }
  unused = networks - network_names_in_use
  if unused && !unused.empty?
    unused.uniq.each do |n|
      vapp.network_config_section.delete_network_config n
    end
    client.invoke_and_wait :put, vapp.network_config_section,
              :payload => vapp.network_config_section,
              :headers => { :content_type => VCloudSdk::Xml::MEDIA_TYPE[:NETWORK_CONFIG_SECTION] }
    state[:vapp] = client.reload vapp
  end
end