1 # Copyright 2h009 Shikhar Bhushan
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 'Locking-related NETCONF operations'
27 'subtree': {'tag': None }
31 def request(self, target):
33 :arg target: see :ref:`source_target`
38 spec = Lock.SPEC.copy()
39 spec['subtree']['subtree']['tag'] = target
40 return self._request(spec)
51 'subtree': {'tag': None }
55 def request(self, target):
57 :arg target: see :ref:`source_target`
62 spec = Unlock.SPEC.copy()
63 spec['subtree']['subtree']['tag'] = target
64 return self._request(spec)
70 A context manager for the :class:`Lock` / :class:`Unlock` pair of RPC's.
72 Initialise with session instance (:class:`Session
73 <ncclient.transport.Session>`) and lock target (:ref:`source_target`)
76 def __init__(self, session, target):
77 self.session = session
81 reply = Lock(self.session).request(self.target)
87 def __exit__(self, *args):
88 reply = Unlock(session).request(self.target)