Revision d771dffc ncclient/operations/edit.py
b/ncclient/operations/edit.py | ||
---|---|---|
27 | 27 |
|
28 | 28 |
SPEC = {'tag': 'edit-config', 'subtree': []} |
29 | 29 |
|
30 |
def request(self, target=None, target_url=None, config=None,
|
|
31 |
default_operation=None, test_option=None, error_option=None):
|
|
32 |
util.one_of(target, target_url)
|
|
30 |
def request(self, target=None, config=None, default_operation=None,
|
|
31 |
test_option=None, error_option=None): |
|
32 |
util.one_of(target, config)
|
|
33 | 33 |
spec = EditConfig.SPEC.copy() |
34 | 34 |
subtree = spec['subtree'] |
35 |
subtree.append({ |
|
36 |
'tag': 'target', |
|
37 |
'subtree': util.store_or_url(target, target_url, self._assert) |
|
38 |
}) |
|
39 |
subtree.append(content.root_ensured(config, 'config')) |
|
35 |
subtree.append(util.store_or_url('target', target, self._assert)) |
|
36 |
subtree.append(content.validated_root(config, 'config')) |
|
40 | 37 |
if default_operation is not None: |
41 | 38 |
subtree.append({ |
42 | 39 |
'tag': 'default-operation', |
... | ... | |
64 | 61 |
|
65 | 62 |
SPEC = {'tag': 'delete-config', 'subtree': []} |
66 | 63 |
|
67 |
def request(self, target=None, target_url=None):
|
|
64 |
def request(self, target): |
|
68 | 65 |
spec = DeleteConfig.SPEC.copy() |
69 |
spec['subtree'].append({ |
|
70 |
'tag': 'target', |
|
71 |
'subtree': util.store_or_url(target, target_url, self._assert) |
|
72 |
}) |
|
66 |
spec['subtree'].append(util.store_or_url('source', source, self._assert)) |
|
73 | 67 |
return self._request(spec) |
74 | 68 |
|
75 | 69 |
|
... | ... | |
80 | 74 |
|
81 | 75 |
SPEC = {'tag': 'copy-config', 'subtree': []} |
82 | 76 |
|
83 |
def request(self, source=None, source_url=None, target=None, target_url=None):
|
|
77 |
def request(self, source, target):
|
|
84 | 78 |
spec = CopyConfig.SPEC.copy() |
85 |
spec['subtree'].append({ |
|
86 |
'tag': 'source', |
|
87 |
'subtree': util.store_or_url(source, source_url, self._assert) |
|
88 |
}) |
|
89 |
spec['subtree'].append({ |
|
90 |
'tag': 'target', |
|
91 |
'subtree': util.store_or_url(target, target_url, self._assert) |
|
92 |
}) |
|
79 |
spec['subtree'].append(util.store_or_url('source', source, self._assert)) |
|
80 |
spec['subtree'].append(util.store_or_url('target', source, self._assert)) |
|
93 | 81 |
return self._request(spec) |
94 | 82 |
|
95 | 83 |
|
... | ... | |
104 | 92 |
|
105 | 93 |
SPEC = {'tag': 'validate', 'subtree': []} |
106 | 94 |
|
107 |
def request(self, source=None, source_url=None, config=None):
|
|
108 |
util.one_of(source, source_url, config)
|
|
95 |
def request(self, source=None, config=None): |
|
96 |
util.one_of(source, config) |
|
109 | 97 |
spec = Validate.SPEC.copy() |
110 | 98 |
if config is None: |
111 |
spec['subtree'].append({ |
|
112 |
'tag': 'source', |
|
113 |
'subtree': util.store_or_url(source, source_url, self._assert) |
|
114 |
}) |
|
99 |
spec['subtree'].append(util.store_or_url('source', source, self._assert)) |
|
115 | 100 |
else: |
116 |
spec['subtree'].append(content.root_ensured(config, 'config'))
|
|
101 |
spec['subtree'].append(content.validated_root(config, 'config'))
|
|
117 | 102 |
return self._request(spec) |
118 | 103 |
|
119 | 104 |
|
... | ... | |
142 | 127 |
return self._request(Commit.SPEC) |
143 | 128 |
|
144 | 129 |
|
130 |
class DiscardChanges(RPC): |
|
131 |
|
|
132 |
# tested: no |
|
133 |
# combed: yes |
|
134 |
|
|
135 |
DEPENDS = [':candidate'] |
|
136 |
|
|
137 |
SPEC = {'tag': 'discard-changes'} |
|
138 |
|
|
139 |
|
|
145 | 140 |
class ConfirmedCommit(Commit): |
146 | 141 |
"psuedo-op" |
147 | 142 |
|
... | ... | |
157 | 152 |
def confirm(self): |
158 | 153 |
"Make the confirming commit" |
159 | 154 |
return Commit.request(self, confirmed=True) |
160 |
|
|
161 |
|
|
162 |
class DiscardChanges(RPC): |
|
163 |
|
|
164 |
# tested: no |
|
165 |
# combed: yes |
|
166 |
|
|
167 |
DEPENDS = [':candidate'] |
|
168 | 155 |
|
169 |
SPEC = {'tag': 'discard-changes'} |
|
170 |
|
|
156 |
def discard(self): |
|
157 |
return DiscardChanges(self.session, self.async, self.timeout).request() |
Also available in: Unified diff