# See the License for the specific language governing permissions and
# limitations under the License.
-__version__ = "0.01"
\ No newline at end of file
+__version__ = "0.01"
+
+class NETCONFClientError(Exception): pass
\ No newline at end of file
import threading
+class SessionError(NETCONFClientError): pass
+
class Session(threading.Thread):
def __init__(self, capabilities, reply_cb):
self._cb = reply_cb
self.id = None # session-id
self.connected = False
-
+
+ def _make_hello(self):
+ pass
+
+ def _parse_hello(self, msg):
+ pass
+
def connect(self):
self.start()
raise NotImplementedError
def send(self, msg):
- if not self.connected:
+ if self.connected:
self._q.add(msg)
-
- def expectClose(self, val=True):
- '''operations.CloseSession must call this before a call to send(),
- so that the remote endpoint closing the connection does not result
- in an exception'''
- self._expectClose = val
-
- @property
- def id(self):
- 'Session ID'
- return self._id
-
- # Preferred way is to access the attributes directly,
- # but here goes:
-
- # TODO
\ No newline at end of file
+ else:
+ raise SessionError('''Attempted to send message before
+ NETCONF session initialisation''')
+
\ No newline at end of file
from select import select as select
-from .session import Session
+from .session import Session, SessionError
logger = logging.getLogger('ncclient.ssh')
-class SomeError(Exception): pass
-
class SSHSession(Session):
BUF_SIZE = 4096
connected = False
# it's not an error if we asked for it
# via CloseSession -- need a way to know this
- raise SomeError
+ raise SessionError
class CallbackPolicy(paramiko.MissingHostKeyPolicy):
def missing_host_key(self, client, hostname, key):
if not self._cb(hostname, key):
- raise SomeError
+ raise SessionError