Skip to content

Commit a072bdd

Browse files
committed
Fix and refactor
1 parent e76addb commit a072bdd

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

engine/orchestration/src/main/java/com/cloud/vm/VirtualMachineManagerImpl.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -935,11 +935,11 @@ public void start(final String vmUuid, final Map<VirtualMachineProfile.Param, Ob
935935
throw new CloudRuntimeException(String.format("Unable to start a VM [%s] due to [%s].", vmUuid, e.getMessage()), e).add(VirtualMachine.class, vmUuid);
936936
} catch (final ResourceUnavailableException e) {
937937
if (e.getScope() != null && e.getScope().equals(VirtualRouter.class)){
938-
if (callingUser.isRootAdmin()) {
939-
throw new CloudRuntimeException("The Guest Network is unavailable: " + e.getMessage()).add(VirtualMachine.class, vmUuid);
940-
} else {
941-
throw new CloudRuntimeException("The Guest Network is unavailable. Please contact administrator. ").add(VirtualMachine.class, vmUuid);
942-
}
938+
Account callingAccount = CallContext.current().getCallingAccount();
939+
String errorSuffix = (callingAccount != null && callingAccount.getType() == Account.Type.ADMIN) ?
940+
String.format("Failure: %s", e.getMessage()) :
941+
"Please contact administrator.";
942+
throw new CloudRuntimeException(String.format("The Network for VM %s is unavailable. %s", vmUuid, errorSuffix), e).add(VirtualMachine.class, vmUuid);
943943
}
944944
throw new CloudRuntimeException(String.format("Unable to start a VM [%s] due to [%s].", vmUuid, e.getMessage()), e).add(VirtualMachine.class, vmUuid);
945945
}

0 commit comments

Comments
 (0)