Method: Cisco::Platform.inventory_of
- Defined in:
- lib/cisco_node_utils/platform.rb
.inventory_of(type) ⇒ Object
Returns hash of hashes with inner keys “name”, “descr”, “pid”, “vid”, “sn” Ex: { ‘Slot 1’ => { ‘descr’ => ‘1/10G SFP+ Ethernet Module’,
'pid' => 'N9K-C9396PX',
'vid' => 'V02',
'sn' => 'SAL1812NTBP' },
'Slot 2' => { ... }}
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/cisco_node_utils/platform.rb', line 112 def self.inventory_of(type) node.cache_flush # TODO: investigate why this is needed inv = config_get('inventory', 'all') return {} if inv.nil? inv.select! { |x| x['name'].include? type } return {} if inv.empty? # match desired output format inv_hsh = {} inv.each do |s| inv_hsh[s['name'].tr('"', '')] = { 'descr' => s['desc'].tr('"', ''), 'pid' => s['productid'], 'vid' => s['vendorid'], 'sn' => s['serialnum'] } end inv_hsh end |