From 2b3d70357efad13c00c2f821751ba4864fe115de Mon Sep 17 00:00:00 2001 From: wangyan Date: Mon, 30 Apr 2018 09:57:01 -0700 Subject: [PATCH] Overwrite some attributes in harbor.cfg 1.5 The values of "redis_url" and "max_job_workers" should be set to new values due to new implementation. --- tools/migration/cfg/migrator_1_5_0/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/migration/cfg/migrator_1_5_0/__init__.py b/tools/migration/cfg/migrator_1_5_0/__init__.py index bead0a172b..e30aecb3ba 100644 --- a/tools/migration/cfg/migrator_1_5_0/__init__.py +++ b/tools/migration/cfg/migrator_1_5_0/__init__.py @@ -3,6 +3,13 @@ import utils import os acceptable_versions = ['1.2.0', '1.3.0', '1.4.0'] +#The dict overwrite is for overwriting any value that was set in previous cfg, +#which needs a new value in new version of .cfg +overwrite = { + 'redis_url':'redis:6379', + 'max_job_workers':'50' +} +#The dict default is for filling in the values that are not set in previous config files. #In 1.5 template the placeholder has the same value as the attribute name. default = { 'log_rotate_count':'50', @@ -10,7 +17,6 @@ default = { 'db_host':'mysql', 'db_port':'3306', 'db_user':'root', - 'redis_url':'', 'clair_db_host':'postgres', 'clair_db_port':'5432', 'clair_db_username':'postgres', @@ -27,11 +33,14 @@ default = { def migrate(input_cfg, output_cfg): d = utils.read_conf(input_cfg) keys = list(default.keys()) + keys.extend(overwrite.keys()) keys.extend(['hostname', 'ui_url_protocol', 'max_job_workers', 'customize_crt', 'ssl_cert', 'ssl_cert_key', 'secretkey_path', 'admiral_url', 'db_password', 'clair_db_password']) val = {} for k in keys: - if k in d: + if k in overwrite: + val[k] = overwrite[k] + elif k in d: val[k] = d[k] else: val[k] = default[k]