summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-02-07 19:55:37 +0100
committerChristian Poessinger <christian@poessinger.com>2021-02-07 19:55:37 +0100
commitfac6d728523aeaf8ab0faf3de7a41f7da3923616 (patch)
tree72d50bb4fafca9e988446c68be90163a6729cae9
parent89108f629ec8cc6990473468c1c67ffa8742b884 (diff)
downloadvyos-1x-fac6d728523aeaf8ab0faf3de7a41f7da3923616.tar.gz
vyos-1x-fac6d728523aeaf8ab0faf3de7a41f7da3923616.zip
rip: T2547: migrate interface specific configuration under protocols rip
-rw-r--r--interface-definitions/include/rip-interface.xml.i73
-rwxr-xr-xsrc/migration-scripts/interfaces/18-to-1994
2 files changed, 115 insertions, 52 deletions
diff --git a/interface-definitions/include/rip-interface.xml.i b/interface-definitions/include/rip-interface.xml.i
index f3f473a90..1d5e6f949 100644
--- a/interface-definitions/include/rip-interface.xml.i
+++ b/interface-definitions/include/rip-interface.xml.i
@@ -1,5 +1,5 @@
<!-- included start from rip-interface.xml.i -->
-<leafNode name="interface">
+<tagNode name="interface">
<properties>
<help>Interface name</help>
<completionHelp>
@@ -12,7 +12,74 @@
<constraint>
<validator name="interface-name"/>
</constraint>
- <multi/>
</properties>
-</leafNode>
+ <children>
+ <node name="authentication">
+ <properties>
+ <help>Authentication</help>
+ </properties>
+ <children>
+ <tagNode name="md5">
+ <properties>
+ <help>MD5 key id</help>
+ <valueHelp>
+ <format>u32:1-255</format>
+ <description>OSPF key id</description>
+ </valueHelp>
+ <constraint>
+ <validator name="numeric" argument="--range 1-255"/>
+ </constraint>
+ </properties>
+ <children>
+ <leafNode name="password">
+ <properties>
+ <help>Authentication password</help>
+ <valueHelp>
+ <format>txt</format>
+ <description>MD5 Key (16 characters or less)</description>
+ </valueHelp>
+ <constraint>
+ <regex>^[^[:space:]]{1,16}$</regex>
+ </constraint>
+ <constraintErrorMessage>Password must be 16 characters or less</constraintErrorMessage>
+ </properties>
+ </leafNode>
+ </children>
+ </tagNode>
+ <leafNode name="plaintext-password">
+ <properties>
+ <help>Plain text password</help>
+ <valueHelp>
+ <format>txt</format>
+ <description>Plain text password (16 characters or less)</description>
+ </valueHelp>
+ <constraint>
+ <regex>^[^[:space:]]{1,16}$</regex>
+ </constraint>
+ <constraintErrorMessage>Password must be 16 characters or less</constraintErrorMessage>
+ </properties>
+ </leafNode>
+ </children>
+ </node>
+ <node name="split-horizon">
+ <properties>
+ <help>Split horizon parameters</help>
+ </properties>
+ <children>
+ <leafNode name="disable">
+ <properties>
+ <help>Disable split horizon on specified interface</help>
+ <valueless/>
+ </properties>
+ </leafNode>
+ <leafNode name="poison-reverse">
+ <properties>
+ <help>Disable split horizon on specified interface</help>
+ <valueless/>
+ </properties>
+ </leafNode>
+ </children>
+ </node>
+ </children>
+</tagNode>
<!-- included end -->
diff --git a/src/migration-scripts/interfaces/18-to-19 b/src/migration-scripts/interfaces/18-to-19
index 965b76a04..31e253098 100755
--- a/src/migration-scripts/interfaces/18-to-19
+++ b/src/migration-scripts/interfaces/18-to-19
@@ -18,6 +18,34 @@ from sys import argv
from sys import exit
from vyos.configtree import ConfigTree
+def migrate_ospf(config, path, interface):
+ path = path + ['ospf']
+ if config.exists(path):
+ new_base = ['protocols', 'ospf', 'interface']
+ config.set(new_base)
+ config.set_tag(new_base)
+ config.copy(path, new_base + [interface])
+ config.delete(path)
+
+ # if "ip ospf" was the only setting, we can clean out the empty
+ # ip node afterwards
+ if len(config.list_nodes(path[:-1])) == 0:
+ config.delete(path[:-1])
+
+def migrate_rip(config, path, interface):
+ path = path + ['rip']
+ if config.exists(path):
+ new_base = ['protocols', 'rip', 'interface']
+ config.set(new_base)
+ config.set_tag(new_base)
+ config.copy(path, new_base + [interface])
+ config.delete(path)
+
+ # if "ip rip" was the only setting, we can clean out the empty
+ # ip node afterwards
+ if len(config.list_nodes(path[:-1])) == 0:
+ config.delete(path[:-1])
+
if __name__ == '__main__':
if (len(argv) < 1):
print("Must specify file name!")
@@ -34,64 +62,33 @@ if __name__ == '__main__':
#
for type in config.list_nodes(['interfaces']):
for interface in config.list_nodes(['interfaces', type]):
-
- ip_ospf = ['interfaces', type, interface, 'ip', 'ospf']
- if config.exists(ip_ospf):
- config.set(['protocols', 'ospf', 'interface'])
- config.set_tag(['protocols', 'ospf', 'interface'])
- config.copy(ip_ospf, ['protocols', 'ospf', 'interface', interface])
- config.delete(ip_ospf)
-
- # if "ip ospf" was the only setting, we can clean out the empty
- # ip node afterwards
- if len(config.list_nodes(ip_ospf[:-1])) == 0:
- config.delete(ip_ospf[:-1])
+ if_base = ['interfaces', type, interface, 'ip']
+ migrate_rip(config, if_base, interface)
+ migrate_ospf(config, if_base, interface)
vif_path = ['interfaces', type, interface, 'vif']
if config.exists(vif_path):
for vif in config.list_nodes(vif_path):
- vif_ospf_path = vif_path + [vif, 'ip', 'ospf']
- if config.exists(vif_ospf_path):
- config.set(['protocols', 'ospf', 'interface'])
- config.set_tag(['protocols', 'ospf', 'interface'])
- config.copy(vif_ospf_path, ['protocols', 'ospf', 'interface', f'{interface}.{vif}'])
- config.delete(vif_ospf_path)
-
- # if "ip ospf" was the only setting, we can clean out the empty
- # ip node afterwards
- if len(config.list_nodes(vif_ospf_path[:-1])) == 0:
- config.delete(vif_ospf_path[:-1])
+ vif_if_base = vif_path + [vif, 'ip']
+ migrate_rip(config, vif_if_base, f'{interface}.{vif}')
+ migrate_ospf(config, vif_if_base, f'{interface}.{vif}')
vif_s_path = ['interfaces', type, interface, 'vif-s']
if config.exists(vif_s_path):
for vif_s in config.list_nodes(vif_s_path):
- vif_s_ospf_path = vif_s_path + [vif_s, 'ip', 'ospf']
- if config.exists(vif_s_ospf_path):
- config.set(['protocols', 'ospf', 'interface'])
- config.set_tag(['protocols', 'ospf', 'interface'])
- config.copy(vif_s_ospf_path, ['protocols', 'ospf', 'interface', f'{interface}.{vif_s}'])
+ vif_s_if_base = vif_s_path + [vif_s, 'ip']
- vif_c_path = ['interfaces', type, interface, 'vif-s', vif_s, 'vif-c']
- if config.exists(vif_c_path):
- for vif_c in config.list_nodes(vif_c_path):
- vif_c_ospf_path = vif_c_path + [vif_c, 'ip', 'ospf']
- if config.exists(vif_c_ospf_path):
- config.set(['protocols', 'ospf', 'interface'])
- config.set_tag(['protocols', 'ospf', 'interface'])
- config.copy(vif_c_ospf_path, ['protocols', 'ospf', 'interface', f'{interface}.{vif_s}.{vif_c}'])
- config.delete(vif_c_ospf_path)
+ # vif-c interfaces MUST be migrated before their parent vif-s
+ # interface as the migrate_*() functions delete the path!
+ vif_c_path = ['interfaces', type, interface, 'vif-s', vif_s, 'vif-c']
+ if config.exists(vif_c_path):
+ for vif_c in config.list_nodes(vif_c_path):
+ vif_c_if_base = vif_c_path + [vif_c, 'ip']
+ migrate_rip(config, vif_c_if_base, f'{interface}.{vif_s}.{vif_c}')
+ migrate_ospf(config, vif_c_if_base, f'{interface}.{vif_s}.{vif_c}')
- # if "ip ospf" was the only setting, we can clean out the empty
- # ip node afterwards
- if len(config.list_nodes(vif_c_ospf_path[:-1])) == 0:
- config.delete(vif_c_ospf_path[:-1])
-
- config.delete(vif_s_ospf_path)
-
- # if "ip ospf" was the only setting, we can clean out the empty
- # ip node afterwards
- if len(config.list_nodes(vif_s_ospf_path[:-1])) == 0:
- config.delete(vif_s_ospf_path[:-1])
+ migrate_rip(config, vif_s_if_base, f'{interface}.{vif_s}')
+ migrate_ospf(config, vif_s_if_base, f'{interface}.{vif_s}')
try:
with open(file_name, 'w') as f:
@@ -99,4 +96,3 @@ if __name__ == '__main__':
except OSError as e:
print("Failed to save the modified config: {}".format(e))
exit(1)
-