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 446E3688F9 for ; Thu, 14 Jan 2021 17:49:28 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 36C4D1E0BB for ; Thu, 14 Jan 2021 17:49:28 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id CF1321E0AE for ; Thu, 14 Jan 2021 17:49:26 +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 996A045FC6 for ; Thu, 14 Jan 2021 17:49:26 +0100 (CET) Date: Thu, 14 Jan 2021 17:49:24 +0100 From: Alwin Antreich To: pve-devel@lists.proxmox.com Message-ID: <20210114164924.GE2853024@dona.proxmox.com> Mail-Followup-To: Alwin Antreich , pve-devel@lists.proxmox.com References: <20210112102153.3215121-1-a.antreich@proxmox.com> <20210112102153.3215121-5-a.antreich@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210112102153.3215121-5-a.antreich@proxmox.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [pveceph.pm, pools.pm] Subject: Re: [pve-devel] [PATCH manager v3 04/10] ceph: add get api call for single pool 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: Thu, 14 Jan 2021 16:49:28 -0000 On Tue, Jan 12, 2021 at 11:21:47AM +0100, Alwin Antreich wrote: > Information of a single pool can be queried. > > Signed-off-by: Alwin Antreich > --- > PVE/API2/Ceph/Pools.pm | 99 ++++++++++++++++++++++++++++++++++++++++++ > PVE/CLI/pveceph.pm | 4 ++ > 2 files changed, 103 insertions(+) > > diff --git a/PVE/API2/Ceph/Pools.pm b/PVE/API2/Ceph/Pools.pm > index 24562456..01c11100 100644 > --- a/PVE/API2/Ceph/Pools.pm > +++ b/PVE/API2/Ceph/Pools.pm > @@ -395,4 +395,103 @@ __PACKAGE__->register_method ({ > }}); > > > +__PACKAGE__->register_method ({ > + name => 'getpool', > + path => '{name}', > + method => 'GET', > + description => "List pool settings.", > + proxyto => 'node', > + protected => 1, > + permissions => { > + check => ['perm', '/', [ 'Sys.Audit', 'Datastore.Audit' ], any => 1], > + }, > + parameters => { > + additionalProperties => 0, > + properties => { > + node => get_standard_option('pve-node'), > + name => { > + description => "The name of the pool. It must be unique.", > + type => 'string', > + }, > + verbose => { > + type => 'boolean', > + default => 0, > + optional => 1, > + description => "If enabled, will display additional data". > + "(eg. statistics).", > + }, > + }, > + }, > + returns => { > + type => "object", > + properties => { > + id => { type => 'integer', title => 'ID' }, > + pgp_num => { type => 'integer', title => 'PGP num' }, > + noscrub => { type => 'boolean', title => 'noscrub' }, > + 'nodeep-scrub' => { type => 'boolean', title => 'nodeep-scrub' }, > + nodelete => { type => 'boolean', title => 'nodelete' }, > + nopgchange => { type => 'boolean', title => 'nopgchange' }, > + nosizechange => { type => 'boolean', title => 'nosizechange' }, > + write_fadvise_dontneed => { type => 'boolean', title => 'write_fadvise_dontneed' }, > + hashpspool => { type => 'boolean', title => 'hashpspool' }, > + use_gmt_hitset => { type => 'boolean', title => 'use_gmt_hitset' }, > + fast_read => { type => 'boolean', title => 'Fast Read' }, > + application_list => { type => 'array', title => 'Application', optional => 1 }, > + statistics => { type => 'object', title => 'Statistics', optional => 1 }, > + %{ $ceph_pool_common_options->() }, > + }, > + }, > + code => sub { > + my ($param) = @_; > + > + PVE::Ceph::Tools::check_ceph_inited(); > + > + my $verbose = $param->{verbose}; > + my $pool = $param->{name}; > + > + my $rados = PVE::RADOS->new(); > + my $res = $rados->mon_command({ > + prefix => 'osd pool get', > + pool => "$pool", > + var => 'all', > + }); > + > + my $data = { > + id => $res->{pool_id}, > + name => $pool, > + size => $res->{size}, > + min_size => $res->{min_size}, > + pg_num => $res->{pg_num}, > + pgp_num => $res->{pgp_num}, > + crush_rule => $res->{crush_rule}, > + pg_autoscale_mode => $res->{pg_autoscale_mode}, > + noscrub => "$res->{noscrub}", > + 'nodeep-scrub' => "$res->{'nodeep-scrub'}", > + nodelete => "$res->{nodelete}", > + nopgchange => "$res->{nopgchange}", > + nosizechange => "$res->{nosizechange}", > + write_fadvise_dontneed => "$res->{write_fadvise_dontneed}", > + hashpspool => "$res->{hashpspool}", > + use_gmt_hitset => "$res->{use_gmt_hitset}", > + fast_read => "$res->{fast_read}", > + }; > + > + if ($verbose) { > + my $stats; > + my $res = $rados->mon_command({ prefix => 'df' }); > + > + foreach my $d (@{$res->{pools}}) { > + next if !$d->{stats}; > + next if !defined($d->{name}) && !$d->{name} ne "$pool"; > + $data->{statistics} = $d->{stats}; > + } > + > + my $apps = $rados->mon_command({ prefix => "osd pool application get", pool => "$pool", }); > + $data->{application_list} = [ keys %$apps ]; > + } > + > + return $data; > + }}); > + > + > 1; > diff --git a/PVE/CLI/pveceph.pm b/PVE/CLI/pveceph.pm > index 4114df7e..ba5067b1 100755 > --- a/PVE/CLI/pveceph.pm > +++ b/PVE/CLI/pveceph.pm > @@ -217,6 +217,10 @@ our $cmddef = { > create => [ 'PVE::API2::Ceph::Pools', 'createpool', ['name'], { node => $nodename }], > destroy => [ 'PVE::API2::Ceph::Pools', 'destroypool', ['name'], { node => $nodename } ], > set => [ 'PVE::API2::Ceph::Pools', 'setpool', ['name'], { node => $nodename } ], > + get => [ 'PVE::API2::Ceph::Pools', 'getpool', ['name'], { node => $nodename }, sub { > + my ($data, $schema, $options) = @_; > + PVE::CLIFormatter::print_api_result($data, $schema, undef, $options); > + }, $PVE::RESTHandler::standard_output_options], > }, > lspools => { alias => 'pool ls' }, > createpool => { alias => 'pool create' }, > -- > 2.29.2 Note: I noticed that the crush_rule selection doesn't work. The value from the get request isn't used. The field uses the pveCephRuleSelector.