Skip to content
Snippets Groups Projects
Commit 910f198f authored by Attila Farkas's avatar Attila Farkas
Browse files

create input validation module (without functionality)

parent 9c11adc3
No related branches found
No related tags found
1 merge request!7Resolve Refactoring
......@@ -10,6 +10,7 @@ from modules.file_generator import generate_vagrantfile, generate_ansible_files
from modules.device_creator import open_file
from modules.routing import create_border_router
from modules.input_argument_parser import parse_input_args
from modules.input_file_validator import validate_device_definitions
""" Parsing the input arguments. """
......@@ -19,15 +20,21 @@ try:
input_file_name = parse_input_args(sys.argv, flags)
except Exception:
print("Input arguments could not be parsed.")
raise
sys.exit(1)
""" Parsing the definitions file. """
try:
device_definitions = open_file(input_file_name)
except Exception:
print("Definitions file could not be parsed.")
raise
sys.exit(1)
""" Validating device definitions. """
try:
validate_device_definitions(device_definitions)
except Exception:
print("Device definition validation was not sussessful.")
sys.exit(1)
# TODO
......
......@@ -12,6 +12,8 @@ def parse_input_args(argv, flags):
input_file_name = None
# TODO implement parsing args using an external module
if len(argv) == 3:
if str(argv[1]) == "-l":
flags["ansible_local"] = True
......
""" This module contains functions for input file validation. """
def validate_device_definitions(definitions):
"""
This function validates the device definitions structure and throws an
error if the syntax is not as expected.
:param definitions: a device definition structure (dictionary)
"""
# TODO implement validation
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment