Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cisco ASR/IOS-XE - Parsing Broken #52

Closed
sts opened this issue Oct 22, 2014 · 7 comments
Closed

Cisco ASR/IOS-XE - Parsing Broken #52

sts opened this issue Oct 22, 2014 · 7 comments

Comments

@sts
Copy link
Contributor

sts commented Oct 22, 2014

I would like to backup configuration of a Cisco ASR 1001 and it seems pulling the backup doesn't really work. Below is the output of the stored configuration. This is a complete show inventory of the host.

! Cisco IOS Software, IOS-XE Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 15.2(4)S6, RELEASE SOFTWARE (fc4)
! NAME: "Chassis", DESCR: "Cisco ASR1001 Chassis w/o IDC"
! PID: ASR1001           , VID: V01, SN: XXXXXXXXXXX
! 
! NAME: "Power Supply Module 0", DESCR: "Cisco ASR1001 AC Power Supply"
! PID: ASR1001-PWR-AC    , VID: V01, SN: XXXXXXXXXXX
! 
! NAME: "Power Supply Module 1", DESCR: "Cisco ASR1001 AC Power Supply"
! PID: ASR1001-PWR-AC    , VID: V01, SN: XXXXXXXXXXX
! 
! NAME: "module 0", DESCR: "Cisco ASR1001 SPA Interface Processor"
! PID: ASR1001           , VID:    , SN:            
! 
! NAME: "SPA subslot 0/0", DESCR: "4-port Gigabit Ethernet Shared Port Adapter"
! PID: ASR1001           , VID:    , SN:            
! 
! NAME: "subslot 0/0 transceiver 0", DESCR: "GE T"
! PID: N/A                 , VID: F   , SN: XXXXXXXXXXX
! 
! NAME: "subslot 0/0 transceiver 1", DESCR: "GE T"
! PID: N/A                 , VID: E   , SN: XXXXXXXXXXX     
! 
! NAME: "subslot 0/0 transceiver 3", DESCR: "GE T"
! PID: N/A                 , VID: 11.0, SN: XXXXXXXXXXX    
! 
! NAME: "module R0", DESCR: "Cisco ASR1001 Route Processor"
! PID: ASR1001           , VID: V01, SN: XXXXXXXXXXX
! 
! NAME: "module F0", DESCR: "Cisco ASR1001 Embedded Services Processor"
! PID: ASR1001           , VID:    , SN:            
! 
! 

Afterwards there is no more output (no traces of the show version, running-config).

Log Output from an update

D, [2014-10-22T17:48:20.147174 #15489] DEBUG -- : SSH: terminal length 0 @ asr01.example.org
D, [2014-10-22T17:48:20.550736 #15489] DEBUG -- : SSH: terminal width 0 @ asr01.example.org
D, [2014-10-22T17:48:20.956171 #15489] DEBUG -- : SSH: show version @ asr01.example.org
D, [2014-10-22T17:48:21.359670 #15489] DEBUG -- : SSH: show inventory @ asr01.example.org
D, [2014-10-22T17:48:21.763836 #15489] DEBUG -- : SSH: show running-config @ asr01.example.org
D, [2014-10-22T17:48:22.167758 #15489] DEBUG -- : SSH: exit @ asr01.example.org

Running the commands above manually using the CLI actually work

bin/oxs asr01.example.org -u foo -p xxxx --verbose -e xxxx --terse --debug 'show version' #=> OK
bin/oxs asr01.example.org -u foo -p xxxx --verbose -e xxxx --terse --debug 'show inventory' #=> OK
bin/oxs asr01.example.org -u foo -p xxxx --verbose -e xxxx --terse --debug 'show running-config' #=> OK

Is there also a way to debug parsing with the IOS module? The router is actually running IOS-XE, but all of the old IOS commands work when it comes to dumping configuration.

@sts sts changed the title Cisco ASR Broken Cisco ASR/IOS-XE - Parsing Broken Oct 22, 2014
@ytti
Copy link
Owner

ytti commented Oct 22, 2014

The first line looks to be the version, so you're only missing running-config. Not sure why, but I'm guessing maybe 'cfg' is 'nil' here for some reason:

cmd 'show running-config' do |cfg|
cfg = cfg.each_line.to_a[3..-1]
cfg = cfg.reject { |line| line.match /^ntp clock-period / }.join
cfg.gsub! /^Current configuration : [^\n]\n/, ''
cfg.gsub! /^\ tunnel\ mpls\ traffic-eng\ bandwidth[^\n]
\n_(
(?:\ [^\n]\n)_
tunnel\ mpls\ traffic-eng\ auto-bw)/mx, '\1'
cfg
end

Probably this returns nil, instead of the expected config string.

There aren't really good ways to debug the models, you can get full ssh and telnet session logs though, by setting:
input:
debug: input.log

For module development/debugging maybe easiest is to copy the model to your oxidized directory under 'model' directory (i.e. ~/.config/oxidized/model/ios.rb), if model is found there it is used, instead of the global/shipping definition, so you could add there your own debugging code.

Certainly

  1. model needs to be fixed
  2. we need better way to debug models, but i don't want solution which bloats the models themselves

@sts
Copy link
Contributor Author

sts commented Oct 22, 2014

Seems like it doesn't run the 'enable' command.

@ytti
Copy link
Owner

ytti commented Oct 22, 2014

How does your config look with regarding 'enable'

@sts
Copy link
Contributor Author

sts commented Oct 22, 2014

---
username: manager
password: S3cret
enable: S3cret
model: junos
interval: 3600
log: /home/sts/.config/oxidized/log
debug: true
threads: 30
timeout: 30
prompt: !ruby/regexp /^([\w.@-]+[#>]\s?)$/
rest: 127.0.0.1:8888
vars: {}
groups: {}
remove_secret: false
input:
  default: ssh
  debug: /home/sts/.config/oxidized/input.log
  ssh:
    secure: true
output:
  default: file
  file:
    directory: /home/sts/.config/oxidized/configs
source:
  default: csv
  csv:
    file: /home/sts/.config/oxidized/router.db
    delimiter: !ruby/regexp /:/
    map:
      name: 0
      model: 1
      username: 2
model_map:
  cisco: ios
  juniper: junos

@ytti
Copy link
Owner

ytti commented Oct 22, 2014

Try

vars:
enable: 'foof'

I don't think the old way is supported anymore. The vars is now used as it supports multiple levels (global, per-group, per-node)

@sts
Copy link
Contributor Author

sts commented Oct 22, 2014

Yes that worked! Documentation should be updated regarding this (also include the debug tip!). Also an example for setting it per item would be cool. Thanks!

@ytti
Copy link
Owner

ytti commented Oct 22, 2014

Yeah documents leave lot to be desired right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants