-
Notifications
You must be signed in to change notification settings - Fork 43
[WIP] Draft / prototype for device discovery #354
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
base: develop
Are you sure you want to change the base?
Conversation
@mzbroch , I like your approach. I think that is fair to start using SSH discovery as an initial option and later add other methods if needed |
|
||
# Dispatch SSH | ||
if target_port_details["protocol"] == AutodiscoveryProtocolTypeChoices.SSH: | ||
guessed_platform, exception, credentials = self._get_target_details_ssh( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we don't get proper details via SSH, should we remove the target from the self.targets? and log an issue? (because it seems to have the port SSH port open, but not able to connect with the credentials)
self.logger.error(f"Error with future for IP {host}: {e}") | ||
|
||
if self.debug: | ||
self.logger.info(f"Results: {results}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.logger.info(f"Results: {results}") | |
self.logger.debug(f"Results: {results}") |
host = future_to_ip[future] | ||
try: | ||
results[host] = future.result() | ||
except Exception as e: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which exception are you expecting?
"""Scan the selected IP Addresses for open protocol-ports - dispatcher method.""" | ||
scan_result = {} | ||
|
||
with concurrent.futures.ThreadPoolExecutor(max_workers=self.scanning_threads_count) as executor: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems odd to me that we're not making these tasks nornir-tasks to keep the pattern the same.
|
||
return scan_result | ||
|
||
def _parse_credentials(self, credentials): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be the third time we define this same function in this app. Can you just import from
from nautobot_device_onboarding.nornir_plays.command_getter import _parse_credentials
) | ||
raise OnboardException("fail-credentials - Unable to parse selected credentials.") from err | ||
|
||
def _get_target_details_ssh(self, hostname, port): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another one where we already have this
from nautobot_device_onboarding.nornir_plays.inventory_creator import guess_netmiko_device_type
Prototype for device discovery built on-top of existing SSOT Job.
Current support is for SSH only (same as existing SSOT job), however more methods like SNMP can be added in the future if needed.
Assumptions:
There is an implemented opinion about network discovery workflow:
Prefixes have to be created and are available for input selection
Integrates with existing device onboarding
Focuses on SSH running on 22, but can be extended for other ports and protocols
Crawling (CDP/LLDP) not being a priority
Re-uses hackaton project for threading
Does not integrate nmap/ scapy / scanners as these can might not allowed by Enterprise Security teams
Does not store models / information about discovered endpoints
Current support is for providing Prefix based on tags - this might need some thought process
TODO