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

Fixes #751 - IPv6 support for Cisco ASA 'show vpn-sessiondb anyconnect' #752

Merged
merged 1 commit into from
Jun 8, 2020

Conversation

smfeldman
Copy link
Contributor

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT

Cisco ASA "show vpn session-db anyconnect"

SUMMARY
  • Adjust template to support IPv6 addresses in command output:
    • Allow IPv6 Public IP address
    • Parse Assigned IPv6 line
  • Add test files with IPv6 addresses
  • Add the new assigned_ipv6 field to existing test output files

Before:

Python 3.7.4 (default, Sep  7 2019, 18:29:04)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ntc_templates.parse import parse_output
>>> from pprint import pprint
>>> with open("/tmp/cisco_asa_show_vpn-sessiondb_anyconnect_ipv6.raw", "r") as f:
...     data = f.read()
...
>>> pprint(parse_output(platform="cisco_asa", command="show vpn-sessiondb anyconnect", data=data))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/feldman/NetEng/asa-ip/ntc-templates/lib/ntc_templates/parse.py", line 35, in parse_output
    cli_table.ParseCmd(data, attrs)
  File "/Users/feldman/NetEng/asa-ip/venv/lib/python3.7/site-packages/textfsm/clitable.py", line 282, in ParseCmd
    self.table = self._ParseCmdItem(self.raw, template_file=template_files[0])
  File "/Users/feldman/NetEng/asa-ip/venv/lib/python3.7/site-packages/textfsm/clitable.py", line 315, in _ParseCmdItem
    for record in fsm.ParseText(cmd_input):
  File "/Users/feldman/NetEng/asa-ip/venv/lib/python3.7/site-packages/textfsm/parser.py", line 895, in ParseText
    self._CheckLine(line)
  File "/Users/feldman/NetEng/asa-ip/venv/lib/python3.7/site-packages/textfsm/parser.py", line 944, in _CheckLine
    if self._Operations(rule, line):
  File "/Users/feldman/NetEng/asa-ip/venv/lib/python3.7/site-packages/textfsm/parser.py", line 1025, in _Operations
    % (rule.line_num, line))
textfsm.parser.TextFSMError: State Error raised. Rule Line: 52. Input Line: Assigned IP  : 10.10.123.123          Public IP    : 2001:db8:91::7

After:

Python 3.7.4 (default, Sep  7 2019, 18:29:04)
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ntc_templates.parse import parse_output
>>> from pprint import pprint
>>> with open("/tmp/cisco_asa_show_vpn-sessiondb_anyconnect_ipv6.raw", "r") as f:
...     data = f.read()
...
>>> pprint(parse_output(platform="cisco_asa", command="show vpn-sessiondb anyconnect", data=data))
[{'assigned_ip': '10.10.123.123',
  'assigned_ipv6': '2001:DB8:1234:1::5678',
  'audt_sess_id': '0a0edc05097bf0005ed99c3c',
  'bytes_rx': '58022385',
  'bytes_tx': '3145031268',
  'duration': '4h:55m:35s',
  'encryption': 'AnyConnect-Parent: (1)none  SSL-Tunnel: (1)AES-GCM-256  '
                'DTLS-Tunnel: (1)AES-GCM-256',
  'group_policy': 'RAVPN',
  'hashing': 'AnyConnect-Parent: (1)none  SSL-Tunnel: (1)SHA384  DTLS-Tunnel: '
             '(1)SHA384',
  'inactivity': '0h:00m:00s',
  'index': '38847',
  'license': 'AnyConnect Premium',
  'login_day': '5',
  'login_month': 'Jun',
  'login_time': '01:13:32',
  'login_time_zone': 'UTC',
  'login_weekday': 'Fri',
  'login_year': '2020',
  'protocol': 'AnyConnect-Parent SSL-Tunnel DTLS-Tunnel',
  'public_ip': '2001:db8:91::7',
  'security_grp': 'none',
  'session_type': 'AnyConnect',
  'tunnel_group': 'RAVPN',
  'username': 'johndoe12',
  'vlan': 'none',
  'vlan_mapping': 'N/A'}]

@FragmentedPacket FragmentedPacket merged commit 51187bf into networktocode:master Jun 8, 2020
@smfeldman smfeldman deleted the issue751 branch June 9, 2020 23:16
thomasblass pushed a commit to thomasblass/ntc-templates that referenced this pull request Oct 25, 2020
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

Successfully merging this pull request may close these issues.

2 participants