Sha256: a564d9e2c84859be34328ea6a406557f38efd110ffae2a93225dbb8c4514cce5

Contents?: true

Size: 764 Bytes

Versions: 2

Compression:

Stored size: 764 Bytes

Contents

require 'netutils/parser'
require 'netutils/vrf'

module Cisco

class ShowVRF < Parser
	attr_reader :vrfs

	def cmd
		return 'show vrf'
	end

	def initialize
		super()
		@vrfs = VRFTable.new
		add('Init',		:init)
		add('VRF',		:vrf)
		add('Interface',	:interface)
	end

	def init(l, m)
		return if l !~ /^ +Name +Default RD +Protocols +Interfaces$/
		changeto('VRF')
	end

	def vrf(l, m)
		if l !~ /^ *([^ ]+) +([^ ]+|<not set>) +[^ ]+ +([^ ]+) *$/ &&
		   l !~ /^ *([^ ]+) +([^ ]+|<not set>) +[^ ]+ *$/
			raise(ArgumentError, "Invalid line: \"#{l}\"")
		end
		@vrf = vrfs.add($1, $2)
		@vrf.interface_add($3) if $3
		changeto('Interface')
	end

	def interface(l, m)
		if l =~ /^ +([^ ]+) *$/
			@vrf.interface_add(m[1])
		else
			vrf(l, nil)
		end
	end
end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
netutils-0.1.2 lib/netutils/cli/cisco/showvrf.rb
netutils-0.1.1 lib/netutils/cli/cisco/showvrf.rb