From 7bfa48ffe4ec23052c3fd833b3c0197b5c705dc0 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Mon, 16 Jan 2017 15:35:41 +0700 Subject: Real initial commit. --- Makefile | 7 ++ configs/etc/vyconfd.conf | 19 +++ configs/etc/vyos/config.boot.default | 21 ++++ data/interface-definitions/system.xml | 42 +++++++ schema/component_definition.rng | 83 ++++++++++++ schema/interface_definition.rng | 230 ++++++++++++++++++++++++++++++++++ scripts/verify-schema.py | 40 ++++++ 7 files changed, 442 insertions(+) create mode 100644 Makefile create mode 100644 configs/etc/vyconfd.conf create mode 100644 configs/etc/vyos/config.boot.default create mode 100644 data/interface-definitions/system.xml create mode 100644 schema/component_definition.rng create mode 100644 schema/interface_definition.rng create mode 100755 scripts/verify-schema.py diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a169332 --- /dev/null +++ b/Makefile @@ -0,0 +1,7 @@ +.PHONY: +verify-definitions: + find data/interface-definitions/ -type f -print | xargs scripts/verify-schema.py schema/interface_definition.rng + +.PHONY: +all: + verify-definitions diff --git a/configs/etc/vyconfd.conf b/configs/etc/vyconfd.conf new file mode 100644 index 0000000..cf25c92 --- /dev/null +++ b/configs/etc/vyconfd.conf @@ -0,0 +1,19 @@ +[appliance] + +name = "VyOS" + +data_dir = "/usr/share/vyos" +program_dir = "/usr/libexec/vyos" +config_dir = "/etc/vyos" + +# paths relative to config_dir +primary_config = "config.boot" +fallback_config = "config.failsafe" + +[vyconf] + +socket = "/var/run/vyconfd.sock" +pid_file = "/var/run/vyconfd.pid" +log_file = "/var/log/vyconfd.log" +log_template = "$(date) $(name)[$(pid)]: $(message)" +log_level = "notice" diff --git a/configs/etc/vyos/config.boot.default b/configs/etc/vyos/config.boot.default new file mode 100644 index 0000000..3af63ca --- /dev/null +++ b/configs/etc/vyos/config.boot.default @@ -0,0 +1,21 @@ +system { + login { + user vyos { + encrypted-password "$6$0qH9IPTOUwKTu$H7f3iyivBvvSR1o8TtD6mL/vQcqblEwIjZNu4auYV20r/xhm6JfbCapCb57bvjAMsD3Fmwdxqg0zJpoJMgTUf0"; + level root; + } + } + host-name vyos; + ntp-server [ + 0.pool.ntp.org; + 1.pool.ntp.org; + 2.pool.ntp.org + ]; + config-management { + commit-revisions 1000; + } +} +interaces { + loopback lo { + } +} diff --git a/data/interface-definitions/system.xml b/data/interface-definitions/system.xml new file mode 100644 index 0000000..92318a9 --- /dev/null +++ b/data/interface-definitions/system.xml @@ -0,0 +1,42 @@ + + + + + + + + + + System host name + + [a-z]([a-z0-9\-]+) + + Host name must start with a letter and contain only lowercase letters, digits, and hyphens + + + + + + DNS server + + + + + DNS server address must be a valid IPv4 or IPv6 address + + + + + + NTP server + + + + + + NTP server address must be a valid hostname, IPv4, or IPv6 address + + + + + diff --git a/schema/component_definition.rng b/schema/component_definition.rng new file mode 100644 index 0000000..4dbb5b8 --- /dev/null +++ b/schema/component_definition.rng @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/schema/interface_definition.rng b/schema/interface_definition.rng new file mode 100644 index 0000000..8aa3ed5 --- /dev/null +++ b/schema/interface_definition.rng @@ -0,0 +1,230 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/verify-schema.py b/scripts/verify-schema.py new file mode 100755 index 0000000..6976d5e --- /dev/null +++ b/scripts/verify-schema.py @@ -0,0 +1,40 @@ +#!/usr/bin/env python +# +# verify_schema.py: simple LXML wrapper for checking XML against +# a RelaxNG schema. +# +# Copyright (C) 2014 VyOS Development Group +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 +# USA +import sys + +from lxml import etree as ET + +if len(sys.argv) < 2: + print("Usage: {0} ".format(sys.argv[0])) + sys.exit(1) + +schema = sys.argv[1] +xml_source = sys.argv[2] + +xml_tree = ET.parse(xml_source) +relaxng_xml = ET.parse(schema) +validator = ET.RelaxNG(relaxng_xml) + +if not validator.validate(xml_tree): + print(validator.error_log) + print("File {0} does not match the schema!".format(xml_source)) + sys.exit(1) -- cgit v1.2.3