mirror of https://github.com/apache/cloudstack.git
Merge release branch 4.17 to main
* 4.17: api: fix new password is applied on host when update host password with update_passwd_on_host=false (#7092) CKS: remove details when delete a cks cluster (#7104) api/server: add project id/name in ssh keypair response (#7100)
This commit is contained in:
commit
07e4debeab
|
|
@ -23,6 +23,7 @@ import org.apache.cloudstack.api.Parameter;
|
|||
import org.apache.cloudstack.api.response.ClusterResponse;
|
||||
import org.apache.cloudstack.api.response.HostResponse;
|
||||
import org.apache.cloudstack.api.response.SuccessResponse;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
|
|
@ -66,7 +67,7 @@ public class UpdateHostPasswordCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
public Boolean getUpdatePasswdOnHost() {
|
||||
return updatePasswdOnHost == null ? false : true;
|
||||
return BooleanUtils.isTrue(updatePasswdOnHost);
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,14 @@ public class SSHKeyPairResponse extends BaseResponseWithAnnotations {
|
|||
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the keypair owner")
|
||||
private String domain;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT_ID)
|
||||
@Param(description = "the project id of the keypair owner")
|
||||
private String projectId;
|
||||
|
||||
@SerializedName(ApiConstants.PROJECT)
|
||||
@Param(description = "the project name of the keypair owner")
|
||||
private String projectName;
|
||||
|
||||
@SerializedName("fingerprint")
|
||||
@Param(description = "Fingerprint of the public key")
|
||||
private String fingerprint;
|
||||
|
|
@ -106,4 +114,12 @@ public class SSHKeyPairResponse extends BaseResponseWithAnnotations {
|
|||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setProjectId(String projectId) {
|
||||
this.projectId = projectId;
|
||||
}
|
||||
|
||||
public void setProjectName(String projectName) {
|
||||
this.projectName = projectName;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import org.junit.Assert;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.resource.ResourceService;
|
||||
|
|
@ -94,4 +95,15 @@ public class UpdateHostPasswordCmdTest extends TestCase {
|
|||
assertFalse("The attribute updatePasswdOnHost should be false, but it isn't.", updateHostPasswordCmd.getUpdatePasswdOnHost());
|
||||
verify(managementServer, times(1)).updateHostPassword(updateHostPasswordCmd);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetUpdatePasswdOnHostValues() {
|
||||
assertFalse(updateHostPasswordCmd.getUpdatePasswdOnHost());
|
||||
|
||||
ReflectionTestUtils.setField(updateHostPasswordCmd, "updatePasswdOnHost", false);
|
||||
assertFalse(updateHostPasswordCmd.getUpdatePasswdOnHost());
|
||||
|
||||
ReflectionTestUtils.setField(updateHostPasswordCmd, "updatePasswdOnHost", true);
|
||||
assertTrue(updateHostPasswordCmd.getUpdatePasswdOnHost());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -267,6 +267,7 @@ public class KubernetesClusterDestroyWorker extends KubernetesClusterResourceMod
|
|||
}
|
||||
stateTransitTo(kubernetesCluster.getId(), KubernetesCluster.Event.OperationSucceeded);
|
||||
annotationDao.removeByEntityType(AnnotationService.EntityType.KUBERNETES_CLUSTER.name(), kubernetesCluster.getUuid());
|
||||
kubernetesClusterDetailsDao.removeDetails(kubernetesCluster.getId());
|
||||
boolean deleted = kubernetesClusterDao.remove(kubernetesCluster.getId());
|
||||
if (!deleted) {
|
||||
logMessage(Level.WARN, String.format("Failed to delete Kubernetes cluster : %s", kubernetesCluster.getName()), null);
|
||||
|
|
|
|||
|
|
@ -4612,7 +4612,13 @@ public class ApiResponseHelper implements ResponseGenerator {
|
|||
sshkeyPair.getFingerprint(), sshkeyPair.getPrivateKey());
|
||||
}
|
||||
Account account = ApiDBUtils.findAccountById(sshkeyPair.getAccountId());
|
||||
response.setAccountName(account.getAccountName());
|
||||
if (account.getType() == Account.Type.PROJECT) {
|
||||
Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getAccountId());
|
||||
response.setProjectId(project.getUuid());
|
||||
response.setProjectName(project.getName());
|
||||
} else {
|
||||
response.setAccountName(account.getAccountName());
|
||||
}
|
||||
Domain domain = ApiDBUtils.findDomainById(sshkeyPair.getDomainId());
|
||||
response.setDomainId(domain.getUuid());
|
||||
response.setDomainName(domain.getName());
|
||||
|
|
|
|||
|
|
@ -702,7 +702,7 @@ export default {
|
|||
return fields
|
||||
},
|
||||
resourceType: 'SSHKeyPair',
|
||||
details: ['id', 'name', 'fingerprint', 'account', 'domain'],
|
||||
details: ['id', 'name', 'fingerprint', 'account', 'domain', 'project'],
|
||||
related: [{
|
||||
name: 'vm',
|
||||
title: 'label.instances',
|
||||
|
|
@ -734,11 +734,14 @@ export default {
|
|||
label: 'label.remove.ssh.key.pair',
|
||||
message: 'message.please.confirm.remove.ssh.key.pair',
|
||||
dataView: true,
|
||||
args: ['name', 'account', 'domainid'],
|
||||
args: ['name', 'account', 'domainid', 'projectid'],
|
||||
mapping: {
|
||||
name: {
|
||||
value: (record, params) => { return record.name }
|
||||
},
|
||||
projectid: {
|
||||
value: (record, params) => { return record.projectid }
|
||||
},
|
||||
account: {
|
||||
value: (record, params) => { return record.account }
|
||||
},
|
||||
|
|
@ -752,7 +755,10 @@ export default {
|
|||
return selection.map(x => {
|
||||
const data = record.filter(y => { return y.id === x })
|
||||
return {
|
||||
name: data[0].name, account: data[0].account, domainid: data[0].domainid
|
||||
name: data[0].name,
|
||||
account: data[0].account,
|
||||
domainid: data[0].domainid,
|
||||
projectid: data[0].projectid
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue