Rename validator/ to config/

This commit is contained in:
Pim van Pelt
2022-03-24 13:56:04 +00:00
parent e8e41098be
commit 672dd65f11
16 changed files with 39 additions and 39 deletions

View File

@ -25,17 +25,17 @@ try:
except ImportError:
print("ERROR: install yamale manually: sudo pip install yamale")
sys.exit(-2)
from validator.loopback import validate_loopbacks
from validator.bondethernet import validate_bondethernets
from validator.interface import validate_interfaces
from validator.bridgedomain import validate_bridgedomains
from validator.vxlan_tunnel import validate_vxlan_tunnels
from config.loopback import validate_loopbacks
from config.bondethernet import validate_bondethernets
from config.interface import validate_interfaces
from config.bridgedomain import validate_bridgedomains
from config.vxlan_tunnel import validate_vxlan_tunnels
from yamale.validators import DefaultValidators, Validator
import ipaddress
class IPInterfaceWithPrefixLength(Validator):
""" Custom IPAddress validator - takes IP/prefixlen as input:
""" Custom IPAddress config - takes IP/prefixlen as input:
192.0.2.1/29 or 2001:db8::1/64 are correct. The PrefixLength
is required, and must be a number (0-32 for IPv4 and 0-128 for
IPv6).
@ -62,7 +62,7 @@ class IPInterfaceWithPrefixLength(Validator):
class Validator(object):
def __init__(self, schema):
self.logger = logging.getLogger('vppcfg.validator')
self.logger = logging.getLogger('vppcfg.config')
self.logger.addHandler(logging.NullHandler())
self.schema = schema
@ -129,7 +129,7 @@ class Validator(object):
def valid_config(self, yaml):
""" Validate the given YAML configuration in 'yaml' against syntax
validation given in the yamale 'schema', and all semantic validators.
validation given in the yamale 'schema', and all semantic configs.
Returns True if the configuration is valid, False otherwise.
"""

View File

@ -12,7 +12,7 @@
# limitations under the License.
#
import logging
import validator.interface as interface
import config.interface as interface
import ipaddress
def get_all_addresses_except_ifname(yaml, except_ifname):

View File

@ -12,7 +12,7 @@
# limitations under the License.
#
import logging
import validator.interface as interface
import config.interface as interface
def get_by_name(yaml, ifname):
""" Return the BondEthernet by name, if it exists. Return None,None otherwise. """
@ -46,7 +46,7 @@ def is_bond_member(yaml, ifname):
def validate_bondethernets(yaml):
result = True
msgs = []
logger = logging.getLogger('vppcfg.validator')
logger = logging.getLogger('vppcfg.config')
logger.addHandler(logging.NullHandler())
if not 'bondethernets' in yaml:

View File

@ -12,9 +12,9 @@
# limitations under the License.
#
import logging
import validator.interface as interface
import validator.lcp as lcp
import validator.address as address
import config.interface as interface
import config.lcp as lcp
import config.address as address
def get_bridgedomains(yaml):
""" Return a list of all bridgedomains. """
@ -88,7 +88,7 @@ def is_bridge_interface(yaml, ifname):
def validate_bridgedomains(yaml):
result = True
msgs = []
logger = logging.getLogger('vppcfg.validator')
logger = logging.getLogger('vppcfg.config')
logger.addHandler(logging.NullHandler())
if not 'bridgedomains' in yaml:

View File

@ -12,12 +12,12 @@
# limitations under the License.
#
import logging
import validator.bondethernet as bondethernet
import validator.bridgedomain as bridgedomain
import validator.loopback as loopback
import validator.vxlan_tunnel as vxlan_tunnel
import validator.lcp as lcp
import validator.address as address
import config.bondethernet as bondethernet
import config.bridgedomain as bridgedomain
import config.loopback as loopback
import config.vxlan_tunnel as vxlan_tunnel
import config.lcp as lcp
import config.address as address
def get_qinx_parent_by_name(yaml, ifname):
""" Returns the sub-interface which matches a QinAD or QinQ outer tag, or None,None
@ -384,7 +384,7 @@ def get_mtu(yaml, ifname):
def validate_interfaces(yaml):
result = True
msgs = []
logger = logging.getLogger('vppcfg.validator')
logger = logging.getLogger('vppcfg.config')
logger.addHandler(logging.NullHandler())
if not 'interfaces' in yaml:

View File

@ -12,8 +12,8 @@
# limitations under the License.
#
import logging
import validator.lcp as lcp
import validator.address as address
import config.lcp as lcp
import config.address as address
def get_loopbacks(yaml):
""" Return a list of all loopbacks. """
@ -43,7 +43,7 @@ def is_loopback(yaml, ifname):
def validate_loopbacks(yaml):
result = True
msgs = []
logger = logging.getLogger('vppcfg.validator')
logger = logging.getLogger('vppcfg.config')
logger.addHandler(logging.NullHandler())
if not 'loopbacks' in yaml:

View File

@ -1,6 +1,6 @@
import unittest
import yaml
import validator.bondethernet as bondethernet
import config.bondethernet as bondethernet
class TestBondEthernetMethods(unittest.TestCase):
def setUp(self):

View File

@ -1,6 +1,6 @@
import unittest
import yaml
import validator.bridgedomain as bridgedomain
import config.bridgedomain as bridgedomain
class TestBridgeDomainMethods(unittest.TestCase):
def setUp(self):

View File

@ -1,6 +1,6 @@
import unittest
import yaml
import validator.interface as interface
import config.interface as interface
class TestInterfaceMethods(unittest.TestCase):
def setUp(self):

View File

@ -1,7 +1,7 @@
import unittest
import yaml
import validator.lcp as lcp
import validator.interface as interface
import config.lcp as lcp
import config.interface as interface
class TestLCPMethods(unittest.TestCase):
def setUp(self):

View File

@ -1,6 +1,6 @@
import unittest
import yaml
import validator.loopback as loopback
import config.loopback as loopback
class TestLoopbackMethods(unittest.TestCase):
def setUp(self):

View File

@ -1,6 +1,6 @@
import unittest
import yaml
import validator.vxlan_tunnel as vxlan_tunnel
import config.vxlan_tunnel as vxlan_tunnel
class TestVXLANMethods(unittest.TestCase):
def setUp(self):

View File

@ -12,7 +12,7 @@
# limitations under the License.
#
import logging
import validator.interface as interface
import config.interface as interface
import ipaddress
def get_by_name(yaml, ifname):
@ -58,7 +58,7 @@ def get_vxlan_tunnels(yaml):
def validate_vxlan_tunnels(yaml):
result = True
msgs = []
logger = logging.getLogger('vppcfg.validator')
logger = logging.getLogger('vppcfg.config')
logger.addHandler(logging.NullHandler())
if not 'vxlan_tunnels' in yaml:

View File

@ -16,7 +16,7 @@
import sys
import yaml
from validator import Validator
from config import Validator
import glob
import re
import unittest

8
vppcfg
View File

@ -17,7 +17,7 @@
import sys
import yaml
import logging
from validator import Validator
from config import Validator
from vpp.vppapi import VPPApi
try:
@ -52,12 +52,12 @@ def main():
logging.error("Couldn't read config from %s" % args.config)
sys.exit(-1)
validator = Validator(schema=args.schema)
if not validator.valid_config(cfg):
config = Validator(schema=args.schema)
if not config.valid_config(cfg):
logging.error("Configuration is not valid, bailing")
sys.exit(-2)
config_phys = validator.get_phys(cfg)
config_phys = config.get_phys(cfg)
vpp = VPPApi()
vpp.readconfig()
if not vpp.phys_exist(config_phys):