Class: Alaxala::ShowVRF

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

Constant Summary collapse

DUMMY_RD =

XXX: Alaxala do not have RD…

'0:0'

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.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/netutils/cli/alaxala/showvrf.rb', line 16

def initialize
  super
  @vrfs = VRFTable.new
  # Date 2017/10/05 21:11:51 JST
  add('Init',    :init,  /^Date/)
  # VRF              Routes          ARP
  add('Title',   :title,  /^VRF/)
  # global           7/-             0/-            
  # 1                235/-           949/-          
  add('VRF',   :vrf)
end

Instance Attribute Details

#vrfsObject (readonly)

Returns the value of attribute vrfs.



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

def vrfs
  @vrfs
end

Instance Method Details

#cmdObject



11
12
13
14
# File 'lib/netutils/cli/alaxala/showvrf.rb', line 11

def cmd
  # XXX: we do not use interfaces for now...
  return 'show ip vrf all'
end

#init(l, m) ⇒ Object



28
29
30
# File 'lib/netutils/cli/alaxala/showvrf.rb', line 28

def init(l, m)
  changeto('Title')
end

#title(l, m) ⇒ Object



32
33
34
# File 'lib/netutils/cli/alaxala/showvrf.rb', line 32

def title(l, m)
  changeto('VRF')
end

#vrf(l, m) ⇒ Object



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

def vrf(l, m)
  if l !~ /^(global|[0-9]+)\s+.*$/
    raise(ArgumentError, "Invalid line: \"#{l}\"")
  end
  name = $1
  name = 'default' if name === 'global'
  @vrf = vrfs.add(name, DUMMY_RD)
end