Skip to content
Merged
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
15 changes: 13 additions & 2 deletions ocp_resources/network_attachment_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ def __init__(
self,
network_name=None,
topology=None,
vlan=None,
mtu=None,
**kwargs,
):
"""
Expand All @@ -211,8 +213,11 @@ def __init__(
https://docs.openshift.com/container-platform/4.14/networking/multiple_networks/configuring-additional-network.html#configuration-ovnk-additional-networks_configuring-additional-network

Args:
network_name (str): The name of the network. This field is mandatory when not using yaml
file.
network_name (str, optional): The name of the network, used to connect
resources created in different namespaces to the same network.
vlan (int, optional): A vlan tag ID that will be assigned to traffic from this
additional network.
mtu (str, optional): The maximum transmission unit (MTU).
topology (str): The secondary network topology to be created.
"""
super().__init__(
Expand All @@ -221,6 +226,8 @@ def __init__(
)
self.network_name = network_name
self.topology = topology
self.vlan = vlan
self.mtu = mtu

def to_dict(self):
super().to_dict()
Expand All @@ -230,6 +237,10 @@ def to_dict(self):
if not self.topology:
raise ValueError("topology is required")
spec_config = self.res["spec"]["config"]
if self.vlan:
spec_config["vlanID"] = self.vlan
if self.mtu:
spec_config["mtu"] = self.mtu
spec_config["name"] = self.network_name
spec_config["topology"] = self.topology
spec_config["netAttachDefName"] = f"{self.namespace}/{self.name}"
Expand Down