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

initial pass on refactor #124

Merged
merged 20 commits into from
Nov 21, 2023
Merged

initial pass on refactor #124

merged 20 commits into from
Nov 21, 2023

Conversation

whitej6
Copy link
Contributor

@whitej6 whitej6 commented Nov 17, 2023

No description provided.

@jeffkala
Copy link
Contributor

Did some testing tonight:

  1. Can't get secret_group (credential) usage to work.
 {'exc_type': 'FieldError', 'exc_module': 'django.core.exceptions', 'exc_message': ["Cannot resolve keyword 'secret_type' into field. Choices are: _custom_field_data, created, description, destination_for_associations, id, last_updated, name, parameters, provider, secrets_group_associations, secrets_groups, source_for_associations, tagged_items, tags"]} 

Would think it needs to be modified to something like

        if credentials:
           try:
               self.username = credentials.get_secret_value(access_type = SecretsGroupAccessTypeChoices.TYPE_GENERIC, secret_type = SecretsGroupSecretTypeChoices.TYPE_USERNAME)
               self.password = credentials.get_secret_value(access_type = SecretsGroupAccessTypeChoices.TYPE_GENERIC, secret_type = SecretsGroupSecretTypeChoices.TYPE_PASSWORD)
               try:
                   secret = credentials.get_secret_value(access_type = SecretsGroupAccessTypeChoices.TYPE_GENERIC, secret_type = SecretsGroupSecretTypeChoices.TYPE_SECRET)
               except SecretsGroupAssociation.DoesNotExist:
                   self.secret = self.password
           except SecretsGroupAssociation.DoesNotExist:
               # should raise error or also fall back to NAPALM creds?

       else:
           self.username = settings.NAPALM_USERNAME
           self.password = settings.NAPALM_PASSWORD
           self.secret = settings.NAPALM_ARGS.get("secret", None)

If this is required we'd probably want to document the 'default" secret group access type to use.

  1. I see odd authentication issues with authentication
 {'exc_type': 'OnboardException', 'exc_module': 'nautobot_device_onboarding.exceptions', 'exc_message': ['fail-general - fail-login - ERROR: Authentication to device failed.\n\nCommon causes of this problem are:\n1. Invalid username (redacted) password\n(redacted) Incorrect SSH-key file\n3. Connecting to the wrong device\n\nDevice settings: autodetect 10.1.1.8:22\n\n\nAuthentication failed: transport shut down or saw EOF']} 

Can ssh from the server directly though. Still trying to figure that one out.
Thinking its an issue with using the settings.NAPALM_* which assumes its in the settings, vs using os.getenv('NAPALM_*. Not sure which one is correct but find it as an antipattern compared to other plugins using those env vars.

The job does function properly when using env_vars instead of settings though.

docs/dev/dev_environment.md Outdated Show resolved Hide resolved
docs/user/faq.md Outdated Show resolved Hide resolved
nautobot_device_onboarding/jobs.py Show resolved Hide resolved
nautobot_device_onboarding/jobs.py Outdated Show resolved Hide resolved
nautobot_device_onboarding/jobs.py Outdated Show resolved Hide resolved
nautobot_device_onboarding/jobs.py Outdated Show resolved Hide resolved
nautobot_device_onboarding/jobs.py Outdated Show resolved Hide resolved
nautobot_device_onboarding/nautobot_keeper.py Show resolved Hide resolved
nautobot_device_onboarding/tests/test_api.py Outdated Show resolved Hide resolved
whitej6 and others added 8 commits November 21, 2023 12:07
Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>
Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>
Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>
Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>
Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>
Copy link
Contributor

@scetron scetron left a comment

Choose a reason for hiding this comment

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

Overall, looks great!

nautobot_device_onboarding/jobs.py Show resolved Hide resolved
nautobot_device_onboarding/jobs.py Show resolved Hide resolved
@whitej6 whitej6 marked this pull request as ready for review November 21, 2023 20:51
@whitej6 whitej6 merged commit 81c5ae0 into develop Nov 21, 2023
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.

4 participants