diff --git a/netman/adapters/switches/juniper/base.py b/netman/adapters/switches/juniper/base.py
index 931cc598..1c62d700 100644
--- a/netman/adapters/switches/juniper/base.py
+++ b/netman/adapters/switches/juniper/base.py
@@ -439,12 +439,16 @@ def add_bond(self, number):
raise
def remove_bond(self, number):
- config = self.query(all_interfaces)
+ config = self.query(all_interfaces, one_rstp_protocol_interface(bond_name(number)))
self.get_bond_config(number, config)
update = Update()
update.add_interface(interface_removal(bond_name(number)))
+ rstp_node = first(config.xpath("data/configuration/protocols/rstp/interface/name[text()=\"{0:s}\"]/..".format(bond_name(number))))
+ if rstp_node is not None:
+ update.add_rstp_protocol_interface(rstp_interface_removal(bond_name(number)))
+
for interface_node in self.get_bond_slaves_config(number, config):
interface_name = first(interface_node.xpath("name")).text
update.add_interface(free_from_bond_operation(interface_name))
@@ -664,6 +668,20 @@ def rstp_protocol_interfaces():
""")
+def one_rstp_protocol_interface(interface_id):
+ def m():
+ return to_ele("""
+
+
+
+ {}
+
+
+
+ """.format(interface_id))
+ return m
+
+
class Update(object):
def __init__(self):
self.root = new_ele("configuration")
diff --git a/tests/adapters/switches/juniper_test.py b/tests/adapters/switches/juniper_test.py
index 6b06a10d..2f9b7209 100644
--- a/tests/adapters/switches/juniper_test.py
+++ b/tests/adapters/switches/juniper_test.py
@@ -3482,6 +3482,13 @@ def test_remove_bond(self):
+
+
+
+ ae10
+
+
+
""")).and_return(a_configuration("""
@@ -3509,6 +3516,63 @@ def test_remove_bond(self):
self.switch.remove_bond(10)
+ def test_remove_bond_also_removes_rstp_protocol(self):
+ with self.expecting_successful_transaction():
+
+ self.netconf_mock.should_receive("get_config").with_args(source="candidate", filter=is_xml("""
+
+
+
+
+
+
+ ae10
+
+
+
+
+
+ """)).and_return(a_configuration("""
+
+
+ ae10
+
+
+ ge-4/3/3
+
+
+
+
+
+ ae10
+
+
+
+
+
+ """))
+
+ self.netconf_mock.should_receive("edit_config").once().with_args(target="candidate", config=is_xml("""
+
+
+
+
+ ae10
+
+
+
+
+
+ ae10
+
+
+
+
+
+ """)).and_return(an_ok_response())
+
+ self.switch.remove_bond(10)
+
def test_remove_bond_invalid_number_raises(self):
with self.expecting_failed_transaction():
@@ -3516,6 +3580,13 @@ def test_remove_bond_invalid_number_raises(self):
+
+
+
+ ae7
+
+
+
""")).and_return(a_configuration())
@@ -3532,6 +3603,13 @@ def test_remove_bond_delete_slaves_and_interface_at_same_time(self):
+
+
+
+ ae10
+
+
+
""")).and_return(a_configuration("""