diff --git a/changelogs/fragments/implement_bridge_domains.yaml b/changelogs/fragments/implement_bridge_domains.yaml
new file mode 100644
index 00000000..be8b3486
--- /dev/null
+++ b/changelogs/fragments/implement_bridge_domains.yaml
@@ -0,0 +1,5 @@
+---
+minor_changes:
+ - Implemented bridge-domains configuration management for routing instances.
+ - Added support for virtual-switch instances.
+ - Tested successfully on Junos MX204.
diff --git a/docs/junipernetworks.junos.junos_routing_instances_module.rst b/docs/junipernetworks.junos.junos_routing_instances_module.rst
index 939482c2..5b69b687 100644
--- a/docs/junipernetworks.junos.junos_routing_instances_module.rst
+++ b/docs/junipernetworks.junos.junos_routing_instances_module.rst
@@ -58,6 +58,194 @@ Parameters
+ |
connector_id_advertise
@@ -427,6 +615,7 @@ Parameters
mpls-internet-multicast
no-forwarding
virtual-router
+ virtual-switch
vpls
vrf
diff --git a/plugins/module_utils/network/junos/argspec/routing_instances/routing_instances.py b/plugins/module_utils/network/junos/argspec/routing_instances/routing_instances.py
index 93e69943..5fc56942 100644
--- a/plugins/module_utils/network/junos/argspec/routing_instances/routing_instances.py
+++ b/plugins/module_utils/network/junos/argspec/routing_instances/routing_instances.py
@@ -58,6 +58,21 @@ def __init__(self, **kwargs):
},
"type": "list",
},
+ "bridge_domains": {
+ "elements": "dict",
+ "options": {
+ "name": {"type": "str"},
+ "description": {"type": "str"},
+ "domain_id": {"type": "int"},
+ "service_id": {"type": "int"},
+ "vlan_id": {"type": "int"},
+ "enable_mac_move_action": {"type": "bool"},
+ "mcae_mac_flush": {"type": "bool"},
+ "no_irb_layer_2_copy": {"type": "bool"},
+ "no_local_switching": {"type": "bool"},
+ },
+ "type": "list",
+ },
"l2vpn_id": {"type": "str"},
"name": {"type": "str"},
"no_irb_layer_2_copy": {"type": "bool"},
@@ -81,6 +96,7 @@ def __init__(self, **kwargs):
"mpls-internet-multicast",
"no-forwarding",
"virtual-router",
+ "virtual-switch",
"vpls",
"vrf",
],
diff --git a/plugins/module_utils/network/junos/config/routing_instances/routing_instances.py b/plugins/module_utils/network/junos/config/routing_instances/routing_instances.py
index 445454d5..30f80913 100644
--- a/plugins/module_utils/network/junos/config/routing_instances/routing_instances.py
+++ b/plugins/module_utils/network/junos/config/routing_instances/routing_instances.py
@@ -266,6 +266,28 @@ def _state_merged(self, want, have):
)
build_child_xml_node(int_node, "name", interface["name"])
+ # add child node bridge-domains
+ if instance.get("bridge_domains"):
+ br_domains = instance["bridge_domains"]
+ for domain in br_domains:
+ br_domain_node = build_child_xml_node(rinst_node, "bridge-domains")
+ domain_node = build_child_xml_node(br_domain_node, "domain")
+
+ attributes = ["name", "description", "domain_id", "service_id", "vlan_id"]
+ for attr in attributes:
+ if domain.get(attr):
+ build_child_xml_node(domain_node, attr.replace("_", "-"), domain[attr])
+
+ boolean_attributes = [
+ "enable_mac_move_action",
+ "mcae_mac_flush",
+ "no_irb_layer_2_copy",
+ "no_local_switching",
+ ]
+ for attr in boolean_attributes:
+ if domain.get(attr):
+ build_child_xml_node(domain_node, attr.replace("_", "-"))
+
# add node l2vpn-id TODO
if instance.get("l2vpn_id"):
build_child_xml_node(
diff --git a/plugins/module_utils/network/junos/facts/routing_instances/routing_instances.py b/plugins/module_utils/network/junos/facts/routing_instances/routing_instances.py
index 1766e483..05a77ebe 100644
--- a/plugins/module_utils/network/junos/facts/routing_instances/routing_instances.py
+++ b/plugins/module_utils/network/junos/facts/routing_instances/routing_instances.py
@@ -231,6 +231,25 @@ def parse_instance(self, instance):
vrf_exp_lst.append(vrf_exp)
instance_dict["vrf_exports"] = vrf_exp_lst
+ # read bridge domains
+ if instance.get("bridge-domains"):
+ br_domain_lst = []
+ br_domains = instance.get("bridge-domains").get("domain")
+ if isinstance(br_domains, list):
+ for domain in br_domains:
+ br_item = {
+ k.replace("-", "_"): (v if v is not None else True)
+ for k, v in domain.items()
+ }
+ br_domain_lst.append(br_item)
+ else:
+ br_item = {
+ k.replace("-", "_"): (v if v is not None else True)
+ for k, v in br_domains.items()
+ }
+ br_domain_lst.append(br_item)
+ instance_dict["bridge_domains"] = br_domain_lst
+
return utils.remove_empties(instance_dict)
def parse_interface(self, interface):
diff --git a/plugins/modules/junos_routing_instances.py b/plugins/modules/junos_routing_instances.py
index eec4720b..a4b2ba95 100644
--- a/plugins/modules/junos_routing_instances.py
+++ b/plugins/modules/junos_routing_instances.py
@@ -89,6 +89,40 @@
description: Primary role of L2Backhaul-vpn router.
type: str
choices: ['access', 'nni']
+ bridge_domains:
+ description:
+ - Bridge domain configuration.
+ - This has been tested for junos MX204.
+ type: list
+ elements: dict
+ suboptions:
+ name:
+ description: Specify the name of the bridge domain.
+ type: str
+ description:
+ description: Specify domain description.
+ type: str
+ domain_id:
+ description: Provide the domain ID.
+ type: int
+ enable_mac_move_action:
+ description: Enable blocking action due to mac-move in this Bridge Domain.
+ type: bool
+ vlan_id:
+ description: IEEE 802.1q VLAN identifier for bridging domain (1..4094)
+ type: int
+ mcae_mac_flush:
+ description: Enable IRB MAC synchronization in this bridge domain
+ type: bool
+ no_irb_layer_2_copy:
+ description: Disable transmission of layer-2 copy of packets of irb routing-interface.
+ type: bool
+ no_local_switching:
+ description: Disable local switching within CE-facing interfaces.
+ type: bool
+ service_id:
+ description: Specify service id.
+ type: int
type:
description: Specify instance type.
type: str
@@ -104,6 +138,7 @@
- mpls-internet-multicast
- no-forwarding
- virtual-router
+ - virtual-switch
- vpls
- vrf
interfaces:
diff --git a/tests/unit/modules/network/junos/test_junos_routing_instances.py b/tests/unit/modules/network/junos/test_junos_routing_instances.py
index 214bddb8..d281a7ef 100644
--- a/tests/unit/modules/network/junos/test_junos_routing_instances.py
+++ b/tests/unit/modules/network/junos/test_junos_routing_instances.py
@@ -95,6 +95,56 @@ def sort_routing_instances(self, entry_list):
if entry.get("instance"):
entry["routing_instances"].sort(key=lambda i: i.get("name"))
+ def test_junos_routing_instances_domains_merged(self):
+ set_module_args(
+ dict(
+ config=[
+ dict(
+ name="EVPN",
+ type="virtual-switch",
+ route_distinguisher="10.0.0.21:444",
+ bridge_domains=[
+ dict(
+ name="BD456",
+ vlan_id=456,
+ enable_mac_move_action=True,
+ mcae_mac_flush=True,
+ no_local_switching=True,
+ service_id=20,
+ ),
+ dict(
+ name="BD457",
+ vlan_id=457,
+ ),
+ ],
+ ),
+ dict(
+ name="mgmt_junos",
+ ),
+ ],
+ state="merged",
+ ),
+ )
+ commands = [
+ ''
+ "EVPN"
+ "virtual-switch"
+ ""
+ "BD456"
+ "20"
+ "456"
+ ""
+ ""
+ ""
+ ""
+ "BD457"
+ "457"
+ "10.0.0.21:444"
+ "mgmt_junos",
+ ]
+ result = self.execute_module(changed=True, commands=commands)
+ self.assertEqual(sorted(result["commands"]), sorted(commands))
+
def test_junos_routing_instances_merged(self):
set_module_args(
dict(
|