Revision a7cb58ce ncclient/operations/edit.py

b/ncclient/operations/edit.py
21 21
"Operations related to configuration editing"
22 22

  
23 23
class EditConfig(RPC):
24
    
25
    # tested: no
26
    # combed: yes
27
    
24

  
28 25
    SPEC = {'tag': 'edit-config', 'subtree': []}
29
    
26

  
30 27
    def request(self, target=None, config=None, default_operation=None,
31 28
                test_option=None, error_option=None):
32 29
        util.one_of(target, config)
......
52 49
                'tag': 'error-option',
53 50
                'text': error_option
54 51
                })
52
        return self._request(spec)
55 53

  
56 54

  
57 55
class DeleteConfig(RPC):
58
    
59
    # tested: no
60
    # combed: yes
61
    
56

  
62 57
    SPEC = {'tag': 'delete-config', 'subtree': []}
63
    
58

  
64 59
    def request(self, target):
65 60
        spec = DeleteConfig.SPEC.copy()
66
        spec['subtree'].append(util.store_or_url('source', source, self._assert))
61
        spec['subtree'].append(util.store_or_url('target', target, self._assert))
67 62
        return self._request(spec)
68 63

  
69 64

  
70 65
class CopyConfig(RPC):
71
    
72
    # tested: no
73
    # combed: yes
74
    
66

  
75 67
    SPEC = {'tag': 'copy-config', 'subtree': []}
76
    
68

  
77 69
    def request(self, source, target):
78 70
        spec = CopyConfig.SPEC.copy()
79 71
        spec['subtree'].append(util.store_or_url('source', source, self._assert))
80
        spec['subtree'].append(util.store_or_url('target', source, self._assert))
72
        spec['subtree'].append(util.store_or_url('target', target, self._assert))
81 73
        return self._request(spec)
82 74

  
83 75

  
84 76
class Validate(RPC):
85
    
86
    # tested: no
87
    # combed: yes
88
    
89
    'config attr shd not include <config> root'
90
    
77

  
91 78
    DEPENDS = [':validate']
92
    
79

  
93 80
    SPEC = {'tag': 'validate', 'subtree': []}
94
    
95
    def request(self, source=None, config=None):
96
        util.one_of(source, config)
81

  
82
    def request(self, source):
83
        # determine if source is a <config> element
97 84
        spec = Validate.SPEC.copy()
98
        if config is None:
85
        try:
86
            spec['subtree'].append({
87
                'tag': 'source',
88
                'subtree': content.validated_root(config, ('config', content.qualify('config')))
89
                })
90
        except ContentError:
99 91
            spec['subtree'].append(util.store_or_url('source', source, self._assert))
100
        else:
101
            spec['subtree'].append(content.validated_root(config, 'config'))
102 92
        return self._request(spec)
103 93

  
104 94

  
105 95
class Commit(RPC):
106
    
107
    # tested: no
108
    # combed: yes
109
    
96

  
110 97
    DEPENDS = [':candidate']
111
    
98

  
112 99
    SPEC = {'tag': 'commit', 'subtree': []}
113
    
100

  
114 101
    def _parse_hook(self):
115 102
        pass
116
    
117
    def request(self, confirmed=False, timeout=None):
103

  
104
    def request(self, confirmed=False):
118 105
        spec = SPEC.copy()
119 106
        if confirmed:
120 107
            self._assert(':confirmed-commit')
......
128 115

  
129 116

  
130 117
class DiscardChanges(RPC):
131
    
132
    # tested: no
133
    # combed: yes
134
    
118

  
135 119
    DEPENDS = [':candidate']
136
    
120

  
137 121
    SPEC = {'tag': 'discard-changes'}
138 122

  
139 123

  
140 124
class ConfirmedCommit(Commit):
141 125
    "psuedo-op"
142
    
143
    # tested: no
144
    # combed: yes
145
    
126

  
146 127
    DEPENDS = [':candidate', ':confirmed-commit']
147
    
148
    def request(self, timeout=None):
149
        "Commit changes; requireing that a confirming commit follow"
150
        return Commit.request(self, confirmed=True, timeout=timeout)
151
    
128

  
129
    def request(self):
130
        "Commit changes requiring that a confirm/discard follow"
131
        return Commit.request(self, confirmed=True)
132

  
152 133
    def confirm(self):
153
        "Make the confirming commit"
134
        "Confirm changes"
154 135
        return Commit.request(self, confirmed=True)
155
    
136

  
156 137
    def discard(self):
138
        "Discard changes"
157 139
        return DiscardChanges(self.session, self.async, self.timeout).request()

Also available in: Unified diff