iosparse 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.md +17 -11
  2. data/iosparse.gemspec +2 -2
  3. data/lib/iosparse.rb +1 -1
  4. metadata +2 -2
data/README.md CHANGED
@@ -1,29 +1,35 @@
1
1
  IOSParse will parse Cisco IOS configuration files, more functionality coming.
2
2
 
3
3
  # How do I use it?
4
- Good question. First install it using `gem install iosparse`. Then use it. Create a new IOSParse object passing it the filename of the Cisco IOS config file (usually a show all type of dump file, I have included a mock config spec/etc/cisco_asa.config). Then ask it questions:
4
+ Good question. First install it using `gem install iosparse`. Then use it. Create a new IOSParse object passing it the filename of the Cisco IOS config file (usually a show all type of dump file, I have included a mock config spec/etc/cisco_asa.config). Then play:
5
5
 
6
6
  ````
7
7
  config = IOSParse.new('path/to/ios.conf')
8
+
8
9
  puts config.find_all('interface')
9
- ````
10
- ````
11
10
  Output:
12
-
13
11
  [0] => interface GigabitEthernet0/0\n description PHYSICAL_INTERFACE_0\n no nameif\n no security-level\n no ip address
14
12
  [1] => interface GigabitEthernet0/0.74\n description VIRTUAL_INTERFACE_0.74\n vlan 74\n nameif INTERNAL\n security-level 70\n ip address 192.168.1.3 255.255.255.0 standby 10.10.1.3
15
13
  [2] => interface GigabitEthernet0/0.82\n description VIRTUAL_INTERFACE_0.82\n vlan 82\n nameif DMZ\n security-level 30\n ip address 192.168.1.4 255.255.255.0 standby 10.10.1.4
16
14
  [3] => interface GigabitEthernet0/0.83\n description VIRTUAL_INTERFACE_0.83\n vlan 83\n nameif WEB\n security-level 30\n ip address 192.168.1.5 255.255.255.0 standby 10.10.1.5
17
15
  [4] => interface GigabitEthernet0/1\n description PHYSICAL_INTERFACE_1\n no nameif\n no security-level\n no ip address
18
- ````
19
16
 
17
+ puts config.has("192.168.1.2")
18
+ Output:
19
+ [0] => name 192.168.1.2 CISCOASA02
20
+ [1] => static (VLAN_03,VLAN_04) tcp 192.168.1.2 smtp access-list SOME_GROUP_02
21
+ [2] => static (VLAN_09,VLAN_10) 192.168.1.1 192.168.1.2 netmask 255.255.255.255
22
+ [3] => ssh 192.168.1.2 255.255.255.0 WWW
23
+
24
+ puts config.group_has_ip("10.10.15.100")
25
+ Output:
26
+ [0] => object-group network NETWORK_GROUP_03
27
+ ````
20
28
  All objects returned are arrays that can be further manipulated and parsed. "Human readable" format coming soon, maybe even a CLI. Please note the mock Cisco ASA config file in the spec test is completely fabricated and is not intended to be a correct configuration, it is only to be used for it's syntax.
21
29
 
22
- All '\n' are injected as delimiters to show where children lines separate from the parent and inteded to be used for easy String#gsub to parse and print in other formats. Feel free to look at the documentation link on the <a href="http://rubygems.org/gems/iosparse">rubygems</a> site.
30
+ All '\n' are injected as delimiters to show where children lines separate from the parent and are inteded to be used for String#gsub-like methods to parse and print. Feel free to look at the documentation link on the <a href="http://rubygems.org/gems/iosparse">rubygems</a> site.
23
31
 
24
32
  Current methods:
25
- ````
26
- find_all() is used to find all specific rules, interface, object-group, route, name, etc.
27
- has() is used to find any rule that includes a specific string like an IP or a group name.
28
- group_has_ip() returns group(s) that include a specific IP (doesn't sanitize input).
29
- ````
33
+ `find_all` is used to find all specific rules, interface, object-group, route, name, etc.
34
+ `has` is used to find any rule that includes a specific string like an IP or a group name.
35
+ `group_has_ip` returns group(s) that include a specific IP (doesn't sanitize input).
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "iosparse"
5
- s.version = "0.0.9"
5
+ s.version = "0.1.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ari Mizrahi"]
9
- s.date = "2013-05-09"
9
+ s.date = "2013-07-02"
10
10
  s.description = "Parse Cisco IOS configurations"
11
11
  s.email = "codemunchies@gmail.com"
12
12
  s.files = ["lib/iosparse.rb", "iosparse.gemspec", "Gemfile", "README.md", "LICENSE"]
@@ -57,7 +57,7 @@ class IOSParse
57
57
 
58
58
  # Load Cisco 'show all' dump
59
59
  def load_config(filename)
60
- @config = File.open(filename, 'r')
60
+ @config = File.open(filename, 'r:ascii-8bit')
61
61
  serialize
62
62
  load_yaml
63
63
  clean_up
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iosparse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-09 00:00:00.000000000 Z
12
+ date: 2013-07-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Parse Cisco IOS configurations
15
15
  email: codemunchies@gmail.com