CiscoTestAutomation / genieparser

sub-component of Genie that parse the device output into structured datastructure
Apache License 2.0
251 stars 388 forks source link

ASA: 'show version' 1 CPU not matched #758

Closed timetoautomate closed 1 year ago

timetoautomate commented 1 year ago

Issue

The ASA parser for show version does not match on ASA hardware with one (1) CPU due to the regex +CPUs on line 127.

For example, the following line from the RAW CLI output of an ASA5555 is not matched (full output below).

# Hardware: ASA5555, 16384 MB RAM, CPU Lynnfield 2800 MHz, 1 CPU (8 cores)

Testing Result

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "src/genie/conf/base/device.py", line 531, in genie.conf.base.device.Device.parse
  File "src/genie/conf/base/device.py", line 581, in genie.conf.base.device.Device._get_parser_output
  File "src/genie/metaparser/_metaparser.py", line 342, in genie.metaparser._metaparser.MetaParser.parse
  File "src/genie/metaparser/_metaparser.py", line 322, in genie.metaparser._metaparser.MetaParser.parse
  File "src/genie/metaparser/util/schemaengine.py", line 419, in genie.metaparser.util.schemaengine.Schema.validate
genie.metaparser.util.exceptions.SchemaMissingKeyError: Missing keys: [['version', 'mem_size'], ['version', 'platform'], ['version', 'processor_type']]

RAW CLI Output

fw09# show version

Cisco Adaptive Security Appliance Software Version 9.14(2)14
SSP Operating System Version 2.8(1.148)
Device Manager Version 7.16(1)150

Compiled on Wed 14-Apr-21 05:25 GMT by builders
System image file is "disk0:/asa9-14-2-14-smp-k8.bin"
Config file at boot was "startup-config"

fw09 up 16 days 14 hours

Hardware:   ASA5555, 16384 MB RAM, CPU Lynnfield 2800 MHz, 1 CPU (8 cores)
            ASA: 8575 MB RAM, 1 CPU (2 cores)
Internal ATA Compact Flash, 8192MB
BIOS Flash MX25L6445E @ 0xffbb0000, 8192KB

Encryption hardware device : Cisco ASA Crypto on-board accelerator (revision 0x1)
                             Boot microcode        : CNPx-MC-BOOT-2.00
                             SSL/IKE microcode     : CNPx-MC-SSL-SB-PLUS-0005
                             IPSec microcode       : CNPx-MC-IPSEC-MAIN-0026
                             Number of accelerators: 1
Baseboard Management Controller (revision 0x1) Firmware Version: 2.4

 0: Int: Internal-Data0/0    : address is d8b1.9041.5c41, irq 11
 1: Ext: GigabitEthernet0/0  : address is d8b1.9041.5c46, irq 5
 2: Ext: GigabitEthernet0/1  : address is d8b1.9041.5c42, irq 5
 3: Ext: GigabitEthernet0/2  : address is d8b1.9041.5c47, irq 10
 4: Ext: GigabitEthernet0/3  : address is d8b1.9041.5c43, irq 10
 5: Ext: GigabitEthernet0/4  : address is d8b1.9041.5c48, irq 5
 6: Ext: GigabitEthernet0/5  : address is d8b1.9041.5c44, irq 5
 7: Ext: GigabitEthernet0/6  : address is d8b1.9041.5c49, irq 10
 8: Ext: GigabitEthernet0/7  : address is d8b1.9041.5c45, irq 10
 9: Int: Internal-Data0/1    : address is 0000.0001.0002, irq 0
10: Int: Internal-Control0/0 : address is 0000.0001.0001, irq 0
11: Int: Internal-Data0/2    : address is 0000.0001.0003, irq 0
12: Ext: Management0/0       : address is d8b1.9041.5c41, irq 0
13: Int: Internal-Data0/3    : address is 0000.0100.0001, irq 0

