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

Fix(eos_validate_state): Update error message when a device does not have httpapi _sub_plugin #4049

Merged
merged 11 commits into from
Jun 5, 2024

Conversation

MaheshGSLAB
Copy link
Contributor

Change Summary

Better error message needed when a device does not have httpapi _sub_plugin

Related Issue(s)

Fixes #3882

Component(s) name

arista.avd.eos_validate_state

Proposed changes

Added the If condition to check _sub_plugin is there or not.

How to test

To reproduce issue we have to comment out ansible_connection vars.

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-4049
# Activate the virtual environment
source test-avd-pr-4049/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/MaheshGSLAB/ansible-avd.git@issue-3882#subdirectory=python-avd" --force
# Install Ansible collection
ansible-galaxy collection install git+https://github.com/MaheshGSLAB/ansible-avd.git#/ansible_collections/arista/avd/,issue-3882 --force
# Optional: Install AVD examples
cd test-avd-pr-4049
ansible-playbook arista.avd.install_examples

@MaheshGSLAB MaheshGSLAB changed the title Fix(eos_validate_state): Better error message needed when a device does not have httpapi _sub_plugin Fix(eos_validate_state): Better error message when a device does not have httpapi _sub_plugin May 29, 2024
@Vibhu-gslab Vibhu-gslab changed the title Fix(eos_validate_state): Better error message when a device does not have httpapi _sub_plugin Fix(eos_validate_state): Update error message when a device does not have httpapi _sub_plugin May 29, 2024
@MaheshGSLAB MaheshGSLAB marked this pull request as ready for review May 31, 2024 09:47
@MaheshGSLAB MaheshGSLAB requested review from a team as code owners May 31, 2024 09:47
else:
raise AristaAvdError(message=f"The provided Ansible connection does not use EOS HttpApi plugin: {plugin_name}")
except AttributeError as err:
raise AristaAvdError(message="AVD could not determine ansible connection. Please configure ansible_connection as `httpapi` for this host.") from err
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
raise AristaAvdError(message="AVD could not determine ansible connection. Please configure ansible_connection as `httpapi` for this host.") from err
raise AristaAvdError(message="AVD could not determine the Ansible connection plugin used. Please ensure that the 'ansible_network_os' and 'ansible_connection' variables are set to 'eos' and 'httpapi' respectively for this host.") from err

Copy link
Contributor Author

@MaheshGSLAB MaheshGSLAB May 31, 2024

Choose a reason for hiding this comment

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

Fixed.
If ansible_network_os is not defined and ansible_connection defined as httpapi then we face below error

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'Connection' object has no attribute 'nonetype'
fatal: [leaf2-dc1]: FAILED! => {"msg": "Unexpected failure during module execution: 'Connection' object has no attribute 'nonetype'", "stdout": ""}

and this is from netcommon collection

File "/home/maheshkumar/Projecct/ansible-avd/ansible_collections/ansible/netcommon/plugins/plugin_utils/connection_base.py", line 50, in __getattr__
    raise AttributeError(
AttributeError: 'Connection' object has no attribute 'nonetype'
fatal: [leaf2-dc1]: FAILED! => {
    "msg": "Unexpected failure during module execution: 'Connection' object has no attribute 'nonetype'",
    "stdout": ""
}

cc: @gmuloc

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets make all this nice maybe outside of the try except

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

Copy link
Contributor

@carl-baillargeon carl-baillargeon left a comment

Choose a reason for hiding this comment

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

LGTM

@carlbuchmann carlbuchmann marked this pull request as draft May 31, 2024 13:03
@MaheshGSLAB MaheshGSLAB marked this pull request as ready for review June 3, 2024 07:27
@MaheshGSLAB MaheshGSLAB requested a review from gmuloc June 3, 2024 07:27
@gmuloc gmuloc added the one approval This PR has one approval and is only missing one more. label Jun 5, 2024
Copy link
Contributor

@carl-baillargeon carl-baillargeon left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

sonarcloud bot commented Jun 5, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@gmuloc gmuloc merged commit 3b630d0 into aristanetworks:devel Jun 5, 2024
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EPIC - eos_validate_state ANTA one approval This PR has one approval and is only missing one more. rn: Fix(eos_validate_state)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix(eos_validate_state): Better error message needed when a device does not have httpapi _subplugin
5 participants