summaryrefslogtreecommitdiff
path: root/src/conf_mode/dynamic_dns.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2018-07-29 19:55:32 +0200
committerChristian Poessinger <christian@poessinger.com>2018-07-29 19:55:32 +0200
commit3a02c31b5bc271f215faf5a7bdb0b4c6c21ef7d6 (patch)
tree9dffe64b12015aa9ef8e1c6f47a891384e61cbd0 /src/conf_mode/dynamic_dns.py
parent6c80c47cc701cec60aec6eca6d55c9c5071b13f7 (diff)
downloadvyos-1x-3a02c31b5bc271f215faf5a7bdb0b4c6c21ef7d6.tar.gz
vyos-1x-3a02c31b5bc271f215faf5a7bdb0b4c6c21ef7d6.zip
T758: add configuration validator
Diffstat (limited to 'src/conf_mode/dynamic_dns.py')
-rwxr-xr-xsrc/conf_mode/dynamic_dns.py43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/conf_mode/dynamic_dns.py b/src/conf_mode/dynamic_dns.py
index fa1102a90..aabd2c499 100755
--- a/src/conf_mode/dynamic_dns.py
+++ b/src/conf_mode/dynamic_dns.py
@@ -138,12 +138,15 @@ def get_config():
'login': '',
'password': '',
'protocol': '',
- 'server': ''
+ 'server': '',
+ 'custom' : False
}
# preload protocol from default service mapping
if service in default_service_protocol.keys():
srv['protocol'] = default_service_protocol[service]
+ else:
+ srv['custom'] = True
if conf.exists('service {0} login'.format(service)):
srv['login'] = conf.return_value('service {0} login'.format(service))
@@ -178,6 +181,44 @@ def verify(dyndns):
if dyndns is None:
return None
+ # A 'node' corresponds to an interface
+ for node in dyndns['interfaces']:
+
+ # RFC2136 - configuration validation
+ for rfc2136 in node['rfc2136']:
+ if not rfc2136['record']:
+ raise ConfigError('Set key for service "{0}" to send DDNS updates for interface "{1}"'.format(rfc2136['name'], node['interface']))
+
+ if not rfc2136['zone']:
+ raise ConfigError('Set zone for service "{0}" to send DDNS updates for interface "{1}"'.format(rfc2136['name'], node['interface']))
+
+ if not rfc2136['keyfile']:
+ raise ConfigError('Set keyfile for service "{0}" to send DDNS updates for interface "{1}"'.format(rfc2136['name'], node['interface']))
+ else:
+ if not os.path.isfile(rfc2136['keyfile']):
+ raise ConfigError('Keyfile for service "{0}" to send DDNS updates for interface "{1}" does not exist'.format(rfc2136['name'], node['interface']))
+
+ if not rfc2136['server']:
+ raise ConfigError('Set server for service "{0}" to send DDNS updates for interface "{1}"'.format(rfc2136['name'], node['interface']))
+
+ # DynDNS service provider - configuration validation
+ for service in node['service']:
+ if not service['host']:
+ raise ConfigError('Set host-name for service "{0}" to send DDNS updates for interface "{1}"'.format(service['provider'], node['interface']))
+
+ if not service['login']:
+ raise ConfigError('Set login for service "{0}" to send DDNS updates for interface "{1}"'.format(service['provider'], node['interface']))
+
+ if not service['password']:
+ raise ConfigError('Set password for service "{0}" to send DDNS updates for interface "{1}"'.format(service['provider'], node['interface']))
+
+ if service['custom'] is True:
+ if not service['protocol']:
+ raise ConfigError('Set protocol for service "{0}" to send DDNS updates for interface "{1}"'.format(service['provider'], node['interface']))
+
+ if not service['server']:
+ raise ConfigError('Set server for service "{0}" to send DDNS updates for interface "{1}"'.format(service['provider'], node['interface']))
+
return None
def generate(dyndns):