]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: accept arbitrary dict via --meta-json
authorSage Weil <sage@newdream.net>
Tue, 23 Feb 2021 17:25:37 +0000 (12:25 -0500)
committerSebastian Wagner <sebastian.wagner@suse.com>
Tue, 9 Mar 2021 14:29:32 +0000 (15:29 +0100)
e.g., --meta-json '{"foo": "bar"}'

Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit f58485efb66548f2f7acd94e448e160480775f81)

src/cephadm/cephadm

index 64299eabe075ebe774c6f893fe5bbb65f79733c3..e316f0a7b94e5ce63e42bf1ecd70823aef48dc67 100755 (executable)
@@ -2635,10 +2635,14 @@ def deploy_daemon_units(
         _write_container_cmd_to_bash(ctx, f, c, '%s.%s' % (daemon_type, str(daemon_id)))
 
         # some metadata about the deploy
-        metaf.write(json.dumps({
+        meta: Dict[str, Any] = {}
+        if 'meta_json' in ctx and ctx.meta_json:
+            meta = json.loads(ctx.meta_json) or {}
+        meta.update({
             'memory_request': int(ctx.memory_request) if ctx.memory_request else None,
             'memory_limit': int(ctx.memory_limit) if ctx.memory_limit else None,
-        }, indent=4) + "\n")
+        })
+        metaf.write(json.dumps(meta, indent=4) + "\n")
 
         os.fchmod(f.fileno(), 0o600)
         os.fchmod(metaf.fileno(), 0o600)
@@ -7606,6 +7610,10 @@ def _get_parser():
         '--memory-limit',
         help='Container memory hard limit'
     )
+    parser_deploy.add_argument(
+        '--meta-json',
+        help='JSON dict of additional metadata'
+    )
 
     parser_check_host = subparsers.add_parser(
         'check-host', help='check host configuration')