Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def scrapli_connection(self, device):
connection = self.get_or_close_connection("scrapli", device.name)
if connection:
self.log("info", "Using cached Scrapli connection", device)
return connection
self.log(
"info", "OPENING Scrapli connection", device, logger="security",
)
username, password = self.get_credentials(device)
connection = Scrapli(
transport=self.transport,
platform=device.scrapli_driver if self.use_device_driver else self.driver,
host=device.ip_address,
auth_username=username,
auth_password=password,
auth_private_key=False,
auth_strict_key=False,
)
connection.open()
app.connections_cache["scrapli"][self.parent_runtime][device.name] = connection
return connection