Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added validator for site infrastructure #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
site_infrastructure: list(include('domain_ip_record'))

domain_ip_record:
fqdn: domain()
ip_address: ip(version=4)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
site_infrastructure:
- fqdn: lightweight_component01.cern.ch
ip_address: 192.168.0.4
- fqdn: lightweight_component02.cern.ch
ip_address: 192.168.0.5
19 changes: 18 additions & 1 deletion config_validation_engine/validators/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from validate_email import validate_email
from urlparse import urlparse
from math import ceil, floor

from fqdn import FQDN

class Email(Validator):
"""Email Validator"""
Expand Down Expand Up @@ -59,11 +59,28 @@ def _is_valid(self, value):
return True
return False

class Domain(Validator):
"""Domain Validator"""
tag = 'domain'

def _is_valid(self, value):
fqdn = FQDN(value)

return fqdn.is_valid

def fail(self, value):
return "{value} is not a valid {tag} value. An acceptable example is {example}".format(
value = value,
tag = self.tag,
example = "lightweight_component01.cern.ch"
)

def all_config_validators():
validators = DefaultValidators.copy()
validators[Email.tag] = Email
validators[Longitude.tag] = Longitude
validators[Latitude.tag] = Latitude
validators[URL.tag] = URL
validators[Domain.tag] = Domain

return validators
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
astroid==1.6.1
attrs==17.4.0
Babel==2.6.0
fqdn==1.1.0
isort==4.2.15
lazy-object-proxy==1.3.1
mccabe==0.6.1
mysql-connector==2.1.6
mysql-connector>=2.1.6
pbr==4.3.0
pluggy==0.6.0
ply==3.11
Expand All @@ -18,4 +19,4 @@ six==1.11.0
wrapt==1.10.11
yamale==1.7.0
yaql==1.1.3
validate_email==1.3
validate_email==1.3