Method: Fog::Parsers::Terremark::Shared::GetVdc#start_element

Defined in:
lib/fog/terremark/parsers/shared/get_vdc.rb

#start_element(name, attributes) ⇒ Object


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/fog/terremark/parsers/shared/get_vdc.rb', line 28

def start_element(name, attributes)
  super
  case name
  when 'Cpu'
    @in_cpu = true
  when 'DeployedVmsQuota'
    @in_deployed_vms_quota = true
  when 'InstantiatedVmsQuota'
    @in_instantiated_vms_quota = true
  when 'Link'
    link = {}
    until attributes.empty?
      if attributes.first.is_a?(Array)
        attribute = attributes.shift
        link[attribute.first] = attribute.last
      else
        link[attributes.shift] = attributes.shift
      end
    end
    @response['links'] << link
  when 'Memory'
    @in_memory = true
  when 'Network'
    network = {}
    until attributes.empty?
      if attributes.first.is_a?(Array)
        attribute = attributes.shift
        network[attribute.first] = attribute.last
      else
        network[attributes.shift] = attributes.shift
      end
    end
    @response['AvailableNetworks'] << network
  when 'ResourceEntity'
    resource_entity = {}
    until attributes.empty?
      if attributes.first.is_a?(Array)
        attribute = attributes.shift
        resource_entity[attribute.first] = attribute.last
      else
        resource_entity[attributes.shift] = attributes.shift
      end
    end
    @response['ResourceEntities'] << resource_entity
  when 'StorageCapacity'
    @in_storage_capacity = true
  when 'Vdc'
    vdc = {}
    until attributes.empty?
      if attributes.first.is_a?(Array)
        attribute = attributes.shift
        vdc[attribute.first] = attribute.last
      else
        vdc[attributes.shift] = attributes.shift
      end
    end
    @response['href'] = vdc['href']
    @response['name'] = vdc['name']
  end
end