[pve-devel] r4907 - pve-storage/pve2

svn-commits at proxmox.com svn-commits at proxmox.com
Fri Jul 16 14:01:11 CEST 2010


Author: dietmar
Date: 2010-07-16 12:01:11 +0000 (Fri, 16 Jul 2010)
New Revision: 4907

Modified:
   pve-storage/pve2/ChangeLog
   pve-storage/pve2/Storage.pm
Log:
* Storage.pm (parse_options): added ability to verify a
	HASH (needed by REST API)



Modified: pve-storage/pve2/ChangeLog
===================================================================
--- pve-storage/pve2/ChangeLog	2010-07-16 06:52:09 UTC (rev 4906)
+++ pve-storage/pve2/ChangeLog	2010-07-16 12:01:11 UTC (rev 4907)
@@ -1,3 +1,8 @@
+2010-07-16  Proxmox Support Team  <support at proxmox.com>
+
+	* Storage.pm (parse_options): added ability to verify a
+	HASH (needed by REST API)
+
 2010-01-25  Proxmox Support Team  <support at proxmox.com>
 
 	* Storage.pm (parse_lvm_name, parse_storage_id, parse_volume_id):

Modified: pve-storage/pve2/Storage.pm
===================================================================
--- pve-storage/pve2/Storage.pm	2010-07-16 06:52:09 UTC (rev 4906)
+++ pve-storage/pve2/Storage.pm	2010-07-16 12:01:11 UTC (rev 4907)
@@ -723,17 +723,33 @@
  	}
     };
 
-    my $getopt;
-    foreach my $opt (keys %{$default_config->{$stype}}) {
-	$getopt->{"$opt=s"} = $get_option_func;
-    }
+    my $ptype = ref($param) || die "internal error";
+    if (ref($param) eq 'ARRAY') {
+	my $getopt;
+	foreach my $opt (keys %{$default_config->{$stype}}) {
+	    $getopt->{"$opt=s"} = $get_option_func;
+	}
 
-    if (!GetOptionsFromArray ($param, %$getopt) || $errmsg) {
-	if ($errmsg) {
-	    die "$errmsg\n";
-	} else {
-	    die "unable to parse options\n";
+	if (!GetOptionsFromArray ($param, %$getopt) || $errmsg) {
+	    if ($errmsg) {
+		die "$errmsg\n";
+	    } else {
+		die "unable to parse options\n";
+	    }
 	}
+    } else {
+	eval {
+	    foreach my $opt (keys %$param) {
+		&$get_option_func($opt, $param->{$opt});
+	    }
+	};
+	if ($@) {
+	    if ($errmsg) {
+		die "$errmsg\n";
+	    } else {
+		die "unable to parse options\n";
+	    }
+	}
     }
 
     if ($create) {




More information about the pve-devel mailing list