Only pass 'schema' to the validator creation.
This commit is contained in:
@ -50,21 +50,21 @@ class NullHandler(logging.Handler):
|
||||
|
||||
|
||||
class Validator(object):
|
||||
def __init__(self, args):
|
||||
def __init__(self, schema):
|
||||
self.logger = logging.getLogger('vppcfg.validator')
|
||||
self.logger.addHandler(NullHandler())
|
||||
|
||||
self.args = args
|
||||
self.schema = schema
|
||||
|
||||
def validate(self, yaml):
|
||||
ret_rv = True
|
||||
ret_msgs = []
|
||||
if self.args.schema:
|
||||
if self.schema:
|
||||
try:
|
||||
self.logger.info("Validating against schema %s" % self.args.schema)
|
||||
self.logger.info("Validating against schema %s" % self.schema)
|
||||
validators = DefaultValidators.copy()
|
||||
validators[IPInterfaceWithPrefixLength.tag] = IPInterfaceWithPrefixLength
|
||||
schema = yamale.make_schema(self.args.schema, validators=validators)
|
||||
schema = yamale.make_schema(self.schema, validators=validators)
|
||||
data = yamale.make_data(content=str(yaml))
|
||||
yamale.validate(schema, data)
|
||||
self.logger.debug("Schema correctly validated by yamale")
|
||||
@ -79,25 +79,25 @@ class Validator(object):
|
||||
|
||||
self.logger.debug("Validating Semantics...")
|
||||
|
||||
rv, msgs = validate_bondethernets(self.args, yaml)
|
||||
rv, msgs = validate_bondethernets(yaml)
|
||||
if msgs:
|
||||
ret_msgs.extend(msgs)
|
||||
if not rv:
|
||||
ret_rv = False
|
||||
|
||||
rv, msgs = validate_interfaces(self.args, yaml)
|
||||
rv, msgs = validate_interfaces(yaml)
|
||||
if msgs:
|
||||
ret_msgs.extend(msgs)
|
||||
if not rv:
|
||||
ret_rv = False
|
||||
|
||||
rv, msgs = validate_loopbacks(self.args, yaml)
|
||||
rv, msgs = validate_loopbacks(yaml)
|
||||
if msgs:
|
||||
ret_msgs.extend(msgs)
|
||||
if not rv:
|
||||
ret_rv = False
|
||||
|
||||
rv, msgs = validate_bridgedomains(self.args, yaml)
|
||||
rv, msgs = validate_bridgedomains(yaml)
|
||||
if msgs:
|
||||
ret_msgs.extend(msgs)
|
||||
if not rv:
|
||||
|
@ -16,7 +16,7 @@ def get_by_name(yaml, ifname):
|
||||
return None
|
||||
|
||||
|
||||
def validate_bondethernets(args, yaml):
|
||||
def validate_bondethernets(yaml):
|
||||
result = True
|
||||
msgs = []
|
||||
logger = logging.getLogger('vppcfg.validator')
|
||||
|
@ -16,7 +16,7 @@ def get_by_name(yaml, ifname):
|
||||
return None
|
||||
|
||||
|
||||
def validate_bridgedomains(args, yaml):
|
||||
def validate_bridgedomains(yaml):
|
||||
result = True
|
||||
msgs = []
|
||||
logger = logging.getLogger('vppcfg.validator')
|
||||
|
@ -259,7 +259,7 @@ def get_mtu(yaml, ifname):
|
||||
return 1500
|
||||
|
||||
|
||||
def validate_interfaces(args, yaml):
|
||||
def validate_interfaces(yaml):
|
||||
result = True
|
||||
msgs = []
|
||||
logger = logging.getLogger('vppcfg.validator')
|
||||
|
@ -14,7 +14,7 @@ def get_by_name(yaml, ifname):
|
||||
return None
|
||||
|
||||
|
||||
def validate_loopbacks(args, yaml):
|
||||
def validate_loopbacks(yaml):
|
||||
result = True
|
||||
msgs = []
|
||||
logger = logging.getLogger('vppcfg.validator')
|
||||
|
Reference in New Issue
Block a user