Sergey Gotliv has uploaded a new change for review. Change subject: engine: unresolved placeholder in getDeviceVisibility error message ......................................................................
engine: unresolved placeholder in getDeviceVisibility error message GetDeviceVisibility API verifies that all LUNs are connected to all hosts in the data center. Up until now in case of failure this API reported the error with unresolved placeholder '$hostName'. This patch takes care to populate it's value. Change-Id: I4b4b40a5296028fc8bcdc1f4a2ed156964a1b1a7 Signed-off-by: Sergey Gotliv <sgot...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ConnectAllHostsToLunCommand.java 1 file changed, 28 insertions(+), 20 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/46/21246/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ConnectAllHostsToLunCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ConnectAllHostsToLunCommand.java index 5383c27..272793c 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ConnectAllHostsToLunCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ConnectAllHostsToLunCommand.java @@ -82,10 +82,7 @@ LUNs lun = lunsMap.get(lunId); if (lun == null) { //fail - final ConnectAllHostsToLunCommandReturnValue result = getResult(); - result.setFailedVds(spmVds); - result.setFailedLun(getDbFacade().getLunDao() - .get(lunId)); + handleFailure(spmVds, getDbFacade().getLunDao().get(lunId)); return; } @@ -127,9 +124,7 @@ if (!connectStorageToLunByVdsId(vds, lun)) { log.errorFormat("Could not connect host {0} to lun {1}", vds.getName(), lun.getLUN_id()); setVds(vds); - final ConnectAllHostsToLunCommandReturnValue result = getResult(); - result.setFailedVds(vds); - result.setFailedLun(lun); + handleFailure(vds, lun); return new Pair<Boolean, Map<String, List<Guid>>>(Boolean.FALSE, resultMap); } else { List<Guid> hosts = resultMap.get(lun.getLUN_id()); @@ -154,9 +149,7 @@ .getItem(getStorageDomain().getStorageType()) .connectStorageToLunByVdsId(getStorageDomain(), vds.getId(), lun, Guid.Empty); } catch (VdcBLLException e) { - final ConnectAllHostsToLunCommandReturnValue result = getResult(); - result.setFailedVds(vds); - result.setFailedLun(lun); + handleFailure(vds, lun); throw e; } } @@ -175,29 +168,44 @@ } /** - * The following method will check which luns were successfully connected to vds + * Verify that all luns are connected to the host. * * @param vds * - the host * @param processedLunIds * - luns ids which we wants to check - * @return - true if all connections successes, false otherwise + * @return - true if all luns are connected to the host, false otherwise + * + * @throws VdcBLLException */ private boolean validateConnectedLuns(VDS vds, List<String> processedLunIds) { - @SuppressWarnings("unchecked") - Map<String, Boolean> returnValue = (Map<String, Boolean>) Backend.getInstance() - .getResourceManager() - .RunVdsCommand(VDSCommandType.GetDevicesVisibility, - new GetDevicesVisibilityVDSCommandParameters(vds.getId(), - processedLunIds.toArray(new String[processedLunIds.size()]))).getReturnValue(); - for (Map.Entry<String, Boolean> returnValueEntry : returnValue.entrySet()) { - if (!Boolean.TRUE.equals(returnValueEntry.getValue())) { + Map<String, Boolean> res; + + try { + res = (Map<String, Boolean>) runVdsCommand(VDSCommandType.GetDevicesVisibility, + new GetDevicesVisibilityVDSCommandParameters(vds.getId(), + processedLunIds.toArray(new String[processedLunIds.size()]))).getReturnValue(); + } catch(VdcBLLException e) { + handleFailure(vds, null); + throw e; + } + + for (Map.Entry<String, Boolean> deviceVisibility : res.entrySet()) { + if (!Boolean.TRUE.equals(deviceVisibility.getValue())) { + handleFailure(vds, getDbFacade().getLunDao().get(deviceVisibility.getKey())); return false; } } + return true; } + private void handleFailure(VDS vds, LUNs lun) { + ConnectAllHostsToLunCommandReturnValue result = getResult(); + result.setFailedVds(vds); + result.setFailedLun(lun); + } + @Override public AuditLogType getAuditLogTypeValue() { // this should return only error, if command succeeded no logging is -- To view, visit http://gerrit.ovirt.org/21246 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4b4b40a5296028fc8bcdc1f4a2ed156964a1b1a7 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Sergey Gotliv <sgot...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches