From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 000C891BC4 for ; Mon, 20 Mar 2023 09:35:54 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D6B2C2FB3B for ; Mon, 20 Mar 2023 09:35:54 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 20 Mar 2023 09:35:52 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 767124584C for ; Mon, 20 Mar 2023 09:35:52 +0100 (CET) Date: Mon, 20 Mar 2023 09:35:44 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20230316134820.1193518-1-a.lauterer@proxmox.com> <20230316134820.1193518-2-a.lauterer@proxmox.com> In-Reply-To: <20230316134820.1193518-2-a.lauterer@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.16.0 (https://github.com/astroidmail/astroid) Message-Id: <1679301146.g3jz78ufjq.astroid@yuna.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.122 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: Re: [pve-devel] [PATCH v2 manager 1/5] api: ceph: add ceph/cfg path, deprecate ceph/config and ceph/configdb X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Mar 2023 08:35:55 -0000 On March 16, 2023 2:48 pm, Aaron Lauterer wrote: > Consolidating the different config paths lets us add more as needed > without polluting our API with too many 'configxxx' endpoints. >=20 > The config and configdb paths are renamed under the ceph/cfg path: > * config -> raw (returns the ceph.conf file as is) > * configdb -> db (returns the ceph config db contents) >=20 > The old paths are still available and need to be dropped at some point. >=20 > Signed-off-by: Aaron Lauterer other than the nit below, patches 1 & 2: Acked-by: Fabian Gr=C3=BCnbichler Reviewed-by: Fabian Gr=C3=BCnbichler > --- >=20 > changes since v1: > * add this commit to rework the API >=20 > PVE/API2/Ceph.pm | 15 ++++-- > PVE/API2/Ceph/Cfg.pm | 116 +++++++++++++++++++++++++++++++++++++++++ > PVE/API2/Ceph/Makefile | 1 + > 3 files changed, 129 insertions(+), 3 deletions(-) > create mode 100644 PVE/API2/Ceph/Cfg.pm >=20 > diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm > index 786a1870..3e3dd399 100644 > --- a/PVE/API2/Ceph.pm > +++ b/PVE/API2/Ceph.pm > @@ -18,6 +18,7 @@ use PVE::RPCEnvironment; > use PVE::Storage; > use PVE::Tools qw(run_command file_get_contents file_set_contents extrac= t_param); > =20 > +use PVE::API2::Ceph::Cfg; > use PVE::API2::Ceph::OSD; > use PVE::API2::Ceph::FS; > use PVE::API2::Ceph::MDS; > @@ -30,6 +31,11 @@ use base qw(PVE::RESTHandler); > =20 > my $pve_osd_default_journal_size =3D 1024*5; > =20 > +__PACKAGE__->register_method ({ > + subclass =3D> "PVE::API2::Ceph::Cfg", > + path =3D> 'cfg', > +}); > + > __PACKAGE__->register_method ({ > subclass =3D> "PVE::API2::Ceph::OSD", > path =3D> 'osd', > @@ -88,6 +94,7 @@ __PACKAGE__->register_method ({ > =20 > my $result =3D [ > { name =3D> 'cmd-safety' }, > + { name =3D> 'cfg' }, > { name =3D> 'config' }, > { name =3D> 'configdb' }, > { name =3D> 'crush' }, > @@ -109,6 +116,8 @@ __PACKAGE__->register_method ({ > return $result; > }}); > =20 > + > +# TODO: deprecrated, remove with PVE 8 > __PACKAGE__->register_method ({ > name =3D> 'config', > path =3D> 'config', > @@ -117,7 +126,7 @@ __PACKAGE__->register_method ({ > permissions =3D> { > check =3D> ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any =3D> 1= ], > }, > - description =3D> "Get the Ceph configuration file.", > + description =3D> "Get the Ceph configuration file. Deprecated, pleas= e use `/nodes/{node}/ceph/cfg/raw.", > parameters =3D> { > additionalProperties =3D> 0, > properties =3D> { > @@ -135,6 +144,7 @@ __PACKAGE__->register_method ({ > =20 > }}); > =20 > +# TODO: deprecrated, remove with PVE 8 > __PACKAGE__->register_method ({ > name =3D> 'configdb', > path =3D> 'configdb', > @@ -144,7 +154,7 @@ __PACKAGE__->register_method ({ > permissions =3D> { > check =3D> ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any =3D> 1= ], > }, > - description =3D> "Get the Ceph configuration database.", > + description =3D> "Get the Ceph configuration database. Deprecated, p= lease use `/nodes/{node}/ceph/cfg/db.", > parameters =3D> { > additionalProperties =3D> 0, > properties =3D> { > @@ -179,7 +189,6 @@ __PACKAGE__->register_method ({ > return $res; > }}); > =20 > - > __PACKAGE__->register_method ({ > name =3D> 'init', > path =3D> 'init', > diff --git a/PVE/API2/Ceph/Cfg.pm b/PVE/API2/Ceph/Cfg.pm > new file mode 100644 > index 00000000..a00ef19c > --- /dev/null > +++ b/PVE/API2/Ceph/Cfg.pm > @@ -0,0 +1,116 @@ > +package PVE::API2::Ceph::Cfg; > + > +use strict; > +use warnings; > + > +use PVE::Ceph::Tools; > +use PVE::Cluster qw(cfs_read_file cfs_write_file); nit: not used by this patch, but only by later ones maybe also a good time to evalute whether ceph.conf should be read via cfs_read_file or file_get_contents, there seems to be some disagreement in = this series ;) > +use PVE::JSONSchema qw(get_standard_option); > +use PVE::RADOS; > +use PVE::Tools qw(run_command file_get_contents file_set_contents extrac= t_param); > + > +use base qw(PVE::RESTHandler); > + > +__PACKAGE__->register_method ({ > + name =3D> 'index', > + path =3D> '', > + method =3D> 'GET', > + description =3D> "Directory index.", > + permissions =3D> { user =3D> 'all' }, > + permissions =3D> { > + check =3D> ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any =3D> 1= ], > + }, > + parameters =3D> { > + additionalProperties =3D> 0, > + properties =3D> { > + node =3D> get_standard_option('pve-node'), > + }, > + }, > + returns =3D> { > + type =3D> 'array', > + items =3D> { > + type =3D> "object", > + properties =3D> {}, > + }, > + links =3D> [ { rel =3D> 'child', href =3D> "{name}" } ], > + }, > + code =3D> sub { > + my ($param) =3D @_; > + > + my $result =3D [ > + { name =3D> 'raw' }, > + { name =3D> 'db' }, > + ]; > + > + return $result; > + }}); > + > +__PACKAGE__->register_method ({ > + name =3D> 'raw', > + path =3D> 'raw', > + method =3D> 'GET', > + proxyto =3D> 'node', > + permissions =3D> { > + check =3D> ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any =3D> 1= ], > + }, > + description =3D> "Get the Ceph configuration file.", > + parameters =3D> { > + additionalProperties =3D> 0, > + properties =3D> { > + node =3D> get_standard_option('pve-node'), > + }, > + }, > + returns =3D> { type =3D> 'string' }, > + code =3D> sub { > + my ($param) =3D @_; > + > + PVE::Ceph::Tools::check_ceph_inited(); > + > + my $path =3D PVE::Ceph::Tools::get_config('pve_ceph_cfgpath'); > + return file_get_contents($path); > + > + }}); > + > +__PACKAGE__->register_method ({ > + name =3D> 'db', > + path =3D> 'db', > + method =3D> 'GET', > + proxyto =3D> 'node', > + protected =3D> 1, > + permissions =3D> { > + check =3D> ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any =3D> 1= ], > + }, > + description =3D> "Get the Ceph configuration database.", > + parameters =3D> { > + additionalProperties =3D> 0, > + properties =3D> { > + node =3D> get_standard_option('pve-node'), > + }, > + }, > + returns =3D> { > + type =3D> 'array', > + items =3D> { > + type =3D> 'object', > + properties =3D> { > + section =3D> { type =3D> "string", }, > + name =3D> { type =3D> "string", }, > + value =3D> { type =3D> "string", }, > + level =3D> { type =3D> "string", }, > + 'can_update_at_runtime' =3D> { type =3D> "boolean", }, > + mask =3D> { type =3D> "string" }, > + }, > + }, > + }, > + code =3D> sub { > + my ($param) =3D @_; > + > + PVE::Ceph::Tools::check_ceph_inited(); > + > + my $rados =3D PVE::RADOS->new(); > + my $res =3D $rados->mon_command( { prefix =3D> 'config dump', format = =3D> 'json' }); > + foreach my $entry (@$res) { > + $entry->{can_update_at_runtime} =3D $entry->{can_update_at_runtime}= ? 1 : 0; # JSON::true/false -> 1/0 > + } > + > + return $res; > + }}); > diff --git a/PVE/API2/Ceph/Makefile b/PVE/API2/Ceph/Makefile > index 45daafda..be7b6926 100644 > --- a/PVE/API2/Ceph/Makefile > +++ b/PVE/API2/Ceph/Makefile > @@ -1,6 +1,7 @@ > include ../../../defines.mk > =20 > PERLSOURCE=3D \ > + Cfg.pm \ > MGR.pm \ > MON.pm \ > OSD.pm \ > --=20 > 2.30.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20