Licensed features for this platform:
Maximum Physical Interfaces       : Unlimited      perpetual
Maximum VLANs                     : 500            perpetual
Inside Hosts                      : Unlimited      perpetual
Failover                          : Active/Active  perpetual
Encryption-DES                    : Enabled        perpetual
Encryption-3DES-AES               : Enabled        perpetual
Security Contexts                 : 2              perpetual
Carrier                           : Disabled       perpetual
AnyConnect Premium Peers          : 2              perpetual
AnyConnect Essentials             : Disabled       perpetual
Other VPN Peers                   : 5000           perpetual
Total VPN Peers                   : 5000           perpetual
AnyConnect for Mobile             : Disabled       perpetual
AnyConnect for Cisco VPN Phone    : Disabled       perpetual
Advanced Endpoint Assessment      : Disabled       perpetual
Shared License                    : Disabled       perpetual
Total TLS Proxy Sessions          : 2              perpetual
Botnet Traffic Filter             : Disabled       perpetual
IPS Module                        : Disabled       perpetual
Cluster                           : Enabled        perpetual
Cluster Members                   : 2              perpetual

This platform has an ASA5555 VPN Premium license.

Serial Number: A0000000000
Running Permanent Activation Key: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
Configuration register is 0x1

Image type          : Release
Key version         : A

Configuration last modified by cisco at 08:09:56.229 UTC Sat Jun 3 2023

Version

genie==23.5
genie.libs.clean==23.5
genie.libs.conf==23.5
genie.libs.filetransferutils==23.5
genie.libs.health==23.5
genie.libs.ops==23.5
genie.libs.parser==23.5
genie.libs.sdk==23.5
pyats==23.5
pyats.aereport==23.5
pyats.aetest==23.5
pyats.async==23.5
pyats.connections==23.5
pyats.datastructures==23.5
pyats.easypy==23.5
pyats.kleenex==23.5
pyats.log==23.5
pyats.reporter==23.5
pyats.results==23.5
pyats.tcl==23.5
pyats.topology==23.5
pyats.utils==23.5

Minor Adjustment

Perhaps the following will account for platforms with and without CPU/core quantities. Will add PR if approved.

        # Hardware:   ASAv, 2048 MB RAM, CPU Xeon E5 series 3491 MHz
        # Hardware:   FPR9K-SM-24, 230696 MB RAM, CPU Xeon E5 series 2200 MHz, 2 CPUs (48 cores)
+       # Hardware:   ASA5555, 16384 MB RAM, CPU Lynnfield 2800 MHz, 1 CPU (8 cores)
        p7 = re.compile(r'^Hardware:\s+(?P<platform>\S+),\s+(?P<mem_size>[\w\s]+) RAM,'
                        r'\s+CPU (?P<processor_type>[\w\s]+),? ?((?P<cpu_count>\d+)'
-                       r' +CPUs +\((?P<core_count>\d+) cores\))?$')
+                       r' +CPUs? +\((?P<core_count>\d+) cores\))?$')

Structured Data

