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 B90AB60041 for ; Wed, 2 Dec 2020 11:51:35 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B23F91A457 for ; Wed, 2 Dec 2020 11:51:35 +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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 7D4881A3FB for ; Wed, 2 Dec 2020 11:51:33 +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 4541244226 for ; Wed, 2 Dec 2020 11:51:33 +0100 (CET) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Date: Wed, 2 Dec 2020 11:51:20 +0100 Message-Id: <20201202105122.1132809-5-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201202105122.1132809-1-t.lamprecht@proxmox.com> References: <20201202105122.1132809-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.076 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. [nodes.pm, gluster.org, nodeconfig.pm, hardware.pm, services.pm, scan.pm, acmeaccount.pm, acmeplugin.pm] Subject: [pve-devel] applied: [PATCH manager 4/6] api: use storage scan module from pve-storage 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: Wed, 02 Dec 2020 10:51:35 -0000 Signed-off-by: Thomas Lamprecht --- note: I had to do a fixup commit for the first hunk, forgot to add it to staging area on commit -.- but the actual changes are those showed here. PVE/API2/Nodes.pm | 4 +- PVE/API2/Makefile | 1 - PVE/API2/Scan.pm | 424 ---------------------------------------------- debian/control | 4 +- 4 files changed, 4 insertions(+), 429 deletions(-) delete mode 100644 PVE/API2/Scan.pm diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm index d84c3e73..8172231e 100644 --- a/PVE/API2/Nodes.pm +++ b/PVE/API2/Nodes.pm @@ -31,7 +31,7 @@ use PVE::API2::Subscription; use PVE::API2::Services; use PVE::API2::Network; use PVE::API2::Tasks; -use PVE::API2::Scan; +use PVE::API2::Storage::Scan; use PVE::API2::Storage::Status; use PVE::API2::Qemu; use PVE::API2::Qemu::CPU; @@ -107,7 +107,7 @@ __PACKAGE__->register_method ({ }); __PACKAGE__->register_method ({ - subclass => "PVE::API2::Scan", + subclass => "PVE::API2::Storage::Scan", path => 'scan', }); diff --git a/PVE/API2/Makefile b/PVE/API2/Makefile index bc5ccc36..116922c6 100644 --- a/PVE/API2/Makefile +++ b/PVE/API2/Makefile @@ -22,7 +22,6 @@ PERLSOURCE = \ ACMEAccount.pm \ ACMEPlugin.pm \ NodeConfig.pm \ - Scan.pm \ Hardware.pm \ Services.pm diff --git a/PVE/API2/Scan.pm b/PVE/API2/Scan.pm deleted file mode 100644 index c096e8f6..00000000 --- a/PVE/API2/Scan.pm +++ /dev/null @@ -1,424 +0,0 @@ -package PVE::API2::Scan; - -use strict; -use warnings; - -use PVE::SafeSyslog; -use PVE::Storage; -use PVE::Storage::LVMPlugin; -use PVE::SysFSTools; -use PVE::JSONSchema qw(get_standard_option); -use PVE::RESTHandler; - -use base qw(PVE::RESTHandler); - -__PACKAGE__->register_method ({ - name => 'index', - path => '', - method => 'GET', - description => "Index of available scan methods", - permissions => { - user => 'all', - }, - parameters => { - additionalProperties => 0, - properties => { - node => get_standard_option('pve-node'), - }, - }, - returns => { - type => 'array', - items => { - type => "object", - properties => { method => { type => 'string'} }, - }, - links => [ { rel => 'child', href => "{method}" } ], - }, - code => sub { - my ($param) = @_; - - my $res = [ - { method => 'lvm' }, - { method => 'iscsi' }, - { method => 'nfs' }, - { method => 'glusterfs' }, - { method => 'usb' }, - { method => 'zfs' }, - { method => 'cifs' }, - ]; - - return $res; - }}); - -__PACKAGE__->register_method ({ - name => 'zfsscan', - path => 'zfs', - method => 'GET', - description => "Scan zfs pool list on local node.", - protected => 1, - proxyto => "node", - permissions => { - check => ['perm', '/storage', ['Datastore.Allocate']], - }, - parameters => { - additionalProperties => 0, - properties => { - node => get_standard_option('pve-node'), - }, - }, - returns => { - type => 'array', - items => { - type => "object", - properties => { - pool => { - description => "ZFS pool name.", - type => 'string', - }, - }, - }, - }, - code => sub { - my ($param) = @_; - - return PVE::Storage::scan_zfs(); - }}); - -__PACKAGE__->register_method ({ - name => 'nfsscan', - path => 'nfs', - method => 'GET', - description => "Scan remote NFS server.", - protected => 1, - proxyto => "node", - permissions => { - check => ['perm', '/storage', ['Datastore.Allocate']], - }, - parameters => { - additionalProperties => 0, - properties => { - node => get_standard_option('pve-node'), - server => { - description => "The server address (name or IP).", - type => 'string', format => 'pve-storage-server', - }, - }, - }, - returns => { - type => 'array', - items => { - type => "object", - properties => { - path => { - description => "The exported path.", - type => 'string', - }, - options => { - description => "NFS export options.", - type => 'string', - }, - }, - }, - }, - code => sub { - my ($param) = @_; - - my $server = $param->{server}; - my $res = PVE::Storage::scan_nfs($server); - - my $data = []; - foreach my $k (keys %$res) { - push @$data, { path => $k, options => $res->{$k} }; - } - return $data; - }}); - -__PACKAGE__->register_method ({ - name => 'cifsscan', - path => 'cifs', - method => 'GET', - description => "Scan remote CIFS server.", - protected => 1, - proxyto => "node", - permissions => { - check => ['perm', '/storage', ['Datastore.Allocate']], - }, - parameters => { - additionalProperties => 0, - properties => { - node => get_standard_option('pve-node'), - server => { - description => "The server address (name or IP).", - type => 'string', format => 'pve-storage-server', - }, - username => { - description => "User name.", - type => 'string', - optional => 1, - }, - password => { - description => "User password.", - type => 'string', - optional => 1, - }, - domain => { - description => "SMB domain (Workgroup).", - type => 'string', - optional => 1, - }, - }, - }, - returns => { - type => 'array', - items => { - type => "object", - properties => { - share => { - description => "The cifs share name.", - type => 'string', - }, - description => { - description => "Descriptive text from server.", - type => 'string', - }, - }, - }, - }, - code => sub { - my ($param) = @_; - - my $server = $param->{server}; - - my $username = $param->{username}; - my $password = $param->{password}; - my $domain = $param->{domain}; - - my $res = PVE::Storage::scan_cifs($server, $username, $password, $domain); - - my $data = []; - foreach my $k (keys %$res) { - next if $k =~ m/NT_STATUS_/; - push @$data, { share => $k, description => $res->{$k} }; - } - - return $data; - }}); - -# Note: GlusterFS currently does not have an equivalent of showmount. -# As workaround, we simply use nfs showmount. -# see http://www.gluster.org/category/volumes/ - -__PACKAGE__->register_method ({ - name => 'glusterfsscan', - path => 'glusterfs', - method => 'GET', - description => "Scan remote GlusterFS server.", - protected => 1, - proxyto => "node", - permissions => { - check => ['perm', '/storage', ['Datastore.Allocate']], - }, - parameters => { - additionalProperties => 0, - properties => { - node => get_standard_option('pve-node'), - server => { - description => "The server address (name or IP).", - type => 'string', format => 'pve-storage-server', - }, - }, - }, - returns => { - type => 'array', - items => { - type => "object", - properties => { - volname => { - description => "The volume name.", - type => 'string', - }, - }, - }, - }, - code => sub { - my ($param) = @_; - - my $server = $param->{server}; - my $res = PVE::Storage::scan_nfs($server); - - my $data = []; - foreach my $path (keys %$res) { - if ($path =~ m!^/([^\s/]+)$!) { - push @$data, { volname => $1 }; - } - } - return $data; - }}); - -__PACKAGE__->register_method ({ - name => 'iscsiscan', - path => 'iscsi', - method => 'GET', - description => "Scan remote iSCSI server.", - protected => 1, - proxyto => "node", - permissions => { - check => ['perm', '/storage', ['Datastore.Allocate']], - }, - parameters => { - additionalProperties => 0, - properties => { - node => get_standard_option('pve-node'), - portal => { - description => "The iSCSI portal (IP or DNS name with optional port).", - type => 'string', format => 'pve-storage-portal-dns', - }, - }, - }, - returns => { - type => 'array', - items => { - type => "object", - properties => { - target => { - description => "The iSCSI target name.", - type => 'string', - }, - portal => { - description => "The iSCSI portal name.", - type => 'string', - }, - }, - }, - }, - code => sub { - my ($param) = @_; - - my $res = PVE::Storage::scan_iscsi($param->{portal}); - - my $data = []; - foreach my $k (keys %$res) { - push @$data, { target => $k, portal => join(',', @{$res->{$k}}) }; - } - - return $data; - }}); - -__PACKAGE__->register_method ({ - name => 'lvmscan', - path => 'lvm', - method => 'GET', - description => "List local LVM volume groups.", - protected => 1, - proxyto => "node", - permissions => { - check => ['perm', '/storage', ['Datastore.Allocate']], - }, - parameters => { - additionalProperties => 0, - properties => { - node => get_standard_option('pve-node'), - }, - }, - returns => { - type => 'array', - items => { - type => "object", - properties => { - vg => { - description => "The LVM logical volume group name.", - type => 'string', - }, - }, - }, - }, - code => sub { - my ($param) = @_; - - my $res = PVE::Storage::LVMPlugin::lvm_vgs(); - return PVE::RESTHandler::hash_to_array($res, 'vg'); - }}); - -__PACKAGE__->register_method ({ - name => 'lvmthinscan', - path => 'lvmthin', - method => 'GET', - description => "List local LVM Thin Pools.", - protected => 1, - proxyto => "node", - permissions => { - check => ['perm', '/storage', ['Datastore.Allocate']], - }, - parameters => { - additionalProperties => 0, - properties => { - node => get_standard_option('pve-node'), - vg => { - type => 'string', - pattern => '[a-zA-Z0-9\.\+\_][a-zA-Z0-9\.\+\_\-]+', # see lvm(8) manpage - maxLength => 100, - }, - }, - }, - returns => { - type => 'array', - items => { - type => "object", - properties => { - lv => { - description => "The LVM Thin Pool name (LVM logical volume).", - type => 'string', - }, - }, - }, - }, - code => sub { - my ($param) = @_; - - return PVE::Storage::LvmThinPlugin::list_thinpools($param->{vg}); - }}); - -__PACKAGE__->register_method ({ - name => 'usbscan', - path => 'usb', - method => 'GET', - description => "List local USB devices.", - protected => 1, - proxyto => "node", - permissions => { - check => ['perm', '/', ['Sys.Modify']], - }, - parameters => { - additionalProperties => 0, - properties => { - node => get_standard_option('pve-node'), - }, - }, - returns => { - type => 'array', - items => { - type => "object", - properties => { - busnum => { type => 'integer'}, - devnum => { type => 'integer'}, - port => { type => 'integer'}, - usbpath => { type => 'string', optional => 1}, - level => { type => 'integer'}, - class => { type => 'integer'}, - vendid => { type => 'string'}, - prodid => { type => 'string'}, - speed => { type => 'string'}, - - product => { type => 'string', optional => 1 }, - serial => { type => 'string', optional => 1 }, - manufacturer => { type => 'string', optional => 1 }, - }, - }, - }, - code => sub { - my ($param) = @_; - - return PVE::SysFSTools::scan_usb(); - }}); - -1; diff --git a/debian/control b/debian/control index cb4977f4..629dfb34 100644 --- a/debian/control +++ b/debian/control @@ -13,7 +13,7 @@ Build-Depends: debhelper (>= 11~), libpve-common-perl, libpve-guest-common-perl (>= 3.0-8~), libpve-http-server-perl (>= 2.0-12), - libpve-storage-perl (>= 6.1-7), + libpve-storage-perl (>= 6.3-2), libtemplate-perl, libtest-mockmodule-perl, lintian, @@ -52,7 +52,7 @@ Depends: apt-transport-https | apt (>= 1.5~), libpve-common-perl (>= 6.2-2), libpve-guest-common-perl (>= 3.1-3~), libpve-http-server-perl (>= 3.0-4), - libpve-storage-perl (>= 6.2-11), + libpve-storage-perl (>= 6.3-2), librados2-perl, libtemplate-perl, libterm-readline-gnu-perl, -- 2.20.1