Revision a6c00291 ncclient/operations/lock.py
b/ncclient/operations/lock.py | ||
---|---|---|
14 | 14 |
|
15 | 15 |
'Locking-related NETCONF operations' |
16 | 16 |
|
17 |
from copy import deepcopy |
|
18 |
|
|
19 | 17 |
from ncclient.rpc import RPC |
20 | 18 |
|
21 |
# TODO - a context manager around some <target> would be real neat
|
|
19 |
import util
|
|
22 | 20 |
|
23 |
class Lock(RPC): # x
|
|
21 |
class Lock(RPC): |
|
24 | 22 |
|
25 | 23 |
SPEC = { |
26 | 24 |
'tag': 'lock', |
... | ... | |
33 | 31 |
def request(self, target='running'): |
34 | 32 |
if target=='candidate': |
35 | 33 |
self._assert(':candidate') |
36 |
spec = deepcopy(Lock.SPEC)
|
|
34 |
spec = Lock.SPEC.copy()
|
|
37 | 35 |
spec['children']['children']['tag'] = target |
38 | 36 |
return self._request(spec) |
39 | 37 |
|
40 | 38 |
|
41 |
class Unlock(RPC): # x
|
|
39 |
class Unlock(RPC): |
|
42 | 40 |
|
43 | 41 |
SPEC = { |
44 | 42 |
'tag': 'unlock', |
... | ... | |
51 | 49 |
def request(self, target='running'): |
52 | 50 |
if target=='candidate': |
53 | 51 |
self._assert(':candidate') |
54 |
spec = deepcopy(Unlock.SPEC)
|
|
52 |
spec = Unlock.SPEC.copy()
|
|
55 | 53 |
spec['children']['children']['tag'] = target |
56 |
return self._request(self.spec)
|
|
54 |
return self._request(spec) |
|
57 | 55 |
|
58 | 56 |
|
59 | 57 |
class LockContext: |
Also available in: Unified diff