@@ -7450,9 +7450,7 @@ protected void validateIfVmSupportsMigration(UserVmVO vm, Long vmId) {
74507450 if (vm == null ) {
74517451 throw new InvalidParameterValueException (String .format ("There is no VM by ID [%s]." , vmId ));
74527452 } else if (vm .getState () == State .Running ) {
7453- String errMsg = String .format ("Unable to move VM [%s] in [%s] state." , vm , vm .getState ());
7454- logger .warn (errMsg );
7455- throw new InvalidParameterValueException (errMsg );
7453+ throw new InvalidParameterValueException (String .format ("Unable to move VM [%s] in [%s] state." , vm , vm .getState ()));
74567454 } else if (UserVmManager .SHAREDFSVM .equals (vm .getUserVmType ())) {
74577455 throw new InvalidParameterValueException ("Migration is not supported for Shared FileSystem Instances." );
74587456 }
@@ -7527,13 +7525,19 @@ protected void verifyResourceLimitsForAccountAndStorage(Account account, UserVmV
75277525 }
75287526
75297527 protected void validateIfNewOwnerHasAccessToTemplate (UserVmVO vm , Account newAccount , VirtualMachineTemplate template ) {
7530- logger .trace (String . format ( "Validating if new owner [%s ] has access to the template specified for VM [%s ]." , newAccount , vm ) );
7528+ logger .trace ("Validating if new owner [{} ] has access to the template specified for VM [{} ]." , newAccount , vm );
75317529
75327530 if (template == null ) {
75337531 throw new InvalidParameterValueException (String .format ("Template for VM [%s] cannot be found." , vm .getUuid ()));
75347532 }
75357533
7536- _accountMgr .checkAccess (newAccount , AccessType .UseEntry , true , template );
7534+ logger .debug ("Verifying if new owner [{}] has access to the template [{}]." , newAccount , template .getUuid ());
7535+ try {
7536+ _accountMgr .checkAccess (newAccount , AccessType .UseEntry , true , template );
7537+ } catch (PermissionDeniedException e ) {
7538+ String newMsg = String .format ("New owner [%s] does not have access to the template specified for VM [%s]." , newAccount , vm );
7539+ throw new PermissionDeniedException (newMsg , e );
7540+ }
75377541 }
75387542
75397543 /**
@@ -7674,6 +7678,8 @@ protected void updateVmNetwork(AssignVMCmd cmd, Account caller, UserVmVO vm, Acc
76747678 protected void validateOldAndNewAccounts (Account oldAccount , Account newAccount , Long oldAccountId , String newAccountName , Long domainId )
76757679 throws InvalidParameterValueException {
76767680
7681+ logger .trace ("Validating old [{}] and new accounts [{}]." , oldAccount , newAccount );
7682+
76777683 if (oldAccount == null ) {
76787684 throw new InvalidParameterValueException (String .format ("Invalid old account [%s] for VM in domain [%s]." , oldAccountId , domainId ));
76797685 }
0 commit comments