[pve-devel] r5045 - in pve-storage/pve2: . PVE/API2 PVE/API2/Storage

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Aug 24 13:13:11 CEST 2010


Author: dietmar
Date: 2010-08-24 11:13:11 +0000 (Tue, 24 Aug 2010)
New Revision: 5045

Modified:
   pve-storage/pve2/ChangeLog
   pve-storage/pve2/PVE/API2/Storage.pm
   pve-storage/pve2/PVE/API2/Storage/Config.pm
   pve-storage/pve2/PVE/API2/Storage/Content.pm
   pve-storage/pve2/PVE/API2/Storage/Scan.pm
   pve-storage/pve2/PVE/API2/Storage/Status.pm
   pve-storage/pve2/pvesm
Log:
	* pvesm: use new PVE::RPCEnvironment

	* PVE/API2/*.pm: remove $conn parameter everywhere

	* use new Scan API



Modified: pve-storage/pve2/ChangeLog
===================================================================
--- pve-storage/pve2/ChangeLog	2010-08-24 11:11:35 UTC (rev 5044)
+++ pve-storage/pve2/ChangeLog	2010-08-24 11:13:11 UTC (rev 5045)
@@ -1,3 +1,9 @@
+2010-08-24  Proxmox Support Team  <support at proxmox.com>
+
+	* pvesm: use new PVE::RPCEnvironment
+
+	* PVE/API2/*.pm: remove $conn parameter everywhere
+
 2010-08-19  Proxmox Support Team  <support at proxmox.com>
 
 	* pvesm: more cleanups - use new API calls

Modified: pve-storage/pve2/PVE/API2/Storage/Config.pm
===================================================================
--- pve-storage/pve2/PVE/API2/Storage/Config.pm	2010-08-24 11:11:35 UTC (rev 5044)
+++ pve-storage/pve2/PVE/API2/Storage/Config.pm	2010-08-24 11:13:11 UTC (rev 5045)
@@ -57,7 +57,7 @@
 	links => [ { rel => 'child', href => "{storage}" } ],
     },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	my $cfg = read_file ("storagecfg");
 
@@ -86,7 +86,7 @@
     },
     returns => {},
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	my $cfg = read_file ("storagecfg");
 
@@ -155,7 +155,7 @@
     },
     returns => { type => 'null' },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	my $type = $param->{type};
 	delete $param->{type};
@@ -239,7 +239,7 @@
     },
     returns => { type => 'null' },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	my $storeid = $param->{storage};
 	delete($param->{storage});
@@ -292,7 +292,7 @@
     },
     returns => { type => 'null' },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	my $storeid = $param->{storage};
 	delete($param->{storage});

Modified: pve-storage/pve2/PVE/API2/Storage/Content.pm
===================================================================
--- pve-storage/pve2/PVE/API2/Storage/Content.pm	2010-08-24 11:11:35 UTC (rev 5044)
+++ pve-storage/pve2/PVE/API2/Storage/Content.pm	2010-08-24 11:13:11 UTC (rev 5045)
@@ -50,7 +50,7 @@
 	links => [ { rel => 'child', href => "{volname}" } ],
     },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	my $cts = $param->{content} ? [ $param->{content} ] : [ @ctypes ];
 
@@ -127,7 +127,7 @@
 	type => 'string',
     },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	# fixme: connect to node
 	# fixme: can we proxy file uploads at all?
@@ -254,7 +254,7 @@
     },
     returns => { type => 'object' },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	# fixme: connect to node
 
@@ -295,7 +295,7 @@
     },
     returns => { type => 'null' },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	# fixme: connect to node
 	
@@ -343,7 +343,7 @@
     },
     returns => { type => 'string' },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	# fixme: connect to node
 	
@@ -406,7 +406,7 @@
 	links => [ { rel => 'child', href => "{storage}" } ],
     },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	my $cfg = read_file ("storagecfg");
 
@@ -457,7 +457,7 @@
 	links => [ { rel => 'child', href => "{node}" } ],
     },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	# fixme: use the real list
 	my $nodes = [ 

Modified: pve-storage/pve2/PVE/API2/Storage/Scan.pm
===================================================================
--- pve-storage/pve2/PVE/API2/Storage/Scan.pm	2010-08-24 11:11:35 UTC (rev 5044)
+++ pve-storage/pve2/PVE/API2/Storage/Scan.pm	2010-08-24 11:13:11 UTC (rev 5045)
@@ -30,7 +30,7 @@
 	links => [ { rel => 'child', href => "{method}" } ],
     },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	my $res = [ 
 	    { method => 'lvm' },
@@ -63,7 +63,7 @@
     },
     returns => {},
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	# fixme: proxy to node if requested
 

Modified: pve-storage/pve2/PVE/API2/Storage/Status.pm
===================================================================
--- pve-storage/pve2/PVE/API2/Storage/Status.pm	2010-08-24 11:11:35 UTC (rev 5044)
+++ pve-storage/pve2/PVE/API2/Storage/Status.pm	2010-08-24 11:13:11 UTC (rev 5045)
@@ -34,7 +34,7 @@
 	links => [ { rel => 'child', href => "{storage}" } ],
     },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	my $cts = $param->{content} ? [ $param->{content} ] : [ @ctypes ];
 	
@@ -66,7 +66,7 @@
     },
     returns => {},
     code =>  sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	my $cts = $param->{content} ? [ $param->{content} ] : [ @ctypes ];
 
@@ -116,7 +116,7 @@
 	links => [ { rel => 'child', href => "{node}" } ],
     },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	# fixme: use the real list
 	my $nodes = [ 

Modified: pve-storage/pve2/PVE/API2/Storage.pm
===================================================================
--- pve-storage/pve2/PVE/API2/Storage.pm	2010-08-24 11:11:35 UTC (rev 5044)
+++ pve-storage/pve2/PVE/API2/Storage.pm	2010-08-24 11:13:11 UTC (rev 5045)
@@ -63,7 +63,7 @@
 	links => [ { rel => 'child', href => "{subdir}" } ],
     },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	my $res = [
 	    { subdir => 'config' },
@@ -94,7 +94,7 @@
 #	links => [ { rel => 'child', href => "{storage}" } ],
     },
     code => sub {
-	my ($conn, $param) = @_;
+	my ($param) = @_;
 
 	my $nodes = [ 'node-0', 'node-1', 'node-2', 'node-3' ]; # fixme: use the real list
 

Modified: pve-storage/pve2/pvesm
===================================================================
--- pve-storage/pve2/pvesm	2010-08-24 11:11:35 UTC (rev 5044)
+++ pve-storage/pve2/pvesm	2010-08-24 11:13:11 UTC (rev 5045)
@@ -6,10 +6,12 @@
 use File::Path;
 
 use PVE::INotify qw(read_file);
+use PVE::RPCEnvironment;
 use PVE::Storage;
 use PVE::API2::Storage::Config;
 use PVE::API2::Storage::Content;
 use PVE::API2::Storage::Status;
+use PVE::API2::Storage::Scan;
 
 use Data::Dumper; # fixme: remove 
 
@@ -19,6 +21,12 @@
 
 PVE::INotify::inotify_init();
 
+my $rpcenv = PVE::RPCEnvironment->init('cli');
+
+$rpcenv->set_language($ENV{LANG});
+
+$rpcenv->set_user('root'); 
+
 # fixme:
 sub print_usage {
     my $msg = shift;
@@ -172,29 +180,21 @@
 	die "wrong number of arguments\n";
     }
 
-    my $type = shift;
-    my $server = shift;
+    my $opts = {};
 
-    if ($type eq 'nfs') {
-	my $res = PVE::Storage::scan_nfs ($server);
-	my $maxlen = 0;
-	foreach my $export (keys %$res) {
-	    my $len = length ($export);
-	    $maxlen = $len if $len > $maxlen;
-	}
-	foreach my $export (keys %$res) {
-	    printf "%-${maxlen}s $res->{$export}\n", $export;
-	}
+    $opts->{method} = shift;
+    $opts->{server} = shift;
 
-    } elsif ($type eq 'iscsi') {
-	my $res = PVE::Storage::scan_iscsi ($server);
-	foreach my $target (keys %$res) {
-	    my $portal = $res->{$target};
-	    print "$portal $target\n";
-	} 
-    } else {
-	die "can't execute scan for storage type '$type'\n";
+    my $res = PVE::API2::Storage::Scan->cli_handler('scan', \@ARGV, $opts);
+
+    my $maxlen = 0;
+    foreach my $k (keys %$res) {
+	my $len = length ($k);
+	$maxlen = $len if $len > $maxlen;
     }
+    foreach my $k (keys %$res) {
+	printf "%-${maxlen}s $res->{$k}\n", $k;
+    }
 
 } elsif ($cmd eq 'path') {
 



More information about the pve-devel mailing list