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 eos_designs structured_config code for monitor_sessions #4937

Draft
wants to merge 3 commits into
base: devel
Choose a base branch
from

Conversation

Shivani-gslab
Copy link
Contributor

Change Summary

Related Issue(s)

Fixes #

Component(s) name

arista.avd.<role-name>

Proposed changes

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

}
monitor_session = EosCliConfigGen.MonitorSessionsItem(
name=session_name,
sources=[],
Copy link
Contributor

Choose a reason for hiding this comment

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

Not needed since it will be autocreated when needed.

Suggested change
sources=[],

Comment on lines +64 to +68
source.access_group = EosCliConfigGen.MonitorSessionsItem.SourcesItem.AccessGroup(
type=session.source_settings.access_group.type,
name=session.source_settings.access_group.name,
priority=session.source_settings.access_group.priority,
)
Copy link
Contributor

Choose a reason for hiding this comment

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

This the properties have the same name and type you can do:

Suggested change
source.access_group = EosCliConfigGen.MonitorSessionsItem.SourcesItem.AccessGroup(
type=session.source_settings.access_group.type,
name=session.source_settings.access_group.name,
priority=session.source_settings.access_group.priority,
)
source.access_group = session.source_settings.access_group._cast_as(EosCliConfigGen.MonitorSessionsItem.SourcesItem.AccessGroup)

)
if session.source_settings.access_group.name is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if session.source_settings.access_group.name is not None:
if session.source_settings.access_group.name:

name=session.source_settings.access_group.name,
priority=session.source_settings.access_group.priority,
)
monitor_session.sources.extend(source)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
monitor_session.sources.extend(source)
monitor_session.sources.append(source)

@cached_property
def monitor_sessions(self: AvdStructuredConfigConnectedEndpoints) -> list | None:
@structured_config_contributor
def monitor_sessions(self: AvdStructuredConfigConnectedEndpoints) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

Check if it makes sense to populate the self._monitor_session_configs with the EosCliConfigGen models directly instead of having to convert all of them here. Only if it makes sense and we can save something.

Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the state: conflict PR with conflict label Jan 30, 2025
Copy link

Conflicts have been resolved. A maintainer will review the pull request shortly.

@github-actions github-actions bot removed the state: conflict PR with conflict label Jan 31, 2025
Copy link

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

Successfully merging this pull request may close these issues.

2 participants