From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 6A72B1FF161 for ; Tue, 10 Sep 2024 13:23:58 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BA2123355F; Tue, 10 Sep 2024 13:23:56 +0200 (CEST) From: Daniel Kral To: pve-devel@lists.proxmox.com Date: Tue, 10 Sep 2024 13:23:42 +0200 Message-Id: <20240910112342.114849-1-d.kral@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.004 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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. [lxc.pm] Subject: [pve-devel] [PATCH container] api: autocomplete rootdir storages for create, move-volume and clone 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: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Adds a helper subroutine for enumerating storages that are enabled and have the content type `rootdir` set, therefore supporting container directories. The autocompletion is added to the clone command and changed for the create and move-volume commands, which previously suggested any storage device. This is misleading as these commands will fail for any storage that is not configured to store container directories. Signed-off-by: Daniel Kral --- I have already noticed that the create command has the default value 'local' for the storage parameter, which could fail on any installation where the local storage is not configured to store rootdirs. This should be fixed in a separate patch in my opinion. src/PVE/API2/LXC.pm | 5 +++-- src/PVE/LXC.pm | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm index d9f1c0a..918e719 100644 --- a/src/PVE/API2/LXC.pm +++ b/src/PVE/API2/LXC.pm @@ -148,9 +148,9 @@ __PACKAGE__->register_method({ }, storage => get_standard_option('pve-storage-id', { description => "Default Storage.", + completion => \&PVE::LXC::complete_storage, default => 'local', optional => 1, - completion => \&PVE::Storage::complete_storage_enabled, }), force => { optional => 1, @@ -1582,6 +1582,7 @@ __PACKAGE__->register_method({ }), storage => get_standard_option('pve-storage-id', { description => "Target storage for full clone.", + completion => \&PVE::LXC::complete_storage, optional => 1, }), full => { @@ -2084,7 +2085,7 @@ __PACKAGE__->register_method({ }, storage => get_standard_option('pve-storage-id', { description => "Target Storage.", - completion => \&PVE::Storage::complete_storage_enabled, + completion => \&PVE::LXC::complete_storage, optional => 1, }), delete => { diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 65d0fa8..269614c 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -2382,6 +2382,20 @@ sub complete_ctid_running { return &$complete_ctid_full(1); } +sub complete_storage { + my $cfg = PVE::Storage::config(); + my $ids = $cfg->{ids}; + + my $res = []; + foreach my $sid (keys %$ids) { + next if !PVE::Storage::storage_check_enabled($cfg, $sid, undef, 1); + next if !$ids->{$sid}->{content}->{rootdir}; + push @$res, $sid; + } + + return $res; +} + sub parse_id_maps { my ($conf) = @_; -- 2.39.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel