Skip to content

Commit ded1184

Browse files
bug 8710: Introducing a new user role in cloudstack called RESOURCE_DOMAIN_ADMIN. The role would have all the domain_admin rights and the rights to list zone,pods,clusters and so on. More info in the bug
1 parent bb895a7 commit ded1184

3 files changed

Lines changed: 56 additions & 55 deletions

File tree

‎api/src/com/cloud/user/Account.java‎

100644100755
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public enum State {
3939
public static final short ACCOUNT_TYPE_NORMAL = 0;
4040
public static final short ACCOUNT_TYPE_ADMIN = 1;
4141
public static final short ACCOUNT_TYPE_DOMAIN_ADMIN = 2;
42-
public static final short ACCOUNT_TYPE_READ_ONLY_ADMIN = 3;
42+
public static final short ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN = 3;
43+
public static final short ACCOUNT_TYPE_READ_ONLY_ADMIN = 4;
4344

4445
public static final String ACCOUNT_STATE_DISABLED = "disabled";
4546
public static final String ACCOUNT_STATE_ENABLED = "enabled";

‎client/tomcatconf/commands.properties.in‎

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
### bitmap of permissions at the end of each classname, 1 = ADMIN, 2 = DOMAIN_ADMIN, 4 = READ_ONLY_ADMIN, 8 = USER
1+
### bitmap of permissions at the end of each classname, 1 = ADMIN, 2 = RESOURCE_DOMAIN_ADMIN, 4 = DOMAIN_ADMIN, 8 = USER
22
### Please standardize naming conventions to camel-case (even for acronyms).
33

44
### Account commands
5-
createAccount=com.cloud.api.commands.CreateAccountCmd;1
6-
deleteAccount=com.cloud.api.commands.DeleteAccountCmd;1
7-
updateAccount=com.cloud.api.commands.UpdateAccountCmd;3
8-
disableAccount=com.cloud.api.commands.DisableAccountCmd;3
9-
enableAccount=com.cloud.api.commands.EnableAccountCmd;3
10-
###lockAccount=com.cloud.api.commands.LockAccountCmd;3
5+
createAccount=com.cloud.api.commands.CreateAccountCmd;3
6+
deleteAccount=com.cloud.api.commands.DeleteAccountCmd;3
7+
updateAccount=com.cloud.api.commands.UpdateAccountCmd;7
8+
disableAccount=com.cloud.api.commands.DisableAccountCmd;7
9+
enableAccount=com.cloud.api.commands.EnableAccountCmd;7
10+
###lockAccount=com.cloud.api.commands.LockAccountCmd;7
1111
listAccounts=com.cloud.api.commands.ListAccountsCmd;15
1212

1313
#### User commands
14-
createUser=com.cloud.api.commands.CreateUserCmd;1
15-
deleteUser=com.cloud.api.commands.DeleteUserCmd;1
16-
updateUser=com.cloud.api.commands.UpdateUserCmd;1
14+
createUser=com.cloud.api.commands.CreateUserCmd;3
15+
deleteUser=com.cloud.api.commands.DeleteUserCmd;3
16+
updateUser=com.cloud.api.commands.UpdateUserCmd;3
1717
listUsers=com.cloud.api.commands.ListUsersCmd;7
18-
####lockUser=com.cloud.api.commands.LockUserCmd;3
19-
disableUser=com.cloud.api.commands.DisableUserCmd;3
20-
enableUser=com.cloud.api.commands.EnableUserCmd;3
18+
####lockUser=com.cloud.api.commands.LockUserCmd;7
19+
disableUser=com.cloud.api.commands.DisableUserCmd;7
20+
enableUser=com.cloud.api.commands.EnableUserCmd;7
2121

2222

2323
#### Domain commands
@@ -31,22 +31,22 @@ listDomainChildren=com.cloud.api.commands.ListDomainChildrenCmd;7
3131
getCloudIdentifier=com.cloud.api.commands.GetCloudIdentifierCmd;15
3232

3333
#### Limit commands
34-
updateResourceLimit=com.cloud.api.commands.UpdateResourceLimitCmd;3
34+
updateResourceLimit=com.cloud.api.commands.UpdateResourceLimitCmd;7
3535
listResourceLimits=com.cloud.api.commands.ListResourceLimitsCmd;15
3636

3737
#### VM commands
38-
deployVirtualMachine=com.cloud.api.commands.DeployVMCmd;11
38+
deployVirtualMachine=com.cloud.api.commands.DeployVMCmd;15
3939
destroyVirtualMachine=com.cloud.api.commands.DestroyVMCmd;15
4040
rebootVirtualMachine=com.cloud.api.commands.RebootVMCmd;15
4141
startVirtualMachine=com.cloud.api.commands.StartVMCmd;15
4242
stopVirtualMachine=com.cloud.api.commands.StopVMCmd;15
4343
resetPasswordForVirtualMachine=com.cloud.api.commands.ResetVMPasswordCmd;15
4444
changeServiceForVirtualMachine=com.cloud.api.commands.UpgradeVMCmd;15
4545
updateVirtualMachine=com.cloud.api.commands.UpdateVMCmd;15
46-
recoverVirtualMachine=com.cloud.api.commands.RecoverVMCmd;3
46+
recoverVirtualMachine=com.cloud.api.commands.RecoverVMCmd;7
4747
listVirtualMachines=com.cloud.api.commands.ListVMsCmd;15
4848
getVMPassword=com.cloud.api.commands.GetVMPasswordCmd;15
49-
migrateVirtualMachine=com.cloud.api.commands.MigrateVMCmd;1
49+
migrateVirtualMachine=com.cloud.api.commands.MigrateVMCmd;1
5050

5151
#### snapshot commands
5252
createSnapshot=com.cloud.api.commands.CreateSnapshotCmd;15
@@ -128,18 +128,18 @@ listLoadBalancerRuleInstances=com.cloud.api.commands.ListLoadBalancerRuleInstanc
128128
updateLoadBalancerRule=com.cloud.api.commands.UpdateLoadBalancerRuleCmd;15
129129

130130
#### router commands
131-
startRouter=com.cloud.api.commands.StartRouterCmd;3
132-
rebootRouter=com.cloud.api.commands.RebootRouterCmd;3
133-
stopRouter=com.cloud.api.commands.StopRouterCmd;3
134-
changeServiceForRouter=com.cloud.api.commands.UpgradeRouterCmd;3
131+
startRouter=com.cloud.api.commands.StartRouterCmd;7
132+
rebootRouter=com.cloud.api.commands.RebootRouterCmd;7
133+
stopRouter=com.cloud.api.commands.StopRouterCmd;7
134+
changeServiceForRouter=com.cloud.api.commands.UpgradeRouterCmd;7
135135
listRouters=com.cloud.api.commands.ListRoutersCmd;7
136136

137137
#### system vm commands
138138
startSystemVm=com.cloud.api.commands.StartSystemVMCmd;1
139139
rebootSystemVm=com.cloud.api.commands.RebootSystemVmCmd;1
140140
stopSystemVm=com.cloud.api.commands.StopSystemVmCmd;1
141141
destroySystemVm=com.cloud.api.commands.DestroySystemVmCmd;1
142-
listSystemVms=com.cloud.api.commands.ListSystemVMsCmd;1
142+
listSystemVms=com.cloud.api.commands.ListSystemVMsCmd;3
143143

144144
#### configuration commands
145145
updateConfiguration=com.cloud.api.commands.UpdateCfgCmd;1
@@ -151,7 +151,7 @@ listCapabilities=com.cloud.api.commands.ListCapabilitiesCmd;15
151151
createPod=com.cloud.api.commands.CreatePodCmd;1
152152
updatePod=com.cloud.api.commands.UpdatePodCmd;1
153153
deletePod=com.cloud.api.commands.DeletePodCmd;1
154-
listPods=com.cloud.api.commands.ListPodsByCmd;1
154+
listPods=com.cloud.api.commands.ListPodsByCmd;3
155155

156156
#### zone commands
157157
createZone=com.cloud.api.commands.CreateZoneCmd;1
@@ -163,22 +163,22 @@ listZones=com.cloud.api.commands.ListZonesByCmd;15
163163
listEvents=com.cloud.api.commands.ListEventsCmd;15
164164

165165
#### alerts commands
166-
listAlerts=com.cloud.api.commands.ListAlertsCmd;1
166+
listAlerts=com.cloud.api.commands.ListAlertsCmd;3
167167

168168
#### system capacity commands
169-
listCapacity=com.cloud.api.commands.ListCapacityCmd;1
169+
listCapacity=com.cloud.api.commands.ListCapacityCmd;3
170170

171171
#### host commands
172-
addHost=com.cloud.api.commands.AddHostCmd;1
172+
addHost=com.cloud.api.commands.AddHostCmd;3
173173
addCluster=com.cloud.api.commands.AddClusterCmd;1
174174
deleteCluster=com.cloud.api.commands.DeleteClusterCmd;1
175175
updateCluster=com.cloud.api.commands.UpdateClusterCmd;1
176176
reconnectHost=com.cloud.api.commands.ReconnectHostCmd;1
177177
updateHost=com.cloud.api.commands.UpdateHostCmd;1
178-
deleteHost=com.cloud.api.commands.DeleteHostCmd;1
178+
deleteHost=com.cloud.api.commands.DeleteHostCmd;3
179179
prepareHostForMaintenance=com.cloud.api.commands.PrepareForMaintenanceCmd;1
180180
cancelHostMaintenance=com.cloud.api.commands.CancelMaintenanceCmd;1
181-
listHosts=com.cloud.api.commands.ListHostsCmd;1
181+
listHosts=com.cloud.api.commands.ListHostsCmd;3
182182
addSecondaryStorage=com.cloud.api.commands.AddSecondaryStorageCmd;1
183183

184184
#### volume commands
@@ -201,20 +201,20 @@ queryAsyncJobResult=com.cloud.api.commands.QueryAsyncJobResultCmd;15
201201
listAsyncJobs=com.cloud.api.commands.ListAsyncJobsCmd;15
202202

203203
#### storage pools commands
204-
listStoragePools=com.cloud.api.commands.ListStoragePoolsCmd;1
204+
listStoragePools=com.cloud.api.commands.ListStoragePoolsCmd;3
205205
createStoragePool=com.cloud.api.commands.CreateStoragePoolCmd;1
206206
#### updateStoragePool=com.cloud.api.commands.UpdateStoragePoolCmd;1
207207
deleteStoragePool=com.cloud.api.commands.DeletePoolCmd;1
208-
listClusters=com.cloud.api.commands.ListClustersCmd;1
208+
listClusters=com.cloud.api.commands.ListClustersCmd;3
209209
enableStorageMaintenance=com.cloud.api.commands.PreparePrimaryStorageForMaintenanceCmd;1
210210
cancelStorageMaintenance=com.cloud.api.commands.CancelPrimaryStorageMaintenanceCmd;1
211211

212212
#### security group commands
213-
createSecurityGroup=com.cloud.api.commands.CreateSecurityGroupCmd;11
214-
deleteSecurityGroup=com.cloud.api.commands.DeleteSecurityGroupCmd;11
215-
authorizeSecurityGroupIngress=com.cloud.api.commands.AuthorizeSecurityGroupIngressCmd;11
216-
revokeSecurityGroupIngress=com.cloud.api.commands.RevokeSecurityGroupIngressCmd;11
217-
listSecurityGroups=com.cloud.api.commands.ListSecurityGroupsCmd;11
213+
createSecurityGroup=com.cloud.api.commands.CreateSecurityGroupCmd;15
214+
deleteSecurityGroup=com.cloud.api.commands.DeleteSecurityGroupCmd;15
215+
authorizeSecurityGroupIngress=com.cloud.api.commands.AuthorizeSecurityGroupIngressCmd;15
216+
revokeSecurityGroupIngress=com.cloud.api.commands.RevokeSecurityGroupIngressCmd;15
217+
listSecurityGroups=com.cloud.api.commands.ListSecurityGroupsCmd;15
218218

219219
#### vm group commands
220220
createInstanceGroup=com.cloud.api.commands.CreateVMGroupCmd;15
@@ -248,11 +248,11 @@ createNetwork=com.cloud.api.commands.CreateNetworkCmd;15
248248
deleteNetwork=com.cloud.api.commands.DeleteNetworkCmd;15
249249
listNetworks=com.cloud.api.commands.ListNetworksCmd;15
250250
restartNetwork=com.cloud.api.commands.RestartNetworkCmd;15
251-
updateNetwork=com.cloud.api.commands.UpdateNetworkCmd;15
252-
253-
#### SSH key pair commands
254-
registerSSHKeyPair=com.cloud.api.commands.RegisterSSHKeyPairCmd;15
255-
createSSHKeyPair=com.cloud.api.commands.CreateSSHKeyPairCmd;15
256-
deleteSSHKeyPair=com.cloud.api.commands.DeleteSSHKeyPairCmd;15
251+
updateNetwork=com.cloud.api.commands.UpdateNetworkCmd;15
252+
253+
#### SSH key pair commands
254+
registerSSHKeyPair=com.cloud.api.commands.RegisterSSHKeyPairCmd;15
255+
createSSHKeyPair=com.cloud.api.commands.CreateSSHKeyPairCmd;15
256+
deleteSSHKeyPair=com.cloud.api.commands.DeleteSSHKeyPairCmd;15
257257
listSSHKeyPairs=com.cloud.api.commands.ListSSHKeyPairsCmd;15
258258

‎server/src/com/cloud/api/ApiServer.java‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ public class ApiServer implements HttpRequestHandler {
109109
private static final Logger s_logger = Logger.getLogger(ApiServer.class.getName());
110110
private static final Logger s_accessLogger = Logger.getLogger("apiserver." + ApiServer.class.getName());
111111

112-
private static final short ADMIN_COMMAND = 1;
113-
private static final short DOMAIN_ADMIN_COMMAND = 2;
114-
private static final short READ_ONLY_ADMIN_COMMAND = 4;
115-
private static final short USER_COMMAND = 8;
112+
public static final short ADMIN_COMMAND = 1;
113+
public static final short DOMAIN_ADMIN_COMMAND = 4;
114+
public static final short RESOURCE_DOMAIN_ADMIN_COMMAND = 2;
115+
public static final short USER_COMMAND = 8;
116116
private Properties _apiCommands = null;
117117
private ApiDispatcher _dispatcher;
118118
private ManagementServer _ms = null;
@@ -127,7 +127,7 @@ public class ApiServer implements HttpRequestHandler {
127127
private static List<String> s_userCommands = null;
128128
private static List<String> s_resellerCommands = null; // AKA domain-admin
129129
private static List<String> s_adminCommands = null;
130-
private static List<String> s_readOnlyAdminCommands = null;
130+
private static List<String> s_resourceDomainAdminCommands = null;
131131
private static List<String> s_allCommands = null;
132132

133133
private static ExecutorService _executor = new ThreadPoolExecutor(10, 150, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new NamedThreadFactory("ApiServer"));
@@ -136,7 +136,7 @@ public class ApiServer implements HttpRequestHandler {
136136
s_userCommands = new ArrayList<String>();
137137
s_resellerCommands = new ArrayList<String>();
138138
s_adminCommands = new ArrayList<String>();
139-
s_readOnlyAdminCommands = new ArrayList<String>();
139+
s_resourceDomainAdminCommands = new ArrayList<String>();
140140
s_allCommands = new ArrayList<String>();
141141
}
142142

@@ -179,12 +179,12 @@ public void init(String[] apiConfig) {
179179
if ((cmdPermissions & ADMIN_COMMAND) != 0) {
180180
s_adminCommands.add((String)key);
181181
}
182+
if ((cmdPermissions & RESOURCE_DOMAIN_ADMIN_COMMAND) != 0) {
183+
s_resourceDomainAdminCommands.add((String)key);
184+
}
182185
if ((cmdPermissions & DOMAIN_ADMIN_COMMAND) != 0) {
183186
s_resellerCommands.add((String)key);
184-
}
185-
if ((cmdPermissions & READ_ONLY_ADMIN_COMMAND) != 0) {
186-
s_readOnlyAdminCommands.add((String)key);
187-
}
187+
}
188188
if ((cmdPermissions & USER_COMMAND) != 0) {
189189
s_userCommands.add((String)key);
190190
}
@@ -195,7 +195,7 @@ public void init(String[] apiConfig) {
195195
}
196196

197197
s_allCommands.addAll(s_adminCommands);
198-
s_allCommands.addAll(s_readOnlyAdminCommands);
198+
s_allCommands.addAll(s_resourceDomainAdminCommands);
199199
s_allCommands.addAll(s_userCommands);
200200
s_allCommands.addAll(s_resellerCommands);
201201
}
@@ -738,8 +738,8 @@ public static boolean isCommandAvailable(short accountType, String commandName)
738738
case Account.ACCOUNT_TYPE_DOMAIN_ADMIN:
739739
isCommandAvailable = s_resellerCommands.contains(commandName);
740740
break;
741-
case Account.ACCOUNT_TYPE_READ_ONLY_ADMIN:
742-
isCommandAvailable = s_readOnlyAdminCommands.contains(commandName);
741+
case Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN:
742+
isCommandAvailable = s_resourceDomainAdminCommands.contains(commandName);
743743
break;
744744
case Account.ACCOUNT_TYPE_NORMAL:
745745
isCommandAvailable = s_userCommands.contains(commandName);

0 commit comments

Comments
 (0)