Skip to content

Commit b379f59

Browse files
DaanHooglandsureshanaparti
authored andcommitted
list only own zones for resource admin (apache#11087)
Co-authored-by: Suresh Kumar Anaparti <[email protected]>
1 parent fdd6b67 commit b379f59

File tree

9 files changed

+266
-240
lines changed

9 files changed

+266
-240
lines changed

api/src/main/java/com/cloud/user/AccountService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ User createUser(String userName, String password, String firstName, String lastN
8787

8888
boolean isDomainAdmin(Long accountId);
8989

90+
boolean isResourceDomainAdmin(Long accountId);
91+
9092
boolean isNormalUser(long accountId);
9193

9294
User getActiveUserByRegistrationToken(String registrationToken);

api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ protected Pair<List<ClusterResponse>, Integer> getClusterResponses() {
190190
@Override
191191
public void execute() {
192192
Pair<List<ClusterResponse>, Integer> clusterResponses = getClusterResponses();
193-
ListResponse<ClusterResponse> response = new ListResponse<ClusterResponse>();
193+
ListResponse<ClusterResponse> response = new ListResponse<>();
194194
response.setResponses(clusterResponses.first(), clusterResponses.second());
195195
response.setResponseName(getCommandName());
196196
this.setResponseObject(response);

api/src/main/java/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ public ListPodsByCmd(String storageAccessGroup) {
103103
@Override
104104
public void execute() {
105105
Pair<List<? extends Pod>, Integer> result = _mgr.searchForPods(this);
106-
ListResponse<PodResponse> response = new ListResponse<PodResponse>();
107-
List<PodResponse> podResponses = new ArrayList<PodResponse>();
106+
ListResponse<PodResponse> response = new ListResponse<>();
107+
List<PodResponse> podResponses = new ArrayList<>();
108108
for (Pod pod : result.first()) {
109109
PodResponse podResponse = _responseGenerator.createPodResponse(pod, showCapacities);
110110
podResponse.setObjectName("pod");

api/src/main/java/org/apache/cloudstack/api/command/user/zone/ListZonesCmd.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@
3434
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
3535
public class ListZonesCmd extends BaseListCmd implements UserCmd {
3636

37-
private static final String s_name = "listzonesresponse";
38-
3937
/////////////////////////////////////////////////////
4038
//////////////// API parameters /////////////////////
4139
/////////////////////////////////////////////////////
@@ -130,11 +128,6 @@ public ListZonesCmd(String storageAccessGroup) {
130128
/////////////// API Implementation///////////////////
131129
/////////////////////////////////////////////////////
132130

133-
@Override
134-
public String getCommandName() {
135-
return s_name;
136-
}
137-
138131
@Override
139132
public void execute() {
140133
ListResponse<ZoneResponse> response = _queryService.listDataCenters(this);

api/src/main/java/org/apache/cloudstack/query/QueryService.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,11 @@ public interface QueryService {
114114
ConfigKey<Boolean> AllowUserViewDestroyedVM = new ConfigKey<>("Advanced", Boolean.class, "allow.user.view.destroyed.vm", "false",
115115
"Determines whether users can view their destroyed or expunging vm ", true, ConfigKey.Scope.Account);
116116

117-
static final ConfigKey<String> UserVMDeniedDetails = new ConfigKey<>(String.class,
117+
ConfigKey<String> UserVMDeniedDetails = new ConfigKey<>(String.class,
118118
"user.vm.denied.details", "Advanced", "rootdisksize, cpuOvercommitRatio, memoryOvercommitRatio, Message.ReservedCapacityFreed.Flag",
119119
"Determines whether users can view certain VM settings. When set to empty, default value used is: rootdisksize, cpuOvercommitRatio, memoryOvercommitRatio, Message.ReservedCapacityFreed.Flag.", true, ConfigKey.Scope.Global, null, null, null, null, null, ConfigKey.Kind.CSV, null);
120120

121-
static final ConfigKey<String> UserVMReadOnlyDetails = new ConfigKey<>(String.class,
121+
ConfigKey<String> UserVMReadOnlyDetails = new ConfigKey<>(String.class,
122122
"user.vm.readonly.details", "Advanced", "dataDiskController, rootDiskController",
123123
"List of read-only VM settings/details as comma separated string", true, ConfigKey.Scope.Global, null, null, null, null, null, ConfigKey.Kind.CSV, null);
124124

@@ -127,16 +127,20 @@ public interface QueryService {
127127
"network offering, zones), we use the flag to determine if the entities should be sorted ascending (when flag is true) " +
128128
"or descending (when flag is false). Within the scope of the config all users see the same result.", true, ConfigKey.Scope.Global);
129129

130-
public static final ConfigKey<Boolean> AllowUserViewAllDomainAccounts = new ConfigKey<>("Advanced", Boolean.class,
130+
ConfigKey<Boolean> AllowUserViewAllDomainAccounts = new ConfigKey<>("Advanced", Boolean.class,
131131
"allow.user.view.all.domain.accounts", "false",
132132
"Determines whether users can view all user accounts within the same domain", true, ConfigKey.Scope.Domain);
133133

134-
static final ConfigKey<Boolean> SharePublicTemplatesWithOtherDomains = new ConfigKey<>("Advanced", Boolean.class, "share.public.templates.with.other.domains", "true",
134+
ConfigKey<Boolean> AllowUserViewAllDataCenters = new ConfigKey<>("Advanced", Boolean.class, "allow.user.view.all.zones", "true",
135+
"Determines whether for instance a Resource Admin can view zones that are not dedicated to them.", true, ConfigKey.Scope.Domain);
136+
137+
ConfigKey<Boolean> SharePublicTemplatesWithOtherDomains = new ConfigKey<>("Advanced", Boolean.class, "share.public.templates.with.other.domains", "true",
135138
"If false, templates of this domain will not show up in the list templates of other domains.", true, ConfigKey.Scope.Domain);
136139

137140
ConfigKey<Boolean> ReturnVmStatsOnVmList = new ConfigKey<>("Advanced", Boolean.class, "list.vm.default.details.stats", "true",
138141
"Determines whether VM stats should be returned when details are not explicitly specified in listVirtualMachines API request. When false, details default to [group, nics, secgrp, tmpl, servoff, diskoff, backoff, iso, volume, min, affgrp]. When true, all details are returned including 'stats'.", true, ConfigKey.Scope.Global);
139142

143+
140144
ListResponse<UserResponse> searchForUsers(ResponseObject.ResponseView responseView, ListUsersCmd cmd) throws PermissionDeniedException;
141145

142146
ListResponse<UserResponse> searchForUsers(Long domainId, boolean recursive) throws PermissionDeniedException;

plugins/network-elements/juniper-contrail/src/test/java/org/apache/cloudstack/network/contrail/management/MockAccountManager.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ public boolean isDomainAdmin(Long accountId) {
236236
return false;
237237
}
238238

239+
@Override
240+
public boolean isResourceDomainAdmin(Long accountId) {
241+
// TODO Auto-generated method stub
242+
return false;
243+
}
244+
239245
@Override
240246
public boolean isNormalUser(long accountId) {
241247
// TODO Auto-generated method stub

0 commit comments

Comments
 (0)