From 79fe5c73ecb0cbcef1370a32d6e97083f546f376 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Tue, 8 Jun 2010 20:38:44 +0000 Subject: [PATCH] -Accept -/+ incremental values for cpu/memory/disk size change requests git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6400 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/esx.pm | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/esx.pm b/xCAT-server/lib/xcat/plugins/esx.pm index 40ea03e17..580b97af5 100644 --- a/xCAT-server/lib/xcat/plugins/esx.pm +++ b/xCAT-server/lib/xcat/plugins/esx.pm @@ -506,7 +506,7 @@ sub chvm { "p=s" => \@purge, "a=s" => \@add, "resize=s%" => \%resize, - "cpus=i" => \$cpuCount, + "cpus=s" => \$cpuCount, "mem=s" => \$memory ); $SIG{__WARN__} = 'DEFAULT'; @@ -531,11 +531,22 @@ sub chvm { my %conargs; if($cpuCount) { + if ($cpuCount =~ /^\+(\d+)/) { + $cpuCount = $vmview->config->hardware->numCPU+$1; + } elsif ($cpuCount =~ /^-(\d+)/) { + $cpuCount = $vmview->config->hardware->numCPU-$1; + } $conargs{numCPUs} = $cpuCount; } if($memory) { - $conargs{memoryMB} = getUnits($memory, "M", 1048576); + if ($memory =~ /^\+(.+)/) { + $conargs{memoryMB} = $vmview->config->hardware->memoryMB + getUnits($1,"M",1048576); + } elsif ($memory =~ /^-(\d+)/) { + $conargs{memoryMB} = $vmview->config->hardware->memoryMB - getUnits($1,"M",1048576); + } else { + $conargs{memoryMB} = getUnits($memory, "M", 1048576); + } } my $disk; @@ -614,7 +625,11 @@ sub chvm { sendmsg([1,"Disk: $disk does not exist"],$node); return; } - $value = getUnits($value, "G", 1024); + if ($value =~ /^\+(.+)/) { + $value = $device->capacityInKB + getUnits($1,"G",1024); + } else { + $value = getUnits($value, "G", 1024); + } my $newDevice = VirtualDisk->new(deviceInfo => $device->deviceInfo, key => $device->key, controllerKey => $device->controllerKey,