mirror of https://github.com/apache/cloudstack.git
Bug 12897: Make updatehostpassword more robust and allow it to be used only for Xenserver hyperVisor
Status 12897: resolved fixed Reviewed-By: Kishan
This commit is contained in:
parent
273de60a5f
commit
5da4c970e6
|
|
@ -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;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
|
|
|||
Loading…
Reference in New Issue