@@ -174,7 +174,7 @@ public Answer execute(VmwareHostService hostService, BackupSnapshotCommand cmd)
174174 if (vmMo == null ) {
175175 dsMo = new DatastoreMO (hyperHost .getContext (), morDs );
176176
177- workerVMName = hostService .getWorkerName (context , cmd );
177+ workerVMName = hostService .getWorkerName (context , cmd , 0 );
178178
179179 // attach a volume to dummay wrapper VM for taking snapshot and exporting the VM for backup
180180 if (!hyperHost .createBlankVm (workerVMName , 1 , 512 , 0 , false , 4 , 0 , VirtualMachineGuestOsIdentifier ._otherGuest .toString (), morDs , false )) {
@@ -203,7 +203,7 @@ public Answer execute(VmwareHostService hostService, BackupSnapshotCommand cmd)
203203 }
204204
205205 snapshotBackupUuid = backupSnapshotToSecondaryStorage (vmMo , accountId , volumeId , cmd .getVolumePath (), snapshotUuid , secondaryStorageUrl , prevSnapshotUuid , prevBackupUuid ,
206- UUID . randomUUID (). toString (). replace ( "-" , "" ));
206+ hostService . getWorkerName ( context , cmd , 1 ));
207207
208208 success = (snapshotBackupUuid != null );
209209 if (success ) {
@@ -238,8 +238,6 @@ public Answer execute(VmwareHostService hostService, BackupSnapshotCommand cmd)
238238 return new BackupSnapshotAnswer (cmd , success , details , snapshotBackupUuid , true );
239239 }
240240
241-
242-
243241 @ Override
244242 public Answer execute (VmwareHostService hostService , CreatePrivateTemplateFromVolumeCommand cmd ) {
245243 String secondaryStoragePoolURL = cmd .getSecondaryStorageUrl ();
@@ -268,7 +266,7 @@ public Answer execute(VmwareHostService hostService, CreatePrivateTemplateFromVo
268266 Ternary <String , Long , Long > result = createTemplateFromVolume (vmMo ,
269267 accountId , templateId , cmd .getTemplateName (),
270268 secondaryStoragePoolURL , volumePath ,
271- hostService .getWorkerName (context , cmd ));
269+ hostService .getWorkerName (context , cmd , 0 ));
272270
273271 return new CreatePrivateTemplateAnswer (cmd , true , null ,
274272 result .first (), result .third (), result .second (),
@@ -331,10 +329,10 @@ public Answer execute(VmwareHostService hostService, CopyVolumeCommand cmd) {
331329
332330 Pair <String , String > result ;
333331 if (cmd .toSecondaryStorage ()) {
334- result = copyVolumeToSecStorage (
335- hyperHost , vmName , volumeId , cmd .getPool ().getUuid (), volumePath ,
332+ result = copyVolumeToSecStorage (hostService ,
333+ hyperHost , cmd , vmName , volumeId , cmd .getPool ().getUuid (), volumePath ,
336334 secondaryStorageURL ,
337- hostService .getWorkerName (context , cmd ));
335+ hostService .getWorkerName (context , cmd , 0 ));
338336 } else {
339337 StorageFilerTO poolTO = cmd .getPool ();
340338
@@ -393,8 +391,7 @@ public Answer execute(VmwareHostService hostService, CreateVolumeFromSnapshotCom
393391
394392 DatastoreMO primaryDsMo = new DatastoreMO (hyperHost .getContext (), morPrimaryDs );
395393 details = createVolumeFromSnapshot (hyperHost , primaryDsMo ,
396- newVolumeName , accountId , volumeId ,
397- secondaryStorageUrl , backedUpSnapshotUuid );
394+ newVolumeName , accountId , volumeId , secondaryStorageUrl , backedUpSnapshotUuid );
398395 if (details == null ) {
399396 success = true ;
400397 }
@@ -738,8 +735,10 @@ private String deleteSnapshotOnSecondaryStorge(long accountId, long volumeId, St
738735 return "Failed to delete snapshot backup file, backupUuid: " + backupUuid ;
739736 }
740737
741- private Pair <String , String > copyVolumeToSecStorage (VmwareHypervisorHost hyperHost , String vmName , long volumeId , String poolId , String volumePath ,
742- String secStorageUrl , String workerVmName ) throws Exception {
738+ private Pair <String , String > copyVolumeToSecStorage (VmwareHostService hostService , VmwareHypervisorHost hyperHost , CopyVolumeCommand cmd ,
739+ String vmName , long volumeId , String poolId , String volumePath ,
740+ String secStorageUrl , String workerVmName ) throws Exception {
741+
743742 String volumeFolder = String .valueOf (volumeId ) + "/" ;
744743 VirtualMachineMO workerVm =null ;
745744 VirtualMachineMO vmMo =null ;
@@ -756,12 +755,11 @@ private Pair<String, String> copyVolumeToSecStorage(VmwareHypervisorHost hyperHo
756755
757756 vmMo = hyperHost .findVmOnHyperHost (vmName );
758757 if (vmMo == null ) {
759- //create a dummy worker vm for attaching the volume
758+ // create a dummy worker vm for attaching the volume
760759 DatastoreMO dsMo = new DatastoreMO (hyperHost .getContext (), morDs );
761760 //restrict VM name to 32 chars, (else snapshot descriptor file name will be truncated to 32 chars of vm name)
762- String workerVMName = UUID .randomUUID ().toString ().replaceAll ("-" , "" );
763761 VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec ();
764- vmConfig .setName (workerVMName );
762+ vmConfig .setName (workerVmName );
765763 vmConfig .setMemoryMB ((long ) 4 );
766764 vmConfig .setNumCPUs (1 );
767765 vmConfig .setGuestId (VirtualMachineGuestOsIdentifier ._otherGuest .toString ());
@@ -780,7 +778,7 @@ private Pair<String, String> copyVolumeToSecStorage(VmwareHypervisorHost hyperHo
780778 vmConfig .setDeviceChange (new VirtualDeviceConfigSpec [] { scsiControllerSpec });
781779
782780 hyperHost .createVm (vmConfig );
783- workerVm = hyperHost .findVmOnHyperHost (workerVMName );
781+ workerVm = hyperHost .findVmOnHyperHost (workerVmName );
784782 if (workerVm == null ) {
785783 String msg = "Unable to create worker VM to execute CopyVolumeCommand" ;
786784 s_logger .error (msg );
@@ -795,7 +793,8 @@ private Pair<String, String> copyVolumeToSecStorage(VmwareHypervisorHost hyperHo
795793
796794 vmMo .createSnapshot (exportName , "Temporary snapshot for copy-volume command" , false , false );
797795
798- exportVolumeToSecondaryStroage (vmMo , volumePath , secStorageUrl , "volumes/" + volumeFolder , exportName , workerVmName );
796+ exportVolumeToSecondaryStroage (vmMo , volumePath , secStorageUrl , "volumes/" + volumeFolder , exportName ,
797+ hostService .getWorkerName (hyperHost .getContext (), cmd , 1 ));
799798 return new Pair <String , String >(volumeFolder , exportName );
800799
801800 } finally {
0 commit comments