dmulyalin / nornir-salt

MIT License
9 stars 3 forks source link

Unable to get structured data using genie for Cisco ASA #5

Closed abhi1693 closed 2 years ago

abhi1693 commented 2 years ago

I'm not sure if the issue is from this repository. Please let me know if I need to open this elsewhere.

The command I'm using is

salt asa_proxy nr.cli 'show version' FB=ASA1 use_genie=True

As per the docs from genie available parsers, show version is supported: https://developer.cisco.com/docs/genie-docs/

Name: salt-nornir
Version: 0.12.0
Summary: Salt-Nornir Proxy Minion SaltStack Modules
Home-page: https://github.com/dmulyalin/salt-nornir
Author: Denis Mulyalin
Author-email: d.mulyalin@gmail.com
License: MIT
Location: /usr/local/lib/python3.8/dist-packages
Requires: nornir-salt, pydantic, nornir
Required-by: 

_Note: use_genie works for IOS devices_

abhi1693 commented 2 years ago

Based on this: https://github.com/CiscoTestAutomation/genieparser/issues/414#issuecomment-816708946, I'm able to get the structured result

abhi1693 commented 2 years ago

@dmulyalin do you have any insight for this issue? I'd like to close this to finalize a PR I've for a fix. I want to also ensure that this is the only way in case the issue did not arise from this repo.

dmulyalin commented 2 years ago

It seems that Netmiko does not enlist PyATS and Genie as its main dependencies. Specifying use_genie=True would not work unless PyATS and Genie installed on the system, one of the ways to install them would be to use salt-nornir install-extras prodmax or pyats:

pip install salt-nornir[prodmax]
or
pip install salt-nornir[pyats]

or install PyATS and Genie directly - which is what aforementioned workaround doing: pip install --upgrade pyats, genie

abhi1693 commented 2 years ago

I'm already using the prodmax install but still got the above issue

dmulyalin commented 2 years ago

Hmm, that is strange, as prodmax extras pulls PyATS and Genie of version 22.1, while version suggested that it works is of 21.3.1, wondering if need to do pyats[full] install to make it work.

I have no access to ASA to test it by myself, would you be able to run this install and give it a go:

python3 -m pip install --upgrade pyats[full]==22.1
python3 -m pip install --upgrade genie[full]==22.1
abhi1693 commented 2 years ago

Using your commands, it still works. Here are the relevant lines from pip install

Installing collected packages: pyats.contrib, pyats.robot, genie.telemetry, genie.trafficgen, genie.libs.robot
  Attempting uninstall: pyats.contrib
    Found existing installation: pyats.contrib 22.6
    Uninstalling pyats.contrib-22.6:
      Successfully uninstalled pyats.contrib-22.6
  Attempting uninstall: pyats.robot
    Found existing installation: pyats.robot 22.6
    Uninstalling pyats.robot-22.6:
      Successfully uninstalled pyats.robot-22.6
  Attempting uninstall: genie.telemetry
    Found existing installation: genie.telemetry 22.6
    Uninstalling genie.telemetry-22.6:
      Successfully uninstalled genie.telemetry-22.6
  Attempting uninstall: genie.trafficgen
    Found existing installation: genie.trafficgen 22.6
    Uninstalling genie.trafficgen-22.6:
      Successfully uninstalled genie.trafficgen-22.6
  Attempting uninstall: genie.libs.robot
    Found existing installation: genie.libs.robot 22.6
    Uninstalling genie.libs.robot-22.6:
      Successfully uninstalled genie.libs.robot-22.6
Successfully installed genie.libs.robot-22.1 genie.telemetry-22.1 genie.trafficgen-22.1 pyats.contrib-22.1 pyats.robot-22.1

Here is the result from the ASA that wasn't working (Note: This is a simulated ASA running inside EVE-NG hosted on cloudmylab.com)

