exscript icon indicating copy to clipboard operation
exscript copied to clipboard

Using --no-authentication gives NoneType error

Open lathspell opened this issue 7 years ago • 1 comments

I'd wanted to use the "--no-authentication" flag as the auto login does not understand this routers CLI prompt. The message looks rather like a bug tough. "NoneType" sounds like a NullPointerException? :)

# exscript -p ssh --no-authentication -v5 --csv-hosts=hosts-xxx.txt test.exscript
Please enter your user name [root]: xxx
Please enter your password:
All jobs enqueued.
Waiting for the queue to finish.
xxx-xxx-1 error: 'NoneType' object has no attribute 'sendall'
Traceback (most recent call last):
  File "build/bdist.linux-x86_64/egg/Exscript/workqueue/job.py", line 78, in run
    self.function(self)
  File "build/bdist.linux-x86_64/egg/Exscript/queue.py", line 102, in _wrapped
    result = func(job, host, conn, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/Exscript-2.4.48-py2.7.egg/EGG-INFO/scripts/exscript", line 252, in function
  File "build/bdist.linux-x86_64/egg/Exscript/util/template.py", line 141, in eval
    return _run(conn, None, string, parser_args, **kwargs)
  File "build/bdist.linux-x86_64/egg/Exscript/util/template.py", line 59, in _run
    return compiled.execute()
  File "build/bdist.linux-x86_64/egg/Exscript/interpreter/program.py", line 50, in execute
    self.value(self)
  File "build/bdist.linux-x86_64/egg/Exscript/interpreter/scope.py", line 94, in value
    result = child.value(context)
  File "build/bdist.linux-x86_64/egg/Exscript/interpreter/scope.py", line 94, in value
    result = child.value(context)
  File "build/bdist.linux-x86_64/egg/Exscript/interpreter/execute.py", line 60, in value
    conn.execute(command)
  File "build/bdist.linux-x86_64/egg/Exscript/protocols/protocol.py", line 972, in execute
    self.send(command + '\r')
  File "build/bdist.linux-x86_64/egg/Exscript/protocols/ssh2.py", line 378, in send
    self.shell.sendall(data)
AttributeError: 'NoneType' object has no attribute 'sendall'

xxx-xxx-1 finally failed.
Waiting for the queue to finish.
Destroying queue...
Queue destroyed.
error: 1 actions failed.

lathspell avatar Sep 12 '18 13:09 lathspell

--no-authentication means that the entire login procedure is skipped, including the SSH authentication that happens before the application layer is ready. In other words, if you device supports authentication and doesn't open a shell on it's own (some devices do this; your's doesn't), this option is not what you want. Put simply, your device doesn't allow for opening a shell unless you are authenticated.

In order to support your CLI prompt, you could either write a driver like this:

https://github.com/knipknap/exscript/blob/master/Exscript/protocols/drivers/nxos.py

and pass that to Exscript using --load-driver, or use something like {connection.set_prompt('foobar#')} as the first line of your template.

knipknap avatar Dec 08 '18 05:12 knipknap