class Fog::VcloudDirector::Parsers::Compute::Vapp

Public Instance Methods

end_element(name) click to toggle source
# File lib/fog/vcloud_director/parsers/compute/vapp.rb, line 26
def end_element(name)
  return vm_end_element(name) if @parsing_vm && name != 'Vm'
  vapp_end_element(name)
end
reset() click to toggle source
# File lib/fog/vcloud_director/parsers/compute/vapp.rb, line 10
def reset
  @response = @vapp = {
    :lease_settings  => 'not-implemented',
    :network_section => 'not-implemented',
    :network_config  => 'not-implemented'
  }
  @in_sections = false
  @parsing_vm  = false
end
start_element(name, attributes) click to toggle source
Calls superclass method
# File lib/fog/vcloud_director/parsers/compute/vapp.rb, line 20
def start_element(name, attributes)
  super
  return vm_start_element(name, attributes) if @parsing_vm
  vapp_start_element(name, attributes)
end

Private Instance Methods

vapp_end_element(name) click to toggle source
# File lib/fog/vcloud_director/parsers/compute/vapp.rb, line 52
def vapp_end_element(name)
  case name
  when 'Description'
    @vapp[:description] = value unless @in_sections
  when 'InMaintenanceMode'
    @vapp[:maintenance] = value == 'true'
  when 'Vm'
    @parsing_vm = false
    @vapp[:vms] ||= []
    @vapp[:vms] << @curr_vm
  end
end
vapp_start_element(name, attributes) click to toggle source
# File lib/fog/vcloud_director/parsers/compute/vapp.rb, line 33
def vapp_start_element(name, attributes)
  case name
  when 'VApp'
    vapp_attrs = extract_attributes(attributes)
    @vapp.merge!(vapp_attrs.reject { |key, _| ![:href, :name, :status, :type, :deployed].include?(key) })
    @vapp[:id] ||= id_from_url(@vapp[:href], id_prefix: 'vapp-')
    @vapp[:deployed] = @vapp[:deployed] == 'true'
  when 'LeaseSettingsSection' # this is the first of the sections
    @in_sections = true
    @vapp[:description] ||= '' # if description wasn't parsed by now, then vApp has empty description
  when 'User'
    @vapp[:owner] = attr_value('href', attributes).to_s.split('/').last
  when 'Vm'
    @parsing_vm = true
    vm_reset(@vapp[:id])
    vm_start_element(name, attributes)
  end
end
vm_end_element(name) click to toggle source
# File lib/fog/vcloud_director/parsers/compute/vapp.rb, line 74
def vm_end_element(name)
  parse_end_element(name, @curr_vm)
end
vm_reset(vapp_id) click to toggle source
# File lib/fog/vcloud_director/parsers/compute/vapp.rb, line 78
def vm_reset(vapp_id)
  @curr_vm                    = initialize_vm
  @curr_vm[:vapp_id]          = vapp_id
  @in_operating_system        = false
  @in_children                = false
  @resource_type              = nil
  @links                      = []
  @element_name               = nil
  @current_network_connection = nil
  @current_host_resource      = nil
end
vm_start_element(name, attributes) click to toggle source

Nested VMs

# File lib/fog/vcloud_director/parsers/compute/vapp.rb, line 69
def vm_start_element(name, attributes)
  return parse_vm_attributes(attributes, @curr_vm) if name == 'Vm'
  parse_start_element(name, attributes, @curr_vm)
end