-
Notifications
You must be signed in to change notification settings - Fork 345
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
Connected property #664
Connected property #664
Conversation
merge Juniper changes into my fork.
adding recent changes including root shell fix
This converts the There is also now a Session Listener attached to the session object in the netconf transport, which responds to errors in the Transport in the background by setting the I also added a step in the |
@@ -940,6 +966,14 @@ def __init__(self, *vargs, **kvargs): | |||
# ----------------------------------------------------------------------- | |||
# Basic device methods | |||
# ----------------------------------------------------------------------- | |||
@property | |||
def connected(self): | |||
return self._connected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is _connected initialized? I guess this is coming from ncclient. Not sure if this will be
self._cnnected or self._conn._connected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vnitinv line 959 in __init__()
initializes self._connected
to False
because it's calling the connected
setter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really what I wanted to have. Thanks a lot Jason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spidercensus It generally looks good. Just one small issue with errback()
. Once you're able to make that change I will merge.
lib/jnpr/junos/device.py
Outdated
:type ex: :exc:`Exception` | ||
""" | ||
self._device.connected = False | ||
raise NcErrors.TransportError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe we should raise an exception here. It's not actually doing anything anyway because ncclient catches the exception and just attempts to log a debug message:
https://github.com/ncclient/ncclient/blob/master/ncclient/transport/session.py#L77-L80
A TransportError
exception will already be raised the next time there's an attempt to send on this connection:
https://github.com/ncclient/ncclient/blob/master/ncclient/transport/session.py#L155
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right. I'll remove that.
lib/jnpr/junos/device.py
Outdated
def __init__(self, device): | ||
self._device = device | ||
def callback(self, root, raw): | ||
"""Called when a new XML document is received. The *root* argument allows the callback to determine whether it wants to further process the document. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please run through pep8
and clean up any reported problems like this long line.
@stacywsmith Give me 1-2 days to test this pull request. Then we can merge this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
made requested changes and ran thru pep8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vnitinv I approve of this pull request, but I don't want to merge without your agreement. Yes, this pull request only addresses the case where the Junos device closes the NETCONF over SSH connection due to an inactivity timeout. However, we can address the issue where the connection is interrupted due to an intermediate network problem in either #668 or a new pull request.
This partly addresses issue #663