summaryrefslogtreecommitdiff
path: root/src/migration-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'src/migration-scripts')
-rwxr-xr-xsrc/migration-scripts/system/11-to-122
-rwxr-xr-xsrc/migration-scripts/system/12-to-1356
2 files changed, 57 insertions, 1 deletions
diff --git a/src/migration-scripts/system/11-to-12 b/src/migration-scripts/system/11-to-12
index 64425e2b9..0c92a0746 100755
--- a/src/migration-scripts/system/11-to-12
+++ b/src/migration-scripts/system/11-to-12
@@ -27,7 +27,7 @@ for host in config.list_nodes(cbase):
if re.search(':[0-9]{1,5}$',host):
h = re.search('^[a-zA-Z\-0-9\.]+', host).group(0)
p = re.sub(':', '', re.search(':[0-9]+$', host).group(0))
- config.set(cbase + [h])
+ config.set(cbase + [h])
config.set(cbase + [h, 'port'], value=p)
for fac in config.list_nodes(cbase + [host, 'facility']):
config.set(cbase + [h, 'facility', fac])
diff --git a/src/migration-scripts/system/12-to-13 b/src/migration-scripts/system/12-to-13
new file mode 100755
index 000000000..deb17e44a
--- /dev/null
+++ b/src/migration-scripts/system/12-to-13
@@ -0,0 +1,56 @@
+#!/usr/bin/env python3
+
+# Fixup non existent time-zones. Some systems have time-zone set to:
+# - Los* (Los_Angeles)
+# - Den* (Denver)
+# ... but thos are no real IANA assigned time zones. In the past the have been
+# silently remapped. Time to clean it up!
+
+import re
+import sys
+
+from vyos.configtree import ConfigTree
+
+if (len(sys.argv) < 1):
+ print("Must specify file name!")
+ sys.exit(1)
+
+file_name = sys.argv[1]
+
+with open(file_name, 'r') as f:
+ config_file = f.read()
+
+config = ConfigTree(config_file)
+tz_base = ['system', 'time-zone']
+if not config.exists(tz_base):
+ # Nothing to do
+ sys.exit(0)
+else:
+ tz = config.return_value(tz_base)
+
+ if re.match(r'[Ll][Oo][Ss].+', tz):
+ tz = 'America/Los_Angeles'
+ elif re.match(r'[Dd][Ee][Nn].+', tz):
+ tz = 'America/Denver'
+ elif re.match(r'[Hh][Oo][Nn][Oo].+', tz):
+ tz = 'Pacific/Honolulu'
+ elif re.match(r'[Nn][Ee][Ww].+', tz):
+ tz = 'America/New_York'
+ elif re.match(r'[Cc][Hh][Ii][Cc]*.+', tz):
+ tz = 'America/Chicago'
+ elif re.match(r'[Aa][Nn][Cc].+', tz):
+ tz = 'America/Anchorage'
+ elif re.match(r'[Pp][Hh][Oo].+', tz):
+ tz = 'America/Phoenix'
+ elif re.match(r'GMT(.+)?', tz):
+ tz = 'Etc/' + tz
+
+ # replace timezone data is required
+ config.set(tz_base, value=tz)
+
+ 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))
+ sys.exit(1)