Add mode, description and optionnal disclaimer for migrations

This commit is contained in:
Alexandre Aubin 2018-02-01 02:59:03 +01:00
parent 020dea6531
commit 7f359e363b
2 changed files with 16 additions and 3 deletions

View file

@ -222,6 +222,8 @@
"migrate_tsig_wait_3": "1min...",
"migrate_tsig_wait_4": "30 secondes...",
"migrate_tsig_not_needed": "You do not appear to use a dyndns domain, so no migration is needed !",
"migration_description_0001_change_cert_group_to_sslcert": "Change certificates group permissions from 'metronome' to 'ssl-cert'",
"migration_description_0002_migrate_to_tsig_sha256": "Improve security of dyndns TSIG by using SHA512 instead of MD5",
"migrations_backward": "Migrating backward.",
"migrations_bad_value_for_target": "Invalide number for target argument, available migrations numbers are 0 or {}",
"migrations_cant_reach_migration_file": "Can't access migrations files at path %s",

View file

@ -950,10 +950,9 @@ def _load_migration(migration_file):
class Migration(object):
# forward() and backward() are to be implemented by daughter classes
# Those are to be implemented by daughter classes
def migrate(self):
self.forward()
mode = "auto"
def forward(self):
raise NotImplementedError()
@ -961,15 +960,27 @@ class Migration(object):
def backward(self):
pass
def disclaimer(self):
return None
# The followings shouldn't be overriden
def migrate(self):
self.forward()
def __init__(self, id_):
self.id = id_
def description(self):
return m18n.n("migration_description_%s" % self.id)
def infos(self):
return {
"id": self.id,
"number": int(self.id.split("_", 1)[0]),
"name": self.id.split("_", 1)[1],
"mode": self.mode,
"description": self.description(),
"disclaimer": self.disclaimer()
}