-
Notifications
You must be signed in to change notification settings - Fork 239
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
Refactor(eos_designs): Refactor eos_designs structured_config code for ip_security(overlay) #5046
base: devel
Are you sure you want to change the base?
Conversation
Review docs on Read the Docs To test this pull request: # Create virtual environment for this testing below the current directory
python -m venv test-avd-pr-5046
# Activate the virtual environment
source test-avd-pr-5046/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/MaheshGSLAB/ansible-avd.git@ip-sec-refactor#subdirectory=python-avd" --force
# Point Ansible collections path to the Python virtual environment
export ANSIBLE_COLLECTIONS_PATH=$VIRTUAL_ENV/ansible_collections
# Install Ansible collection
ansible-galaxy collection install git+https://github.com/MaheshGSLAB/ansible-avd.git#/ansible_collections/arista/avd/,ip-sec-refactor --force
# Optional: Install AVD examples
cd test-avd-pr-5046
ansible-playbook arista.avd.install_examples |
python-avd/pyavd/_eos_designs/structured_config/overlay/ip_security.py
Outdated
Show resolved
Hide resolved
python-avd/pyavd/_eos_designs/structured_config/overlay/ip_security.py
Outdated
Show resolved
Hide resolved
python-avd/pyavd/_eos_designs/structured_config/overlay/ip_security.py
Outdated
Show resolved
Hide resolved
python-avd/pyavd/_eos_designs/structured_config/overlay/ip_security.py
Outdated
Show resolved
Hide resolved
python-avd/pyavd/_eos_designs/structured_config/overlay/ip_security.py
Outdated
Show resolved
Hide resolved
Moving to draft to keep track of reviews. Set it ready again once you have addressed comments. Thanks. |
if self.shared_utils.is_wan_client and self.inputs.wan_ipsec_profiles.data_plane: | ||
self._append_data_plane(self.inputs.wan_ipsec_profiles.data_plane) | ||
self._append_control_plane(self.inputs.wan_ipsec_profiles.control_plane) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self.shared_utils.is_wan_client and self.inputs.wan_ipsec_profiles.data_plane: | |
self._append_data_plane(self.inputs.wan_ipsec_profiles.data_plane) | |
self._append_control_plane(self.inputs.wan_ipsec_profiles.control_plane) | |
if self.shared_utils.is_wan_client and self.inputs.wan_ipsec_profiles.data_plane: | |
self._set_data_plane() | |
self._set_control_plane() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated the method and doc string for all places
return strip_null_from_data(ip_security) | ||
|
||
def _append_data_plane(self: AvdStructuredConfigOverlayProtocol, ip_security: dict, data_plane_config: dict) -> None: | ||
def _append_data_plane(self: AvdStructuredConfigOverlayProtocol, data_plane_config: EosDesigns.WanIpsecProfiles.DataPlane) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def _append_data_plane(self: AvdStructuredConfigOverlayProtocol, data_plane_config: EosDesigns.WanIpsecProfiles.DataPlane) -> None: | |
def _set_data_plane(self: AvdStructuredConfigOverlayProtocol) -> None: |
return strip_null_from_data(ip_security) | ||
|
||
def _append_data_plane(self: AvdStructuredConfigOverlayProtocol, ip_security: dict, data_plane_config: dict) -> None: | ||
def _append_data_plane(self: AvdStructuredConfigOverlayProtocol, data_plane_config: EosDesigns.WanIpsecProfiles.DataPlane) -> None: | ||
"""In place update of ip_security for DataPlane.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""In place update of ip_security for DataPlane.""" | |
"""Set ip_security structured config for DataPlane.""" |
sa_policy_name = get(data_plane_config, "sa_policy_name", default="DP-SA-POLICY") | ||
profile_name = get(data_plane_config, "profile_name", default="DP-PROFILE") | ||
key = get(data_plane_config, "shared_key", required=True) | ||
ike_policy_name = data_plane_config.ike_policy_name if self.shared_utils.wan_ha_ipsec else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ike_policy_name = data_plane_config.ike_policy_name if self.shared_utils.wan_ha_ipsec else None | |
data_plane_config = self.inputs.wan_ipsec_profiles.data_plane | |
ike_policy_name = data_plane_config.ike_policy_name if self.shared_utils.wan_ha_ipsec else None |
|
||
def _append_control_plane(self: AvdStructuredConfigOverlayProtocol, ip_security: dict, control_plane_config: dict) -> None: | ||
def _append_control_plane(self: AvdStructuredConfigOverlayProtocol, control_plane_config: EosDesigns.WanIpsecProfiles.ControlPlane) -> None: | ||
""" | ||
In place update of ip_security for control plane data. | ||
|
||
expected to be called AFTER _append_data_plane as CP is used for data-plane as well if not configured. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expected to be called AFTER _append_data_plane as CP is used for data-plane as well if not configured. | |
expected to be called AFTER _set_data_plane as CP is used for data-plane as well if not configured. |
The expectation is that potential None values are stripped later. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The expectation is that potential None values are stripped later. |
dpd=EosCliConfigGen.IpSecurity.ProfilesItem.Dpd(interval=10, time=50, action="clear"), | ||
) | ||
|
||
def _key_controller(self: AvdStructuredConfigOverlayProtocol, profile_name: str) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def _key_controller(self: AvdStructuredConfigOverlayProtocol, profile_name: str) -> None: | |
def _set_key_controller(self: AvdStructuredConfigOverlayProtocol, profile_name: str) -> None: |
""" | ||
Return an SA policy. | ||
Set the SA policy. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set the SA policy. | |
Set structured_config for one SA policy. |
|
||
# For data plane, adding key_controller by default | ||
ip_security["key_controller"] = self._key_controller(profile_name) | ||
self._key_controller(profile_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._key_controller(profile_name) | |
self._set_key_controller(profile_name) |
"name": name, | ||
"local_id": self.shared_utils.vtep_ip, | ||
} | ||
self._key_controller(profile_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self._key_controller(profile_name) | |
self._set_key_controller(profile_name) |
|
Change Summary
Refactor eos_designs structured_config code for ip_security(overlay)
Related Issue(s)
Fixes #
Component(s) name
arista.avd.eos_designs
Proposed changes
Refactor eos_designs structured_config code for ip_security(overlay)
How to test
Run Molecule
Checklist
User Checklist
Repository Checklist