PaloAltoNetworks / PaloAltoNetworks/pan-os-python

Error when modifying firewall interface attributes on a parent firewall interface with sub-interfaces

Open
#171 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
400
Forks
199
PR merge metrics
No merged PRs in 30d

Description

def config_comment(fw_obj):
    x = ['ethernet1/1']

    try:
        EthernetInterface.refreshall(fw_obj)
        AggregateInterface.refreshall(fw_obj)
    except PanDeviceError as e:
        print(e.message)

    for interface_name in x:
        if 'ae' in interface_name:
            try:
                target_int = fw_obj.find(interface_name, AggregateInterface)
            except PanDeviceError as e:
                print(e.message)         
        elif 'ethernet' in interface_name:
            try:
                target_int = fw_obj.find(interface_name, EthernetInterface)
            except PanDeviceError as e:
                print(e.message) 
        else:
            print('Invalid interface {0}'.format(interface_name))

        target_int.comment = 'test comment'

        target_int.apply()

Error:

Traceback (most recent call last):
  File "/home/admin/venvs/auto_venv_py3.6/lib64/python3.6/site-packages/pandevice/base.py", line 3447, in method
    super_method(self, *args, **kwargs)
  File "/home/admin/venvs/auto_venv_py3.6/lib64/python3.6/site-packages/pan/xapi.py", line 741, in set
    self.__type_config('set', query, extra_qs)
  File "/home/admin/venvs/auto_venv_py3.6/lib64/python3.6/site-packages/pan/xapi.py", line 805, in __type_config
    raise PanXapiError(self.status_detail)
pan.xapi.PanXapiError:  interface 'ethernet1/1.2' is already in use

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "enable_lldp.py", line 154, in <module>
    main()
  File "enable_lldp.py", line 151, in main
    config_lldp(firewall, lldp_ints)
  File "enable_lldp.py", line 122, in config_lldp
    target_int.apply()
  File "/home/admin/venvs/auto_venv_py3.6/lib64/python3.6/site-packages/pandevice/base.py", line 3001, in apply
    super(VsysOperations, self).apply()
  File "/home/admin/venvs/auto_venv_py3.6/lib64/python3.6/site-packages/pandevice/base.py", line 561, in apply
    child._check_child_methods("apply")
  File "/home/admin/venvs/auto_venv_py3.6/lib64/python3.6/site-packages/pandevice/base.py", line 518, in _check_child_methods
    getattr(self, "child_"+method)()
  File "/home/admin/venvs/auto_venv_py3.6/lib64/python3.6/site-packages/pandevice/base.py", line 3012, in child_apply
    return self._create_apply_child()
  File "/home/admin/venvs/auto_venv_py3.6/lib64/python3.6/site-packages/pandevice/base.py", line 3019, in _create_apply_child
    self.create_import('vsys1')
  File "/home/admin/venvs/auto_venv_py3.6/lib64/python3.6/site-packages/pandevice/base.py", line 3050, in create_import
    device.active().xapi.set(xpath, element, retry_on_peer=True)
  File "/home/admin/venvs/auto_venv_py3.6/lib64/python3.6/site-packages/pandevice/base.py", line 3464, in method
    raise the_exception
pandevice.errors.PanDeviceXapiError:  interface 'ethernet1/1.2' is already in use

Python Module Versions:
pan-python 0.15.0
pandevice 0.11.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the apply flow shown in pandevice/base.py, especially child_apply and create_import, then inspect pan/xapi.py where set raises the interface-in-use error. Reproduce the supplied EthernetInterface example with a parent interface that has sub-interfaces; done means modifying the parent interface attributes without the reported ethernet1/1.2 conflict.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
networking, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.