Class: Cisco::ShowVRF

Inherits:
Parser show all
Defined in:
lib/netutils/cli/cisco/showvrf.rb

Constant Summary

Constants inherited from FSM

FSM::FSM_S_INIT

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Parser

#add, #parse, #regexp

Methods inherited from FSM

#add, #cb, #changeto, #state_name

Constructor Details

#initializeShowVRF

Returns a new instance of ShowVRF.



13
14
15
16
17
18
19
# File 'lib/netutils/cli/cisco/showvrf.rb', line 13

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

Instance Attribute Details

#vrfsObject (readonly)

Returns the value of attribute vrfs.



7
8
9
# File 'lib/netutils/cli/cisco/showvrf.rb', line 7

def vrfs
  @vrfs
end

Instance Method Details

#cmdObject



9
10
11
# File 'lib/netutils/cli/cisco/showvrf.rb', line 9

def cmd
	return 'show vrf'
end

#init(l, m) ⇒ Object



21
22
23
24
# File 'lib/netutils/cli/cisco/showvrf.rb', line 21

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

#interface(l, m) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/netutils/cli/cisco/showvrf.rb', line 36

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

#vrf(l, m) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/netutils/cli/cisco/showvrf.rb', line 26

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