Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doing a logical AND in find_objects_w_child()? #63

Closed
micyew opened this issue Nov 11, 2016 · 1 comment
Closed

Doing a logical AND in find_objects_w_child()? #63

micyew opened this issue Nov 11, 2016 · 1 comment

Comments

@micyew
Copy link

micyew commented Nov 11, 2016

Is there a way to implement a logical AND in find_objects_w_child()?

Eg. I like to pull out the interface when both of the child config "switchport mode trunk" AND "udld port" present. I know we can do OR using "|" but when I try "&" or "&&" it doesn't work..

How do I accomplish this? Thanks...

@mpenning
Copy link
Owner

As of version 1.2.43, you can use find_objects_w_all_children()... this is an example...

>>> config = ['!',
...           'interface FastEthernet0/1',
...           ' switchport access vlan 532',
...           ' spanning-tree vlan 532 cost 3',
...           '!',
...           'interface FastEthernet0/2',
...           ' switchport access vlan 300',
...           ' spanning-tree portfast',
...           '!',
...           'interface FastEthernet0/3',
...           ' duplex full',
...           ' speed 100',
...           ' switchport access vlan 300',
...           ' spanning-tree portfast',
...           '!',
...     ]
>>> p = CiscoConfParse(config)
>>> p.find_objects_w_all_children('^interface',
...     ['switchport access vlan 300', 'spanning-tree portfast'])
...
[<IOSCfgLine # 5 'interface FastEthernet0/2'>, <IOSCfgLine # 9 'interface FastEthernet0/3'>]
>>>

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants