From 5da4c970e6682b1462c86660ffb7f830446c6168 Mon Sep 17 00:00:00 2001 From: Nitin Mehta Date: Wed, 25 Jan 2012 15:10:10 +0530 Subject: [PATCH] Bug 12897: Make updatehostpassword more robust and allow it to be used only for Xenserver hyperVisor Status 12897: resolved fixed Reviewed-By: Kishan --- .../api/commands/UpdateHostPasswordCmd.java | 5 +---- .../com/cloud/server/ManagementServerImpl.java | 16 ++++------------ 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/api/src/com/cloud/api/commands/UpdateHostPasswordCmd.java b/api/src/com/cloud/api/commands/UpdateHostPasswordCmd.java index 38b70b7744a..02ce463e8ab 100644 --- a/api/src/com/cloud/api/commands/UpdateHostPasswordCmd.java +++ b/api/src/com/cloud/api/commands/UpdateHostPasswordCmd.java @@ -25,9 +25,6 @@ import com.cloud.api.ApiConstants; import com.cloud.api.BaseCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; -import com.cloud.api.ServerApiException; -import com.cloud.api.BaseCmd.CommandType; -import com.cloud.api.response.RegisterResponse; import com.cloud.api.response.SuccessResponse; import com.cloud.user.Account; @@ -50,7 +47,7 @@ public class UpdateHostPasswordCmd extends BaseCmd { @Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="the username for the host/cluster") private String username; - @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="the password for the host/cluster") + @Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="the new password for the host/cluster") private String password; // /////////////////////////////////////////////////// diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index db227f54316..ed1c562ccf7 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -4761,18 +4761,10 @@ public class ManagementServerImpl implements ManagementServer { throw new InvalidParameterValueException("You should provide one of cluster id or a host id."); } else if (cmd.getClusterId() == null) { HostVO host = _hostDao.findById(cmd.getHostId()); - if (host == null){ - throw new InvalidParameterValueException("The hostId " +cmd.getHostId()+ " doesnt exist"); - }if (host.getHypervisorType() != HypervisorType.KVM) { - throw new InvalidParameterValueException("This operation is not permitted for " + host.getHypervisorType() + " with the parameter hostId"); - } - DetailVO nv = _detailsDao.findDetail(host.getId(), ApiConstants.USERNAME); - if (nv.getValue().equals(cmd.getUsername())) { - DetailVO nvp = new DetailVO(host.getId(), ApiConstants.PASSWORD, cmd.getPassword()); - nvp.setValue(cmd.getPassword()); - _detailsDao.persist(nvp); - } else { - throw new InvalidParameterValueException("The username is not under use by management server."); + if (host != null && host.getHypervisorType() == HypervisorType.XenServer) { + throw new InvalidParameterValueException("You should provide cluster id for Xenserver cluster."); + }else { + throw new InvalidParameterValueException("This operation is not supported for this hypervisor type"); } } else { ClusterVO cluster = _clusterDao.findById(cmd.getClusterId());