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

Adding Configure Spanning Tree for interface #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions pyaoscx/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2389,3 +2389,59 @@ def configure_speed_duplex(
)
self.user_config.update(_user_config)
return self.apply()

@PyaoscxModule.materialized
def configure_spanning_tree(
self,
admin_edge_port_enable=None,
bpdu_filter_enable=None,
bpdu_guard_enable=None,
link_type=None,
loop_guard_enable=None,
root_guard_enable=None,
):
"""
Configure the Interface Spanning Tree Settings.

:param admin_edge_port_enable: Boolean to set admin type: admin-edge or
admin-network (default)
:param bpdu_filter_enable: Boolean to set BPDU filter (disable by
default)
:param bpdu_guard_enable: Boolean to set BPDU guard (disable
by default)
:param link_type: string to set link-type (auto/point_to_point/shared)
(auto by default)
:param loop_guard_enable: Boolean to set Loop guard (disable
by default)
:param root_guard_enable: Boolean to set Root guard (disable
by default)
:return: True if object changed.
"""

if hasattr(self, "routing") and self.routing:
raise VerificationError(
"Configuring Spanning Tree is allowed only on bridged ports."
)

_stp_config = {}

if admin_edge_port_enable is not None:
_stp_config["admin_edge_port_enable"] = admin_edge_port_enable

if bpdu_filter_enable is not None:
_stp_config["bpdu_filter_enable"] = bpdu_filter_enable

if bpdu_guard_enable is not None:
_stp_config["bpdu_guard_enable"] = bpdu_guard_enable

if loop_guard_enable is not None:
_stp_config["loop_guard_enable"] = loop_guard_enable

if root_guard_enable is not None:
_stp_config["root_guard_enable"] = root_guard_enable

if link_type is not None:
_stp_config["link_type"] = link_type

self.stp_config.update(_stp_config)
return self.apply()