ytti / oxidized

Oxidized is a network device configuration backup tool. It's a RANCID replacement!
Apache License 2.0
2.78k stars 920 forks source link

Assitance: Creating a model for Dell Vertex aka vrtx #2078

Closed graceless70 closed 1 year ago

graceless70 commented 4 years ago

Hello,

I have installed oxidized and have it successfully backup equipment using ftos, junos, os10, fortios among others.

I have search around and read Creating-Models.md, I am wanting to backup a Dell Vertex (aka vrtx) 10G Switch Module.

https://downloads.dell.com/manuals/all-products/esuprt_ser_stor_net/esuprt_poweredge/poweredge-vrtx_reference%20guide8_en-us.pdf

The switch is a bit basic.

I have bashed around a created the following model. It only sort of works and is full of workarounds so would like some help...

*** Start of model **** class VRTX < Oxidized::Model

DELL Vertex VRTX model

prompt /^(\e[\??\d+(;\d+)[A-Za-z])*([\w\s]+):$/

prompt /^([[]\w\s.@-]+[#:>]\s?)$/

Should be this once logged in

prompt /^[A-Z,a-z,\d-]*#$/

comment '! '

cmd :all do |cfg| cfg.gsub! /[A-Z,a-z,\d-]*#/, '' # Remove Prompt from output cfg.cut_both cfg end

cmd :secret do |cfg| cfg.gsub! /^(snmp-server community)./, '\1 ' cfg.gsub! /(secret \d {0,1})\S+(.)/, '\1)/, '\1

cmd 'show system' do |cfg|

cfg.gsub! /^(System Up Time).*/, ''
cfg.gsub! /^(\s*Unit\s*Temperature).*/, ''     # *Remove temperature table heading
cfg.gsub! /^((\-{24}\s){2}\-{24}).*$/, ''      # Remove temperature table line
cfg.gsub! /^(\s{10,11}\d).*/, ''               # Remove temperature table values
comment cfg.lines.to_a[5..-5].join

end

cmd 'show version' do |cfg| cfg.gsub! /^(show version).*/, ' Versions ' # Remove command cfg.gsub! /(SW\s*version)./, '! \1 \2' # comment mark missing on first line comment cfg end

cmd 'show running-config' do |cfg| cfg.gsub! /^(show running-config).*/, '!' + "\n" + '! Running-Config ' # Remove command cfg end

cfg :telnet, :ssh do

the switch blindy accepts the SSH connection without password validation and then spawns a telnet login prompt

# first thing we've to send is something maybe
username /^User name:/

username /^(\e[\??\d+(;\d+)[A-Za-z])*User Name:/i

password /^Password:/

post_login do
  send @node.auth[:username] + "\n"
  expect /[pP]assword:$/
  send @node.auth[:password] + "\n"
  send 'terminal datadump' + "\n"
   send 'terminal width 0' + "\n"
end

pre_logout do
  send "\n"                                 # Carriage Returns to try and get prompt back before exit
  send "\n"
  send "\n"
  send "\n"
  send "\n"
  send "\n"
  send "\n"
  send "\n"
  send 'exit' + "\n"
end

end end

*** end of model ****

This is a less (redacted and reduced) output from the ssh log (Start and end )

** Start ***

^M

User Name:oxidized ^MPassword:** ^Mterminal datadump ^Mterminal width 0 ^Mshow system ^M

SWITCH#SWITCH#SWITCH#System Description: R1-2210 VRTX 10Gb Switch System Type: R1-2210 System Up Time (days,hour:min:sec): 00,03:32:12 System Contact: US System Name: SWITCH System Location: Someplace System MAC Address: e4:f0:04:01:01:01 System Object ID: 1.3.6.1.4.1.674.10895.3062

      Unit            Temperature (Celsius)            Status

       1                        55                       OK

SWITCH#show running-config ^Mconfig-file-header SWITCH v2.0.0.78 / RPLASMA_800_007 CLI v1.0 @ port jumbo-frame vlan database vlan 2,3,5-6,9-15,20-21,96,100,816 exit voice vlan oui-table add 000181 Nortel__ voice vlan oui-table add 0001e3 Siemens_AG_phone____ voice vlan oui-table add 00036b Ciscophone____ voice vlan oui-table add 00096e Avaya_____ voice vlan oui-table add 000fe2 H3C_Aolynk voice vlan oui-table add 001049 Shoretel____ voice vlan oui-table add 0060b9 Philips_and_NEC_AG_phone voice vlan oui-table add 00907a Polycom/Veritel_phone_ voice vlan oui-table add 00e0bb 3Com_phone____ hostname SWITCH

. . . Redacted . . .

interface tengigabitethernet4/2 switchport mode trunk ! interface tengigabitethernet4/3 switchport mode trunk ! interface tengigabitethernet4/4 switchport mode trunk ! interface Port-channel1 switchport mode trunk ! interface oob ip address 192.168.1.3 255.255.255.0 no ip address dhcp sntp client enable ! exit ip default-gateway 192.168.1.1

Default settings: Service tag:

SW version 2.0.0.78 (date 29-Jan-2020 time 21:43:17)

Gigabit Ethernet Ports

no shutdown speed 1000 duplex full negotiation flow-control on mdix auto no back-pressure

interface vlan 1 interface port-channel 1 - 32

spanning-tree spanning-tree mode RSTP ^M ^M ^M ^M ^M ^M ^M ^M ^M ^Mexit

** end ***

Issues/Questions Looking for help with: 1) How does the username password prompt/response work (aka why isn't it working for me)

2) How/when is 'prompt' refereed to? Is it at the beginning, or is is login prompt, or once logged into the device? The one I have created seemed to need to include the ESC CHAR's before and including "User Name:", where as when looking at other models it seems to be just the prompt once logged in.

3) The backup file being generated is being truncated at the end somewhere after the output of "Default Settings", it is inconsistent where it is truncated Note: I added the extra carriage returns at the end to try and deal with this truncation.

Whats the difference between the ^M and a standard new line (nothing on the line)?

4) I'm not a dev, can someone explain - how do the numbers in "cfg.each_line.to_a[1..-0].join", work?

Can you please help/enhance?

Regards to all

graceless70 commented 4 years ago

Interestingly the writes into gitlab show there "\ No newline at end of file"

https://ibb.co/WPQqvRt

mortzu commented 2 years ago

Can you please reformat your paste to make it readable? (https://docs.github.com/en/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#quoting-code)