napalm-automation-community / napalm-panos

NAPALM driver for PAN-OS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ansible - napalm_install_config - with config

tnich opened this issue · comments

Description of Issue/Question

When using with napalm-ansible (napalm_install_config), the config input gets parsed as a string.
https://github.com/napalm-automation-community/napalm-panos/blob/develop/napalm_panos/panos.py#L228
This line splits the string by the spaces (rather than splitlines), so the command ends up being something like ['delete', 'device-group' ...] rather than ['delete device-group'].

Why is this code needed?

Looking at EOS, they do splitlines rather than split:
https://github.com/napalm-automation/napalm/blob/develop/napalm/eos/eos.py#L244

Did you follow the steps from https://github.com/napalm-automation/napalm#faq

  • Yes
  • No

Setup

napalm-panos version

(Paste verbatim output from pip freeze | grep napalm-panos between quotes below)

napalm-panos==0.5.2

PanOS version

(Paste verbatim output from show system info between quotes below)

n/a

Steps to Reproduce the Issue

Run an ansible playbook against Panos using the napalm_install_config and config option (rather than config file). For example:

  • napalm_install_config:
    hostname: x
    username: x
    password: x
    dev_os: 'panos'
    config: 'delete device-group'

The returned diff is nothing as the code runs the delete command followed by device-group.

Error Traceback

(Paste the complete traceback of the exception between quotes below)

n/a

Honestly, I think it is just a miss, it looks like normally would send the file, but in your case you are doing that, so likely just a mis-type.

So could we just change that entire if statement to just:
if isinstance(config, str):
config = config.splitlines()

Get rid of the 'if file_config' check?

I think it should be

        if isinstance(config, str):
            if file_config:
                config = config.splitlines()
            else:
                config = str(config).splitlines()

Fixed in #73