This is an automated email from the ASF dual-hosted git repository. pearl11594 pushed a commit to branch ud-support-proj in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 8410707f2012f6b9fefc265800f95c89d394bd0b Author: Pearl Dsilva <pearl1...@gmail.com> AuthorDate: Thu Jul 11 09:31:44 2024 -0400 Support Projects in Userdata --- .../apache/cloudstack/api/response/UserDataResponse.java | 16 ++++++++++++++++ .../src/main/java/com/cloud/api/ApiResponseHelper.java | 10 ++++++++-- ui/src/config/section/compute.js | 10 ++++++++-- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/api/src/main/java/org/apache/cloudstack/api/response/UserDataResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/UserDataResponse.java index bbe27f84520..cceee8afaee 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/UserDataResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/UserDataResponse.java @@ -46,6 +46,14 @@ public class UserDataResponse extends BaseResponseWithAnnotations { @SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the userdata owner") private String domain; + @SerializedName(ApiConstants.PROJECT_ID) + @Param(description = "the project id of the userdata owner") + private String projectId; + + @SerializedName(ApiConstants.PROJECT) + @Param(description = "the project name of the userdata owner") + private String projectName; + @SerializedName(ApiConstants.USER_DATA) @Param(description="base64 encoded userdata content") private String userData; @@ -125,4 +133,12 @@ public class UserDataResponse extends BaseResponseWithAnnotations { public void setDomainName(String domain) { this.domain = domain; } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } } diff --git a/server/src/main/java/com/cloud/api/ApiResponseHelper.java b/server/src/main/java/com/cloud/api/ApiResponseHelper.java index 17c465d40ce..375d6d953b0 100644 --- a/server/src/main/java/com/cloud/api/ApiResponseHelper.java +++ b/server/src/main/java/com/cloud/api/ApiResponseHelper.java @@ -4690,8 +4690,14 @@ public class ApiResponseHelper implements ResponseGenerator { public UserDataResponse createUserDataResponse(UserData userData) { UserDataResponse response = new UserDataResponse(userData.getUuid(), userData.getName(), userData.getUserData(), userData.getParams()); Account account = ApiDBUtils.findAccountById(userData.getAccountId()); - response.setAccountId(account.getUuid()); - 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()); + response.setAccountId(account.getUuid()); + } Domain domain = ApiDBUtils.findDomainById(userData.getDomainId()); response.setDomainId(domain.getUuid()); response.setDomainName(domain.getName()); diff --git a/ui/src/config/section/compute.js b/ui/src/config/section/compute.js index 9bf8c949144..67cbbf67744 100644 --- a/ui/src/config/section/compute.js +++ b/ui/src/config/section/compute.js @@ -820,11 +820,14 @@ export default { label: 'label.remove.user.data', message: 'message.please.confirm.remove.user.data', dataView: true, - args: ['id', 'account', 'domainid'], + args: ['id', 'account', 'domainid', 'projectid'], mapping: { id: { value: (record, params) => { return record.id } }, + projectid: { + value: (record, params) => { return record.projectid } + }, account: { value: (record, params) => { return record.account } }, @@ -838,7 +841,10 @@ export default { return selection.map(x => { const data = record.filter(y => { return y.id === x }) return { - id: x, account: data[0].account, domainid: data[0].domainid + id: x, + account: data[0].account, + domainid: data[0].domainid, + projectid: data[0].projectid } }) }