Method: Stats#get_hash

Defined in:
lib/ucslib/service/ucs/stats.rb

#get_hash(xml, statname = :all) ⇒ Object

Translate stats XML into a hash.

If statname is supplied, only include that stat. Otherwise, include all stats.

Hash looks like hash[dn] = value



91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/ucslib/service/ucs/stats.rb', line 91

def get_hash(xml,statname=:all)
    statnames = STATNAMES if statname == :all

    h = Hash.new{|k,v| k[v] = Hash.new}
    statnames.each do |statname|
        xml.xpath("configResolveClasses/outConfigs/#{statname}").each do |stat|
            dn = stat.attributes['dn'].value
            h[statname][dn] = Hash.new
            stat.attributes.each do |attr,value|
                next if attr == 'dn'
                h[statname][dn][attr] = value.value
            end
        end
    end
    return h
end