git-svn-id: http://ncclient.googlecode.com/svn/trunk@15 6dbcf712-26ac-11de-a2f3-13738...
authorShikhar Bhushan <shikhar@schmizz.net>
Thu, 16 Apr 2009 02:44:57 +0000 (02:44 +0000)
committerShikhar Bhushan <shikhar@schmizz.net>
Thu, 16 Apr 2009 02:44:57 +0000 (02:44 +0000)
src/__init__.py
src/session.py
src/ssh.py

index 519a659..655152b 100644 (file)
@@ -12,4 +12,6 @@
 # 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
index 76ab7da..ed8823d 100644 (file)
@@ -14,6 +14,8 @@
 
 import threading
 
+class SessionError(NETCONFClientError): pass
+
 class Session(threading.Thread):
     
     def __init__(self, capabilities, reply_cb):
@@ -26,7 +28,13 @@ class Session(threading.Thread):
         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()
         
@@ -34,21 +42,9 @@ class Session(threading.Thread):
         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
index 0d4e877..67381ec 100644 (file)
@@ -17,12 +17,10 @@ import paramiko
 
 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
@@ -98,7 +96,7 @@ class SSHSession(Session):
                     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):
     
@@ -107,4 +105,4 @@ class CallbackPolicy(paramiko.MissingHostKeyPolicy):
     
     def missing_host_key(self, client, hostname, key):
         if not self._cb(hostname, key):
-            raise SomeError
+            raise SessionError