Class: ASA

Inherits:
Oxidized::Model show all
Defined in:
lib/oxidized/model/asa.rb

Instance Attribute Summary

Attributes inherited from Oxidized::Model

#input, #node

Instance Method Summary collapse

Methods inherited from Oxidized::Model

cfg, #cfg, cfgs, cmd, #cmd, cmds, comment, #comment, expect, #expect, expects, #expects, #get, inherited, #output, post, pre, prompt, #prompt, #screenscrape, #send

Methods included from Oxidized::Config::Vars

#vars

Instance Method Details

#multiple_contextObject



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/oxidized/model/asa.rb', line 87

def multiple_context
  # Multiple context mode
  cmd 'changeto system' do |cfg|
    cmd 'show running-config' do |systemcfg|
      allcfg = "\n\n" + systemcfg + "\n\n"
      contexts = systemcfg.scan(/^context (\S+)$/)
      files = systemcfg.scan(/config-url (\S+)$/)
      contexts.each_with_index do |cont, i|
        allcfg = allcfg + "\n\n----------========== [ CONTEXT " + cont.join(" ") + " FILE " + files[i].join(" ") + " ] ==========----------\n\n"
        cmd "more " + files[i].join(" ") do |cfgcontext|
          allcfg = allcfg + "\n\n" + cfgcontext
        end
      end
      cfg = allcfg
    end
    cfg
  end
end

#single_contextObject



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/oxidized/model/asa.rb', line 63

def single_context
  # Single context mode
  cmd 'more system:running-config' do |cfg|
    cfg = cfg.each_line.to_a[3..-1].join
    cfg.gsub! /^: [^\n]*\n/, ''
    # backup any xml referenced in the configuration.
    anyconnect_profiles = cfg.scan(Regexp.new('(\sdisk0:/.+\.xml)')).flatten
    anyconnect_profiles.each do |profile|
      cfg << (comment profile + "\n")
      cmd("more" + profile) do |xml|
        cfg << (comment xml)
      end
    end
    # if DAP is enabled, also backup dap.xml
    if cfg.rindex(/dynamic-access-policy-record\s(?!DfltAccessPolicy)/)
      cfg << (comment "disk0:/dap.xml\n")
      cmd "more disk0:/dap.xml" do |xml|
        cfg << (comment xml)
      end
    end
    cfg
  end
end