summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-10-04 12:11:23 +0200
committerChristian Poessinger <christian@poessinger.com>2020-10-04 12:11:23 +0200
commitf4e9248d2a24fc4fd0cdc7089aed0193d7a2884f (patch)
tree4069629e4ff2fb88e44bedde3d6754e80f53a457
parentfe6326c96e6e481fc4498c10c493dfd393c3956c (diff)
downloadvyos-1x-f4e9248d2a24fc4fd0cdc7089aed0193d7a2884f.tar.gz
vyos-1x-f4e9248d2a24fc4fd0cdc7089aed0193d7a2884f.zip
pppoe-server: T2953: rename CLI local-ip to gateway-address
Required to get a common CLI for all services provided by Accel-PPP. Once the CLI for each service is consitent - Jinja2 templates can be reused together with get_config_dict().
-rw-r--r--data/templates/accel-ppp/config_ip_pool.j26
-rw-r--r--data/templates/accel-ppp/pppoe.config.tmpl4
-rw-r--r--interface-definitions/service_pppoe-server.xml.in9
-rw-r--r--smoketest/scripts/cli/base_accel_ppp_test.py4
-rwxr-xr-xsmoketest/scripts/cli/test_service_pppoe-server.py6
-rwxr-xr-xsmoketest/scripts/cli/test_vpn_sstp.py2
-rwxr-xr-xsrc/conf_mode/service_pppoe-server.py4
-rwxr-xr-xsrc/migration-scripts/pppoe-server/4-to-549
8 files changed, 62 insertions, 22 deletions
diff --git a/data/templates/accel-ppp/config_ip_pool.j2 b/data/templates/accel-ppp/config_ip_pool.j2
index 51fe67334..973bc0071 100644
--- a/data/templates/accel-ppp/config_ip_pool.j2
+++ b/data/templates/accel-ppp/config_ip_pool.j2
@@ -1,11 +1,11 @@
{% if client_ip_pool is defined and client_ip_pool is not none %}
[ip-pool]
-{% if local_ip is defined and local_ip is not none %}
-gw-ip-address={{ local_ip }}
+{% if gateway_address is defined and gateway_address is not none %}
+gw-ip-address={{ gateway_address }}
{% endif %}
{% if client_ip_pool.start is defined and client_ip_pool.stop is defined and client_ip_pool.start is not none and client_ip_pool.stop is not none %}
{{ client_ip_pool.start }}-{{ client_ip_pool.stop }}
-{% endif -%}
+{% endif %}
{% if client_ip_pool.subnet is defined and client_ip_pool.subnet is not none %}
{% for subnet in client_ip_pool.subnet %}
{{ subnet }}
diff --git a/data/templates/accel-ppp/pppoe.config.tmpl b/data/templates/accel-ppp/pppoe.config.tmpl
index acc7df0a2..8f1b9e7c5 100644
--- a/data/templates/accel-ppp/pppoe.config.tmpl
+++ b/data/templates/accel-ppp/pppoe.config.tmpl
@@ -92,8 +92,8 @@ dae-server={{ authentication.radius.dynamic_author.server }}:{{ authentication.r
{% endif -%}
{% endif %}
-{% if local_ip is defined and local_ip is not none %}
-gw-ip-address={{ local_ip }}
+{% if gateway_address is defined and gateway_address is not none %}
+gw-ip-address={{ gateway_address }}
{% endif %}
{% if session_control is defined and session_control != 'disable' %}
diff --git a/interface-definitions/service_pppoe-server.xml.in b/interface-definitions/service_pppoe-server.xml.in
index 3a9c25496..78bbda089 100644
--- a/interface-definitions/service_pppoe-server.xml.in
+++ b/interface-definitions/service_pppoe-server.xml.in
@@ -110,14 +110,7 @@
</leafNode>
</children>
</tagNode>
- <leafNode name="local-ip">
- <properties>
- <help>local gateway address</help>
- <constraint>
- <validator name="ipv4-address"/>
- </constraint>
- </properties>
- </leafNode>
+ #include <include/accel-gateway-address.xml.i>
<leafNode name="mtu">
<properties>
<help>Maximum Transmission Unit (MTU) - default 1492</help>
diff --git a/smoketest/scripts/cli/base_accel_ppp_test.py b/smoketest/scripts/cli/base_accel_ppp_test.py
index 94834ad4c..cf401b0d8 100644
--- a/smoketest/scripts/cli/base_accel_ppp_test.py
+++ b/smoketest/scripts/cli/base_accel_ppp_test.py
@@ -30,6 +30,8 @@ class BasicAccelPPPTest:
def setUp(self):
self.session = ConfigSession(os.getpid())
+ self._gateway = '192.0.2.1'
+
# ensure we can also run this test on a live system - so lets clean
# out the current configuration :)
self.session.delete(self._base_path)
@@ -46,7 +48,7 @@ class BasicAccelPPPTest:
# PPPoE local auth mode requires local users to be configured!
self.set(['authentication', 'local-users', 'username', 'vyos', 'password', 'vyos'])
self.set(['authentication', 'mode', 'local'])
-
+ self.set(['gateway-address', self._gateway])
def verify(self, conf):
self.assertEqual(conf['core']['thread-count'], str(get_half_cpus()))
diff --git a/smoketest/scripts/cli/test_service_pppoe-server.py b/smoketest/scripts/cli/test_service_pppoe-server.py
index dea8d838e..8db002b57 100755
--- a/smoketest/scripts/cli/test_service_pppoe-server.py
+++ b/smoketest/scripts/cli/test_service_pppoe-server.py
@@ -27,7 +27,6 @@ from vyos.util import cmd
local_if = ['interfaces', 'dummy', 'dum667']
ac_name = 'ACN'
-gateway = '192.0.2.1'
interface = 'eth0'
@@ -74,7 +73,6 @@ class TestServicePPPoEServer(BasicAccelPPPTest.BaseTest):
self.set(['access-concentrator', ac_name])
self.set(['interface', interface])
- self.set(['local-ip', gateway])
super().basic_config()
@@ -106,7 +104,7 @@ class TestServicePPPoEServer(BasicAccelPPPTest.BaseTest):
# basic verification
self.verify(conf)
- self.assertEqual(conf['chap-secrets']['gw-ip-address'], gateway)
+ self.assertEqual(conf['chap-secrets']['gw-ip-address'], self._gateway)
# check ppp
self.assertEqual(conf['ppp']['mppe'], mppe)
@@ -163,7 +161,7 @@ class TestServicePPPoEServer(BasicAccelPPPTest.BaseTest):
# check configured subnet
self.assertEqual(conf['ip-pool'][subnet], None)
self.assertEqual(conf['ip-pool'][start_stop], None)
- self.assertEqual(conf['ip-pool']['gw-ip-address'], gateway)
+ self.assertEqual(conf['ip-pool']['gw-ip-address'], self._gateway)
# Check for running process
self.assertTrue(process_named_running(self._process_name))
diff --git a/smoketest/scripts/cli/test_vpn_sstp.py b/smoketest/scripts/cli/test_vpn_sstp.py
index 03ed23495..83be4c248 100755
--- a/smoketest/scripts/cli/test_vpn_sstp.py
+++ b/smoketest/scripts/cli/test_vpn_sstp.py
@@ -41,9 +41,7 @@ class TestVPNSSTPServer(BasicAccelPPPTest.BaseTest):
self.set(['ssl', 'ca-cert-file', ca_cert])
self.set(['ssl', 'cert-file', ssl_cert])
self.set(['ssl', 'key-file', ssl_key])
-
self.set(['client-ip-pool', 'subnet', '192.0.2.0/24'])
- self.set(['gateway-address', '1.1.1.1'])
super().basic_config()
diff --git a/src/conf_mode/service_pppoe-server.py b/src/conf_mode/service_pppoe-server.py
index 8ed8c6812..445311391 100755
--- a/src/conf_mode/service_pppoe-server.py
+++ b/src/conf_mode/service_pppoe-server.py
@@ -141,8 +141,8 @@ def verify(pppoe):
if 'interface' not in pppoe:
raise ConfigError('At least one listen interface must be defined!')
- if 'local_ip' not in pppoe:
- raise ConfigError('PPPoE server requires local-ip to be configured!')
+ if 'gateway_address' not in pppoe:
+ raise ConfigError('PPPoE server requires gateway-address to be configured!')
# local ippool and gateway settings config checks
if not (vyos_dict_search('client_ip_pool.subnet', pppoe) or
diff --git a/src/migration-scripts/pppoe-server/4-to-5 b/src/migration-scripts/pppoe-server/4-to-5
new file mode 100755
index 000000000..05e9c17d6
--- /dev/null
+++ b/src/migration-scripts/pppoe-server/4-to-5
@@ -0,0 +1,49 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2020 VyOS maintainers and contributors
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# - rename local-ip to gateway-address
+
+from vyos.configtree import ConfigTree
+from sys import argv
+from sys import exit
+
+if (len(argv) < 1):
+ print("Must specify file name!")
+ exit(1)
+
+file_name = argv[1]
+
+with open(file_name, 'r') as f:
+ config_file = f.read()
+
+config = ConfigTree(config_file)
+base_path = ['service', 'pppoe-server']
+if not config.exists(base_path):
+ # Nothing to do
+ exit(0)
+else:
+ config_gw = base_path + ['local-ip']
+ if config.exists(config_gw):
+ config.rename(config_gw, 'gateway-address')
+ config.delete(config_gw)
+
+ try:
+ with open(file_name, 'w') as f:
+ f.write(config.to_string())
+ except OSError as e:
+ print("Failed to save the modified config: {}".format(e))
+ exit(1)
+