@@ -145,7 +145,7 @@ def parse_config(self, device=None, profile=None, native=None):
145
145
device (NetworkDriver): Device to load the configuration from.
146
146
profile (list): Profiles that the device supports. If no ``profile`` is passed it will
147
147
be read from ``device``.
148
- native (string ): Native configuration to parse.
148
+ native (list of strings ): Native configuration to parse.
149
149
150
150
Examples:
151
151
@@ -160,14 +160,42 @@ def parse_config(self, device=None, profile=None, native=None):
160
160
>>>
161
161
>>> running_config = napalm_yang.base.Root()
162
162
>>> running_config.add_model(napalm_yang.models.openconfig_interfaces)
163
- >>> running_config.parse_config(config =config, profile="junos")
163
+ >>> running_config.parse_config(native =config, profile="junos")
164
164
"""
165
165
166
166
for k , v in self :
167
167
parser = Parser (v , device = device , profile = profile , native = native , is_config = True )
168
168
parser .parse ()
169
169
170
170
def parse_state (self , device = None , profile = None , native = None ):
171
+ """
172
+ Parse native state and load it into the corresponding models. Only models
173
+ that have been added to the root object will be parsed.
174
+
175
+ If ``native`` is passed to the method that's what we will parse, otherwise, we will use the
176
+ ``device`` to retrieve it.
177
+
178
+ Args:
179
+ device (NetworkDriver): Device to load the configuration from.
180
+ profile (list): Profiles that the device supports. If no ``profile`` is passed it will
181
+ be read from ``device``.
182
+ native (list string): Native output to parse.
183
+
184
+ Examples:
185
+
186
+ >>> # Load from device
187
+ >>> state = napalm_yang.base.Root()
188
+ >>> state.add_model(napalm_yang.models.openconfig_interfaces)
189
+ >>> state.parse_config(device=d)
190
+
191
+ >>> # Load from file
192
+ >>> with open("junos.state", "r") as f:
193
+ >>> state_data = f.read()
194
+ >>>
195
+ >>> state = napalm_yang.base.Root()
196
+ >>> state.add_model(napalm_yang.models.openconfig_interfaces)
197
+ >>> state.parse_config(native=state_data, profile="junos")
198
+ """
171
199
for k , v in self :
172
200
parser = Parser (v , device = device , profile = profile , native = native , is_config = False )
173
201
parser .parse ()
0 commit comments