Skip to content
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 structured_config code for dhcp_servers.py #5084

Open
wants to merge 9 commits into
base: devel
Choose a base branch
from

Conversation

laxmikantchintakindi
Copy link
Contributor

@laxmikantchintakindi laxmikantchintakindi commented Feb 21, 2025

Change Summary

Refactor structured_config code for dhcp_servers.py

Related Issue(s)

Fixes #

Component(s) name

arista.avd.eos_designs

Proposed changes

Refactor structured_config code for dhcp_servers.py

How to test

Checklist

User Checklist

  • N/A

Repository Checklist

  • My code has been rebased from devel before I start
  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation and documentation have been updated accordingly.
  • I have updated molecule CI testing accordingly. (check the box if not applicable)

Copy link

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-5084
# Activate the virtual environment
source test-avd-pr-5084/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/laxmikantchintakindi/avd.git@refactor/underlay/dhcp-servers#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/laxmikantchintakindi/avd.git#/ansible_collections/arista/avd/,refactor/underlay/dhcp-servers --force
# Optional: Install AVD examples
cd test-avd-pr-5084
ansible-playbook arista.avd.install_examples

@laxmikantchintakindi laxmikantchintakindi force-pushed the refactor/underlay/dhcp-servers branch 2 times, most recently from d30c553 to 48635d6 Compare February 24, 2025 05:09
@Vibhu-gslab Vibhu-gslab force-pushed the refactor/underlay/dhcp-servers branch from 48635d6 to b116eda Compare February 24, 2025 05:30
@Vibhu-gslab Vibhu-gslab force-pushed the refactor/underlay/dhcp-servers branch from 497e922 to 97b5a20 Compare February 28, 2025 08:06
@Vibhu-gslab Vibhu-gslab marked this pull request as ready for review February 28, 2025 08:06
@Vibhu-gslab Vibhu-gslab requested review from a team as code owners February 28, 2025 08:06
@cached_property
def _ipv4_ztp_boot_file(self: AvdStructuredConfigUnderlayProtocol) -> str | None:
"""Returns the file name to allow for ZTP to CV. TODO: Add inband_ztp_bootstrap_file to schema."""
dhcp_server.vrf = "default"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably keep this in the main function rather than hiding it in the middle of the servers. Move it after the check for if len(dhcp_server.subnets) == 0:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

dhcp_server.subnets.append(subnet_item)

def _set_ipv4_ztp_boot_file(self: AvdStructuredConfigUnderlayProtocol, dhcp_server: EosCliConfigGen.DhcpServersItem) -> None:
"""Set the file name to allow for ZTP to CV. TODO: Add inband_ztp_bootstrap_file to schema."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laxmikantchintakindi can you please add the inband_ztp_bootstrap_file to the schema? shoud be a string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

if ntp_servers := self._ntp_servers:
dhcp_server["ipv4_vendor_options"] = [ntp_servers]
dhcp_servers.append(dhcp_server)
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think you need this return, instead do a:

if not ntp_servers:
    raise
Do the subotoptions stuff

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants