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

Arista CloudVision Integration job failing #571

Closed
bwilt1464 opened this issue Oct 16, 2024 · 3 comments · Fixed by #572
Closed

Arista CloudVision Integration job failing #571

bwilt1464 opened this issue Oct 16, 2024 · 3 comments · Fixed by #572
Labels
integration: cloudvision Issues/PRs for the Arista CloudVision SSoT integration.

Comments

@bwilt1464
Copy link

Environment

  • Python version: 3.9.19 (within latest nautobot-docker-compose)
  • Nautobot version: 2.3.2 (within latest nautobot-docker-compose)
  • nautobot-ssot version: 3.1.0

Expected Behavior

Using on-prem Cloudvision, I believe that the job should run successfully but fails with the error below.

Observed Behavior

{ "exc_message": [ "No connection adapters were found for 'cvp-1.vmw-sddc.lab:443/cvpservice/login/authenticate.do'" ], "exc_module": "requests.exceptions", "exc_type": "InvalidSchema" } --

Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/celery/app/trace.py", line 477, in trace_task
R = retval = fun(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/celery/app/trace.py", line 760, in protected_call
return self.run(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/nautobot/extras/jobs.py", line 1136, in run_job
result = job(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/nautobot/extras/jobs.py", line 149, in call
return self.run(*args, **deserialized_kwargs)
File "/usr/local/lib/python3.9/site-packages/nautobot_ssot/integrations/aristacv/jobs.py", line 138, in run
super().run(dryrun=self.dryrun, memory_profiling=self.memory_profiling, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/nautobot_ssot/jobs/base.py", line 330, in run
self.sync_data(memory_profiling)
File "/usr/local/lib/python3.9/site-packages/nautobot_ssot/jobs/base.py", line 149, in sync_data
self.load_source_adapter()
File "/usr/local/lib/python3.9/site-packages/nautobot_ssot/integrations/aristacv/jobs.py", line 114, in load_source_adapter
with CloudvisionApi(self.app_config) as client:
File "/usr/local/lib/python3.9/site-packages/nautobot_ssot/integrations/aristacv/utils/cloudvision.py", line 67, in init
response = requests.post(
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 115, in post
return request("post", url, data=data, json=json, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 697, in send
adapter = self.get_adapter(url=request.url)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 792, in get_adapter
raise InvalidSchema(f"No connection adapters were found for {url!r}")
requests.exceptions.InvalidSchema: No connection adapters were found for 'hostname.lab:443/cvpservice/login/authenticate.do'

Steps to Reproduce

  1. Setup nautobot using nautobot-docker-compose SOP (https://github.com/nautobot/nautobot-docker-compose/tree/main)
  2. Setup nautobot-app-ssot using nautobot-docker-compose plugin SOP (https://github.com/nautobot/nautobot-docker-compose/blob/main/docs/plugins.md)
    a. poetry add nautobot-ssot[all]
    b. configure config/nautobot_config.py

PLUGINS_CONFIG = {
"nautobot_ssot": {
"hide_example_jobs": True,
# Infoblox
"enable_infoblox": True,
# Arista CloudVision
"enable_aristacv": True,
"aristacv_cvp_token": os.getenv("NAUTOBOT_ARISTACV_TOKEN", ""),
"aristacv_cvp_host": os.getenv("NAUTOBOT_ARISTACV_HOST", "hostname.lab"),
"aristacv_cvp_port": os.getenv("NAUTOBOT_ARISTACV_PORT", 443),
"aristacv_cvp_user": os.getenv("NAUTOBOT_ARISTACV_USERNAME", "temp-user"),
"aristacv_cvp_password": os.getenv("NAUTOBOT_ARISTACV_PASSWORD", "fake-password"),
"aristacv_verify": is_truthy(os.getenv("NAUTOBOT_ARISTACV_VERIFY", False)),
"aristacv_from_cloudvision_default_site": "default_site",
"aristacv_from_cloudvision_default_device_role": "default_role",
"aristacv_from_cloudvision_default_device_role_color": "ff0000",
"aristacv_delete_devices_on_sync": is_truthy(os.getenv("NAUTOBOT_ARISTACV_DELETE_ON_SYNC", False)),
"aristacv_apply_import_tag": is_truthy(os.getenv("NAUTOBOT_ARISTACV_IMPORT_TAG", True)),
"aristacv_import_active": is_truthy(os.getenv("NAUTOBOT_ARISTACV_IMPORT_ACTIVE", False)),
"aristacv_create_controller": is_truthy(os.getenv("NAUTOBOT_ARISTACV_CREATE_CONTROLLER", True)),
"aristacv_controller_site": os.getenv("NAUTOBOT_ARISTACV_CONTROLLER_SITE", "control"),
"aristacv_hostname_patterns": [""],
"aristacv_site_mappings": {},
"aristacv_role_mappings": {},
c. invoke build --no-cache
d. invoke stop start

  1. run job
@jdrew82
Copy link
Contributor

jdrew82 commented Oct 17, 2024

@bwilt1464 That error is specifically coming from the requests library and is an InvalidSchema Exception. That specifically is complaining because you don't have the schema, ie http/https defined for your CVP host value. It appears you have it as just hostname.lab. It should be https://hostname.lab.

@jdrew82 jdrew82 closed this as completed Oct 17, 2024
@jdrew82 jdrew82 added the integration: cloudvision Issues/PRs for the Arista CloudVision SSoT integration. label Oct 17, 2024
@bwilt1464
Copy link
Author

@jdrew82 thank you for looking at the ticket so quickly! I'm more on the networking side and only know enough python to be dangerous.

I've tried a number of different things, including editing plugin python files and the config/nautobot_config.py file
config/nautobot_config.py

...
PLUGINS_CONFIG = {
    "nautobot_ssot": {
        "hide_example_jobs": True,
        "enable_aristacv": True,
        "aristacv_cvp_token": os.getenv("NAUTOBOT_ARISTACV_TOKEN", ""),
        "aristacv_cvp_host": os.getenv("NAUTOBOT_ARISTACV_HOST", "https://hostname.lab"),
...

in plugins/nautobot-app-ssot/nautobot_ssot/integrations/aristacv/utils/nautobot.py

...
    if config["is_on_premise"]:
        url = app_settings.get("aristacv_cvp_host", "")
        if not url.startswith("http"):
            url = f"https://{url}"
        parsed_url = urlparse(url)
        port = parsed_url.port or app_settings.get("aristacv_cvp_port", 443)
        config["url"] = f"{parsed_url.scheme}://{parsed_url.hostname}:{port}"
...

From my interpretation, it seems like the https:// should be added regardless of whether I have it in NAUTOBOT_ARISTACV_HOST but it should definitely be there if I explicitly add it

@jdrew82 jdrew82 reopened this Oct 17, 2024
@jdrew82
Copy link
Contributor

jdrew82 commented Oct 17, 2024

@bwilt1464 I had forgotten that bit got updated. You are correct that it should automatically be inserting the HTTPS schema. However, the Exception that you provided actually shows that the error is occurring during the initialization of the CVP client:

File "/usr/local/lib/python3.9/site-packages/nautobot_ssot/integrations/aristacv/utils/cloudvision.py", line 67, in init
response = requests.post(

Looking at the code, it does appear that we're not including the schema for some odd reason:

                response = requests.post(
                    f"{parsed_url.hostname}:{parsed_url.port}/cvpservice/login/authenticate.do",
                    auth=(config.cvp_user, config.cvp_password),

I'll get a PR in to get that fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration: cloudvision Issues/PRs for the Arista CloudVision SSoT integration.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants