Error PanObject.add() missing 1 required positional argument: 'child'\n" on using BGP Peer Group Creation Task in Ansible
gwoodwa1 opened this issue ยท 3 comments
Describe the bug
When running the BGP Peer Group Creation Task, it always fails with the following traceback message from Ansible:
ansible_collections/paloaltonetworks/panos/plugins/module_utils/panos.py\", line 478, in process\nTypeError: PanObject.add() missing 1 required positional argument: 'child'\n",
I have done some debugging and narrowed it down to this line of code in panos.py line : 478 parent.add(obj)
full path : ansible/collections/ansible_collections/paloaltonetworks/panos/plugins/module_utils/panos.py
Extract of the block of code from panos.py:
# Attach the object to the parent.
if self.sdk_cls is None:
raise Exception("sdk_cls must be specified")
elif not isinstance(self.sdk_cls, tuple) or len(self.sdk_cls) != 2:
raise Exception("helper.sdk_cls must be tuple of len()=2")
obj = to_sdk_cls(*self.sdk_cls)(**spec)
parent.add(obj)
Here is the full playbook which just does the BGP Peer Group Creation Task. I have removed any optional parameters for debugging purposes
- hosts: '{{ target | default("firewall") }}'
connection: local
vars:
device:
ip_address: '{{ ip_address }}'
username: '{{ username | default(omit) }}'
password: '{{ password | default(omit) }}'
api_key: '{{ api_key | default(omit) }}'
interfaces:
- if_name: 'ethernet1/1'
mode: 'layer3'
ip: ['192.168.55.20/24']
enable_dhcp: false
- if_name: 'ethernet1/2'
mode: 'layer3'
ip: ['192.168.45.20/24']
enable_dhcp: false
- if_name: 'ethernet1/3'
mode: 'layer3'
ip: ['192.168.35.20/24']
enable_dhcp: false
tasks:
- name: Create BGP Peer Group
paloaltonetworks.panos.panos_bgp_peer_group:
provider: '{{ device }}'
state: 'present'
name: 'peer-group-4'
Expected behavior
I think the obj variable should contain the correct output such that the parent class is not complaining about a missing child element
Current behavior
Consistent Traceback message as above
Possible solution
Having identified the line of code where it is failing, I wonder if the structure of the obj variable/object is incorrect and I would like to know what is expected and how I could examine that. I assumed it was a dictionary object of some sort with contents?
Steps to reproduce
- I am using a PanOS VM container created via containerlab
- Built on PA-VM-KVM-10.1.6
Context
I am testing provisioning of BGP for PanOS
Your Environment
- Collection:
- Python: Python 3.10.4
- Ansible: ansible 2.10.8
- PAN-OS Python Library & version pan-os-python==1.4.0 pan-python==0.16.0 Ansible plugin : paloaltonetworks.panos 3.0.0
๐ Thanks for opening your first issue here! Welcome to the community!
Confirmed, this appears to have been created with the following commit #325
def main():
helper = get_connection(
@@ -133,10 +125,10 @@ def main():
with_classic_provider_spec=True,
with_commit=True,
parents=(
- (VirtualRouter, "vr_name", "default"),
- (Bgp, None),
+ ("network", "VirtualRouter", "vr_name", "default"),
+ ("network", "Bgp", None),
),
- sdk_cls=BgpPeerGroup,
+ sdk_cls=("network", "BgpPeerGroup"),
sdk_params=dict(
name=dict(required=True),
enable=dict(default=True, type="bool"),
running through the debugger provided this insight on the obj
object being passed into the parent.add()
method:
ipdb> next
> /home/cdot/.ansible/collections/ansible_collections/paloaltonetworks/panos/plugins/module_utils/panos.py(482)process()
481 obj = to_sdk_cls(*self.sdk_cls)(**spec)
--> 482 parent.add(obj)
483
ipdb> type(obj)
<class 'panos.network.BgpPeerGroup'>
ipdb> dir(obj)
['CHILDMETHODS', 'CHILDTYPES', 'HA_SYNC', 'NAME', 'OPSTATES', 'ROOT', 'SUFFIX', 'TEMPLATE_NATIVE', 'XPATH', '_DEFAULT_NAME', '_TEMPLATE_DEVICE_XPATH', '_TEMPLATE_MGTCONFIG_XPATH', '_TEMPLATE_VSYS_XPATH', '_UNKNOWN_PANOS_VERSION', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_about_object', '_about_parameter', '_build_element_info', '_check_child_methods', '_convert_var', '_dot', '_gather_bulk_info', '_get_param_specific_info', '_merge_elements', '_nearest_pandevice', '_params', '_parse_xml', '_perform_vsys_dict_import_delete', '_perform_vsys_dict_import_set', '_refresh_children', '_refresh_xml', '_requires_import_consideration', '_root_element', '_root_xpath_vsys', '_set_reference', '_setup', '_setup_opstate', '_setups', '_stubs', '_subelements', '_xpaths', 'about', 'add', 'aggregated_confed_as_path', 'apply', 'apply_similar', 'children', 'create', 'create_similar', 'delete', 'delete_similar', 'devicegroup', 'dot', 'element', 'element_str', 'enable', 'equal', 'export_nexthop', 'extend', 'find', 'find_index', 'find_or_create', 'findall', 'findall_or_create', 'fulltree', 'hierarchy_info', 'import_nexthop', 'insert', 'move', 'name', 'nearest_pandevice', 'opstate', 'panorama', 'parent', 'parse_xml', 'pop', 'refresh', 'refresh_variable', 'refreshall', 'refreshall_from_xml', 'remove', 'remove_by_name', 'remove_private_as', 'removeall', 'rename', 'retrieve_panos_version', 'soft_reset_with_stored_info', 'tree', 'type', 'uid', 'update', 'variables', 'vsys', 'xml_merge', 'xpath', 'xpath_nosuffix', 'xpath_panorama', 'xpath_root', 'xpath_short', 'xpath_vsys']
ipdb> next
TypeError: add() missing 1 required positional argument: 'child'
> /home/cdot/.ansible/collections/ansible_collections/paloaltonetworks/panos/plugins/module_utils/panos.py(482)process()
481 obj = to_sdk_cls(*self.sdk_cls)(**spec)
--> 482 parent.add(obj)
483
Downgrading to Ansible Collection 2.9.0 is the best workaround for now @gwoodwa1
๐ This issue has been resolved in version 2.11.0 ๐
The release is available on Ansible Galaxy and GitHub release
Posted by semantic-release bot