Skip to content

Commit

Permalink
serialization fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
amyasnikov committed Feb 18, 2024
1 parent 5286168 commit 425b7bd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion validity/compliance/serialization/textfsm.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import textfsm


def serialize_textfsm(plain_data: str, template: str):
def serialize_textfsm(plain_data: str, template: str) -> list[dict]:
dict_results = []
template_file = io.StringIO(template)
fsm = textfsm.TextFSM(template_file)
Expand Down
5 changes: 3 additions & 2 deletions validity/pollers/netconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ class ScrapliNetconfPoller(ConsecutivePoller):
host_param_name = "host"

def poll_one_command(self, driver: NetconfDriver, command: "Command") -> str:
response = driver.rpc(command.parameters["rpc"])
return response.result
with driver:
response = driver.rpc(command.parameters["rpc"])
return response.result
12 changes: 11 additions & 1 deletion validity/subforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
1. Render part of the main form for JSON Field
2. Validate JSON Field
"""
import textwrap
import xml.etree.ElementTree as ET

from django import forms
Expand Down Expand Up @@ -31,7 +32,16 @@ class JSONAPICommandForm(BootstrapMixin, forms.Form):


class NetconfCommandForm(BootstrapMixin, forms.Form):
rpc = forms.CharField(label=_("RPC"), widget=forms.Textarea(attrs={"placeholder": "<get-config/>"}))
get_config = textwrap.dedent(
"""
<get-config>
<source>
<running/>
</source>
</get-config>
"""
).lstrip("\n")
rpc = forms.CharField(label=_("RPC"), widget=forms.Textarea(attrs={"placeholder": get_config}))

def clean_rpc(self):
rpc = self.cleaned_data["rpc"]
Expand Down

0 comments on commit 425b7bd

Please sign in to comment.