Python Forum
Paramiko resource shortage error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Paramiko resource shortage error
#1
I have a script that reads from a CSV file to ssh to devices. I am trying to run exec.command to read some info and place in a variable. When i run it, i receive an exception error on resource shortage. I've googled it and have tried a couple of things (sleep etc.) but cant seem to figure it out. Both script and error listed. Any help would be appreciated.

### script ###
with open(r'Customer_Info.csv', 'r') as f:
    for line in f:
        router = {}
        router_line = line.split(',')
        router = {
            'ip': router_line[11],
            'username': router_line[21],
            'password': router_line[22],
        }
        if valid_ip(router['ip']) and router['password'] and router['username']:
           #Create an SSH client
            client = paramiko.SSHClient()
            #Make sure that we add the remote server's SSH key automatically
            client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
            #Connect to the client
            client.connect(router['ip'], username=router['username'], password=router['password'], allow_agent=False, look_for_keys=False)
            #Create a raw shell
            shell = client.invoke_shell()
            [b]#Grab hostname of device
            stdin, stdout, stderr  = client.exec_command('sh run | i hostname')
            mystring = stdout.read()
            print (mystring)
            hostname = mystring[9:][/b]
### Error ###
Error:
Secsh channel 1 open FAILED: : Resource shortage Traceback (most recent call last): File "V:\Workspace\Scripting\Python Scripts\Sandbox\HNS_VPN-AutoConfig2.py", line 157, in <module> stdin, stdout, stderr = client.exec_command('sh run | i hostname') File "C:\Users\jkey\AppData\Local\Programs\Python\Python36-32\lib\site-packages\paramiko\client.py", line 480, in exec_command chan = self._transport.open_session(timeout=timeout) File "C:\Users\jkey\AppData\Local\Programs\Python\Python36-32\lib\site-packages\paramiko\transport.py", line 767, in open_session timeout=timeout) File "C:\Users\jkey\AppData\Local\Programs\Python\Python36-32\lib\site-packages\paramiko\transport.py", line 902, in open_channel raise e paramiko.ssh_exception.ChannelException: (4, 'Resource shortage')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to set CPU and memory resource SriRajesh 1 1,438 Aug-16-2021, 05:23 PM
Last Post: Larz60+
  Problem importing resource library ChrisM 8 3,866 Oct-23-2019, 01:40 PM
Last Post: ChrisM
  Resource Monitoring MuntyScruntfundle 1 39,254 Feb-20-2019, 10:00 PM
Last Post: Larz60+
  Py3 Data Resource file help esteel 0 2,057 May-20-2018, 10:33 PM
Last Post: esteel
  'OSError: [Errno 16] Device or resource busy' for ralationship with ds1307 gray 4 8,955 Jul-31-2017, 02:17 AM
Last Post: jackbk

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020