Skip to content

Commit bbaa742

Browse files
author
Prachi Damle
committed
Adding annotations to admin commands
1 parent f0a9b3b commit bbaa742

17 files changed

Lines changed: 61 additions & 19 deletions

‎api/src/org/apache/cloudstack/acl/AclEntityType.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public enum AclEntityType {
1313
Condition,
1414
Vpc,
1515
VpcGateway,
16+
PrivateGateway,
1617
VpnUser,
1718
VMSnapshot,
1819
VirtualMachineTemplate,
@@ -34,7 +35,7 @@ public enum AclEntityType {
3435
InstanceGroup,
3536
GlobalLoadBalancerRule,
3637
FirewallRule,
37-
PortForwardingRule,
38+
PortForwardingRule,
3839
Event,
3940
AsyncJob,
4041
AclPolicy,

‎api/src/org/apache/cloudstack/api/command/admin/systemvm/DestroySystemVmCmd.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import org.apache.log4j.Logger;
2020

21+
import org.apache.cloudstack.acl.AclEntityType;
22+
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
23+
import org.apache.cloudstack.api.ACL;
2124
import org.apache.cloudstack.api.APICommand;
2225
import org.apache.cloudstack.api.ApiCommandJobType;
2326
import org.apache.cloudstack.api.ApiConstants;
@@ -32,12 +35,13 @@
3235
import com.cloud.user.Account;
3336
import com.cloud.vm.VirtualMachine;
3437

35-
@APICommand(name = "destroySystemVm", responseObject = SystemVmResponse.class, description = "Destroyes a system virtual machine.")
38+
@APICommand(name = "destroySystemVm", responseObject = SystemVmResponse.class, description = "Destroyes a system virtual machine.", entityType = { AclEntityType.VirtualMachine })
3639
public class DestroySystemVmCmd extends BaseAsyncCmd {
3740
public static final Logger s_logger = Logger.getLogger(DestroySystemVmCmd.class.getName());
3841

3942
private static final String s_name = "destroysystemvmresponse";
4043

44+
@ACL(accessType = AccessType.OperateEntry)
4145
@Parameter(name = ApiConstants.ID,
4246
type = CommandType.UUID,
4347
entityType = SystemVmResponse.class,

‎api/src/org/apache/cloudstack/api/command/admin/systemvm/ListSystemVMsCmd.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.log4j.Logger;
2323

24+
import org.apache.cloudstack.acl.AclEntityType;
2425
import org.apache.cloudstack.api.APICommand;
2526
import org.apache.cloudstack.api.ApiCommandJobType;
2627
import org.apache.cloudstack.api.ApiConstants;
@@ -36,7 +37,7 @@
3637
import com.cloud.utils.Pair;
3738
import com.cloud.vm.VirtualMachine;
3839

39-
@APICommand(name = "listSystemVms", description = "List system virtual machines.", responseObject = SystemVmResponse.class)
40+
@APICommand(name = "listSystemVms", description = "List system virtual machines.", responseObject = SystemVmResponse.class, entityType = { AclEntityType.VirtualMachine })
4041
public class ListSystemVMsCmd extends BaseListCmd {
4142
public static final Logger s_logger = Logger.getLogger(ListSystemVMsCmd.class.getName());
4243

‎api/src/org/apache/cloudstack/api/command/admin/systemvm/MigrateSystemVMCmd.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import org.apache.log4j.Logger;
2020

21+
import org.apache.cloudstack.acl.AclEntityType;
22+
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
23+
import org.apache.cloudstack.api.ACL;
2124
import org.apache.cloudstack.api.APICommand;
2225
import org.apache.cloudstack.api.ApiConstants;
2326
import org.apache.cloudstack.api.ApiErrorCode;
@@ -38,7 +41,7 @@
3841
import com.cloud.user.Account;
3942
import com.cloud.vm.VirtualMachine;
4043

41-
@APICommand(name = "migrateSystemVm", description = "Attempts Migration of a system virtual machine to the host specified.", responseObject = SystemVmResponse.class)
44+
@APICommand(name = "migrateSystemVm", description = "Attempts Migration of a system virtual machine to the host specified.", responseObject = SystemVmResponse.class, entityType = { AclEntityType.VirtualMachine })
4245
public class MigrateSystemVMCmd extends BaseAsyncCmd {
4346
public static final Logger s_logger = Logger.getLogger(MigrateSystemVMCmd.class.getName());
4447

@@ -55,6 +58,7 @@ public class MigrateSystemVMCmd extends BaseAsyncCmd {
5558
description = "destination Host ID to migrate VM to")
5659
private Long hostId;
5760

61+
@ACL(accessType = AccessType.OperateEntry)
5862
@Parameter(name = ApiConstants.VIRTUAL_MACHINE_ID,
5963
type = CommandType.UUID,
6064
entityType = SystemVmResponse.class,

‎api/src/org/apache/cloudstack/api/command/admin/systemvm/RebootSystemVmCmd.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import org.apache.log4j.Logger;
2020

21+
import org.apache.cloudstack.acl.AclEntityType;
22+
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
23+
import org.apache.cloudstack.api.ACL;
2124
import org.apache.cloudstack.api.APICommand;
2225
import org.apache.cloudstack.api.ApiCommandJobType;
2326
import org.apache.cloudstack.api.ApiConstants;
@@ -32,7 +35,7 @@
3235
import com.cloud.user.Account;
3336
import com.cloud.vm.VirtualMachine;
3437

35-
@APICommand(name = "rebootSystemVm", description = "Reboots a system VM.", responseObject = SystemVmResponse.class)
38+
@APICommand(name = "rebootSystemVm", description = "Reboots a system VM.", responseObject = SystemVmResponse.class, entityType = { AclEntityType.VirtualMachine })
3639
public class RebootSystemVmCmd extends BaseAsyncCmd {
3740
public static final Logger s_logger = Logger.getLogger(RebootSystemVmCmd.class.getName());
3841

@@ -41,7 +44,7 @@ public class RebootSystemVmCmd extends BaseAsyncCmd {
4144
/////////////////////////////////////////////////////
4245
//////////////// API parameters /////////////////////
4346
/////////////////////////////////////////////////////
44-
47+
@ACL(accessType = AccessType.OperateEntry)
4548
@Parameter(name = ApiConstants.ID,
4649
type = CommandType.UUID,
4750
entityType = SystemVmResponse.class,

‎api/src/org/apache/cloudstack/api/command/admin/systemvm/ScaleSystemVMCmd.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
import java.util.Iterator;
2222
import java.util.Map;
2323

24+
import org.apache.cloudstack.acl.AclEntityType;
25+
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
26+
import org.apache.cloudstack.api.ACL;
2427
import org.apache.cloudstack.api.APICommand;
2528
import org.apache.cloudstack.api.ApiConstants;
2629
import org.apache.cloudstack.api.ApiErrorCode;
@@ -44,7 +47,7 @@
4447
import com.cloud.vm.VirtualMachine;
4548

4649
@APICommand(name = "scaleSystemVm", responseObject = SystemVmResponse.class, description = "Scale the service offering for a system vm (console proxy or secondary storage). "
47-
+ "The system vm must be in a \"Stopped\" state for " + "this command to take effect.")
50+
+ "The system vm must be in a \"Stopped\" state for " + "this command to take effect.", entityType = { AclEntityType.VirtualMachine })
4851
public class ScaleSystemVMCmd extends BaseAsyncCmd {
4952
public static final Logger s_logger = Logger.getLogger(UpgradeVMCmd.class.getName());
5053
private static final String s_name = "changeserviceforsystemvmresponse";
@@ -53,6 +56,7 @@ public class ScaleSystemVMCmd extends BaseAsyncCmd {
5356
//////////////// API parameters /////////////////////
5457
/////////////////////////////////////////////////////
5558

59+
@ACL(accessType = AccessType.OperateEntry)
5660
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = SystemVmResponse.class, required = true, description = "The ID of the system vm")
5761
private Long id;
5862

‎api/src/org/apache/cloudstack/api/command/admin/systemvm/StartSystemVMCmd.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import org.apache.log4j.Logger;
2020

21+
import org.apache.cloudstack.acl.AclEntityType;
22+
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
23+
import org.apache.cloudstack.api.ACL;
2124
import org.apache.cloudstack.api.APICommand;
2225
import org.apache.cloudstack.api.ApiCommandJobType;
2326
import org.apache.cloudstack.api.ApiConstants;
@@ -32,7 +35,7 @@
3235
import com.cloud.user.Account;
3336
import com.cloud.vm.VirtualMachine;
3437

35-
@APICommand(name = "startSystemVm", responseObject = SystemVmResponse.class, description = "Starts a system virtual machine.")
38+
@APICommand(name = "startSystemVm", responseObject = SystemVmResponse.class, description = "Starts a system virtual machine.", entityType = { AclEntityType.VirtualMachine })
3639
public class StartSystemVMCmd extends BaseAsyncCmd {
3740
public static final Logger s_logger = Logger.getLogger(StartSystemVMCmd.class.getName());
3841

@@ -41,7 +44,7 @@ public class StartSystemVMCmd extends BaseAsyncCmd {
4144
/////////////////////////////////////////////////////
4245
//////////////// API parameters /////////////////////
4346
/////////////////////////////////////////////////////
44-
47+
@ACL(accessType = AccessType.OperateEntry)
4548
@Parameter(name = ApiConstants.ID,
4649
type = CommandType.UUID,
4750
entityType = SystemVmResponse.class,

‎api/src/org/apache/cloudstack/api/command/admin/systemvm/StopSystemVmCmd.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import org.apache.log4j.Logger;
2020

21+
import org.apache.cloudstack.acl.AclEntityType;
22+
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
23+
import org.apache.cloudstack.api.ACL;
2124
import org.apache.cloudstack.api.APICommand;
2225
import org.apache.cloudstack.api.ApiCommandJobType;
2326
import org.apache.cloudstack.api.ApiConstants;
@@ -34,7 +37,7 @@
3437
import com.cloud.user.Account;
3538
import com.cloud.vm.VirtualMachine;
3639

37-
@APICommand(name = "stopSystemVm", description = "Stops a system VM.", responseObject = SystemVmResponse.class)
40+
@APICommand(name = "stopSystemVm", description = "Stops a system VM.", responseObject = SystemVmResponse.class, entityType = { AclEntityType.VirtualMachine })
3841
public class StopSystemVmCmd extends BaseAsyncCmd {
3942
public static final Logger s_logger = Logger.getLogger(StopSystemVmCmd.class.getName());
4043

@@ -44,6 +47,7 @@ public class StopSystemVmCmd extends BaseAsyncCmd {
4447
//////////////// API parameters /////////////////////
4548
/////////////////////////////////////////////////////
4649

50+
@ACL(accessType = AccessType.OperateEntry)
4751
@Parameter(name = ApiConstants.ID,
4852
type = CommandType.UUID,
4953
entityType = SystemVmResponse.class,

‎api/src/org/apache/cloudstack/api/command/admin/systemvm/UpgradeSystemVMCmd.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
import java.util.Iterator;
2222
import java.util.Map;
2323

24+
import org.apache.cloudstack.acl.AclEntityType;
25+
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
26+
import org.apache.cloudstack.api.ACL;
2427
import org.apache.cloudstack.api.APICommand;
2528
import org.apache.cloudstack.api.ApiConstants;
2629
import org.apache.cloudstack.api.ApiErrorCode;
@@ -39,7 +42,7 @@
3942
import com.cloud.vm.VirtualMachine;
4043

4144
@APICommand(name = "changeServiceForSystemVm", responseObject = SystemVmResponse.class, description = "Changes the service offering for a system vm (console proxy or secondary storage). "
42-
+ "The system vm must be in a \"Stopped\" state for " + "this command to take effect.")
45+
+ "The system vm must be in a \"Stopped\" state for " + "this command to take effect.", entityType = { AclEntityType.VirtualMachine })
4346
public class UpgradeSystemVMCmd extends BaseCmd {
4447
public static final Logger s_logger = Logger.getLogger(UpgradeVMCmd.class.getName());
4548
private static final String s_name = "changeserviceforsystemvmresponse";
@@ -48,6 +51,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
4851
//////////////// API parameters /////////////////////
4952
/////////////////////////////////////////////////////
5053

54+
@ACL(accessType = AccessType.OperateEntry)
5155
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = SystemVmResponse.class, required = true, description = "The ID of the system vm")
5256
private Long id;
5357

‎api/src/org/apache/cloudstack/api/command/admin/template/PrepareTemplateCmd.java‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121
import org.apache.log4j.Logger;
2222

23+
import org.apache.cloudstack.acl.AclEntityType;
24+
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
25+
import org.apache.cloudstack.api.ACL;
2326
import org.apache.cloudstack.api.APICommand;
2427
import org.apache.cloudstack.api.ApiConstants;
2528
import org.apache.cloudstack.api.BaseCmd;
@@ -32,7 +35,7 @@
3235
import com.cloud.template.VirtualMachineTemplate;
3336
import com.cloud.user.Account;
3437

35-
@APICommand(name = "prepareTemplate", responseObject = TemplateResponse.class, description = "load template into primary storage")
38+
@APICommand(name = "prepareTemplate", responseObject = TemplateResponse.class, description = "load template into primary storage", entityType = { AclEntityType.VirtualMachineTemplate })
3639
public class PrepareTemplateCmd extends BaseCmd {
3740
public static final Logger s_logger = Logger.getLogger(PrepareTemplateCmd.class.getName());
3841

@@ -49,6 +52,7 @@ public class PrepareTemplateCmd extends BaseCmd {
4952
description = "zone ID of the template to be prepared in primary storage(s).")
5053
private Long zoneId;
5154

55+
@ACL(accessType = AccessType.OperateEntry)
5256
@Parameter(name = ApiConstants.TEMPLATE_ID,
5357
type = CommandType.UUID,
5458
entityType = TemplateResponse.class,

0 commit comments

Comments
 (0)