Formatting w/ black
This commit is contained in:
@ -76,6 +76,7 @@ class Validator:
|
||||
The purpose is to ensure that the YAML file is both syntactically correct,
|
||||
which is ensured by Yamale, and semantically correct, which is ensured by a set
|
||||
of built-in validators, and user-added validators (see the add_validator() method)."""
|
||||
|
||||
def __init__(self, schema):
|
||||
self.logger = logging.getLogger("vppcfg.config")
|
||||
self.logger.addHandler(logging.NullHandler())
|
||||
|
3
tests.py
3
tests.py
@ -39,6 +39,7 @@ def example_validator(_yaml):
|
||||
class YAMLTest(unittest.TestCase):
|
||||
"""This test suite takes a YAML configuration file and holds it against the syntax
|
||||
(Yamale) and semantic validators, returning errors in case of validation failures."""
|
||||
|
||||
def __init__(self, testName, yaml_filename, yaml_schema):
|
||||
# calling the super class init varies for different python versions. This works for 2.7
|
||||
super().__init__(testName)
|
||||
@ -46,7 +47,7 @@ class YAMLTest(unittest.TestCase):
|
||||
self.yaml_schema = yaml_schema
|
||||
|
||||
def test_yaml(self):
|
||||
""" The test executor """
|
||||
"""The test executor"""
|
||||
test = None
|
||||
cfg = None
|
||||
ncount = 0
|
||||
|
@ -45,7 +45,9 @@ class Applier(VPPApi):
|
||||
"""Delete a sub-int identified by name (ie GigabitEthernet3/0/0.100)"""
|
||||
pass
|
||||
|
||||
def set_interface_l2_tag_rewrite(self, ifname, vtr_op, vtr_push_dot1q, vtr_tag1, vtr_tag2):
|
||||
def set_interface_l2_tag_rewrite(
|
||||
self, ifname, vtr_op, vtr_push_dot1q, vtr_tag1, vtr_tag2
|
||||
):
|
||||
"""Set l2 tag rewrite on an interface identified by name (ie GigabitEthernet3/0/0.100)
|
||||
into a certain operational mode. TODO(pim) clarify the vtr_* arguments."""
|
||||
## somewhere in interface.api see vtr_* fields
|
||||
|
@ -30,11 +30,12 @@ class Dumper(VPPApi):
|
||||
|
||||
Note that not all running VPP configs are "valid" in vppcfg's eyes. It is not
|
||||
guaranteed that the output of the Dumper() will stand validation."""
|
||||
|
||||
def __init__(self, address="/run/vpp/api.sock", clientname="vppcfg"):
|
||||
VPPApi.__init__(self, address, clientname)
|
||||
|
||||
def write(self, outfile):
|
||||
""" Emit the configuration to either stdout (outfile=='-') or a filename """
|
||||
"""Emit the configuration to either stdout (outfile=='-') or a filename"""
|
||||
if outfile and outfile == "-":
|
||||
file = sys.stdout
|
||||
outfile = "(stdout)"
|
||||
@ -50,7 +51,7 @@ class Dumper(VPPApi):
|
||||
self.logger.info(f"Wrote YAML config to {outfile}")
|
||||
|
||||
def cache_to_config(self):
|
||||
""" Convert the VPP configuration cache (previously read by readconfig() into
|
||||
"""Convert the VPP configuration cache (previously read by readconfig() into
|
||||
a YAML representation."""
|
||||
config = {
|
||||
"loopbacks": {},
|
||||
|
@ -27,6 +27,7 @@ from vpp_papi import VPPApiClient
|
||||
|
||||
class VPPApi:
|
||||
"""The VPPApi class is a base class that abstracts the vpp_papi."""
|
||||
|
||||
def __init__(self, address="/run/vpp/api.sock", clientname="vppcfg"):
|
||||
self.logger = logging.getLogger("vppcfg.vppapi")
|
||||
self.logger.addHandler(logging.NullHandler())
|
||||
@ -40,7 +41,7 @@ class VPPApi:
|
||||
self.lcp_enabled = False
|
||||
|
||||
def connect(self):
|
||||
""" Connect to the VPP Dataplane, if we're not already connected """
|
||||
"""Connect to the VPP Dataplane, if we're not already connected"""
|
||||
if self.connected:
|
||||
return True
|
||||
|
||||
@ -81,7 +82,7 @@ class VPPApi:
|
||||
return True
|
||||
|
||||
def cache_clear(self):
|
||||
""" Remove the cached VPP configuration elements and return an empty dictionary"""
|
||||
"""Remove the cached VPP configuration elements and return an empty dictionary"""
|
||||
self.cache_read = False
|
||||
return {
|
||||
"lcps": {},
|
||||
|
Reference in New Issue
Block a user