Skip to content

Commit 5e96ba0

Browse files
weizhouapachedhslove
authored andcommitted
api,server,ui: add project ID and name to UserDataResponse (apache#8656)
* api,server,ui: add project ID and name to UserDataResponse * Update: add since
1 parent 11a0fb3 commit 5e96ba0

4 files changed

Lines changed: 26 additions & 8 deletions

File tree

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import org.apache.cloudstack.api.EntityReference;
2525

2626
@EntityReference(value = UserData.class)
27-
public class UserDataResponse extends BaseResponseWithAnnotations {
27+
public class UserDataResponse extends BaseResponseWithAnnotations implements ControlledEntityResponse {
2828

2929
@SerializedName(ApiConstants.ID)
3030
@Param(description = "ID of the ssh keypair")
@@ -40,6 +40,14 @@ public class UserDataResponse extends BaseResponseWithAnnotations {
4040
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the owner of the userdata")
4141
private String accountName;
4242

43+
@SerializedName(ApiConstants.PROJECT_ID)
44+
@Param(description = "the project id of the userdata", since = "4.19.1")
45+
private String projectId;
46+
47+
@SerializedName(ApiConstants.PROJECT)
48+
@Param(description = "the project name of the userdata", since = "4.19.1")
49+
private String projectName;
50+
4351
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain id of the userdata owner")
4452
private String domainId;
4553

@@ -118,6 +126,16 @@ public void setAccountName(String accountName) {
118126
this.accountName = accountName;
119127
}
120128

129+
@Override
130+
public void setProjectId(String projectId) {
131+
this.projectId = projectId;
132+
}
133+
134+
@Override
135+
public void setProjectName(String projectName) {
136+
this.projectName = projectName;
137+
}
138+
121139
public String getDomainName() {
122140
return domain;
123141
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4862,12 +4862,7 @@ public SSHKeyPairResponse createSSHKeyPairResponse(SSHKeyPair sshkeyPair, boolea
48624862
@Override
48634863
public UserDataResponse createUserDataResponse(UserData userData) {
48644864
UserDataResponse response = new UserDataResponse(userData.getUuid(), userData.getName(), userData.getUserData(), userData.getParams());
4865-
Account account = ApiDBUtils.findAccountById(userData.getAccountId());
4866-
response.setAccountId(account.getUuid());
4867-
response.setAccountName(account.getAccountName());
4868-
Domain domain = ApiDBUtils.findDomainById(userData.getDomainId());
4869-
response.setDomainId(domain.getUuid());
4870-
response.setDomainName(domain.getName());
4865+
populateOwner(response, userData);
48714866
response.setHasAnnotation(annotationDao.hasAnnotations(userData.getUuid(), AnnotationService.EntityType.USER_DATA.name(),
48724867
_accountMgr.isRootAdmin(CallContext.current().getCallingAccount().getId())));
48734868
return response;

ui/src/config/section/compute.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,7 +964,12 @@ export default {
964964
var fields = ['name', 'id']
965965
if (['Admin', 'DomainAdmin'].includes(store.getters.userInfo.roletype)) {
966966
fields.push('account')
967+
if (store.getters.listAllProjects) {
968+
fields.push('project')
969+
}
967970
fields.push('domain')
971+
} else if (store.getters.listAllProjects) {
972+
fields.push('project')
968973
}
969974
return fields
970975
},

ui/src/views/AutogenView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ export default {
10891089
}
10901090
10911091
this.projectView = Boolean(store.getters.project && store.getters.project.id)
1092-
this.hasProjectId = ['vm', 'vmgroup', 'ssh', 'affinitygroup', 'volume', 'snapshot', 'vmsnapshot', 'guestnetwork',
1092+
this.hasProjectId = ['vm', 'vmgroup', 'ssh', 'affinitygroup', 'userdata', 'volume', 'snapshot', 'vmsnapshot', 'guestnetwork',
10931093
'vpc', 'securitygroups', 'publicip', 'vpncustomergateway', 'template', 'iso', 'event', 'kubernetes',
10941094
'autoscalevmgroup', 'vnfapp'].includes(this.$route.name)
10951095

0 commit comments

Comments
 (0)