Skip to content

Commit d1c554c

Browse files
committed
refactor error messages
Signed-off-by: Abhishek Kumar <[email protected]>
1 parent fa398b9 commit d1c554c

File tree

4 files changed

+26
-13
lines changed

4 files changed

+26
-13
lines changed

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -968,8 +968,10 @@ public UserVm resetVMUserData(ResetVMUserDataCmd cmd) throws ResourceUnavailable
968968
throw new InvalidParameterValueException("Operation not supported on Shared FileSystem Instance");
969969
}
970970
if (Hypervisor.HypervisorType.External.equals(userVm.getHypervisorType())) {
971-
throw new InvalidParameterValueException(String.format("Operation not supported for %s hypervisor Instance",
972-
Hypervisor.HypervisorType.External.name()));
971+
logger.error("Reset VM userdata not supported for {} as it is {} hypervisor instance",
972+
userVm, Hypervisor.HypervisorType.External.name());
973+
throw new InvalidParameterValueException(String.format("Operation not supported for instance: %s",
974+
userVm.getName()));
973975
}
974976
_accountMgr.checkAccess(caller, null, true, userVm);
975977

@@ -1019,8 +1021,10 @@ public UserVm resetVMSSHKey(ResetVMSSHKeyCmd cmd) throws ResourceUnavailableExce
10191021
throw new InvalidParameterValueException("Operation not supported on Shared FileSystem Instance");
10201022
}
10211023
if (Hypervisor.HypervisorType.External.equals(userVm.getHypervisorType())) {
1022-
throw new InvalidParameterValueException(String.format("Operation not supported for %s hypervisor Instance",
1023-
Hypervisor.HypervisorType.External.name()));
1024+
logger.error("Reset VM SSH key not supported for {} as it is {} hypervisor instance",
1025+
userVm, Hypervisor.HypervisorType.External.name());
1026+
throw new InvalidParameterValueException(String.format("Operation not supported for instance: %s",
1027+
userVm.getName()));
10241028
}
10251029

10261030
VMTemplateVO template = _templateDao.findByIdIncludingRemoved(userVm.getTemplateId());
@@ -1954,8 +1958,10 @@ public UserVm upgradeVirtualMachine(ScaleVMCmd cmd) throws ResourceUnavailableEx
19541958
throw new InvalidParameterValueException("Unable to find VM's UUID");
19551959
}
19561960
if (Hypervisor.HypervisorType.External.equals(vm.getHypervisorType())) {
1957-
throw new InvalidParameterValueException(String.format("Operation not supported for %s hypervisor Instance",
1958-
Hypervisor.HypervisorType.External.name()));
1961+
logger.error("Scale VM not supported for {} as it is {} hypervisor instance",
1962+
vm, Hypervisor.HypervisorType.External.name());
1963+
throw new InvalidParameterValueException(String.format("Operation not supported for instance: %s",
1964+
vm.getName()));
19591965
}
19601966
CallContext.current().setEventDetails("Vm Id: " + vm.getUuid());
19611967

@@ -8539,8 +8545,10 @@ public UserVm restoreVM(RestoreVMCmd cmd) throws InsufficientCapacityException,
85398545
throw new InvalidParameterValueException("Operation not supported on Shared FileSystem Instance");
85408546
}
85418547
if (Hypervisor.HypervisorType.External.equals(vm.getHypervisorType())) {
8542-
throw new InvalidParameterValueException(String.format("Operation not supported for %s hypervisor Instance",
8543-
Hypervisor.HypervisorType.External.name()));
8548+
logger.error("Restore VM not supported for {} as it is {} hypervisor instance",
8549+
vm, Hypervisor.HypervisorType.External.name());
8550+
throw new InvalidParameterValueException(String.format("Operation not supported for instance: %s",
8551+
vm.getName()));
85448552
}
85458553
_accountMgr.checkAccess(caller, null, true, vm);
85468554

server/src/main/java/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,8 +515,10 @@ public VMSnapshot createVMSnapshot(Long vmId, Long vmSnapshotId, Boolean quiesce
515515
throw new InvalidParameterValueException("Operation not supported on Shared FileSystem Instance");
516516
}
517517
if (Hypervisor.HypervisorType.External.equals(userVm.getHypervisorType())) {
518-
throw new InvalidParameterValueException(String.format("Operation not supported for %s hypervisor Instance",
519-
Hypervisor.HypervisorType.External.name()));
518+
logger.error("Create VM snapshot not supported for {} as it is {} hypervisor instance",
519+
userVm, Hypervisor.HypervisorType.External.name());
520+
throw new InvalidParameterValueException(String.format("Operation not supported for instance: %s",
521+
userVm.getName()));
520522
}
521523
VMSnapshotVO vmSnapshot = _vmSnapshotDao.findById(vmSnapshotId);
522524
if (vmSnapshot == null) {

server/src/main/java/org/apache/cloudstack/affinity/AffinityGroupServiceImpl.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,10 @@ public UserVm updateVMAffinityGroups(Long vmId, List<Long> affinityGroupIds) {
436436
throw new InvalidParameterValueException("Operation not supported on Shared FileSystem Instance");
437437
}
438438
if (Hypervisor.HypervisorType.External.equals(vmInstance.getHypervisorType())) {
439-
throw new InvalidParameterValueException(String.format("Operation not supported for %s hypervisor Instance",
440-
Hypervisor.HypervisorType.External.name()));
439+
logger.error("Update VM Affinity Group not supported for {} as it is {} hypervisor instance",
440+
vmInstance, Hypervisor.HypervisorType.External.name());
441+
throw new InvalidParameterValueException(String.format("Operation not supported for instance: %s",
442+
vmInstance.getName()));
441443
}
442444

443445
// Check that the VM is stopped

server/src/main/java/org/apache/cloudstack/consoleproxy/ConsoleAccessManagerImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ public ConsoleEndpoint generateConsoleEndpoint(Long vmId, String extraSecurityTo
209209
}
210210

211211
if (Hypervisor.HypervisorType.External.equals(vm.getHypervisorType())) {
212-
logger.info("Console access to this instance cannot be provided in case of hypervisor type External");
212+
logger.error("Console access for {} cannot be provided it is {} hypervisor instance", vm,
213+
Hypervisor.HypervisorType.External);
213214
return new ConsoleEndpoint(false, null, "Console access to this instance cannot be provided");
214215
}
215216

0 commit comments

Comments
 (0)