@@ -294,22 +294,23 @@ public void createVolumeDownloadURL(Long entityId, String path, Type type, Long
294294 }
295295 // Create Symlink at ssvm
296296 String uuid = UUID .randomUUID ().toString () + ".vhd" ;
297- CreateEntityDownloadURLCommand cmd = new CreateEntityDownloadURLCommand (path , uuid );
298- long result = send (ApiDBUtils .findUploadById (uploadId ).getHostId (), cmd , null );
297+ HostVO secStorage = ApiDBUtils .findHostById (ApiDBUtils .findUploadById (uploadId ).getHostId ());
298+ HostVO ssvm = _agentMgr .getSSAgent (secStorage );
299+ if ( ssvm == null ) {
300+ errorString = "There is no secondary storage VM for secondary storage host " + secStorage .getName ();
301+ throw new CloudRuntimeException (errorString );
302+ }
303+
304+ CreateEntityDownloadURLCommand cmd = new CreateEntityDownloadURLCommand (secStorage .getParent (), path , uuid );
305+ long result = send (ssvm .getId (), cmd , null );
299306 if (result == -1 ){
300307 errorString = "Unable to create a link for " +type + " id:" +entityId ;
301308 s_logger .warn (errorString );
302309 throw new CloudRuntimeException (errorString );
303310 }
304311
305- //Construct actual URL locally now that the symlink exists at SSVM
306- SecondaryStorageVmVO ssVm = ssVms .get (0 );
307- if (ssVm .getPublicIpAddress () == null ) {
308- errorString = "A running secondary storage vm has a null public ip?" ;
309- s_logger .warn (errorString );
310- throw new CloudRuntimeException (errorString );
311- }
312- String extractURL = generateCopyUrl (ssVm .getPublicIpAddress (), uuid );
312+ //Construct actual URL locally now that the symlink exists at SSVM
313+ String extractURL = generateCopyUrl (ssvm .getPublicIpAddress (), uuid );
313314 UploadVO vo = _uploadDao .createForUpdate ();
314315 vo .setLastUpdated (new Date ());
315316 vo .setUploadUrl (extractURL );
0 commit comments