[pve-devel] [PATCH manager v3 08/20] ceph: create/destroypool: shorten variable name

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Aug 31 11:38:11 CEST 2017


Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
changes since v2:
- merged and rebased patches 15 and 17

 PVE/API2/Ceph.pm | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 207654b0..a2c094fd 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -1598,6 +1598,8 @@ __PACKAGE__->register_method ({
 	die "not fully configured - missing '$pve_ckeyring_path'\n"
 	    if ! -f $pve_ckeyring_path;
 
+	my $pool = $param->{name};
+
 	my $pg_num = $param->{pg_num} || 64;
 	my $size = $param->{size} || 3;
 	my $min_size = $param->{min_size} || 2;
@@ -1606,14 +1608,14 @@ __PACKAGE__->register_method ({
 
 	$rados->mon_command({
 	    prefix => "osd pool create",
-	    pool => $param->{name},
+	    pool => $pool,
 	    pg_num => int($pg_num),
 	    format => 'plain',
 	});
 
 	$rados->mon_command({
 	    prefix => "osd pool set",
-	    pool => $param->{name},
+	    pool => $pool,
 	    var => 'min_size',
 	    val => $min_size,
 	    format => 'plain',
@@ -1621,7 +1623,7 @@ __PACKAGE__->register_method ({
 
 	$rados->mon_command({
 	    prefix => "osd pool set",
-	    pool => $param->{name},
+	    pool => $pool,
 	    var => 'size',
 	    val => $size,
 	    format => 'plain',
@@ -1630,7 +1632,7 @@ __PACKAGE__->register_method ({
 	if (defined($param->{crush_rule})) {
 	    $rados->mon_command({
 		prefix => "osd pool set",
-		pool => $param->{name},
+		pool => $pool,
 		var => 'crush_rule',
 		val => $param->{crush_rule},
 		format => 'plain',
@@ -1639,7 +1641,7 @@ __PACKAGE__->register_method ({
 
 	$rados->mon_command({
 		prefix => "osd pool application enable",
-		pool => $param->{name},
+		pool => $pool,
 		app => $application,
 	});
 
@@ -1798,6 +1800,8 @@ __PACKAGE__->register_method ({
 
 	PVE::CephTools::check_ceph_inited();
 
+	my $pool = $param->{name};
+
 	# if not forced, destroy ceph pool only when no
 	# vm disks are on it anymore
 	if (!$param->{force}) {
@@ -1805,11 +1809,11 @@ __PACKAGE__->register_method ({
 	    foreach my $storageid (keys %{$storagecfg->{ids}}) {
 		my $storage = $storagecfg->{ids}->{$storageid};
 		next if $storage->{type} ne 'rbd';
-		next if $storage->{pool} ne $param->{name};
+		next if $storage->{pool} ne $pool;
 
 		# check if any vm disks are on the pool
 		my $res = PVE::Storage::vdisk_list($storagecfg, $storageid);
-		die "ceph pool '$param->{name}' still in use by storage '$storageid'\n"
+		die "ceph pool '$pool' still in use by storage '$storageid'\n"
 		    if @{$res->{$storageid}} != 0;
 	    }
 	}
@@ -1818,8 +1822,8 @@ __PACKAGE__->register_method ({
 	# fixme: '--yes-i-really-really-mean-it'
 	$rados->mon_command({
 	    prefix => "osd pool delete",
-	    pool => $param->{name},
-	    pool2 => $param->{name},
+	    pool => $pool,
+	    pool2 => $pool,
 	    sure => '--yes-i-really-really-mean-it',
 	    format => 'plain',
         });
-- 
2.11.0





More information about the pve-devel mailing list