Revision 179b00d4 ncclient/operations/session.py

b/ncclient/operations/session.py
16 16

  
17 17
from ncclient.rpc import RPC
18 18

  
19
class CloseSession(RPC): # x
20
    
21
    'CloseSession is always synchronous'
19
class CloseSession(RPC):
20
    # tested: no
21
    # combed: yes
22 22
    
23 23
    SPEC = { 'tag': 'close-session' }
24 24
    
......
26 26
        if self.reply.ok:
27 27
            self.session.expect_close()
28 28
        self.session.close()
29
    
30
    def request(self):
31
        return self._request(CloseSession.SPEC)
32 29

  
33 30

  
34
class KillSession(RPC): # x
31
class KillSession(RPC):
32
    # tested: no
35 33
    
36 34
    SPEC = {
37 35
        'tag': 'kill-session',
38
        'children': { 'tag': 'session-id', 'text': None}
36
        'subtree': []
39 37
    }
40 38
    
41 39
    def request(self, session_id):
40
        spec = KillSession.SPEC.copy()
42 41
        if not isinstance(session_id, basestring): # just making sure...
43 42
            session_id = str(session_id)
44
        spec = KillSession.SPEC.copy()
45
        spec['children'][0]['text'] = session_id
43
        spec['subtree'].append({
44
            'tag': 'session-id',
45
            'text': session_id
46
        })
46 47
        return self._request(spec)

Also available in: Unified diff