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

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Jul 28 11:05:26 CEST 2011


Author: dietmar
Date: 2011-07-28 11:05:25 +0200 (Thu, 28 Jul 2011)
New Revision: 6375

Modified:
   pve-storage/pve2/ChangeLog
   pve-storage/pve2/PVE/API2/Storage/Config.pm
   pve-storage/pve2/PVE/Storage.pm
Log:
	* PVE/API2/Storage/Config.pm (create): add 'nodes' options, do not
	activate storage automatically.
	
	* PVE/API2/Storage/Config.pm (update): add 'nodes' options, do not
	activate storage automatically.



Modified: pve-storage/pve2/ChangeLog
===================================================================
--- pve-storage/pve2/ChangeLog	2011-07-28 05:51:35 UTC (rev 6374)
+++ pve-storage/pve2/ChangeLog	2011-07-28 09:05:25 UTC (rev 6375)
@@ -1,5 +1,11 @@
 2011-07-28  Proxmox Support Team  <support at proxmox.com>
 
+	* PVE/API2/Storage/Config.pm (create): add 'nodes' options, do not
+	activate storage automatically.
+	
+	* PVE/API2/Storage/Config.pm (update): add 'nodes' options, do not
+	activate storage automatically.
+
 	* pvesm (lock): removed - we do not use the central lock manager
 	anymore.
 

Modified: pve-storage/pve2/PVE/API2/Storage/Config.pm
===================================================================
--- pve-storage/pve2/PVE/API2/Storage/Config.pm	2011-07-28 05:51:35 UTC (rev 6374)
+++ pve-storage/pve2/PVE/API2/Storage/Config.pm	2011-07-28 09:05:25 UTC (rev 6375)
@@ -29,6 +29,10 @@
     $scfg->{digest} = $cfg->{digest};
     $scfg->{content} = PVE::Storage::content_hash_to_string($scfg->{content});
 
+    if ($scfg->{nodes}) {
+	$scfg->{nodes} = join(',', keys(%{$scfg->{nodes}}));
+    }
+
     return $scfg;
 };
 
@@ -104,6 +108,7 @@
     	additionalProperties => 0,
 	properties => { 
 	    storage => get_standard_option('pve-storage-id'),
+	    nodes => get_standard_option('pve-node-list'),
 	    type => { 
 		type => 'string', 
 		enum => $storage_type_enum,
@@ -174,7 +179,6 @@
 
 	my $opts = PVE::Storage::parse_options($storeid, $type, $param, 1);
 
-
         PVE::Storage::lock_storage_config(
 	    sub {
 
@@ -203,8 +207,6 @@
 		    PVE::Storage::lvm_create_volume_group ($path, $opts->{vgname}, $opts->{shared});
 		}
 	
-		PVE::Storage::activate_storage ($cfg, $storeid) if !$opts->{disable};
-
 		cfs_write_file('storage.cfg', $cfg);
 	    
 	    }, "create storage failed");
@@ -221,6 +223,7 @@
     	additionalProperties => 0,
 	properties => { 
 	    storage => get_standard_option('pve-storage-id'),
+	    nodes => get_standard_option('pve-node-list'),
 	    content => {
 		type => 'string', format => 'pve-storage-content-list',
 		optional => 1,
@@ -272,15 +275,6 @@
 		$scfg->{$k} = $opts->{$k};
 	    }
 
-	    if (defined($opts->{disable})) {
-		if ($opts->{disable}) {
-		    PVE::Storage::deactivate_storage ($cfg, $storeid);
-		} else {
-		    delete $scfg->{disable};
-		    PVE::Storage::activate_storage ($cfg, $storeid);	
-		}
-	    }
-
 	    cfs_write_file('storage.cfg', $cfg);
 
 	    }, "update storage failed");

Modified: pve-storage/pve2/PVE/Storage.pm
===================================================================
--- pve-storage/pve2/PVE/Storage.pm	2011-07-28 05:51:35 UTC (rev 6374)
+++ pve-storage/pve2/PVE/Storage.pm	2011-07-28 09:05:25 UTC (rev 6375)
@@ -144,6 +144,7 @@
     base   => 'volume',
     portal => 'portal',
     target => 'target',
+    nodes => 'nodes',
     options => 'options',
 };
 
@@ -164,6 +165,7 @@
 my $default_config = {
     dir => {
 	path => 1,
+        nodes => 0,
 	shared => 0,
 	disable => 0,
 	content => [ { images => 1, rootdir => 1, vztmpl => 1, iso => 1, backup => 1, none => 1 },
@@ -173,6 +175,7 @@
 
     nfs => {
 	path => 1,
+        nodes => 0,
 	disable => 0,
         server => 1,
         export => 1,
@@ -184,6 +187,7 @@
 
     lvm => {
 	vgname => 1,
+        nodes => 0,
 	shared => 0,
 	disable => 0,
 	content => [ {images => 1}, { images => 1 }],
@@ -193,6 +197,7 @@
     iscsi => {
         portal => 1,
         target => 1,
+        nodes => 0,
 	disable => 0,
 	content => [ {images => 1, none => 1}, { images => 1 }],
     },
@@ -365,6 +370,22 @@
 	return parse_lvm_name ($value, $noerr);
     } elsif ($ct eq 'portal') {
 	return verify_portal($value, $noerr);
+    } elsif ($ct eq 'nodes') {
+	my $res = {};
+
+	foreach my $node (PVE::Tools::split_list($value)) {
+	    if (PVE::JSONSchema::pve_verify_node_name($node, $noerr)) {
+		$res->{$node} = 1;
+	    }
+	}
+
+	# no node restrictions for local storage
+	if ($storeid && $storeid eq 'local' && scalar(keys(%$res))) {
+	    return undef if $noerr;
+	    die "storage '$storeid' does not allow node restrictions\n";
+	}
+
+	return $res;
     } elsif ($ct eq 'target') {
 	return $value;
     } elsif ($ct eq 'string') {
@@ -495,6 +516,9 @@
     $ids->{local}->{content}->{vztmpl} = 1;
     delete ($ids->{local}->{disable});
 
+    # remove node restrictions for local storage
+    delete($ids->{local}->{nodes});
+
     foreach my $storeid (keys %$ids) {
 	my $d = $ids->{$storeid};
 
@@ -641,6 +665,9 @@
 
     if ($ct eq 'bool') {
 	return $v ? "\t$k\n" : '';
+    } elsif ($ct eq 'nodes') {
+	my $nlist = join(',', keys(%$v));
+	return $nlist ? "\tnodes $nlist\n" : ''; 
     } elsif ($ct eq 'content') {
 	my $clist = content_hash_to_string($v);
 	if ($clist) {




More information about the pve-devel mailing list