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

Fatal error: No existing session when using execute() #1889

Open
gvfnix opened this issue Oct 9, 2018 · 0 comments
Open

Fatal error: No existing session when using execute() #1889

gvfnix opened this issue Oct 9, 2018 · 0 comments

Comments

@gvfnix
Copy link

gvfnix commented Oct 9, 2018

Hi, I have some strange issue when using Fabric 1.14 with python 2.7. If the code contains execute() statement, then fabric cannot open SSH connection to the host and the script fails with Fatal error: No existing session. But if I do not use execute(), the script runs normally.

Code sample:

#!/usr/bin/env python
#encoding: utf-8
import os, sys, logging
logging.basicConfig(level=logging.DEBUG)
from fabric.api import (execute, run, task, sudo, env, roles, hosts)

env.user="root"
env.password="***"
env.reject_unknown_hosts = False

@task
@hosts('10.100.0.100')
def getnproc():
    # cores = int(sudo('nproc'))
    # ram = int(sudo("cat /proc/meminfo | grep MemTotal | awk '{ print $2 }'")) / 1024
    # return {'cores': cores, 'RAM': ram}
    return run('nproc')

a = execute(getnproc, host='10.100.0.100')

Running the script:

[root@38768029c5f2 stress]# fab getnproc
[10.100.0.100] Executing task 'getnproc'
[10.100.0.100] run: nproc
DEBUG:paramiko.transport:starting thread (client mode): 0x8f161810L
DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.4.2

Fatal error: No existing session

Underlying exception:
    No existing session

Aborting.
DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-OpenSSH_7.4
INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_7.4)
DEBUG:paramiko.transport:EOF in transport thread

But if I comment out the line a = execute(getnproc, host='10.100.0.100'), this script runs normally:

[root@38768029c5f2 stress]# fab getnproc
[10.100.0.100] Executing task 'getnproc'
[10.100.0.100] run: nproc
DEBUG:paramiko.transport:starting thread (client mode): 0xf27b27d0L
DEBUG:paramiko.transport:Local version/idstring: SSH-2.0-paramiko_2.4.2
DEBUG:paramiko.transport:Remote version/idstring: SSH-2.0-OpenSSH_7.4
INFO:paramiko.transport:Connected (version 2.0, client OpenSSH_7.4)
DEBUG:paramiko.transport:kex algos:[u'curve25519-sha256', u'curve25519-sha256@libssh.org', u'ecdh-sha2-nistp256', u'ecdh-sha2-nistp384', u'ecdh-sha2-nistp521', u'diffie-hellman-group-exchange-sha256', u'diffie-hellman-group16-sha512', u'diffie-hellman-group18-sha512', u'diffie-hellman-group-exchange-sha1', u'diffie-hellman-group14-sha256', u'diffie-hellman-group14-sha1', u'diffie-hellman-group1-sha1'] server key:[u'ssh-rsa', u'rsa-sha2-512', u'rsa-sha2-256', u'ecdsa-sha2-nistp256', u'ssh-ed25519'] client encrypt:[u'chacha20-poly1305@openssh.com', u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'aes128-gcm@openssh.com', u'aes256-gcm@openssh.com', u'aes128-cbc', u'aes192-cbc', u'aes256-cbc', u'blowfish-cbc', u'cast128-cbc', u'3des-cbc'] server encrypt:[u'chacha20-poly1305@openssh.com', u'aes128-ctr', u'aes192-ctr', u'aes256-ctr', u'aes128-gcm@openssh.com', u'aes256-gcm@openssh.com', u'aes128-cbc', u'aes192-cbc', u'aes256-cbc', u'blowfish-cbc', u'cast128-cbc', u'3des-cbc'] client mac:[u'umac-64-etm@openssh.com', u'umac-128-etm@openssh.com', u'hmac-sha2-256-etm@openssh.com', u'hmac-sha2-512-etm@openssh.com', u'hmac-sha1-etm@openssh.com', u'umac-64@openssh.com', u'umac-128@openssh.com', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-sha1'] server mac:[u'umac-64-etm@openssh.com', u'umac-128-etm@openssh.com', u'hmac-sha2-256-etm@openssh.com', u'hmac-sha2-512-etm@openssh.com', u'hmac-sha1-etm@openssh.com', u'umac-64@openssh.com', u'umac-128@openssh.com', u'hmac-sha2-256', u'hmac-sha2-512', u'hmac-sha1'] client compress:[u'none', u'zlib@openssh.com'] server compress:[u'none', u'zlib@openssh.com'] client lang:[u''] server lang:[u''] kex follows?False
DEBUG:paramiko.transport:Kex agreed: ecdh-sha2-nistp256
DEBUG:paramiko.transport:HostKey agreed: ssh-ed25519
DEBUG:paramiko.transport:Cipher agreed: aes128-ctr
DEBUG:paramiko.transport:MAC agreed: hmac-sha2-256
DEBUG:paramiko.transport:Compression agreed: none
DEBUG:paramiko.transport:kex engine KexNistp256 specified hash_algo <built-in function openssl_sha256>
DEBUG:paramiko.transport:Switch to new keys ...
DEBUG:paramiko.transport:Adding ssh-ed25519 host key for 10.100.0.100: a2ad0722bf03431667fed3e2655f4ff7
DEBUG:paramiko.transport:userauth is OK
INFO:paramiko.transport:Authentication (password) successful!
DEBUG:paramiko.transport:[chan 0] Max packet in: 32768 bytes
DEBUG:paramiko.transport:Received global request "hostkeys-00@openssh.com"
DEBUG:paramiko.transport:Rejecting "hostkeys-00@openssh.com" global request from server.
DEBUG:paramiko.transport:[chan 0] Max packet out: 32768 bytes
DEBUG:paramiko.transport:Secsh channel 0 opened.
DEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok
DEBUG:paramiko.transport:[chan 0] Sesch channel 0 request ok
DEBUG:paramiko.transport:[chan 0] EOF received (0)
DEBUG:paramiko.transport:[chan 0] EOF sent (0)
[10.100.0.100] out: 4
[10.100.0.100] out: 


Done.
DEBUG:paramiko.transport:EOF in transport thread
Disconnecting from 10.100.0.100... done.

Python 2.7.5
Fabric 1.14.0
Paramiko 2.4.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant