Skip to content

Commit 8410707

Browse files
committed
Support Projects in Userdata
1 parent beebeed commit 8410707

3 files changed

Lines changed: 32 additions & 4 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/response/UserDataResponse.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ public class UserDataResponse extends BaseResponseWithAnnotations {
4646
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the userdata owner")
4747
private String domain;
4848

49+
@SerializedName(ApiConstants.PROJECT_ID)
50+
@Param(description = "the project id of the userdata owner")
51+
private String projectId;
52+
53+
@SerializedName(ApiConstants.PROJECT)
54+
@Param(description = "the project name of the userdata owner")
55+
private String projectName;
56+
4957
@SerializedName(ApiConstants.USER_DATA) @Param(description="base64 encoded userdata content")
5058
private String userData;
5159

@@ -125,4 +133,12 @@ public String getDomainName() {
125133
public void setDomainName(String domain) {
126134
this.domain = domain;
127135
}
136+
137+
public void setProjectId(String projectId) {
138+
this.projectId = projectId;
139+
}
140+
141+
public void setProjectName(String projectName) {
142+
this.projectName = projectName;
143+
}
128144
}

server/src/main/java/com/cloud/api/ApiResponseHelper.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4690,8 +4690,14 @@ public SSHKeyPairResponse createSSHKeyPairResponse(SSHKeyPair sshkeyPair, boolea
46904690
public UserDataResponse createUserDataResponse(UserData userData) {
46914691
UserDataResponse response = new UserDataResponse(userData.getUuid(), userData.getName(), userData.getUserData(), userData.getParams());
46924692
Account account = ApiDBUtils.findAccountById(userData.getAccountId());
4693-
response.setAccountId(account.getUuid());
4694-
response.setAccountName(account.getAccountName());
4693+
if (account.getType() == Account.Type.PROJECT) {
4694+
Project project = ApiDBUtils.findProjectByProjectAccountIdIncludingRemoved(account.getAccountId());
4695+
response.setProjectId(project.getUuid());
4696+
response.setProjectName(project.getName());
4697+
} else {
4698+
response.setAccountName(account.getAccountName());
4699+
response.setAccountId(account.getUuid());
4700+
}
46954701
Domain domain = ApiDBUtils.findDomainById(userData.getDomainId());
46964702
response.setDomainId(domain.getUuid());
46974703
response.setDomainName(domain.getName());

ui/src/config/section/compute.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,11 +820,14 @@ export default {
820820
label: 'label.remove.user.data',
821821
message: 'message.please.confirm.remove.user.data',
822822
dataView: true,
823-
args: ['id', 'account', 'domainid'],
823+
args: ['id', 'account', 'domainid', 'projectid'],
824824
mapping: {
825825
id: {
826826
value: (record, params) => { return record.id }
827827
},
828+
projectid: {
829+
value: (record, params) => { return record.projectid }
830+
},
828831
account: {
829832
value: (record, params) => { return record.account }
830833
},
@@ -838,7 +841,10 @@ export default {
838841
return selection.map(x => {
839842
const data = record.filter(y => { return y.id === x })
840843
return {
841-
id: x, account: data[0].account, domainid: data[0].domainid
844+
id: x,
845+
account: data[0].account,
846+
domainid: data[0].domainid,
847+
projectid: data[0].projectid
842848
}
843849
})
844850
}

0 commit comments

Comments
 (0)