Class: Arista::EAPI::Parser::Show

Inherits:
Object
  • Object
show all
Defined in:
lib/arista/eapi/parser/show.rb

Class Method Summary collapse

Class Method Details

.show_lldp_neighbors(body) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/arista/eapi/parser/show.rb', line 5

def self.show_lldp_neighbors(body)
  lldp = {
    :last_update => nil,
    :ports => {}
  }

  lldp[:last_update] = body.match(/^Last table change time\s+:\s(.*?)$/m)[1]
  ports = body.match(/.*Neighbor Port ID\s*TTL\s(.*)/m)[1]

  unless ports.nil?
    ports.split("\n").each do |line|
      name, neighbor_device_id, neighbor_port_id, ttl = line.split
      lldp[:ports][name] = {
        :neighbor_device_id => neighbor_device_id,
        :neighbor_port_id   => neighbor_port_id,
        :ttl                => ttl
      }
    end
  end

  { :lldp_neighbors => lldp }
end