Skip to content
This repository was archived by the owner on May 15, 2019. It is now read-only.

Commit 39b9b59

Browse files
committed
Added logs
1 parent 72b1f5c commit 39b9b59

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

napalm_yang/base.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def parse_config(self, device=None, profile=None, native=None):
145145
device (NetworkDriver): Device to load the configuration from.
146146
profile (list): Profiles that the device supports. If no ``profile`` is passed it will
147147
be read from ``device``.
148-
native (string): Native configuration to parse.
148+
native (list of strings): Native configuration to parse.
149149
150150
Examples:
151151
@@ -160,14 +160,42 @@ def parse_config(self, device=None, profile=None, native=None):
160160
>>>
161161
>>> running_config = napalm_yang.base.Root()
162162
>>> 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")
164164
"""
165165

166166
for k, v in self:
167167
parser = Parser(v, device=device, profile=profile, native=native, is_config=True)
168168
parser.parse()
169169

170170
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+
"""
171199
for k, v in self:
172200
parser = Parser(v, device=device, profile=profile, native=native, is_config=False)
173201
parser.parse()

0 commit comments

Comments
 (0)