Shireesh Anjal has uploaded a new change for review. Change subject: engine: Added new canDoAction check for gluster ......................................................................
engine: Added new canDoAction check for gluster In case the server being added is already part of an existing gluster cluster, canDoAction should fail with an appropriate error message. Change-Id: I81427fa940bf1edabf316acebc428becac0171f8 Bug-Url: https://bugzilla.redhat.com/916982 Signed-off-by: Shireesh Anjal <san...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java 4 files changed, 28 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/80/13980/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java index 88d881f..4d052d7 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVdsCommand.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.concurrent.TimeUnit; import javax.naming.AuthenticationException; @@ -50,6 +51,7 @@ import org.ovirt.engine.core.dal.VdcBllMessages; import org.ovirt.engine.core.dal.dbbroker.DbFacade; import org.ovirt.engine.core.dal.job.ExecutionMessageDirector; +import org.ovirt.engine.core.utils.gluster.GlusterUtil; import org.ovirt.engine.core.utils.ssh.SSHClient; import org.ovirt.engine.core.utils.threadpool.ThreadPoolUtil; import org.ovirt.engine.core.utils.transaction.TransactionMethod; @@ -82,6 +84,7 @@ protected void setActionMessageParameters() { addCanDoActionMessage(VdcBllMessages.VAR__ACTION__ADD); addCanDoActionMessage(VdcBllMessages.VAR__TYPE__HOST); + addCanDoActionMessage(String.format("$server %1$s", getParameters().getvds().getHostName())); } @Override @@ -342,6 +345,16 @@ returnValue = false; } } + + try { + if(serverHasPeers()) { + addCanDoActionMessage(VdcBllMessages.SERVER_ALREADY_PART_OF_ANOTHER_CLUSTER); + returnValue = false; + } + } catch (AuthenticationException e) { + addCanDoActionMessage(VdcBllMessages.SSH_AUTHENTICATION_FAILED); + returnValue = false; + } } return returnValue; } @@ -351,6 +364,14 @@ .getcompatibility_version().toString()); } + private boolean serverHasPeers() throws AuthenticationException { + VDS server = getParameters().getvds(); + Set<String> servers = + GlusterUtil.getInstance().getPeers(server.getHostName(), + getParameters().getRootPassword()); + return !servers.isEmpty(); + } + private boolean clusterHasServers() { return ClusterUtils.getInstance().hasServers(getVdsGroupId()); } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java index 01b10ad..557bbf4 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/VdcBllMessages.java @@ -715,8 +715,10 @@ MIGRATE_PAUSED_VM_IS_UNSUPPORTED, ACTION_TYPE_FAILED_SERVER_NAME_REQUIRED, SERVER_ALREADY_EXISTS_IN_ANOTHER_CLUSTER, + SERVER_ALREADY_PART_OF_ANOTHER_CLUSTER, CLUSTER_ALL_SERVERS_NOT_UP, SSH_AUTHENTICATION_FAILED, + ACTION_TYPE_FAILED_SERVER_PART_OF_ANOTHER_CLUSTER, VM_INTERFACE_NOT_EXIST, ACTION_TYPE_FAILED_CANNOT_REMOVE_ACTIVE_DEVICE, diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index 03936c0..735002e 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -848,8 +848,10 @@ ENGINE_IS_RUNNING_IN_PREPARE_MODE=This action is not allowed when Engine is preparing for maintenance. ACTION_TYPE_FAILED_SERVER_NAME_REQUIRED=Cannot ${action} ${type}. Server Name required. SERVER_ALREADY_EXISTS_IN_ANOTHER_CLUSTER=One or more servers are already part of an existing cluster. +SERVER_ALREADY_PART_OF_ANOTHER_CLUSTER=Server ${server} is already part of another cluster. CLUSTER_ALL_SERVERS_NOT_UP=One or more servers in the cluster is down SSH_AUTHENTICATION_FAILED=SSH Authentication failed. Please make sure password is correct. +ACTION_TYPE_FAILED_SERVER_PART_OF_ANOTHER_CLUSTER=Cannot ${action} ${type}. Server ${server} is already part of another cluster. # External Events Errors Messages VAR__TYPE__EXTERNAL_EVENT=$type External Event diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index f4abd0e..95fe123 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -2251,6 +2251,9 @@ @DefaultStringValue("One or more servers are already part of an existing cluster") String SERVER_ALREADY_EXISTS_IN_ANOTHER_CLUSTER(); + @DefaultStringValue("Server ${server} is already part of another cluster.") + String SERVER_ALREADY_PART_OF_ANOTHER_CLUSTER(); + @DefaultStringValue("SSH Authentication failed. Please make sure password is correct.") String SSH_AUTHENTICATION_FAILED(); -- To view, visit http://gerrit.ovirt.org/13980 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I81427fa940bf1edabf316acebc428becac0171f8 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Shireesh Anjal <san...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches