Timothy Asir has uploaded a new change for review. Change subject: gluster: Fix add host gluster uuid already exists in the db. ......................................................................
gluster: Fix add host gluster uuid already exists in the db. Check whether add host uuid already exists in the database and throw an appropriate error message. Change-Id: I1cca4c64cdbcb6a681089e1fbb2f0d707f768083 Signed-off-by: Timothy Asir <tjeya...@redhat.com> Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=992899 Signed-off-by: Timothy Asir <tjeya...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetNonOperationalVdsCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NonOperationalReason.java M frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties 5 files changed, 31 insertions(+), 15 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/91/21391/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java index e2b0633..fe4e22f 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java @@ -343,7 +343,18 @@ private boolean initGlusterHost() { glusterHostUuidFound = true; if (GlusterFeatureSupported.glusterHostUuidSupported(getVdsGroup().getcompatibility_version())) { - if (!saveGlusterHostUuid()) { + VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterHostUUID, + new VdsIdVDSCommandParametersBase(getVds().getId())); + Guid addServerGlusterUuid = Guid.createGuidFromString((String) returnValue.getReturnValue()); + if (returnValue.getSucceeded() && returnValue.getReturnValue() != null) { + if (!validateGlusterHostUuid(addServerGlusterUuid)) { + glusterHostUuidFound = true; + setNonOperational(NonOperationalReason.GLUSTER_HOST_UUID_ALREADY_FOUND, null); + return false; + } + saveGlusterHostUuid(addServerGlusterUuid); + } + else { glusterHostUuidFound = false; setNonOperational(NonOperationalReason.GLUSTER_HOST_UUID_NOT_FOUND, null); } @@ -419,23 +430,23 @@ return false; } - private boolean saveGlusterHostUuid() { + private boolean validateGlusterHostUuid(Guid addServerGlusterUuid) { + GlusterServerDao glusterServerDao = DbFacade.getInstance().getGlusterServerDao(); + if (glusterServerDao.getByGlusterServerUuid(addServerGlusterUuid) != null) { + return false; + } + return true; + } + + private void saveGlusterHostUuid(Guid addServerGlusterUuid) { GlusterServerDao glusterServerDao = DbFacade.getInstance().getGlusterServerDao(); GlusterServer glusterServer = glusterServerDao.getByServerId(getVds().getId()); if (glusterServer == null) { - VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterHostUUID, - new VdsIdVDSCommandParametersBase(getVds().getId())); - if (returnValue.getSucceeded() && returnValue.getReturnValue() != null) { - glusterServer = new GlusterServer(); - glusterServer.setId(getVds().getId()); - glusterServer.setGlusterServerUuid(Guid.createGuidFromString((String) returnValue.getReturnValue())); - glusterServerDao.save(glusterServer); - } - else { - return false; - } + glusterServer = new GlusterServer(); + glusterServer.setId(getVds().getId()); + glusterServer.setGlusterServerUuid(addServerGlusterUuid); + glusterServerDao.save(glusterServer); } - return true; } public InterfaceDao getInterfaceDAO() { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetNonOperationalVdsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetNonOperationalVdsCommand.java index 5bd2eae..ad1fb71 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetNonOperationalVdsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetNonOperationalVdsCommand.java @@ -118,6 +118,8 @@ return AuditLogType.GLUSTER_COMMAND_FAILED; case GLUSTER_HOST_UUID_NOT_FOUND: return AuditLogType.GLUSTER_HOST_UUID_NOT_FOUND; + case GLUSTER_HOST_UUID_ALREADY_FOUND: + return AuditLogType.GLUSTER_HOST_UUID_ALREADY_FOUND; case EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER: return AuditLogType.EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER; case UNTRUSTED: diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java index acb79a6..3b52d90 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java @@ -305,6 +305,7 @@ GLUSTER_VOLUME_REMOVE_BRICKS_COMMIT(4084), GLUSTER_VOLUME_REMOVE_BRICKS_COMMIT_FAILED(4085), GLUSTER_BRICK_STATUS_CHANGED(4086), + GLUSTER_HOST_UUID_ALREADY_FOUND(4087), USER_FORCE_SELECTED_SPM(159), USER_VDS_RESTART(41), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NonOperationalReason.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NonOperationalReason.java index d872e6d..33ce5b4 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NonOperationalReason.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NonOperationalReason.java @@ -19,7 +19,8 @@ EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER(11), UNTRUSTED(12), UNINITIALIZED(13), - CLUSTER_VERSION_INCOMPATIBLE_WITH_CLUSTER(14); + CLUSTER_VERSION_INCOMPATIBLE_WITH_CLUSTER(14), + GLUSTER_HOST_UUID_ALREADY_FOUND(15); private final int value; diff --git a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties index df6b6f5..ea8ec0e 100644 --- a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties +++ b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties @@ -10,6 +10,7 @@ NonOperationalReason___TIMEOUT_RECOVERING_FROM_CRASH=Timeout connecting to Host. NonOperationalReason___GLUSTER_COMMAND_FAILED=Gluster command failed on server. NonOperationalReason___GLUSTER_HOST_UUID_NOT_FOUND=Could not find Gluster UUID of the server. +NonOperationalReason___GLUSTER_HOST_UUID_ALREADY_FOUND=Gluster UUID already exists. NonOperationalReason___EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER=The Host emulated machine flags doesn't match one of the cluster emulated machines. NonOperationalReason___UNTRUSTED=Host is untrusted. NonOperationalReason___UNINITIALIZED=Host is uninitialized as it is not attested yet. -- To view, visit http://gerrit.ovirt.org/21391 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1cca4c64cdbcb6a681089e1fbb2f0d707f768083 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Timothy Asir <tjeya...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches