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

switchport object properties missing (trunk_vlans_allowed and native_vlan) #62

Closed
bandrel opened this issue Sep 2, 2016 · 2 comments
Closed

Comments

@bandrel
Copy link

bandrel commented Sep 2, 2016

Add properties for common trunk attributes in properties.

switchport trunk native vlan
switchport trunk allowed vlans

@XenonR
Copy link

XenonR commented Nov 14, 2016

Sounds fairly commanding, no thanks, no please, no money ;)

Take a look at richardstrnad/ciscoconfparse
It already includes trunk_allowed_vlan

def trunk_allowed_vlan(self):
""" Returns a list with all Vlans.
If there is no configuration to allow specific Vlans return an empty list.

However, if there is 'switchport trunk allowed vlan none' return None (NoneType)
to be able to differntiate between no configuration and explicit 'none'.
"""

Feel free to extend ciscoconfparse with a property for the native vlan

Regards.

mpenning added a commit that referenced this issue Nov 24, 2016
@mpenning
Copy link
Owner

As of CiscoConfParse 1.2.42, this should work now... please let me know if you find gaps...

Usage example follows...

from ciscoconfparse import CiscoConfParse

lines = ['!',
    'interface GigabitEthernet 1/1',
    ' switchport mode trunk',
    ' switchport trunk allowed vlan none',
    ' switchport trunk allowed vlan add 2-4094',
    ' switchport trunk native vlan 911',
    '!',
]
cfg = CiscoConfParse(lines, factory=True)
intf_obj = cfg.find_objects('^interface')[0]

print "ALLOWED_VLANS", intf_obj.trunk_vlans_allowed.as_list
print "NATIVE", intf_obj.native_vlan

@mpenning mpenning changed the title interface object properties missing switchport object properties missing (trunk_vlans_allowed and native_vlan) Nov 25, 2016
@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

3 participants