{"version": {"asa_version": "9.14(2)14",
             "asdm_version": "7.16(1)150",
             "bios_flash": "MX25L6445E @ 0xffbb0000, 8192KB",
             "boot_config_file": "startup-config",
             "compiled_by": "builders",
             "compiled_date": "Wed 14-Apr-21 05:25 GMT",
             "core_count": 8,
             "cpu_count": 1,
             "disks": {"Internal": {"disk_size": "8192MB",
                                    "type_of_disk": "ATA Compact Flash"}},
             "encryption_hardware": {"boot_microcode": "CNPx-MC-BOOT-2.00",
                                     "encryption_device": "Cisco ASA Crypto "
                                                          "on-board "
                                                          "accelerator "
                                                          "(revision 0x1)",
                                     "ipsec_microcode": "CNPx-MC-IPSEC-MAIN-0026",
                                     "ssl_ike_microcode": "CNPx-MC-SSL-SB-PLUS-0005"},
             "firepower_version": "2.8(1.148)",
             "hostname": "fw09",
             "image_type": "Release",
             "interfaces": {"1": {"interface": "GigabitEthernet0/0",
                                "intf_irq": 5,
                                "mac_addr": "d8b1.9041.5c46"},
                            "2": {"interface": "GigabitEthernet0/1",
                                "intf_irq": 5,
                                "mac_addr": "d8b1.9041.5c42"},
                            "3": {"interface": "GigabitEthernet0/2",
                                "intf_irq": 10,
                                "mac_addr": "d8b1.9041.5c47"},
                            "4": {"interface": "GigabitEthernet0/3",
                                "intf_irq": 10,
                                "mac_addr": "d8b1.9041.5c43"},
                            "5": {"interface": "GigabitEthernet0/4",
                                "intf_irq": 5,
                                "mac_addr": "d8b1.9041.5c48"},
                            "6": {"interface": "GigabitEthernet0/5",
                                "intf_irq": 5,
                                "mac_addr": "d8b1.9041.5c44"},
                            "7": {"interface": "GigabitEthernet0/6",
                                "intf_irq": 10,
                                "mac_addr": "d8b1.9041.5c49"},
                            "8": {"interface": "GigabitEthernet0/7",
                                "intf_irq": 10,
                                "mac_addr": "d8b1.9041.5c45"},
                            "12": {"interface": "Management0/0",
                                 "intf_irq": 0,
                                 "mac_addr": "d8b1.9041.5c41"}},
             "key_version": "A",
             "last_modified_by": "cisco",
             "last_modified_date": "08:09:56.229 UTC Sat Jun 3 2023",
             "licensed_features": {"advanced_endpoint_assessment": {"status": "Disabled",
                                                                    "time_remaining": "perpetual"},
                                   "anyconnect_essentials": {"status": "Disabled",
                                                             "time_remaining": "perpetual"},
                                   "anyconnect_for_cisco_vpn_phone": {"status": "Disabled",
                                                                      "time_remaining": "perpetual"},
                                   "anyconnect_for_mobile": {"status": "Disabled",
                                                             "time_remaining": "perpetual"},
                                   "anyconnect_premium_peers": {"status": "2",
                                                                "time_remaining": "perpetual"},
                                   "botnet_traffic_filter": {"status": "Disabled",
                                                             "time_remaining": "perpetual"},
                                   "crypto_3des_aes": {"status": "Enabled",
                                                       "time_remaining": "perpetual"},
                                   "crypto_des": {"status": "Enabled",
                                                  "time_remaining": "perpetual"},
                                   "failover": {"status": "Active/Active",
                                                "time_remaining": "perpetual"},
                                   "inside_hosts": {"status": "Unlimited",
                                                    "time_remaining": "perpetual"},
                                   "max_physical_interfaces": {"status": "Unlimited",
                                                               "time_remaining": "perpetual"},
                                   "max_vlans": {"status": "500",
                                                 "time_remaining": "perpetual"},
                                   "other_vpn_peers": {"status": "5000",
                                                       "time_remaining": "perpetual"},
                                   "security_contexts": {"status": "2",
                                                         "time_remaining": "perpetual"},
                                   "shared_license": {"status": "Disabled",
                                                      "time_remaining": "perpetual"},
                                   "total_vpn_peers": {"status": "5000",
                                                       "time_remaining": "perpetual"}},
             "mem_size": "16384 MB",
             "platform": "ASA5555",
             "processor_type": "Lynnfield 2800 MHz",
             "serial_number": "A0000000000",
             "system_image": "disk0:/asa9-14-2-14-smp-k8.bin",
             "uptime": "16 days 14 hours"}}
iamsatyanarayan commented 1 year ago

Hi @timetoautomate I will be working on your ticket. I'll get back to you once I have any update on it.

iamsatyanarayan commented 1 year ago

Hi @timetoautomate PR raised for your issue. I will update you after merge.

iamsatyanarayan commented 1 year ago

HI @timetoautomate , PR has been merged. It will reflect in next release.

iamsatyanarayan commented 1 year ago

Hi @timetoautomate The latest version has been released kindly upgrade to 23.8 and confirm.

iamsatyanarayan commented 1 year ago

Hi @timetoautomate , Could you please provide any update on your issue ?

timetoautomate commented 1 year ago

@iamsatyanarayan, confirmed. show version is now matching one (1) CPU with 23.8 using ASA5555s. Thanks!

iamsatyanarayan commented 1 year ago

Hi @timetoautomate , Thanks for your confirmation.