[pve-devel] r5096 - in pve-storage/pve2: . PVE/API2/Storage
svn-commits at proxmox.com
svn-commits at proxmox.com
Tue Sep 7 12:26:39 CEST 2010
Author: dietmar
Date: 2010-09-07 10:26:38 +0000 (Tue, 07 Sep 2010)
New Revision: 5096
Modified:
pve-storage/pve2/ChangeLog
pve-storage/pve2/PVE/API2/Storage/Config.pm
pve-storage/pve2/Storage.pm
Log:
* Storage.pm (parse_options): renamed from parse_options_new
Modified: pve-storage/pve2/ChangeLog
===================================================================
--- pve-storage/pve2/ChangeLog 2010-09-07 10:11:20 UTC (rev 5095)
+++ pve-storage/pve2/ChangeLog 2010-09-07 10:26:38 UTC (rev 5096)
@@ -1,3 +1,7 @@
+2010-09-07 Proxmox Support Team <support at proxmox.com>
+
+ * Storage.pm (parse_options): renamed from parse_options_new
+
2010-08-26 Proxmox Support Team <support at proxmox.com>
* Storage.pm (vdisk_list): return full volid instead of volume name.
Modified: pve-storage/pve2/PVE/API2/Storage/Config.pm
===================================================================
--- pve-storage/pve2/PVE/API2/Storage/Config.pm 2010-09-07 10:11:20 UTC (rev 5095)
+++ pve-storage/pve2/PVE/API2/Storage/Config.pm 2010-09-07 10:26:38 UTC (rev 5096)
@@ -163,7 +163,7 @@
my $storeid = $param->{storage};
delete $param->{storage};
- my $opts = PVE::Storage::parse_options_new($storeid, $type, $param, 1);
+ my $opts = PVE::Storage::parse_options($storeid, $type, $param, 1);
PVE::Storage::lock_storage_config(
sub {
@@ -256,7 +256,7 @@
my $scfg = PVE::Storage::storage_config ($cfg, $storeid);
- my $opts = PVE::Storage::parse_options_new($storeid, $scfg->{type}, $param);
+ my $opts = PVE::Storage::parse_options($storeid, $scfg->{type}, $param);
foreach my $k (%$opts) {
$scfg->{$k} = $opts->{$k};
Modified: pve-storage/pve2/Storage.pm
===================================================================
--- pve-storage/pve2/Storage.pm 2010-09-07 10:11:20 UTC (rev 5095)
+++ pve-storage/pve2/Storage.pm 2010-09-07 10:26:38 UTC (rev 5096)
@@ -669,7 +669,6 @@
return $cfg;
}
-# fixme: remove
sub parse_options {
my ($storeid, $stype, $param, $create) = @_;
@@ -678,90 +677,6 @@
die "unknown storage type '$stype'\n"
if !$default_config->{$stype};
- my $errmsg;
-
- my $get_option_func = sub {
- my ($opt, $value) = @_;
-
- my $ct = $confvars->{$opt};
- if (defined($value)) {
- eval {
- $settings->{$opt} = check_type ($stype, $ct, $opt, $value, $storeid);
- };
- if ($@) {
- $errmsg = "unable to parse value for '$opt': $@";
- die("!FINISH"); # abort GetOption
- }
- } else {
- $errmsg = "unable to parse value for '$opt'";
- die("!FINISH"); # abort GetOption
- }
- };
-
- 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";
- }
- }
- } 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) {
- my $req_keys = $required_config->{$stype};
- foreach my $k (@$req_keys) {
-
- if ($stype eq 'nfs' && !$settings->{path}) {
- $settings->{path} = "/mnt/pve/$storeid";
- }
-
- # check if we have a value for all required options
- if (!defined ($settings->{$k})) {
- raise_param_exc({ $k => "property is missing and it is not optional" });
- }
- }
- } else {
- my $fixed_keys = $fixed_config->{$stype};
- foreach my $k (@$fixed_keys) {
-
- # only allow to change non-fixed values
- die "can't change value for option '$k'\n"
- if defined ($settings->{$k});
- }
- }
-
- return $settings;
-
-}
-
-sub parse_options_new {
- my ($storeid, $stype, $param, $create) = @_;
-
- my $settings = { type => $stype };
-
- die "unknown storage type '$stype'\n"
- if !$default_config->{$stype};
-
foreach my $opt (keys %$param) {
my $value = $param->{$opt};
More information about the pve-devel
mailing list