Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cyber-sandbox-creator
Manage
Activity
Members
Labels
Plan
Issues
10
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MUNI-KYPO-CSC
cyber-sandbox-creator
Commits
910f198f
Commit
910f198f
authored
5 years ago
by
Attila Farkas
Browse files
Options
Downloads
Patches
Plain Diff
create input validation module (without functionality)
parent
9c11adc3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!7
Resolve Refactoring
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
create.py
+9
-2
9 additions, 2 deletions
create.py
modules/input_argument_parser.py
+2
-0
2 additions, 0 deletions
modules/input_argument_parser.py
modules/input_file_validator.py
+11
-0
11 additions, 0 deletions
modules/input_file_validator.py
with
22 additions
and
2 deletions
create.py
+
9
−
2
View file @
910f198f
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
modules/input_argument_parser.py
+
2
−
0
View file @
910f198f
...
...
@@ -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 diff is collapsed.
Click to expand it.
modules/input_file_validator.py
0 → 100644
+
11
−
0
View file @
910f198f
"""
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment