From d0ae4d9a9f7dc2ef39ee24f09c36f67ccb7502d7 Mon Sep 17 00:00:00 2001 From: Min Chen Date: Tue, 4 Mar 2014 17:14:25 -0800 Subject: [PATCH] CLOUDSTACK-5920:Add interface to ControlledEntity to return IAM entity type. --- api/src/com/cloud/network/NetworkProfile.java | 7 + .../cloud/network/vpc/StaticRouteProfile.java | 28 +-- .../cloudstack/acl/ControlledEntity.java | 1 + .../apache/cloudstack/acl/IAMEntityType.java | 45 +++++ .../firewall/CreateEgressFirewallRuleCmd.java | 11 +- .../user/firewall/CreateFirewallRuleCmd.java | 12 +- .../firewall/CreatePortForwardingRuleCmd.java | 10 +- .../user/nat/CreateIpForwardingRuleCmd.java | 18 +- .../src/com/cloud/network/addr/PublicIp.java | 7 + .../network/rules/StaticNatRuleImpl.java | 33 ++-- .../schema/src/com/cloud/event/EventVO.java | 12 +- .../com/cloud/network/UserIpv6AddressVO.java | 17 +- .../src/com/cloud/network/VpnUserVO.java | 19 +- .../cloud/network/as/AutoScalePolicyVO.java | 9 +- .../cloud/network/as/AutoScaleVmGroupVO.java | 11 +- .../network/as/AutoScaleVmProfileVO.java | 11 +- .../src/com/cloud/network/as/ConditionVO.java | 11 +- .../com/cloud/network/dao/IPAddressVO.java | 45 +++-- .../network/dao/MonitoringServiceVO.java | 7 + .../src/com/cloud/network/dao/NetworkVO.java | 46 ++--- .../cloud/network/dao/RemoteAccessVpnVO.java | 17 +- .../dao/Site2SiteCustomerGatewayVO.java | 9 +- .../network/dao/Site2SiteVpnConnectionVO.java | 14 +- .../network/dao/Site2SiteVpnGatewayVO.java | 13 +- .../src/com/cloud/network/dao/SslCertVO.java | 14 +- .../cloud/network/rules/FirewallRuleVO.java | 24 ++- .../network/security/SecurityGroupVO.java | 13 +- .../com/cloud/network/vpc/StaticRouteVO.java | 15 +- .../com/cloud/network/vpc/VpcGatewayVO.java | 17 +- .../src/com/cloud/network/vpc/VpcVO.java | 15 +- .../cloud/projects/ProjectInvitationVO.java | 17 +- .../src/com/cloud/storage/SnapshotVO.java | 19 +- .../src/com/cloud/storage/VMTemplateVO.java | 6 + .../src/com/cloud/storage/VolumeVO.java | 101 ++++++----- .../src/com/cloud/tags/ResourceTagVO.java | 11 +- .../schema/src/com/cloud/user/AccountVO.java | 16 +- .../src/com/cloud/user/SSHKeyPairVO.java | 6 + .../src/com/cloud/vm/InstanceGroupVO.java | 11 +- .../schema/src/com/cloud/vm/VMInstanceVO.java | 28 +-- .../src/com/cloud/vm/dao/NicIpAliasVO.java | 14 +- .../com/cloud/vm/dao/NicSecondaryIpVO.java | 9 +- .../com/cloud/vm/snapshot/VMSnapshotVO.java | 14 +- .../cloudstack/affinity/AffinityGroupVO.java | 12 +- .../cloud/entity/api/db/VMEntityVO.java | 28 +-- .../region/gslb/GlobalLoadBalancerRuleVO.java | 15 +- .../storage/image/store/TemplateObject.java | 5 + .../storage/snapshot/SnapshotObject.java | 6 + .../storage/image/TemplateEntityImpl.java | 5 + .../storage/snapshot/SnapshotEntityImpl.java | 5 + .../storage/volume/VolumeObject.java | 164 +++++++++--------- .../api/query/vo/AffinityGroupJoinVO.java | 6 + .../api/query/vo/DomainRouterJoinVO.java | 8 + .../com/cloud/api/query/vo/EventJoinVO.java | 8 + .../api/query/vo/InstanceGroupJoinVO.java | 8 + .../api/query/vo/ProjectInvitationJoinVO.java | 8 + .../cloud/api/query/vo/ResourceTagJoinVO.java | 8 + .../api/query/vo/SecurityGroupJoinVO.java | 8 + .../cloud/api/query/vo/TemplateJoinVO.java | 9 +- .../com/cloud/api/query/vo/UserVmJoinVO.java | 8 + .../com/cloud/api/query/vo/VolumeJoinVO.java | 8 + .../response/SecurityGroupResultObject.java | 8 +- .../network/vpc/PrivateGatewayProfile.java | 6 + 62 files changed, 778 insertions(+), 318 deletions(-) create mode 100644 api/src/org/apache/cloudstack/acl/IAMEntityType.java diff --git a/api/src/com/cloud/network/NetworkProfile.java b/api/src/com/cloud/network/NetworkProfile.java index 1b66c7c5f7c..3f576945a57 100644 --- a/api/src/com/cloud/network/NetworkProfile.java +++ b/api/src/com/cloud/network/NetworkProfile.java @@ -18,6 +18,8 @@ package com.cloud.network; import java.net.URI; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.Mode; import com.cloud.network.Networks.TrafficType; @@ -275,4 +277,9 @@ public class NetworkProfile implements Network { public String getIp6Cidr() { return ip6Cidr; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.Network; + } } diff --git a/api/src/com/cloud/network/vpc/StaticRouteProfile.java b/api/src/com/cloud/network/vpc/StaticRouteProfile.java index 05cff4986a2..b38d5ea15a8 100644 --- a/api/src/com/cloud/network/vpc/StaticRouteProfile.java +++ b/api/src/com/cloud/network/vpc/StaticRouteProfile.java @@ -16,6 +16,8 @@ // under the License. package com.cloud.network.vpc; +import org.apache.cloudstack.acl.IAMEntityType; + public class StaticRouteProfile implements StaticRoute { private long id; private String uuid; @@ -31,18 +33,18 @@ public class StaticRouteProfile implements StaticRoute { String ipAddress; public StaticRouteProfile(StaticRoute staticRoute, VpcGateway gateway) { - this.id = staticRoute.getId(); - this.uuid = staticRoute.getUuid(); - this.targetCidr = staticRoute.getCidr(); - this.accountId = staticRoute.getAccountId(); - this.domainId = staticRoute.getDomainId(); - this.gatewayId = staticRoute.getVpcGatewayId(); - this.state = staticRoute.getState(); - this.vpcId = staticRoute.getVpcId(); - this.vlanTag = gateway.getBroadcastUri(); + id = staticRoute.getId(); + uuid = staticRoute.getUuid(); + targetCidr = staticRoute.getCidr(); + accountId = staticRoute.getAccountId(); + domainId = staticRoute.getDomainId(); + gatewayId = staticRoute.getVpcGatewayId(); + state = staticRoute.getState(); + vpcId = staticRoute.getVpcId(); + vlanTag = gateway.getBroadcastUri(); this.gateway = gateway.getGateway(); - this.netmask = gateway.getNetmask(); - this.ipAddress = gateway.getIp4Address(); + netmask = gateway.getNetmask(); + ipAddress = gateway.getIp4Address(); } @Override @@ -101,4 +103,8 @@ public class StaticRouteProfile implements StaticRoute { return netmask; } + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.StaticRoute; + } } diff --git a/api/src/org/apache/cloudstack/acl/ControlledEntity.java b/api/src/org/apache/cloudstack/acl/ControlledEntity.java index 59575768011..2572705daaf 100644 --- a/api/src/org/apache/cloudstack/acl/ControlledEntity.java +++ b/api/src/org/apache/cloudstack/acl/ControlledEntity.java @@ -29,4 +29,5 @@ public interface ControlledEntity extends OwnedBy, PartOf { Account, Domain } + IAMEntityType getEntityType(); } diff --git a/api/src/org/apache/cloudstack/acl/IAMEntityType.java b/api/src/org/apache/cloudstack/acl/IAMEntityType.java new file mode 100644 index 00000000000..9299ae9ae0c --- /dev/null +++ b/api/src/org/apache/cloudstack/acl/IAMEntityType.java @@ -0,0 +1,45 @@ +package org.apache.cloudstack.acl; + +public enum IAMEntityType { + // currently supported entity, to be added one by one after we support acl on the entity + VirtualMachine, + Volume, + ResourceTag, + Account, + AffinityGroup, + AutoScalePolicy, + AutoScaleVmGroup, + AutoScaleVmProfile, + Condition, + Vpc, + VpcGateway, + PrivateGateway, + VpnUser, + VMSnapshot, + VirtualMachineTemplate, + UserIpv6Address, + StaticRoute, + SSHKeyPair, + Snapshot, + Site2SiteVpnGateway, + Site2SiteVpnConnection, + Site2SiteCustomerGateway, + SecurityGroup, + RemoteAccessVpn, + PublicIpAddress, + ProjectInvitation, + NicSecondaryIp, + NicIpAlias, + Network, + IpAddress, + InstanceGroup, + GlobalLoadBalancerRule, + FirewallRule, + PortForwardingRule, + Event, + AsyncJob, + IAMPolicy, + IAMGroup, + MonitorService, + SSLCert +} diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java index ca787550f64..d15ea4ba5d1 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateEgressFirewallRuleCmd.java @@ -20,6 +20,9 @@ package org.apache.cloudstack.api.command.user.firewall; import java.util.ArrayList; import java.util.List; +import org.apache.log4j.Logger; + +import org.apache.cloudstack.acl.IAMEntityType; import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; @@ -32,7 +35,6 @@ import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.FirewallResponse; import org.apache.cloudstack.api.response.NetworkResponse; import org.apache.cloudstack.context.CallContext; -import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; @@ -275,7 +277,7 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F @Override public String getEventDescription() { Network network = _networkService.getNetwork(networkId); - return ("Creating firewall rule for network: " + network + " for protocol:" + this.getProtocol()); + return ("Creating firewall rule for network: " + network + " for protocol:" + getProtocol()); } @Override @@ -354,4 +356,9 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F } } + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.FirewallRule; + } + } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java index 0b342f2f620..76c6e74380e 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreateFirewallRuleCmd.java @@ -19,6 +19,9 @@ package org.apache.cloudstack.api.command.user.firewall; import java.util.ArrayList; import java.util.List; +import org.apache.log4j.Logger; + +import org.apache.cloudstack.acl.IAMEntityType; import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; @@ -31,7 +34,6 @@ import org.apache.cloudstack.api.ServerApiException; import org.apache.cloudstack.api.response.FirewallResponse; import org.apache.cloudstack.api.response.IPAddressResponse; import org.apache.cloudstack.context.CallContext; -import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; @@ -266,7 +268,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal @Override public String getEventDescription() { IpAddress ip = _networkService.getIp(ipAddressId); - return ("Creating firewall rule for Ip: " + ip.getAddress() + " for protocol:" + this.getProtocol()); + return ("Creating firewall rule for Ip: " + ip.getAddress() + " for protocol:" + getProtocol()); } @Override @@ -346,4 +348,10 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal return true; } } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.FirewallRule; + } + } diff --git a/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java index 61d585656aa..53945a64d73 100644 --- a/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/firewall/CreatePortForwardingRuleCmd.java @@ -18,6 +18,9 @@ package org.apache.cloudstack.api.command.user.firewall; import java.util.List; +import org.apache.log4j.Logger; + +import org.apache.cloudstack.acl.IAMEntityType; import org.apache.cloudstack.acl.RoleType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; @@ -32,7 +35,6 @@ import org.apache.cloudstack.api.response.IPAddressResponse; import org.apache.cloudstack.api.response.NetworkResponse; import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.context.CallContext; -import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; @@ -428,4 +430,10 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P return true; } } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.FirewallRule; + } + } diff --git a/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java index 70be1677a41..77edbfccca8 100644 --- a/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java +++ b/api/src/org/apache/cloudstack/api/command/user/nat/CreateIpForwardingRuleCmd.java @@ -18,6 +18,9 @@ package org.apache.cloudstack.api.command.user.nat; import java.util.List; +import org.apache.log4j.Logger; + +import org.apache.cloudstack.acl.IAMEntityType; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiConstants; @@ -30,7 +33,6 @@ import org.apache.cloudstack.api.response.FirewallRuleResponse; import org.apache.cloudstack.api.response.IPAddressResponse; import org.apache.cloudstack.api.response.IpForwardingRuleResponse; import org.apache.cloudstack.context.CallContext; -import org.apache.log4j.Logger; import com.cloud.event.EventTypes; import com.cloud.exception.InvalidParameterValueException; @@ -126,7 +128,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false); IpForwardingRuleResponse fwResponse = _responseGenerator.createIpForwardingRuleResponse(staticNatRule); fwResponse.setResponseName(getCommandName()); - this.setResponseObject(fwResponse); + setResponseObject(fwResponse); } finally { if (!result || rule == null) { @@ -152,8 +154,8 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta try { StaticNatRule rule = _rulesService.createStaticNatRule(this, getOpenFirewall()); - this.setEntityId(rule.getId()); - this.setEntityUuid(rule.getUuid()); + setEntityId(rule.getId()); + setEntityUuid(rule.getUuid()); } catch (NetworkRuleConflictException e) { s_logger.info("Unable to create Static Nat Rule due to ", e); throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage()); @@ -179,7 +181,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta @Override public String getEventDescription() { IpAddress ip = _networkService.getIp(ipAddressId); - return ("Applying an ipforwarding 1:1 NAT rule for Ip: " + ip.getAddress() + " with virtual machine:" + this.getVirtualMachineId()); + return ("Applying an ipforwarding 1:1 NAT rule for Ip: " + ip.getAddress() + " with virtual machine:" + getVirtualMachineId()); } private long getVirtualMachineId() { @@ -321,4 +323,10 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta public boolean isDisplay() { return true; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.FirewallRule; + } + } diff --git a/engine/components-api/src/com/cloud/network/addr/PublicIp.java b/engine/components-api/src/com/cloud/network/addr/PublicIp.java index 9a1b66324f0..12e4d34e158 100644 --- a/engine/components-api/src/com/cloud/network/addr/PublicIp.java +++ b/engine/components-api/src/com/cloud/network/addr/PublicIp.java @@ -18,6 +18,8 @@ package com.cloud.network.addr; import java.util.Date; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.dc.VlanVO; import com.cloud.network.PublicIpAddress; import com.cloud.network.dao.IPAddressVO; @@ -236,4 +238,9 @@ public class PublicIp implements PublicIpAddress { public boolean isDisplay() { return _addr.isDisplay(); } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.PublicIpAddress; + } } diff --git a/engine/components-api/src/com/cloud/network/rules/StaticNatRuleImpl.java b/engine/components-api/src/com/cloud/network/rules/StaticNatRuleImpl.java index 7104715e482..bdaf2bc1b20 100644 --- a/engine/components-api/src/com/cloud/network/rules/StaticNatRuleImpl.java +++ b/engine/components-api/src/com/cloud/network/rules/StaticNatRuleImpl.java @@ -18,6 +18,8 @@ package com.cloud.network.rules; import java.util.List; +import org.apache.cloudstack.acl.IAMEntityType; + public class StaticNatRuleImpl implements StaticNatRule { long id; String xid; @@ -34,19 +36,19 @@ public class StaticNatRuleImpl implements StaticNatRule { boolean forDisplay; public StaticNatRuleImpl(FirewallRuleVO rule, String dstIp) { - this.id = rule.getId(); - this.xid = rule.getXid(); - this.uuid = rule.getUuid(); - this.protocol = rule.getProtocol(); - this.portStart = rule.getSourcePortStart(); - this.portEnd = rule.getSourcePortEnd(); - this.state = rule.getState(); - this.accountId = rule.getAccountId(); - this.domainId = rule.getDomainId(); - this.networkId = rule.getNetworkId(); - this.sourceIpAddressId = rule.getSourceIpAddressId(); - this.destIpAddress = dstIp; - this.forDisplay = rule.isDisplay(); + id = rule.getId(); + xid = rule.getXid(); + uuid = rule.getUuid(); + protocol = rule.getProtocol(); + portStart = rule.getSourcePortStart(); + portEnd = rule.getSourcePortEnd(); + state = rule.getState(); + accountId = rule.getAccountId(); + domainId = rule.getDomainId(); + networkId = rule.getNetworkId(); + sourceIpAddressId = rule.getSourceIpAddressId(); + destIpAddress = dstIp; + forDisplay = rule.isDisplay(); } @Override @@ -148,4 +150,9 @@ public class StaticNatRuleImpl implements StaticNatRule { public boolean isDisplay() { return forDisplay; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.FirewallRule; + } } diff --git a/engine/schema/src/com/cloud/event/EventVO.java b/engine/schema/src/com/cloud/event/EventVO.java index 91174fcbd33..6fecaa61452 100644 --- a/engine/schema/src/com/cloud/event/EventVO.java +++ b/engine/schema/src/com/cloud/event/EventVO.java @@ -29,6 +29,8 @@ import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Transient; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.utils.db.GenericDao; @Entity @@ -87,7 +89,7 @@ public class EventVO implements Event { public static final String LEVEL_ERROR = "ERROR"; public EventVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } @Override @@ -196,7 +198,7 @@ public class EventVO implements Event { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -219,4 +221,10 @@ public class EventVO implements Event { public void setDisplayEventEnabled(boolean displayEventEnabled) { isDisplayEventEnabled = displayEventEnabled; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.Event; + } + } diff --git a/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java b/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java index 3098a68c27c..93149936200 100644 --- a/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java +++ b/engine/schema/src/com/cloud/network/UserIpv6AddressVO.java @@ -28,6 +28,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.utils.db.GenericDao; @Entity @@ -76,16 +78,16 @@ public class UserIpv6AddressVO implements UserIpv6Address { Date created; protected UserIpv6AddressVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public UserIpv6AddressVO(String address, long dataCenterId, String macAddress, long vlanDbId) { this.address = address; this.dataCenterId = dataCenterId; - this.vlanId = vlanDbId; - this.state = State.Free; - this.setMacAddress(macAddress); - this.uuid = UUID.randomUUID().toString(); + vlanId = vlanDbId; + state = State.Free; + setMacAddress(macAddress); + uuid = UUID.randomUUID().toString(); } @Override @@ -184,4 +186,9 @@ public class UserIpv6AddressVO implements UserIpv6Address { public void setCreated(Date created) { this.created = created; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.UserIpv6Address; + } } diff --git a/engine/schema/src/com/cloud/network/VpnUserVO.java b/engine/schema/src/com/cloud/network/VpnUserVO.java index 07b6326e768..695aac0a9d2 100644 --- a/engine/schema/src/com/cloud/network/VpnUserVO.java +++ b/engine/schema/src/com/cloud/network/VpnUserVO.java @@ -27,6 +27,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.utils.db.Encrypt; @Entity @@ -58,16 +60,16 @@ public class VpnUserVO implements VpnUser { private String uuid; public VpnUserVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public VpnUserVO(long accountId, long domainId, String userName, String password) { this.accountId = accountId; this.domainId = domainId; - this.username = userName; + username = userName; this.password = password; - this.state = State.Add; - this.uuid = UUID.randomUUID().toString(); + state = State.Add; + uuid = UUID.randomUUID().toString(); } @Override @@ -86,7 +88,7 @@ public class VpnUserVO implements VpnUser { } public void setUsername(String userName) { - this.username = userName; + username = userName; } @Override @@ -119,10 +121,15 @@ public class VpnUserVO implements VpnUser { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { this.uuid = uuid; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.VpnUser; + } } diff --git a/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java b/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java index b69907c51c3..bde38f83d94 100644 --- a/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java +++ b/engine/schema/src/com/cloud/network/as/AutoScalePolicyVO.java @@ -30,6 +30,7 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import org.apache.cloudstack.acl.IAMEntityType; import org.apache.cloudstack.api.InternalIdentity; import com.cloud.utils.db.GenericDao; @@ -77,7 +78,7 @@ public class AutoScalePolicyVO implements AutoScalePolicy, InternalIdentity { public AutoScalePolicyVO(long domainId, long accountId, int duration, int quietTime, Date lastQuiteTime, String action) { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.domainId = domainId; this.accountId = accountId; this.duration = duration; @@ -150,4 +151,10 @@ public class AutoScalePolicyVO implements AutoScalePolicy, InternalIdentity { public void setLastQuiteTime(Date lastQuiteTime) { this.lastQuiteTime = lastQuiteTime; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.AutoScalePolicy; + } + } diff --git a/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java b/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java index 6694f64ec86..89d079dde0c 100644 --- a/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java +++ b/engine/schema/src/com/cloud/network/as/AutoScaleVmGroupVO.java @@ -30,6 +30,7 @@ import javax.persistence.Table; import javax.persistence.Temporal; import javax.persistence.TemporalType; +import org.apache.cloudstack.acl.IAMEntityType; import org.apache.cloudstack.api.InternalIdentity; import com.cloud.utils.db.GenericDao; @@ -97,8 +98,8 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity { long accountId, int minMembers, int maxMembers, int memberPort, int interval, Date lastInterval, long profileId, String state) { - this.uuid = UUID.randomUUID().toString(); - this.loadBalancerId = lbRuleId; + uuid = UUID.randomUUID().toString(); + loadBalancerId = lbRuleId; this.minMembers = minMembers; this.maxMembers = maxMembers; this.memberPort = memberPort; @@ -224,4 +225,10 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity { public boolean isDisplay() { return display; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.AutoScaleVmGroup; + } + } diff --git a/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java b/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java index 40dbe905508..0b59394ddd8 100644 --- a/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java +++ b/engine/schema/src/com/cloud/network/as/AutoScaleVmProfileVO.java @@ -33,6 +33,7 @@ import javax.persistence.Inheritance; import javax.persistence.InheritanceType; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.InternalIdentity; @@ -94,7 +95,7 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter public AutoScaleVmProfileVO(long zoneId, long domainId, long accountId, long serviceOfferingId, long templateId, String otherDeployParams, Map counterParamList, Integer destroyVmGraceperiod, long autoscaleUserId) { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.zoneId = zoneId; this.domainId = domainId; this.accountId = accountId; @@ -149,7 +150,7 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter } public void setCounterParams(String counterParam) { - this.counterParams = counterParam; + counterParams = counterParam; } public void setCounterParamsForUpdate(Map counterParamList) { @@ -232,4 +233,10 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter public boolean isDisplay() { return display; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.AutoScaleVmProfile; + } + } diff --git a/engine/schema/src/com/cloud/network/as/ConditionVO.java b/engine/schema/src/com/cloud/network/as/ConditionVO.java index 8d7e776c89f..e8c1d0bc598 100644 --- a/engine/schema/src/com/cloud/network/as/ConditionVO.java +++ b/engine/schema/src/com/cloud/network/as/ConditionVO.java @@ -29,6 +29,7 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.InternalIdentity; @@ -77,7 +78,7 @@ public class ConditionVO implements Condition, Identity, InternalIdentity { this.relationalOperator = relationalOperator; this.accountId = accountId; this.domainId = domainId; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public Date getCreated() { @@ -121,10 +122,16 @@ public class ConditionVO implements Condition, Identity, InternalIdentity { @Override public String getUuid() { - return this.uuid; + return uuid; } public Date getRemoved() { return removed; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.Condition; + } + } diff --git a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java index 9abecbef05b..d06b8c51d7b 100644 --- a/engine/schema/src/com/cloud/network/dao/IPAddressVO.java +++ b/engine/schema/src/com/cloud/network/dao/IPAddressVO.java @@ -31,6 +31,8 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.network.IpAddress; import com.cloud.utils.net.Ip; @@ -118,7 +120,7 @@ public class IPAddressVO implements IpAddress { protected boolean display = true; protected IPAddressVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } @Override @@ -129,26 +131,26 @@ public class IPAddressVO implements IpAddress { public IPAddressVO(Ip address, long dataCenterId, long macAddress, long vlanDbId, boolean sourceNat) { this.address = address; this.dataCenterId = dataCenterId; - this.vlanId = vlanDbId; + vlanId = vlanDbId; this.sourceNat = sourceNat; - this.allocatedInDomainId = null; - this.allocatedToAccountId = null; - this.allocatedTime = null; - this.state = State.Free; + allocatedInDomainId = null; + allocatedToAccountId = null; + allocatedTime = null; + state = State.Free; this.macAddress = macAddress; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public IPAddressVO(Ip address, long dataCenterId, Long networkId, Long vpcId, long physicalNetworkId, long sourceNetworkId, long vlanDbId, boolean portable) { this.address = address; this.dataCenterId = dataCenterId; - this.associatedWithNetworkId = networkId; + associatedWithNetworkId = networkId; this.vpcId = vpcId; this.physicalNetworkId = physicalNetworkId; this.sourceNetworkId = sourceNetworkId; - this.vlanId = vlanDbId; + vlanId = vlanDbId; this.portable = portable; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public long getMacAddress() { @@ -161,7 +163,7 @@ public class IPAddressVO implements IpAddress { } public void setDataCenterId(long dcId) { - this.dataCenterId = dcId; + dataCenterId = dcId; } @Override @@ -185,7 +187,7 @@ public class IPAddressVO implements IpAddress { } public void setAssociatedWithNetworkId(Long networkId) { - this.associatedWithNetworkId = networkId; + associatedWithNetworkId = networkId; } @Override @@ -203,11 +205,11 @@ public class IPAddressVO implements IpAddress { } public void setAllocatedToAccountId(Long accountId) { - this.allocatedToAccountId = accountId; + allocatedToAccountId = accountId; } public void setAllocatedInDomainId(Long domainId) { - this.allocatedInDomainId = domainId; + allocatedInDomainId = domainId; } public void setSourceNat(boolean sourceNat) { @@ -220,16 +222,16 @@ public class IPAddressVO implements IpAddress { } public void setAllocatedTime(Date allocated) { - this.allocatedTime = allocated; + allocatedTime = allocated; } @Override public long getVlanId() { - return this.vlanId; + return vlanId; } public void setVlanId(long vlanDbId) { - this.vlanId = vlanDbId; + vlanId = vlanDbId; } @Override @@ -281,7 +283,7 @@ public class IPAddressVO implements IpAddress { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -303,7 +305,7 @@ public class IPAddressVO implements IpAddress { } public void setSystem(boolean isSystem) { - this.system = isSystem; + system = isSystem; } @Override @@ -346,4 +348,9 @@ public class IPAddressVO implements IpAddress { public void setDisplay(boolean display) { this.display = display; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.IpAddress; + } } diff --git a/engine/schema/src/com/cloud/network/dao/MonitoringServiceVO.java b/engine/schema/src/com/cloud/network/dao/MonitoringServiceVO.java index f9967ec486c..999fdfc649b 100644 --- a/engine/schema/src/com/cloud/network/dao/MonitoringServiceVO.java +++ b/engine/schema/src/com/cloud/network/dao/MonitoringServiceVO.java @@ -25,6 +25,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.network.MonitoringService; @Entity @@ -116,4 +118,9 @@ public class MonitoringServiceVO implements MonitoringService { public String getProcessName() { return processName; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.MonitorService; + } } diff --git a/engine/schema/src/com/cloud/network/dao/NetworkVO.java b/engine/schema/src/com/cloud/network/dao/NetworkVO.java index f3776df89b8..13e8dbff09e 100644 --- a/engine/schema/src/com/cloud/network/dao/NetworkVO.java +++ b/engine/schema/src/com/cloud/network/dao/NetworkVO.java @@ -30,6 +30,7 @@ import javax.persistence.TableGenerator; import javax.persistence.Transient; import org.apache.cloudstack.acl.ControlledEntity; +import org.apache.cloudstack.acl.IAMEntityType; import com.cloud.network.Network; import com.cloud.network.Networks.BroadcastDomainType; @@ -167,7 +168,7 @@ public class NetworkVO implements Network { Long networkACLId; public NetworkVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } /** @@ -193,8 +194,8 @@ public class NetworkVO implements Network { } else { this.state = state; } - this.id = -1; - this.uuid = UUID.randomUUID().toString(); + id = -1; + uuid = UUID.randomUUID().toString(); } public NetworkVO(long id, Network that, long offeringId, String guruName, long domainId, long accountId, long related, String name, String displayText, @@ -216,19 +217,19 @@ public class NetworkVO implements Network { aclType, specifyIpRanges, vpcId); - this.gateway = that.getGateway(); - this.cidr = that.getCidr(); - this.networkCidr = that.getNetworkCidr(); - this.broadcastUri = that.getBroadcastUri(); - this.broadcastDomainType = that.getBroadcastDomainType(); + gateway = that.getGateway(); + cidr = that.getCidr(); + networkCidr = that.getNetworkCidr(); + broadcastUri = that.getBroadcastUri(); + broadcastDomainType = that.getBroadcastDomainType(); this.guruName = guruName; - this.state = that.getState(); + state = that.getState(); if (state == null) { state = State.Allocated; } - this.uuid = UUID.randomUUID().toString(); - this.ip6Gateway = that.getIp6Gateway(); - this.ip6Cidr = that.getIp6Cidr(); + uuid = UUID.randomUUID().toString(); + ip6Gateway = that.getIp6Gateway(); + ip6Cidr = that.getIp6Cidr(); } /** @@ -260,7 +261,7 @@ public class NetworkVO implements Network { this.displayText = displayText; this.aclType = aclType; this.networkDomain = networkDomain; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.guestType = guestType; this.specifyIpRanges = specifyIpRanges; this.vpcId = vpcId; @@ -436,7 +437,7 @@ public class NetworkVO implements Network { } public void setDns1(String dns) { - this.dns1 = dns; + dns1 = dns; } public String getDns2() { @@ -444,7 +445,7 @@ public class NetworkVO implements Network { } public void setDns2(String dns) { - this.dns2 = dns; + dns2 = dns; } @Override @@ -492,19 +493,19 @@ public class NetworkVO implements Network { return false; } NetworkVO that = (NetworkVO)obj; - if (this.trafficType != that.trafficType) { + if (trafficType != that.trafficType) { return false; } - if ((this.cidr == null && that.cidr != null) || (this.cidr != null && that.cidr == null)) { + if ((cidr == null && that.cidr != null) || (cidr != null && that.cidr == null)) { return false; } - if (this.cidr == null && that.cidr == null) { + if (cidr == null && that.cidr == null) { return true; } - return NetUtils.isNetworkAWithinNetworkB(this.cidr, that.cidr); + return NetUtils.isNetworkAWithinNetworkB(cidr, that.cidr); } @Override @@ -516,7 +517,7 @@ public class NetworkVO implements Network { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -583,4 +584,9 @@ public class NetworkVO implements Network { public Long getNetworkACLId() { return networkACLId; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.Network; + } } diff --git a/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java b/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java index 3d416f2ddf2..827b59bd457 100644 --- a/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java +++ b/engine/schema/src/com/cloud/network/dao/RemoteAccessVpnVO.java @@ -25,6 +25,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.network.RemoteAccessVpn; @Entity @@ -69,19 +71,19 @@ public class RemoteAccessVpnVO implements RemoteAccessVpn { protected boolean display = true; public RemoteAccessVpnVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public RemoteAccessVpnVO(long accountId, long domainId, Long networkId, long publicIpId, Long vpcId, String localIp, String ipRange, String presharedKey) { this.accountId = accountId; - this.serverAddressId = publicIpId; + serverAddressId = publicIpId; this.ipRange = ipRange; - this.ipsecPresharedKey = presharedKey; + ipsecPresharedKey = presharedKey; this.localIp = localIp; this.domainId = domainId; this.networkId = networkId; - this.state = State.Added; - this.uuid = UUID.randomUUID().toString(); + state = State.Added; + uuid = UUID.randomUUID().toString(); this.vpcId = vpcId; } @@ -164,4 +166,9 @@ public class RemoteAccessVpnVO implements RemoteAccessVpn { public boolean isDisplay() { return display; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.RemoteAccessVpn; + } } diff --git a/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java b/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java index c922855d53d..4a32b316676 100644 --- a/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java +++ b/engine/schema/src/com/cloud/network/dao/Site2SiteCustomerGatewayVO.java @@ -26,6 +26,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.network.Site2SiteCustomerGateway; import com.cloud.utils.db.Encrypt; import com.cloud.utils.db.GenericDao; @@ -92,7 +94,7 @@ public class Site2SiteCustomerGatewayVO implements Site2SiteCustomerGateway { this.ikeLifetime = ikeLifetime; this.espLifetime = espLifetime; this.dpd = dpd; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.accountId = accountId; this.domainId = domainId; } @@ -206,4 +208,9 @@ public class Site2SiteCustomerGatewayVO implements Site2SiteCustomerGateway { public long getAccountId() { return accountId; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.Site2SiteCustomerGateway; + } } diff --git a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionVO.java b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionVO.java index beba999b407..c515fc26173 100644 --- a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionVO.java +++ b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnConnectionVO.java @@ -28,6 +28,7 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; import org.apache.cloudstack.api.InternalIdentity; import com.cloud.network.Site2SiteVpnConnection; @@ -76,10 +77,10 @@ public class Site2SiteVpnConnectionVO implements Site2SiteVpnConnection, Interna } public Site2SiteVpnConnectionVO(long accountId, long domainId, long vpnGatewayId, long customerGatewayId, boolean passive) { - this.uuid = UUID.randomUUID().toString(); - this.setVpnGatewayId(vpnGatewayId); - this.setCustomerGatewayId(customerGatewayId); - this.setState(State.Pending); + uuid = UUID.randomUUID().toString(); + setVpnGatewayId(vpnGatewayId); + setCustomerGatewayId(customerGatewayId); + setState(State.Pending); this.accountId = accountId; this.domainId = domainId; this.passive = passive; @@ -171,4 +172,9 @@ public class Site2SiteVpnConnectionVO implements Site2SiteVpnConnection, Interna public boolean isDisplay() { return display; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.Site2SiteVpnConnection; + } } diff --git a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnGatewayVO.java b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnGatewayVO.java index 226f608d9bc..c465334135e 100644 --- a/engine/schema/src/com/cloud/network/dao/Site2SiteVpnGatewayVO.java +++ b/engine/schema/src/com/cloud/network/dao/Site2SiteVpnGatewayVO.java @@ -26,6 +26,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.network.Site2SiteVpnGateway; import com.cloud.utils.db.GenericDao; @@ -62,9 +64,9 @@ public class Site2SiteVpnGatewayVO implements Site2SiteVpnGateway { } public Site2SiteVpnGatewayVO(long accountId, long domainId, long addrId, long vpcId) { - this.uuid = UUID.randomUUID().toString(); - this.setAddrId(addrId); - this.setVpcId(vpcId); + uuid = UUID.randomUUID().toString(); + setAddrId(addrId); + setVpcId(vpcId); this.accountId = accountId; this.domainId = domainId; } @@ -128,4 +130,9 @@ public class Site2SiteVpnGatewayVO implements Site2SiteVpnGateway { public boolean isDisplay() { return display; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.Site2SiteVpnGateway; + } } diff --git a/engine/schema/src/com/cloud/network/dao/SslCertVO.java b/engine/schema/src/com/cloud/network/dao/SslCertVO.java index 7d73f49daed..6ef7afd1c70 100644 --- a/engine/schema/src/com/cloud/network/dao/SslCertVO.java +++ b/engine/schema/src/com/cloud/network/dao/SslCertVO.java @@ -23,6 +23,8 @@ import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.network.lb.SslCert; import com.cloud.utils.db.Encrypt; @@ -61,18 +63,18 @@ public class SslCertVO implements SslCert { String fingerPrint; public SslCertVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public SslCertVO(String cert, String key, String password, String chain, Long accountId, Long domainId, String fingerPrint) { - this.certificate = cert; + certificate = cert; this.key = key; this.chain = chain; this.password = password; this.accountId = accountId; this.domainId = domainId; this.fingerPrint = fingerPrint; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } // Getters @@ -120,4 +122,10 @@ public class SslCertVO implements SslCert { public String getFingerPrint() { return fingerPrint; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.SSLCert; + } + } \ No newline at end of file diff --git a/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java b/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java index 4fa751d6e22..0acc24a0aef 100644 --- a/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java +++ b/engine/schema/src/com/cloud/network/rules/FirewallRuleVO.java @@ -34,6 +34,8 @@ import javax.persistence.InheritanceType; import javax.persistence.Table; import javax.persistence.Transient; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.utils.db.GenericDao; import com.cloud.utils.net.NetUtils; @@ -191,7 +193,7 @@ public class FirewallRuleVO implements FirewallRule { } protected FirewallRuleVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public FirewallRuleVO(String xId, Long ipAddressId, Integer portStart, Integer portEnd, String protocol, long networkId, long accountId, long domainId, @@ -202,13 +204,13 @@ public class FirewallRuleVO implements FirewallRule { } this.accountId = accountId; this.domainId = domainId; - this.sourceIpAddressId = ipAddressId; - this.sourcePortStart = portStart; - this.sourcePortEnd = portEnd; + sourceIpAddressId = ipAddressId; + sourcePortStart = portStart; + sourcePortEnd = portEnd; this.protocol = protocol; this.purpose = purpose; this.networkId = networkId; - this.state = State.Staged; + state = State.Staged; this.icmpCode = icmpCode; this.icmpType = icmpType; this.sourceCidrs = sourceCidrs; @@ -218,8 +220,8 @@ public class FirewallRuleVO implements FirewallRule { } this.related = related; - this.uuid = UUID.randomUUID().toString(); - this.type = FirewallRuleType.User; + uuid = UUID.randomUUID().toString(); + type = FirewallRuleType.User; this.trafficType = trafficType; } @@ -256,7 +258,7 @@ public class FirewallRuleVO implements FirewallRule { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -280,4 +282,10 @@ public class FirewallRuleVO implements FirewallRule { public boolean isDisplay() { return display; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.FirewallRule; + } + } diff --git a/engine/schema/src/com/cloud/network/security/SecurityGroupVO.java b/engine/schema/src/com/cloud/network/security/SecurityGroupVO.java index df8427c1fbf..26859f704e8 100644 --- a/engine/schema/src/com/cloud/network/security/SecurityGroupVO.java +++ b/engine/schema/src/com/cloud/network/security/SecurityGroupVO.java @@ -25,6 +25,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + @Entity @Table(name = ("security_group")) public class SecurityGroupVO implements SecurityGroup { @@ -49,7 +51,7 @@ public class SecurityGroupVO implements SecurityGroup { private String uuid; public SecurityGroupVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public SecurityGroupVO(String name, String description, long domainId, long accountId) { @@ -57,7 +59,7 @@ public class SecurityGroupVO implements SecurityGroup { this.description = description; this.domainId = domainId; this.accountId = accountId; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } @Override @@ -87,10 +89,15 @@ public class SecurityGroupVO implements SecurityGroup { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { this.uuid = uuid; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.SecurityGroup; + } } diff --git a/engine/schema/src/com/cloud/network/vpc/StaticRouteVO.java b/engine/schema/src/com/cloud/network/vpc/StaticRouteVO.java index 08e39656c4d..a9ba05154b4 100644 --- a/engine/schema/src/com/cloud/network/vpc/StaticRouteVO.java +++ b/engine/schema/src/com/cloud/network/vpc/StaticRouteVO.java @@ -28,6 +28,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.utils.db.GenericDao; @Entity @@ -64,7 +66,7 @@ public class StaticRouteVO implements StaticRoute { Date created; protected StaticRouteVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } /** @@ -78,11 +80,11 @@ public class StaticRouteVO implements StaticRoute { super(); this.vpcGatewayId = vpcGatewayId; this.cidr = cidr; - this.state = State.Staged; + state = State.Staged; this.vpcId = vpcId; this.accountId = accountId; this.domainId = domainId; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } @Override @@ -107,7 +109,7 @@ public class StaticRouteVO implements StaticRoute { @Override public String getUuid() { - return this.uuid; + return uuid; } @Override @@ -135,4 +137,9 @@ public class StaticRouteVO implements StaticRoute { buf.append(uuid).append("|").append(cidr).append("|").append(vpcGatewayId).append("]"); return buf.toString(); } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.StaticRoute; + } } \ No newline at end of file diff --git a/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java b/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java index 5f156607889..48238b19719 100644 --- a/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java +++ b/engine/schema/src/com/cloud/network/vpc/VpcGatewayVO.java @@ -28,6 +28,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.utils.db.GenericDao; @Entity @@ -90,7 +92,7 @@ public class VpcGatewayVO implements VpcGateway { long networkACLId; protected VpcGatewayVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } /** @@ -117,10 +119,10 @@ public class VpcGatewayVO implements VpcGateway { this.broadcastUri = broadcastUri; this.gateway = gateway; this.netmask = netmask; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.accountId = accountId; this.domainId = domainId; - this.state = State.Creating; + state = State.Creating; this.sourceNat = sourceNat; this.networkACLId = networkACLId; @@ -128,7 +130,7 @@ public class VpcGatewayVO implements VpcGateway { @Override public String getUuid() { - return this.uuid; + return uuid; } @Override @@ -204,7 +206,7 @@ public class VpcGatewayVO implements VpcGateway { @Override public boolean getSourceNat() { - return this.sourceNat; + return sourceNat; } public void setNetworkACLId(long networkACLId) { @@ -215,4 +217,9 @@ public class VpcGatewayVO implements VpcGateway { public long getNetworkACLId() { return networkACLId; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.VpcGateway; + } } diff --git a/engine/schema/src/com/cloud/network/vpc/VpcVO.java b/engine/schema/src/com/cloud/network/vpc/VpcVO.java index 7d1933a6727..d1cfd7c1a1e 100644 --- a/engine/schema/src/com/cloud/network/vpc/VpcVO.java +++ b/engine/schema/src/com/cloud/network/vpc/VpcVO.java @@ -26,6 +26,8 @@ import javax.persistence.Enumerated; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.utils.db.GenericDao; @Entity @@ -80,7 +82,7 @@ public class VpcVO implements Vpc { protected boolean display = true; public VpcVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public VpcVO(long zoneId, String name, String displayText, long accountId, long domainId, long vpcOffId, String cidr, String networkDomain) { @@ -90,10 +92,10 @@ public class VpcVO implements Vpc { this.accountId = accountId; this.domainId = domainId; this.cidr = cidr; - this.uuid = UUID.randomUUID().toString(); - this.state = State.Enabled; + uuid = UUID.randomUUID().toString(); + state = State.Enabled; this.networkDomain = networkDomain; - this.vpcOfferingId = vpcOffId; + vpcOfferingId = vpcOffId; } @Override @@ -194,4 +196,9 @@ public class VpcVO implements Vpc { public boolean isDisplay() { return display; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.Vpc; + } } diff --git a/engine/schema/src/com/cloud/projects/ProjectInvitationVO.java b/engine/schema/src/com/cloud/projects/ProjectInvitationVO.java index 6136862f25c..885c148c2b4 100644 --- a/engine/schema/src/com/cloud/projects/ProjectInvitationVO.java +++ b/engine/schema/src/com/cloud/projects/ProjectInvitationVO.java @@ -28,6 +28,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.utils.db.GenericDao; @Entity @@ -64,16 +66,16 @@ public class ProjectInvitationVO implements ProjectInvitation { private String uuid; protected ProjectInvitationVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public ProjectInvitationVO(long projectId, Long accountId, Long domainId, String email, String token) { - this.forAccountId = accountId; - this.inDomainId = domainId; + forAccountId = accountId; + inDomainId = domainId; this.projectId = projectId; this.email = email; this.token = token; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } @Override @@ -129,7 +131,7 @@ public class ProjectInvitationVO implements ProjectInvitation { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -145,4 +147,9 @@ public class ProjectInvitationVO implements ProjectInvitation { public long getAccountId() { return forAccountId == null ? -1 : forAccountId; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.ProjectInvitation; + } } diff --git a/engine/schema/src/com/cloud/storage/SnapshotVO.java b/engine/schema/src/com/cloud/storage/SnapshotVO.java index 85216369c08..4c8ceb7cdd1 100644 --- a/engine/schema/src/com/cloud/storage/SnapshotVO.java +++ b/engine/schema/src/com/cloud/storage/SnapshotVO.java @@ -30,6 +30,8 @@ import javax.persistence.Table; import com.google.gson.annotations.Expose; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.utils.db.GenericDao; @@ -93,12 +95,12 @@ public class SnapshotVO implements Snapshot { String uuid; public SnapshotVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public SnapshotVO(long dcId, long accountId, long domainId, Long volumeId, Long diskOfferingId, String name, short snapshotType, String typeDescription, long size, HypervisorType hypervisorType) { - this.dataCenterId = dcId; + dataCenterId = dcId; this.accountId = accountId; this.domainId = domainId; this.volumeId = volumeId; @@ -107,10 +109,10 @@ public class SnapshotVO implements Snapshot { this.snapshotType = snapshotType; this.typeDescription = typeDescription; this.size = size; - this.state = State.Allocated; + state = State.Allocated; this.hypervisorType = hypervisorType; - this.version = "2.2"; - this.uuid = UUID.randomUUID().toString(); + version = "2.2"; + uuid = UUID.randomUUID().toString(); } @Override @@ -229,10 +231,15 @@ public class SnapshotVO implements Snapshot { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { this.uuid = uuid; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.Snapshot; + } } diff --git a/engine/schema/src/com/cloud/storage/VMTemplateVO.java b/engine/schema/src/com/cloud/storage/VMTemplateVO.java index da9373505c2..e619f68a89e 100755 --- a/engine/schema/src/com/cloud/storage/VMTemplateVO.java +++ b/engine/schema/src/com/cloud/storage/VMTemplateVO.java @@ -31,6 +31,8 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.TemplateType; @@ -632,4 +634,8 @@ public class VMTemplateVO implements VirtualMachineTemplate { this.updated = updated; } + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.VirtualMachineTemplate; + } } diff --git a/engine/schema/src/com/cloud/storage/VolumeVO.java b/engine/schema/src/com/cloud/storage/VolumeVO.java index fb79c1345fb..82f47d4c1ce 100755 --- a/engine/schema/src/com/cloud/storage/VolumeVO.java +++ b/engine/schema/src/com/cloud/storage/VolumeVO.java @@ -32,6 +32,8 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.storage.Storage.StoragePoolType; import com.cloud.utils.NumbersUtil; import com.cloud.utils.db.GenericDao; @@ -164,18 +166,18 @@ public class VolumeVO implements Volume { // Real Constructor public VolumeVO(Type type, String name, long dcId, long domainId, long accountId, long diskOfferingId, long size, Long minIops, Long maxIops, String iScsiName) { - this.volumeType = type; + volumeType = type; this.name = name; - this.dataCenterId = dcId; + dataCenterId = dcId; this.accountId = accountId; this.domainId = domainId; this.size = size; this.minIops = minIops; this.maxIops = maxIops; - this._iScsiName = iScsiName; + _iScsiName = iScsiName; this.diskOfferingId = diskOfferingId; - this.state = State.Allocated; - this.uuid = UUID.randomUUID().toString(); + state = State.Allocated; + uuid = UUID.randomUUID().toString(); } public VolumeVO(String name, long dcId, Long podId, long accountId, long domainId, Long instanceId, String folder, String path, long size, Long minIops, @@ -189,13 +191,13 @@ public class VolumeVO implements Volume { this.size = size; this.minIops = minIops; this.maxIops = maxIops; - this._iScsiName = iScsiName; + _iScsiName = iScsiName; this.podId = podId; - this.dataCenterId = dcId; - this.volumeType = vType; - this.state = Volume.State.Allocated; - this.recreatable = false; - this.uuid = UUID.randomUUID().toString(); + dataCenterId = dcId; + volumeType = vType; + state = Volume.State.Allocated; + recreatable = false; + uuid = UUID.randomUUID().toString(); } public VolumeVO(String name, long dcId, long podId, long accountId, long domainId, Long instanceId, String folder, String path, long size, Volume.Type vType) { @@ -206,15 +208,15 @@ public class VolumeVO implements Volume { this.folder = folder; this.path = path; this.size = size; - this.minIops = null; - this.maxIops = null; - this._iScsiName = null; + minIops = null; + maxIops = null; + _iScsiName = null; this.podId = podId; - this.dataCenterId = dcId; - this.volumeType = vType; - this.state = Volume.State.Allocated; - this.recreatable = false; - this.uuid = UUID.randomUUID().toString(); + dataCenterId = dcId; + volumeType = vType; + state = Volume.State.Allocated; + recreatable = false; + uuid = UUID.randomUUID().toString(); } // Copy Constructor @@ -232,34 +234,34 @@ public class VolumeVO implements Volume { that.getMaxIops(), that.get_iScsiName(), that.getVolumeType()); - this.recreatable = that.isRecreatable(); - this.state = that.getState(); - this.size = that.getSize(); - this.minIops = that.getMinIops(); - this.maxIops = that.getMaxIops(); - this._iScsiName = that.get_iScsiName(); - this.diskOfferingId = that.getDiskOfferingId(); - this.poolId = that.getPoolId(); - this.attached = that.getAttached(); - this.chainInfo = that.getChainInfo(); - this.templateId = that.getTemplateId(); - this.deviceId = that.getDeviceId(); - this.format = that.getFormat(); - this.uuid = UUID.randomUUID().toString(); + recreatable = that.isRecreatable(); + state = that.getState(); + size = that.getSize(); + minIops = that.getMinIops(); + maxIops = that.getMaxIops(); + _iScsiName = that.get_iScsiName(); + diskOfferingId = that.getDiskOfferingId(); + poolId = that.getPoolId(); + attached = that.getAttached(); + chainInfo = that.getChainInfo(); + templateId = that.getTemplateId(); + deviceId = that.getDeviceId(); + format = that.getFormat(); + uuid = UUID.randomUUID().toString(); } @Override public long getUpdatedCount() { - return this.updatedCount; + return updatedCount; } @Override public void incrUpdatedCount() { - this.updatedCount++; + updatedCount++; } public void decrUpdatedCount() { - this.updatedCount--; + updatedCount--; } @Override @@ -481,7 +483,7 @@ public class VolumeVO implements Volume { @Override public Date getAttached() { - return this.attached; + return attached; } public void setAttached(Date attached) { @@ -490,7 +492,7 @@ public class VolumeVO implements Volume { @Override public String getChainInfo() { - return this.chainInfo; + return chainInfo; } public void setChainInfo(String chainInfo) { @@ -498,11 +500,11 @@ public class VolumeVO implements Volume { } public Long getLastPoolId() { - return this.lastPoolId; + return lastPoolId; } public void setLastPoolId(Long poolId) { - this.lastPoolId = poolId; + lastPoolId = poolId; } @Override @@ -521,17 +523,17 @@ public class VolumeVO implements Volume { @Override public String getReservationId() { - return this.reservationId; + return reservationId; } @Override public void setReservationId(String reserv) { - this.reservationId = reserv; + reservationId = reserv; } @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -540,11 +542,11 @@ public class VolumeVO implements Volume { @Override public String get_iScsiName() { - return this._iScsiName; + return _iScsiName; } public void set_iScsiName(String iScsiName) { - this._iScsiName = iScsiName; + _iScsiName = iScsiName; } @Override @@ -571,11 +573,11 @@ public class VolumeVO implements Volume { @Override public Long getVmSnapshotChainSize() { - return this.vmSnapshotChainSize; + return vmSnapshotChainSize; } public Long getIsoId() { - return this.isoId; + return isoId; } public void setIsoId(Long isoId) { @@ -596,4 +598,9 @@ public class VolumeVO implements Volume { public Integer getHypervisorSnapshotReserve() { return hypervisorSnapshotReserve; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.Volume; + } } diff --git a/engine/schema/src/com/cloud/tags/ResourceTagVO.java b/engine/schema/src/com/cloud/tags/ResourceTagVO.java index ca790bd18f3..45e7b27b49f 100644 --- a/engine/schema/src/com/cloud/tags/ResourceTagVO.java +++ b/engine/schema/src/com/cloud/tags/ResourceTagVO.java @@ -27,6 +27,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.server.ResourceTag; @Entity @@ -67,7 +69,7 @@ public class ResourceTagVO implements ResourceTag { String customer; protected ResourceTagVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } /** @@ -88,7 +90,7 @@ public class ResourceTagVO implements ResourceTag { this.accountId = accountId; this.resourceId = resourceId; this.resourceType = resourceType; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); this.customer = customer; this.resourceUuid = resourceUuid; } @@ -161,4 +163,9 @@ public class ResourceTagVO implements ResourceTag { public String getResourceUuid() { return resourceUuid; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.ResourceTag; + } } diff --git a/engine/schema/src/com/cloud/user/AccountVO.java b/engine/schema/src/com/cloud/user/AccountVO.java index 7fa9fe2e89f..fb1b58a89ac 100644 --- a/engine/schema/src/com/cloud/user/AccountVO.java +++ b/engine/schema/src/com/cloud/user/AccountVO.java @@ -28,6 +28,8 @@ import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.utils.db.GenericDao; @Entity @@ -70,12 +72,12 @@ public class AccountVO implements Account { boolean isDefault; public AccountVO() { - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public AccountVO(long id) { this.id = id; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } public AccountVO(String accountName, long domainId, String networkDomain, short type, String uuid) { @@ -83,7 +85,7 @@ public class AccountVO implements Account { this.domainId = domainId; this.networkDomain = networkDomain; this.type = type; - this.state = State.enabled; + state = State.enabled; this.uuid = uuid; } @@ -175,7 +177,7 @@ public class AccountVO implements Account { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -186,4 +188,10 @@ public class AccountVO implements Account { public boolean isDefault() { return isDefault; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.Account; + } + } diff --git a/engine/schema/src/com/cloud/user/SSHKeyPairVO.java b/engine/schema/src/com/cloud/user/SSHKeyPairVO.java index 9fb035d4d1a..4dc03c45b0f 100644 --- a/engine/schema/src/com/cloud/user/SSHKeyPairVO.java +++ b/engine/schema/src/com/cloud/user/SSHKeyPairVO.java @@ -24,6 +24,8 @@ import javax.persistence.Id; import javax.persistence.Table; import javax.persistence.Transient; +import org.apache.cloudstack.acl.IAMEntityType; + @Entity @Table(name = "ssh_keypairs") public class SSHKeyPairVO implements SSHKeyPair { @@ -114,4 +116,8 @@ public class SSHKeyPairVO implements SSHKeyPair { this.privateKey = privateKey; } + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.SSHKeyPair; + } } diff --git a/engine/schema/src/com/cloud/vm/InstanceGroupVO.java b/engine/schema/src/com/cloud/vm/InstanceGroupVO.java index 1089017e151..9b463d34287 100644 --- a/engine/schema/src/com/cloud/vm/InstanceGroupVO.java +++ b/engine/schema/src/com/cloud/vm/InstanceGroupVO.java @@ -28,6 +28,8 @@ import javax.persistence.PrimaryKeyJoinColumn; import javax.persistence.SecondaryTable; import javax.persistence.Table; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.utils.db.GenericDao; @Entity @@ -63,7 +65,7 @@ public class InstanceGroupVO implements InstanceGroup { public InstanceGroupVO(String name, long accountId) { this.name = name; this.accountId = accountId; - this.uuid = UUID.randomUUID().toString(); + uuid = UUID.randomUUID().toString(); } protected InstanceGroupVO() { @@ -105,7 +107,7 @@ public class InstanceGroupVO implements InstanceGroup { @Override public String getUuid() { - return this.uuid; + return uuid; } public void setUuid(String uuid) { @@ -116,4 +118,9 @@ public class InstanceGroupVO implements InstanceGroup { public Short getAccountType() { return accountType; } + + @Override + public IAMEntityType getEntityType() { + return IAMEntityType.InstanceGroup; + } } diff --git a/engine/schema/src/com/cloud/vm/VMInstanceVO.java b/engine/schema/src/com/cloud/vm/VMInstanceVO.java index 30ef60f1747..437db54178d 100644 --- a/engine/schema/src/com/cloud/vm/VMInstanceVO.java +++ b/engine/schema/src/com/cloud/vm/VMInstanceVO.java @@ -36,6 +36,8 @@ import javax.persistence.Temporal; import javax.persistence.TemporalType; import javax.persistence.Transient; +import org.apache.cloudstack.acl.IAMEntityType; + import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.utils.db.Encrypt; import com.cloud.utils.db.GenericDao; @@ -183,27 +185,27 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject