Skip to content

Instantly share code, notes, and snippets.

@justincjahn
Created March 24, 2018 00:04
Show Gist options
  • Save justincjahn/b185969294581dce83bec731fa3c2dee to your computer and use it in GitHub Desktop.
Save justincjahn/b185969294581dce83bec731fa3c2dee to your computer and use it in GitHub Desktop.
Oxidized NCM: PANOS XML Model
class PanOS < Oxidized::Model
# PaloAlto PAN-OS model #
# Modified by https://github.com/justinjahn to output XML from CLI instead of JSON
comment '! '
prompt /^[\w.\@:\(\)-]+[#>]\s?$/
cmd :all do |cfg|
cfg.each_line.to_a[2..-3].join
end
cmd 'show system info' do |cfg|
cfg.gsub! /^(up)?time:\ .*$/, ''
cfg.gsub! /^app-.*?:\ .*$/, ''
cfg.gsub! /^av-.*?:\ .*$/, ''
cfg.gsub! /^threat-.*?:\ .*$/, ''
cfg.gsub! /^wildfire-.*?:\ .*$/, ''
cfg.gsub! /^wf-private.*?:\ .*$/, ''
cfg.gsub! /^url-filtering.*?:\ .*$/, ''
cfg.gsub! /^global-.*?:\ .*$/, ''
comment cfg
end
cmd 'configure' do |cfg|
cmd 'show' do |showconfig|
cfg = showconfig
end
send "quit\n"
cfg
end
cfg :ssh do
post_login 'set cli pager off'
post_login 'set cli config-output-format xml'
pre_logout 'quit'
end
end
@justincjahn
Copy link
Author

The Oxidized folks are working on a way to use the Web API to pull this, but i'm lazy. See ytti/oxidized#440 for more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment