Author: fapeeler
Date: Fri Sep 17 12:47:27 2010
New Revision: 998098

URL: http://svn.apache.org/viewvc?rev=998098&view=rev
Log:
VCL-382
added support for free server 1.x using network datastores

Modified:
    incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm

Modified: 
incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm
URL: 
http://svn.apache.org/viewvc/incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm?rev=998098&r1=998097&r2=998098&view=diff
==============================================================================
--- incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm 
(original)
+++ incubator/vcl/trunk/managementnode/lib/VCL/Module/Provisioning/vmware.pm 
Fri Sep 17 12:47:27 2010
@@ -487,18 +487,45 @@ sub load {
                                                my $srcDisk = 
"$datastorepath/$requestedimagename/$requestedimagename" . ".vmdk";
                                                my $dstDisk = 
"$datastorepath/$mybasedirname/$myimagename" . ".vmdk";
                                                my $dstDir  = 
"$datastorepath/$mybasedirname";
-
-                                               #create a clone -
-                                               if (_vmwareclone($hostnode, 
$management_node_keys, $srcDisk, $dstDisk, $dstDir)) {
-                                                       $baseexists = 1;
-                                                       
insertloadlog($reservation_id, $vmclient_computerid, "transfervm", "cloning 
base image files");
+                                               my $srcdir  = 
"$datastorepath/$requestedimagename";
+                                               
+                                               if($vmtype eq "vmwareESX"){
+                                                       #create a clone -
+                                                       if 
(_vmwareclone($hostnode, $management_node_keys, $srcDisk, $dstDisk, $dstDir)) {
+                                                               $baseexists = 1;
+                                                               
insertloadlog($reservation_id, $vmclient_computerid, "transfervm", "cloning 
base image files");
+                                                       }
+                                                       else {
+                                                               
insertloadlog($reservation_id, $vmclient_computerid, "failed", "cloning base 
image failed");
+                                                               
notify($ERRORS{'CRITICAL'}, 0, "problem cloning failed $srcDisk to $dstDisk");
+                                                               close(TMPLOCK);
+                                                               
unlink($tmplockfile);
+                                                               return 0;
+                                                       }
                                                }
-                                               else {
-                                                       
insertloadlog($reservation_id, $vmclient_computerid, "failed", "cloning base 
image failed");
-                                                       
notify($ERRORS{'CRITICAL'}, 0, "problem cloning failed $srcDisk to $dstDisk");
-                                                       close(TMPLOCK);
-                                                       unlink($tmplockfile);
-                                                       return 0;
+                                               elsif($vmtype =~ 
/freeserver|gsx|vmwareGSX/) {
+                                                       #copy srcdir to dstDir
+                                                       my $cpcmd = "/bin/cp -r 
$srcdir $dstDir";
+                                                       
if(defined(run_ssh_command($hostnode, $identity, $cpcmd, "root"))) {
+                                                               
notify($ERRORS{'OK'}, 0, "copied $srcdir to $dstDir");
+                                                               my $renamecmd = 
"vmware-vdiskmanager -n $dstDir/$requestedimagename" . ".vmdk " . 
+$dstDisk;
+                                                               
if(defined(run_ssh_command($hostnode, $identity, $renamecmd, "root"))) {
+                                                                       
notify($ERRORS{'OK'}, 0, "renamed $dstDir/$requestedimagename to $dstDisk"
+                                                                       
$baseexists = 1;
+                                                        }
+                                                        else{
+                                                                
insertloadlog($reservation_id, $vmclient_computerid, "failed", "cloning ba
+se image failed");
+                                                                
notify($ERRORS{'CRITICAL'}, 0, "problem running renamecmd $renamecmd");
+                                                                close(TMPLOCK);
+                                                                
unlink($tmplockfile);
+                                                                return 0;
+
+                                                        }
+                                                }
+
+                       
                                                }
                                        } ## end if ($persistent)
                                        else {


Reply via email to