Skip to content

Commit

Permalink
Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kdhlab committed Sep 16, 2024
1 parent f1856f1 commit 19e41f3
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 760 deletions.
16 changes: 15 additions & 1 deletion plugins/module_utils/interfaces_assignments_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class InterfaceAssignment:
device: str
descr: Optional[str] = None
enable: Optional[bool] = False
lock: Optional[bool] = False

# since only the above attributes are needed, the rest is handled here
extra_attrs: Dict[str, Any] = field(default_factory=dict, repr=False)
Expand All @@ -69,8 +70,9 @@ def __init__(
self,
identifier: str,
device: str,
enable: Optional[bool] = False,
descr: Optional[str] = None,
enable: Optional[bool] = False,
lock: Optional[bool] = False,
**kwargs,
):
self.identifier = identifier
Expand Down Expand Up @@ -133,6 +135,10 @@ def to_etree(self) -> Element:
SubElement(main_element, "descr").text = interface_assignment_dict.get("descr")
if getattr(self, "enable", None):
SubElement(main_element, "enable").text = "1"
# Enumerate the basic attributes if the interface is enabled

if getattr(self, "lock", None):
SubElement(main_element, "lock").text = "1"
# handle special cases
if getattr(self, "alias-subnet", None):
interface_assignment_dict["extra_attrs"]["alias-subnet"] = getattr(
Expand Down Expand Up @@ -217,6 +223,14 @@ def from_ansible_module_params(cls, params: dict) -> "InterfaceAssignment":
"device": params.get("device"),
"descr": params.get("description"),
"enable": params.get("enabled"),
"lock": params.get("locked"),
# "blockpriv": params.get("block_private"),
# "blockbogons": params.get("block_bogons"),
# "spoofmac": params.get("mac_address"),
# "promisc": params.get("promiscuous_mode"),
# "mtu": params.get("mtu"),
# "mss": params.get("mss"),
# "gateway_interface": params.get("dynamic_gateway"),
}

interface_assignment_dict = {
Expand Down
Loading

0 comments on commit 19e41f3

Please sign in to comment.