@@ -363,6 +363,7 @@ protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData)
363363
364364 if (cacheStore == null ) {
365365 if (bypassSecondaryStorage ) {
366+ logger .debug ("Secondary storage is bypassed, copy volume between pools directly" );
366367 CopyCommand cmd = new CopyCommand (srcData .getTO (), destData .getTO (), _copyvolumewait , VirtualMachineManager .ExecuteInSequence .value ());
367368 EndPoint ep = selector .select (srcData , destData , encryptionRequired );
368369 Answer answer = null ;
@@ -391,8 +392,8 @@ protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData)
391392 answer = copyObject (srcData , objOnImageStore );
392393
393394 if (answer == null || !answer .getResult ()) {
394- if (answer != null ) {
395- if ( logger .isDebugEnabled ()) logger . debug ("copy to image store failed: " + answer .getDetails ());
395+ if (answer != null && logger . isDebugEnabled () ) {
396+ logger .debug ("copy to image store failed: {}" , answer .getDetails ());
396397 }
397398 objOnImageStore .processEvent (Event .OperationFailed );
398399 imageStore .delete (objOnImageStore );
@@ -414,8 +415,8 @@ protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData)
414415 }
415416
416417 if (answer == null || !answer .getResult ()) {
417- if (answer != null ) {
418- if ( logger .isDebugEnabled ()) logger . debug ("copy to primary store failed: " + answer .getDetails ());
418+ if (answer != null && logger . isDebugEnabled () ) {
419+ logger .debug ("copy to primary store failed: {}" , answer .getDetails ());
419420 }
420421 objOnImageStore .processEvent (Event .OperationFailed );
421422 imageStore .delete (objOnImageStore );
@@ -426,7 +427,7 @@ protected Answer copyVolumeBetweenPools(DataObject srcData, DataObject destData)
426427 objOnImageStore .processEvent (Event .OperationFailed );
427428 imageStore .delete (objOnImageStore );
428429 }
429- logger .error ("Failed to perform operation: " + e .getLocalizedMessage ());
430+ logger .error ("Failed to perform operation: {}" , e .getLocalizedMessage ());
430431 throw e ;
431432 }
432433
@@ -462,30 +463,63 @@ private boolean canBypassSecondaryStorage(DataObject srcData, DataObject destDat
462463 if (destData instanceof VolumeInfo ) {
463464 Scope srcDataStoreScope = srcData .getDataStore ().getScope ();
464465 Scope destDataStoreScope = destData .getDataStore ().getScope ();
465- logger .info ("srcDataStoreScope: {}, destDataStoreScope: {}" , srcDataStoreScope , destDataStoreScope );
466- logger .info ("srcData - pool type: {}, scope: {}; destData - pool type: {}, scope: {}" ,
467- ((VolumeInfo )srcData ).getStoragePoolType (), srcDataStoreScope != null ? srcDataStoreScope .getScopeType () : null , ((VolumeInfo )destData ).getStoragePoolType (), destDataStoreScope != null ? destDataStoreScope .getScopeType () : null );
466+ logger .info ("srcDataStoreScope: {}, srcData pool type: {}; destDataStoreScope: {}, destData pool type: {}" ,
467+ srcDataStoreScope , ((VolumeInfo )srcData ).getStoragePoolType (), destDataStoreScope , ((VolumeInfo )destData ).getStoragePoolType ());
468468
469469 if (srcDataStoreScope != null && destDataStoreScope != null &&
470470 SUPPORTED_POOL_TYPES_TO_BYPASS_SECONDARY_STORE .contains (((VolumeInfo )srcData ).getStoragePoolType ()) &&
471471 SUPPORTED_POOL_TYPES_TO_BYPASS_SECONDARY_STORE .contains (((VolumeInfo )destData ).getStoragePoolType ())) {
472472
473- if (srcDataStoreScope .isSameScope (destDataStoreScope )) {
474- return true ;
475- }
473+ return canDirectlyCopyBetweenDataStoreScopes (srcDataStoreScope , destDataStoreScope );
474+ }
475+ }
476+ }
476477
477- if (srcDataStoreScope .getScopeType () == ScopeType .CLUSTER &&
478- destDataStoreScope .getScopeType () == ScopeType .HOST &&
479- (Objects .equals (((ClusterScope ) srcDataStoreScope ).getScopeId (), ((HostScope ) destDataStoreScope ).getClusterId ()))) {
480- return true ;
481- }
478+ return false ;
479+ }
482480
483- if (srcDataStoreScope .getScopeType () == ScopeType .HOST &&
484- destDataStoreScope .getScopeType () == ScopeType .CLUSTER &&
485- (Objects .equals (((HostScope ) srcDataStoreScope ).getClusterId (), ((ClusterScope ) destDataStoreScope ).getScopeId ()))) {
486- return true ;
487- }
488- }
481+ private boolean canDirectlyCopyBetweenDataStoreScopes (Scope srcDataStoreScope , Scope destDataStoreScope ) {
482+ if (srcDataStoreScope == null || destDataStoreScope == null ) {
483+ return false ;
484+ }
485+
486+ if (srcDataStoreScope .isSameScope (destDataStoreScope )) {
487+ return true ;
488+ }
489+
490+ if (srcDataStoreScope .getScopeType () == ScopeType .HOST ) {
491+ if (destDataStoreScope .getScopeType () == ScopeType .CLUSTER &&
492+ (Objects .equals (((HostScope ) srcDataStoreScope ).getClusterId (), ((ClusterScope ) destDataStoreScope ).getScopeId ()))) {
493+ return true ;
494+ }
495+ if (destDataStoreScope .getScopeType () == ScopeType .ZONE &&
496+ (Objects .equals (((HostScope ) srcDataStoreScope ).getZoneId (), ((ZoneScope ) destDataStoreScope ).getScopeId ()))) {
497+ return true ;
498+ }
499+ }
500+
501+ if (destDataStoreScope .getScopeType () == ScopeType .HOST ) {
502+ if (srcDataStoreScope .getScopeType () == ScopeType .CLUSTER &&
503+ (Objects .equals (((ClusterScope ) srcDataStoreScope ).getScopeId (), ((HostScope ) destDataStoreScope ).getClusterId ()))) {
504+ return true ;
505+ }
506+ if (srcDataStoreScope .getScopeType () == ScopeType .ZONE &&
507+ (Objects .equals (((ZoneScope ) srcDataStoreScope ).getScopeId (), ((HostScope ) destDataStoreScope ).getZoneId ()))) {
508+ return true ;
509+ }
510+ }
511+
512+ if (srcDataStoreScope .getScopeType () == ScopeType .CLUSTER ) {
513+ if (destDataStoreScope .getScopeType () == ScopeType .ZONE &&
514+ (Objects .equals (((ClusterScope ) srcDataStoreScope ).getZoneId (), ((ZoneScope ) destDataStoreScope ).getScopeId ()))) {
515+ return true ;
516+ }
517+ }
518+
519+ if (destDataStoreScope .getScopeType () == ScopeType .CLUSTER ) {
520+ if (srcDataStoreScope .getScopeType () == ScopeType .ZONE &&
521+ (Objects .equals (((ZoneScope ) srcDataStoreScope ).getScopeId (), ((ClusterScope ) destDataStoreScope ).getZoneId ()))) {
522+ return true ;
489523 }
490524 }
491525
0 commit comments