"evalue": "HTTPSConnectionPool(host='10.171.0.34', port=443): Max retries exceeded with url: /rest/v1/login (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fab87770820>: Failed to establish a new connection: [Errno 110] Connection timed out'))",
"\u001b[0;32m/usr/lib/python3/dist-packages/urllib3/connection.py\u001b[0m in \u001b[0;36m_new_conn\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 170\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mSocketError\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 171\u001b[0;31m raise NewConnectionError(\n\u001b[0m\u001b[1;32m 172\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"Failed to establish a new connection: %s\"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNewConnectionError\u001b[0m: <urllib3.connection.VerifiedHTTPSConnection object at 0x7fab87770820>: Failed to establish a new connection: [Errno 110] Connection timed out",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[0;31mMaxRetryError\u001b[0m: HTTPSConnectionPool(host='10.171.0.34', port=443): Max retries exceeded with url: /rest/v1/login (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fab87770820>: Failed to establish a new connection: [Errno 110] Connection timed out'))",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[0;32m/tmp/ipykernel_24880/1664368059.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 45\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Enter the Switch IP:\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 46\u001b[0m \u001b[0mip_add\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 47\u001b[0;31m \u001b[0mget_logs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mip_add\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m/tmp/ipykernel_24880/1664368059.py\u001b[0m in \u001b[0;36mget_logs\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mget_logs\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 13\u001b[0m \u001b[0;31m# send post request to switch to login to the switch\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 14\u001b[0;31m \u001b[0mlogin\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msession\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpost\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"https://{self}/rest/v1/login\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mcreds\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mverify\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mFalse\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 15\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34mf\"Login code from Switch: {login.status_code}\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0;31m# we use this cookies keep secure connection to the switch\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m/usr/lib/python3/dist-packages/requests/sessions.py\u001b[0m in \u001b[0;36msend\u001b[0;34m(self, request, **kwargs)\u001b[0m\n\u001b[1;32m 644\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 645\u001b[0m \u001b[0;31m# Send the request\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 646\u001b[0;31m \u001b[0mr\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0madapter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrequest\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 647\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 648\u001b[0m \u001b[0;31m# Total elapsed time of the request (approximately)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mConnectionError\u001b[0m: HTTPSConnectionPool(host='10.171.0.34', port=443): Max retries exceeded with url: /rest/v1/login (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fab87770820>: Failed to establish a new connection: [Errno 110] Connection timed out'))"
" data = f'{{\"stp_config\":{{\"admin_edge_port_enable\":true,\"bpdu_filter_enable\":true,\"bpdu_guard_enable\":true}},\"user_config\":{{\"admin\":\"{up_down}\"}},\"loop_protect_enable\":true}}'\n",
664 # Make the request on the httplib connection object.
--> 665 httplib_response = self._make_request(
666 conn,
/usr/lib/python3/dist-packages/urllib3/connectionpool.py in _make_request(self, conn, method, url, timeout, chunked, **httplib_request_kw)
375 try:
--> 376 self._validate_conn(conn)
377 except (SocketTimeout, BaseSSLError) as e:
/usr/lib/python3/dist-packages/urllib3/connectionpool.py in _validate_conn(self, conn)
995 if not getattr(conn, "sock", None): # AppEngine might not have `.sock`
--> 996 conn.connect()
997
/usr/lib/python3/dist-packages/urllib3/connection.py in connect(self)
313 # Add certificate verification
--> 314 conn = self._new_conn()
315 hostname = self.host
/usr/lib/python3/dist-packages/urllib3/connection.py in _new_conn(self)
170 except SocketError as e:
--> 171 raise NewConnectionError(
172 self, "Failed to establish a new connection: %s" % e
NewConnectionError: <urllib3.connection.VerifiedHTTPSConnectionobjectat0x7fab87770820>: Failed to establish a new connection: [Errno 110] Connection timed out
During handling of the above exception, another exception occurred:
MaxRetryError Traceback (most recent call last)
/usr/lib/python3/dist-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
/usr/lib/python3/dist-packages/urllib3/util/retry.py in increment(self, method, url, response, error, _pool, _stacktrace)
435 if new_retry.is_exhausted():
--> 436 raise MaxRetryError(_pool, url, error or ResponseError(cause))
437
MaxRetryError: HTTPSConnectionPool(host='10.171.0.34', port=443): Max retries exceeded with url: /rest/v1/login (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnectionobjectat0x7fab87770820>: Failed to establish a new connection: [Errno 110] Connection timed out'))
During handling of the above exception, another exception occurred:
ConnectionError Traceback (most recent call last)
/tmp/ipykernel_24880/1664368059.py in <module>
45 print("Enter the Switch IP:")
46 ip_add = input()
---> 47 get_logs(ip_add)
/tmp/ipykernel_24880/1664368059.py in get_logs(self)
12 def get_logs(self):
13 # send post request to switch to login to the switch
/usr/lib/python3/dist-packages/requests/sessions.py in send(self, request, **kwargs)
644
645 # Send the request
--> 646 r = adapter.send(request, **kwargs)
647
648 # Total elapsed time of the request (approximately)
/usr/lib/python3/dist-packages/requests/adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
514 raise SSLError(e, request=request)
515
--> 516 raise ConnectionError(e, request=request)
517
518 except ClosedPoolError as e:
ConnectionError: HTTPSConnectionPool(host='10.171.0.34', port=443): Max retries exceeded with url: /rest/v1/login (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fab87770820>: Failed to establish a new connection: [Errno 110] Connection timed out'))
%% Cell type:code id: tags:
``` python
fromnetmikoimportConnectHandler
fromgetpassimportgetpass
fromprettyprinterimportpprint
net_connect=ConnectHandler(
device_type="aruba_procurve",
host="10.171.0.34",
username="35021233",
password="Overwatch20!!",
)
policyrole="wired_l2_print_dur-3134-6"
output=net_connect.send_command("show port-access clients role wired_l2_print_dur-3134-6")