Revision cc9af1c3 ncclient/operations/edit.py
b/ncclient/operations/edit.py | ||
---|---|---|
12 | 12 |
# See the License for the specific language governing permissions and |
13 | 13 |
# limitations under the License. |
14 | 14 |
|
15 |
from ncclient.rpc import RPC |
|
16 | 15 |
from ncclient.content import iselement |
17 | 16 |
|
17 |
from rpc import RPC |
|
18 |
|
|
18 | 19 |
import util |
19 | 20 |
|
20 |
""" |
|
21 |
""" |
|
22 | 21 |
|
23 |
# NOTES |
|
24 |
# - consider class for helping define <config> for EditConfig?? |
|
22 |
"Operations related to configuration editing" |
|
25 | 23 |
|
26 | 24 |
|
27 | 25 |
class EditConfig(RPC): |
28 | 26 |
|
29 | 27 |
# tested: no |
30 |
# combed: no
|
|
28 |
# combed: yes
|
|
31 | 29 |
|
32 |
SPEC = { |
|
33 |
'tag': 'edit-config', |
|
34 |
'subtree': [] |
|
35 |
} |
|
30 |
SPEC = {'tag': 'edit-config', 'subtree': []} |
|
36 | 31 |
|
37 | 32 |
def request(self, target=None, target_url=None, config=None, |
38 | 33 |
default_operation=None, test_option=None, error_option=None): |
... | ... | |
41 | 36 |
subtree = spec['subtree'] |
42 | 37 |
subtree.append({ |
43 | 38 |
'tag': 'target', |
44 |
'subtree': util.store_or_url(target, target_url) |
|
45 |
}) |
|
46 |
subtree.append({ |
|
47 |
'tag': 'config', |
|
48 |
'subtree': config |
|
39 |
'subtree': util.store_or_url(target, target_url, self._assert) |
|
49 | 40 |
}) |
41 |
subtree.append(config) |
|
50 | 42 |
if default_operation is not None: |
51 | 43 |
subtree.append({ |
52 | 44 |
'tag': 'default-operation', |
... | ... | |
72 | 64 |
# tested: no |
73 | 65 |
# combed: yes |
74 | 66 |
|
75 |
SPEC = { |
|
76 |
'tag': 'delete-config', |
|
77 |
'subtree': [ { 'tag': 'target', 'subtree': None } ] |
|
78 |
} |
|
67 |
SPEC = {'tag': 'delete-config', 'subtree': []} |
|
79 | 68 |
|
80 | 69 |
def request(self, target=None, target_url=None): |
81 | 70 |
spec = DeleteConfig.SPEC.copy() |
82 |
spec['subtree'][0]['subtree'] = util.store_or_url(target, target_url) |
|
71 |
spec['subtree'].append({ |
|
72 |
'tag': 'target', |
|
73 |
'subtree': util.store_or_url(target, target_url, self._assert) |
|
74 |
}) |
|
83 | 75 |
return self._request(spec) |
84 | 76 |
|
85 | 77 |
|
... | ... | |
88 | 80 |
# tested: no |
89 | 81 |
# combed: yes |
90 | 82 |
|
91 |
SPEC = { |
|
92 |
'tag': 'copy-config', |
|
93 |
'subtree': [] |
|
94 |
} |
|
83 |
SPEC = {'tag': 'copy-config', 'subtree': []} |
|
95 | 84 |
|
96 | 85 |
def request(self, source=None, source_url=None, target=None, target_url=None): |
97 | 86 |
spec = CopyConfig.SPEC.copy() |
98 | 87 |
spec['subtree'].append({ |
99 |
'tag': 'target',
|
|
100 |
'subtree': util.store_or_url(source, source_url) |
|
88 |
'tag': 'source',
|
|
89 |
'subtree': util.store_or_url(source, source_url, self._assert)
|
|
101 | 90 |
}) |
102 | 91 |
spec['subtree'].append({ |
103 | 92 |
'tag': 'target', |
104 |
'subtree': util.store_or_url(target, target_url) |
|
93 |
'subtree': util.store_or_url(target, target_url, self._assert)
|
|
105 | 94 |
}) |
106 | 95 |
return self._request(spec) |
107 | 96 |
|
... | ... | |
115 | 104 |
|
116 | 105 |
DEPENDS = [':validate'] |
117 | 106 |
|
118 |
SPEC = { |
|
119 |
'tag': 'validate', |
|
120 |
'subtree': [] |
|
121 |
} |
|
107 |
SPEC = {'tag': 'validate', 'subtree': []} |
|
122 | 108 |
|
123 |
def request(self, source=None, config=None): |
|
124 |
util.one_of(source, capability)
|
|
125 |
spec = SPEC.copy() |
|
126 |
if source is not None:
|
|
109 |
def request(self, source=None, source_url=None, config=None):
|
|
110 |
util.one_of(source, source_url, config)
|
|
111 |
spec = Validate.SPEC.copy()
|
|
112 |
if config is None:
|
|
127 | 113 |
spec['subtree'].append({ |
128 | 114 |
'tag': 'source', |
129 |
'subtree': {'tag': source}
|
|
115 |
'subtree': util.store_or_url(source, source_url, self._assert)
|
|
130 | 116 |
}) |
131 | 117 |
else: |
132 |
spec['subtree'].append({ |
|
133 |
'tag': 'config', |
|
134 |
'subtree': config |
|
135 |
}) |
|
118 |
spec['subtree'].append(config) |
|
136 | 119 |
return self._request(spec) |
137 | 120 |
|
138 | 121 |
|
... | ... | |
143 | 126 |
|
144 | 127 |
DEPENDS = [':candidate'] |
145 | 128 |
|
146 |
SPEC = { 'tag': 'commit', 'subtree': [] }
|
|
129 |
SPEC = {'tag': 'commit', 'subtree': []}
|
|
147 | 130 |
|
148 | 131 |
def _parse_hook(self): |
149 | 132 |
pass |
... | ... | |
151 | 134 |
def request(self, confirmed=False, timeout=None): |
152 | 135 |
spec = SPEC.copy() |
153 | 136 |
if confirmed: |
137 |
self._assert(':confirmed-commit') |
|
154 | 138 |
spec['subtree'].append({'tag': 'confirmed'}) |
155 | 139 |
if timeout is not None: |
156 | 140 |
spec['subtree'].append({ |
Also available in: Unified diff