{
  "version":{
    "asa_version":"9.15(1)1",
    "firepower_version":"2.9(1.131)",
    "asdm_version":"7.15(1)",
    "compiled_date":"Fri 20-Nov-20 18:48 GMT",
    "compiled_by":"builders",
    "system_image":"boot:/asa9151-1-smp-k8.bin",
    "boot_config_file":"startup-config",
    "hostname":"ASA-NB-TEST",
    "uptime":"3 days 16 hours",
    "platform":"ASAv",
    "mem_size":"2048 MB",
    "processor_type":"Xeon E5 series 2800 MHz",
    "disks":{
      "Internal":{
        "disk_size":"8192MB",
        "type_of_disk":"ATA Compact Flash"
      },
      "Slot 1":{
        "disk_size":"8192MB",
        "type_of_disk":"ATA Compact Flash"
      }
    },
    "bios_flash":"Firmware Hub @ 0x0, 0KB",
    "interfaces":{
      "0":{
        "interface":"Management0/0",
        "mac_addr":"5000.0003.0000",
        "intf_irq":11
      },
      "1":{
        "interface":"GigabitEthernet0/0",
        "mac_addr":"5000.0003.0001",
        "intf_irq":11
      },
      "2":{
        "interface":"GigabitEthernet0/1",
        "mac_addr":"5000.0003.0002",
        "intf_irq":10
      },
      "3":{
        "interface":"GigabitEthernet0/2",
        "mac_addr":"5000.0003.0003",
        "intf_irq":10
      },
      "4":{
        "interface":"GigabitEthernet0/3",
        "mac_addr":"5000.0003.0004",
        "intf_irq":11
      },
      "5":{
        "interface":"GigabitEthernet0/4",
        "mac_addr":"5000.0003.0005",
        "intf_irq":11
      },
      "6":{
        "interface":"GigabitEthernet0/5",
        "mac_addr":"5000.0003.0006",
        "intf_irq":10
      },
      "7":{
        "interface":"GigabitEthernet0/6",
        "mac_addr":"5000.0003.0007",
        "intf_irq":10
      }
    },
    "license_mode":"Smart Licensing",
    "license_state":"Unlicensed",
    "entitlement":"no feature tier and no throughput level configured",
    "licensed_features":{
      "max_vlans":{
        "status":"50"
      },
      "inside_hosts":{
        "status":"Unlimited"
      },
      "failover":{
        "status":"Active/Active"
      },
      "crypto_des":{
        "status":"Enabled"
      },
      "crypto_3des_aes":{
        "status":"Enabled"
      },
      "security_contexts":{
        "status":"2"
      },
      "carrier":{
        "status":"Disabled"
      },
      "anyconnect_premium_peers":{
        "status":"2"
      },
      "anyconnect_essentials":{
        "status":"Disabled"
      },
      "other_vpn_peers":{
        "status":"250"
      },
      "total_vpn_peers":{
        "status":"250"
      },
      "anyconnect_for_mobile":{
        "status":"Disabled"
      },
      "anyconnect_for_cisco_vpn_phone":{
        "status":"Disabled"
      },
      "advanced_endpoint_assessment":{
        "status":"Disabled"
      },
      "shared_license":{
        "status":"Disabled"
      },
      "total_tls_proxy_sessions":{
        "status":"2"
      },
      "botnet_traffic_filter":{
        "status":"Enabled"
      },
      "cluster":{
        "status":"Disabled"
      }
    },
    "serial_number":"9ATHR9HPXJV",
    "image_type":"Release",
    "key_version":"A",
    "last_modified_by":"enable_15",
    "last_modified_date":"12:47:41.032 UTC Sat Jul 16 2022"
  }
}
dmulyalin commented 2 years ago

Released nornir-salt /salt-nornir 0.13.0 that includes "full" extras for PyATS and Genie installation when using "prodmax" extras.

abhi1693 commented 2 years ago

Closing this as it's working as expected