Revision 1fca349b ncclient/operations/lock.py
b/ncclient/operations/lock.py | ||
---|---|---|
14 | 14 |
|
15 | 15 |
'Locking-related NETCONF operations' |
16 | 16 |
|
17 |
from rpc import RPC
|
|
17 |
# TODO - a context manager around some <target> would be real neat
|
|
18 | 18 |
|
19 |
from rpc import RPC |
|
20 |
from copy import deepcopy |
|
19 | 21 |
|
20 | 22 |
class Lock(RPC): |
21 | 23 |
|
22 |
def __init__(self, *args, **kwds): |
|
23 |
RPC.__init__(self, *args, **kwds) |
|
24 |
self.spec = { |
|
25 |
'tag': 'lock', |
|
26 |
'children': { 'tag': 'target', 'children': {'tag': None} } |
|
27 |
} |
|
24 |
SPEC = { |
|
25 |
'tag': 'lock', |
|
26 |
'children': { |
|
27 |
'tag': 'target', |
|
28 |
'children': {'tag': None } |
|
29 |
} |
|
30 |
} |
|
28 | 31 |
|
29 | 32 |
def request(self, target='running'): |
30 |
self.spec['children']['children']['tag'] = target |
|
31 |
self._request(self.spec) |
|
33 |
spec = deepcopy(Lock.SPEC) |
|
34 |
spec['children']['children']['tag'] = target |
|
35 |
return self._request(spec) |
|
32 | 36 |
|
33 | 37 |
|
34 | 38 |
class Unlock(RPC): |
35 | 39 |
|
36 |
def __init__(self, *args, **kwds): |
|
37 |
RPC.__init__(self, *args, **kwds) |
|
38 |
self.spec = { |
|
39 |
'tag': 'unlock', |
|
40 |
'children': { 'tag': 'target', 'children': {'tag': None} } |
|
41 |
} |
|
40 |
SPEC = { |
|
41 |
'tag': 'unlock', |
|
42 |
'children': { |
|
43 |
'tag': 'target', |
|
44 |
'children': {'tag': None } |
|
45 |
} |
|
46 |
} |
|
42 | 47 |
|
43 | 48 |
def request(self, target='running'): |
44 |
self.spec['children']['children']['tag'] = target |
|
45 |
self._request(self.spec) |
|
49 |
spec = deepcopy(Unlock.SPEC) |
|
50 |
spec['children']['children']['tag'] = target |
|
51 |
return self._request(self.spec) |
Also available in: Unified diff