CLOUDSTACK-5920:Add interface to ControlledEntity to return IAM

entity type.
This commit is contained in:
Min Chen 2014-03-04 17:14:25 -08:00
parent b8413b9413
commit d0ae4d9a9f
62 changed files with 778 additions and 318 deletions

View File

@ -18,6 +18,8 @@ package com.cloud.network;
import java.net.URI; import java.net.URI;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode; import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType; import com.cloud.network.Networks.TrafficType;
@ -275,4 +277,9 @@ public class NetworkProfile implements Network {
public String getIp6Cidr() { public String getIp6Cidr() {
return ip6Cidr; return ip6Cidr;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Network;
}
} }

View File

@ -16,6 +16,8 @@
// under the License. // under the License.
package com.cloud.network.vpc; package com.cloud.network.vpc;
import org.apache.cloudstack.acl.IAMEntityType;
public class StaticRouteProfile implements StaticRoute { public class StaticRouteProfile implements StaticRoute {
private long id; private long id;
private String uuid; private String uuid;
@ -31,18 +33,18 @@ public class StaticRouteProfile implements StaticRoute {
String ipAddress; String ipAddress;
public StaticRouteProfile(StaticRoute staticRoute, VpcGateway gateway) { public StaticRouteProfile(StaticRoute staticRoute, VpcGateway gateway) {
this.id = staticRoute.getId(); id = staticRoute.getId();
this.uuid = staticRoute.getUuid(); uuid = staticRoute.getUuid();
this.targetCidr = staticRoute.getCidr(); targetCidr = staticRoute.getCidr();
this.accountId = staticRoute.getAccountId(); accountId = staticRoute.getAccountId();
this.domainId = staticRoute.getDomainId(); domainId = staticRoute.getDomainId();
this.gatewayId = staticRoute.getVpcGatewayId(); gatewayId = staticRoute.getVpcGatewayId();
this.state = staticRoute.getState(); state = staticRoute.getState();
this.vpcId = staticRoute.getVpcId(); vpcId = staticRoute.getVpcId();
this.vlanTag = gateway.getBroadcastUri(); vlanTag = gateway.getBroadcastUri();
this.gateway = gateway.getGateway(); this.gateway = gateway.getGateway();
this.netmask = gateway.getNetmask(); netmask = gateway.getNetmask();
this.ipAddress = gateway.getIp4Address(); ipAddress = gateway.getIp4Address();
} }
@Override @Override
@ -101,4 +103,8 @@ public class StaticRouteProfile implements StaticRoute {
return netmask; return netmask;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.StaticRoute;
}
} }

View File

@ -29,4 +29,5 @@ public interface ControlledEntity extends OwnedBy, PartOf {
Account, Domain Account, Domain
} }
IAMEntityType getEntityType();
} }

View File

@ -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
}

View File

@ -20,6 +20,9 @@ package org.apache.cloudstack.api.command.user.firewall;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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.acl.RoleType;
import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType; 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.FirewallResponse;
import org.apache.cloudstack.api.response.NetworkResponse; import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes; import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.InvalidParameterValueException;
@ -275,7 +277,7 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F
@Override @Override
public String getEventDescription() { public String getEventDescription() {
Network network = _networkService.getNetwork(networkId); 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 @Override
@ -354,4 +356,9 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F
} }
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.FirewallRule;
}
} }

View File

@ -19,6 +19,9 @@ package org.apache.cloudstack.api.command.user.firewall;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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.acl.RoleType;
import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType; 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.FirewallResponse;
import org.apache.cloudstack.api.response.IPAddressResponse; import org.apache.cloudstack.api.response.IPAddressResponse;
import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes; import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.InvalidParameterValueException;
@ -266,7 +268,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
@Override @Override
public String getEventDescription() { public String getEventDescription() {
IpAddress ip = _networkService.getIp(ipAddressId); 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 @Override
@ -346,4 +348,10 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
return true; return true;
} }
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.FirewallRule;
}
} }

View File

@ -18,6 +18,9 @@ package org.apache.cloudstack.api.command.user.firewall;
import java.util.List; 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.acl.RoleType;
import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType; 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.NetworkResponse;
import org.apache.cloudstack.api.response.UserVmResponse; import org.apache.cloudstack.api.response.UserVmResponse;
import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes; import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.InvalidParameterValueException;
@ -428,4 +430,10 @@ public class CreatePortForwardingRuleCmd extends BaseAsyncCreateCmd implements P
return true; return true;
} }
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.FirewallRule;
}
} }

View File

@ -18,6 +18,9 @@ package org.apache.cloudstack.api.command.user.nat;
import java.util.List; 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.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType; import org.apache.cloudstack.api.ApiCommandJobType;
import org.apache.cloudstack.api.ApiConstants; 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.IPAddressResponse;
import org.apache.cloudstack.api.response.IpForwardingRuleResponse; import org.apache.cloudstack.api.response.IpForwardingRuleResponse;
import org.apache.cloudstack.context.CallContext; import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes; import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException; import com.cloud.exception.InvalidParameterValueException;
@ -126,7 +128,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false); StaticNatRule staticNatRule = _rulesService.buildStaticNatRule(rule, false);
IpForwardingRuleResponse fwResponse = _responseGenerator.createIpForwardingRuleResponse(staticNatRule); IpForwardingRuleResponse fwResponse = _responseGenerator.createIpForwardingRuleResponse(staticNatRule);
fwResponse.setResponseName(getCommandName()); fwResponse.setResponseName(getCommandName());
this.setResponseObject(fwResponse); setResponseObject(fwResponse);
} finally { } finally {
if (!result || rule == null) { if (!result || rule == null) {
@ -152,8 +154,8 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
try { try {
StaticNatRule rule = _rulesService.createStaticNatRule(this, getOpenFirewall()); StaticNatRule rule = _rulesService.createStaticNatRule(this, getOpenFirewall());
this.setEntityId(rule.getId()); setEntityId(rule.getId());
this.setEntityUuid(rule.getUuid()); setEntityUuid(rule.getUuid());
} catch (NetworkRuleConflictException e) { } catch (NetworkRuleConflictException e) {
s_logger.info("Unable to create Static Nat Rule due to ", e); s_logger.info("Unable to create Static Nat Rule due to ", e);
throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage()); throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
@ -179,7 +181,7 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
@Override @Override
public String getEventDescription() { public String getEventDescription() {
IpAddress ip = _networkService.getIp(ipAddressId); 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() { private long getVirtualMachineId() {
@ -321,4 +323,10 @@ public class CreateIpForwardingRuleCmd extends BaseAsyncCreateCmd implements Sta
public boolean isDisplay() { public boolean isDisplay() {
return true; return true;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.FirewallRule;
}
} }

View File

@ -18,6 +18,8 @@ package com.cloud.network.addr;
import java.util.Date; import java.util.Date;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.dc.VlanVO; import com.cloud.dc.VlanVO;
import com.cloud.network.PublicIpAddress; import com.cloud.network.PublicIpAddress;
import com.cloud.network.dao.IPAddressVO; import com.cloud.network.dao.IPAddressVO;
@ -236,4 +238,9 @@ public class PublicIp implements PublicIpAddress {
public boolean isDisplay() { public boolean isDisplay() {
return _addr.isDisplay(); return _addr.isDisplay();
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.PublicIpAddress;
}
} }

View File

@ -18,6 +18,8 @@ package com.cloud.network.rules;
import java.util.List; import java.util.List;
import org.apache.cloudstack.acl.IAMEntityType;
public class StaticNatRuleImpl implements StaticNatRule { public class StaticNatRuleImpl implements StaticNatRule {
long id; long id;
String xid; String xid;
@ -34,19 +36,19 @@ public class StaticNatRuleImpl implements StaticNatRule {
boolean forDisplay; boolean forDisplay;
public StaticNatRuleImpl(FirewallRuleVO rule, String dstIp) { public StaticNatRuleImpl(FirewallRuleVO rule, String dstIp) {
this.id = rule.getId(); id = rule.getId();
this.xid = rule.getXid(); xid = rule.getXid();
this.uuid = rule.getUuid(); uuid = rule.getUuid();
this.protocol = rule.getProtocol(); protocol = rule.getProtocol();
this.portStart = rule.getSourcePortStart(); portStart = rule.getSourcePortStart();
this.portEnd = rule.getSourcePortEnd(); portEnd = rule.getSourcePortEnd();
this.state = rule.getState(); state = rule.getState();
this.accountId = rule.getAccountId(); accountId = rule.getAccountId();
this.domainId = rule.getDomainId(); domainId = rule.getDomainId();
this.networkId = rule.getNetworkId(); networkId = rule.getNetworkId();
this.sourceIpAddressId = rule.getSourceIpAddressId(); sourceIpAddressId = rule.getSourceIpAddressId();
this.destIpAddress = dstIp; destIpAddress = dstIp;
this.forDisplay = rule.isDisplay(); forDisplay = rule.isDisplay();
} }
@Override @Override
@ -148,4 +150,9 @@ public class StaticNatRuleImpl implements StaticNatRule {
public boolean isDisplay() { public boolean isDisplay() {
return forDisplay; return forDisplay;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.FirewallRule;
}
} }

View File

@ -29,6 +29,8 @@ import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@Entity @Entity
@ -87,7 +89,7 @@ public class EventVO implements Event {
public static final String LEVEL_ERROR = "ERROR"; public static final String LEVEL_ERROR = "ERROR";
public EventVO() { public EventVO() {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
@Override @Override
@ -196,7 +198,7 @@ public class EventVO implements Event {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
public void setUuid(String uuid) { public void setUuid(String uuid) {
@ -219,4 +221,10 @@ public class EventVO implements Event {
public void setDisplayEventEnabled(boolean displayEventEnabled) { public void setDisplayEventEnabled(boolean displayEventEnabled) {
isDisplayEventEnabled = displayEventEnabled; isDisplayEventEnabled = displayEventEnabled;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Event;
}
} }

View File

@ -28,6 +28,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@Entity @Entity
@ -76,16 +78,16 @@ public class UserIpv6AddressVO implements UserIpv6Address {
Date created; Date created;
protected UserIpv6AddressVO() { protected UserIpv6AddressVO() {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
public UserIpv6AddressVO(String address, long dataCenterId, String macAddress, long vlanDbId) { public UserIpv6AddressVO(String address, long dataCenterId, String macAddress, long vlanDbId) {
this.address = address; this.address = address;
this.dataCenterId = dataCenterId; this.dataCenterId = dataCenterId;
this.vlanId = vlanDbId; vlanId = vlanDbId;
this.state = State.Free; state = State.Free;
this.setMacAddress(macAddress); setMacAddress(macAddress);
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
@Override @Override
@ -184,4 +186,9 @@ public class UserIpv6AddressVO implements UserIpv6Address {
public void setCreated(Date created) { public void setCreated(Date created) {
this.created = created; this.created = created;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.UserIpv6Address;
}
} }

View File

@ -27,6 +27,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.Encrypt; import com.cloud.utils.db.Encrypt;
@Entity @Entity
@ -58,16 +60,16 @@ public class VpnUserVO implements VpnUser {
private String uuid; private String uuid;
public VpnUserVO() { public VpnUserVO() {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
public VpnUserVO(long accountId, long domainId, String userName, String password) { public VpnUserVO(long accountId, long domainId, String userName, String password) {
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.username = userName; username = userName;
this.password = password; this.password = password;
this.state = State.Add; state = State.Add;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
@Override @Override
@ -86,7 +88,7 @@ public class VpnUserVO implements VpnUser {
} }
public void setUsername(String userName) { public void setUsername(String userName) {
this.username = userName; username = userName;
} }
@Override @Override
@ -119,10 +121,15 @@ public class VpnUserVO implements VpnUser {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
public void setUuid(String uuid) { public void setUuid(String uuid) {
this.uuid = uuid; this.uuid = uuid;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.VpnUser;
}
} }

View File

@ -30,6 +30,7 @@ import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.api.InternalIdentity; import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@ -77,7 +78,7 @@ public class AutoScalePolicyVO implements AutoScalePolicy, InternalIdentity {
public AutoScalePolicyVO(long domainId, long accountId, int duration, public AutoScalePolicyVO(long domainId, long accountId, int duration,
int quietTime, Date lastQuiteTime, String action) { int quietTime, Date lastQuiteTime, String action) {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.domainId = domainId; this.domainId = domainId;
this.accountId = accountId; this.accountId = accountId;
this.duration = duration; this.duration = duration;
@ -150,4 +151,10 @@ public class AutoScalePolicyVO implements AutoScalePolicy, InternalIdentity {
public void setLastQuiteTime(Date lastQuiteTime) { public void setLastQuiteTime(Date lastQuiteTime) {
this.lastQuiteTime = lastQuiteTime; this.lastQuiteTime = lastQuiteTime;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.AutoScalePolicy;
}
} }

View File

@ -30,6 +30,7 @@ import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.api.InternalIdentity; import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@ -97,8 +98,8 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity {
long accountId, int minMembers, int maxMembers, int memberPort, long accountId, int minMembers, int maxMembers, int memberPort,
int interval, Date lastInterval, long profileId, String state) { int interval, Date lastInterval, long profileId, String state) {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.loadBalancerId = lbRuleId; loadBalancerId = lbRuleId;
this.minMembers = minMembers; this.minMembers = minMembers;
this.maxMembers = maxMembers; this.maxMembers = maxMembers;
this.memberPort = memberPort; this.memberPort = memberPort;
@ -224,4 +225,10 @@ public class AutoScaleVmGroupVO implements AutoScaleVmGroup, InternalIdentity {
public boolean isDisplay() { public boolean isDisplay() {
return display; return display;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.AutoScaleVmGroup;
}
} }

View File

@ -33,6 +33,7 @@ import javax.persistence.Inheritance;
import javax.persistence.InheritanceType; import javax.persistence.InheritanceType;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity; 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, public AutoScaleVmProfileVO(long zoneId, long domainId, long accountId, long serviceOfferingId, long templateId, String otherDeployParams, Map counterParamList,
Integer destroyVmGraceperiod, long autoscaleUserId) { Integer destroyVmGraceperiod, long autoscaleUserId) {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.zoneId = zoneId; this.zoneId = zoneId;
this.domainId = domainId; this.domainId = domainId;
this.accountId = accountId; this.accountId = accountId;
@ -149,7 +150,7 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter
} }
public void setCounterParams(String counterParam) { public void setCounterParams(String counterParam) {
this.counterParams = counterParam; counterParams = counterParam;
} }
public void setCounterParamsForUpdate(Map counterParamList) { public void setCounterParamsForUpdate(Map counterParamList) {
@ -232,4 +233,10 @@ public class AutoScaleVmProfileVO implements AutoScaleVmProfile, Identity, Inter
public boolean isDisplay() { public boolean isDisplay() {
return display; return display;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.AutoScaleVmProfile;
}
} }

View File

@ -29,6 +29,7 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.api.Identity; import org.apache.cloudstack.api.Identity;
import org.apache.cloudstack.api.InternalIdentity; import org.apache.cloudstack.api.InternalIdentity;
@ -77,7 +78,7 @@ public class ConditionVO implements Condition, Identity, InternalIdentity {
this.relationalOperator = relationalOperator; this.relationalOperator = relationalOperator;
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
public Date getCreated() { public Date getCreated() {
@ -121,10 +122,16 @@ public class ConditionVO implements Condition, Identity, InternalIdentity {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
public Date getRemoved() { public Date getRemoved() {
return removed; return removed;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Condition;
}
} }

View File

@ -31,6 +31,8 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.network.IpAddress; import com.cloud.network.IpAddress;
import com.cloud.utils.net.Ip; import com.cloud.utils.net.Ip;
@ -118,7 +120,7 @@ public class IPAddressVO implements IpAddress {
protected boolean display = true; protected boolean display = true;
protected IPAddressVO() { protected IPAddressVO() {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
@Override @Override
@ -129,26 +131,26 @@ public class IPAddressVO implements IpAddress {
public IPAddressVO(Ip address, long dataCenterId, long macAddress, long vlanDbId, boolean sourceNat) { public IPAddressVO(Ip address, long dataCenterId, long macAddress, long vlanDbId, boolean sourceNat) {
this.address = address; this.address = address;
this.dataCenterId = dataCenterId; this.dataCenterId = dataCenterId;
this.vlanId = vlanDbId; vlanId = vlanDbId;
this.sourceNat = sourceNat; this.sourceNat = sourceNat;
this.allocatedInDomainId = null; allocatedInDomainId = null;
this.allocatedToAccountId = null; allocatedToAccountId = null;
this.allocatedTime = null; allocatedTime = null;
this.state = State.Free; state = State.Free;
this.macAddress = macAddress; 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) { public IPAddressVO(Ip address, long dataCenterId, Long networkId, Long vpcId, long physicalNetworkId, long sourceNetworkId, long vlanDbId, boolean portable) {
this.address = address; this.address = address;
this.dataCenterId = dataCenterId; this.dataCenterId = dataCenterId;
this.associatedWithNetworkId = networkId; associatedWithNetworkId = networkId;
this.vpcId = vpcId; this.vpcId = vpcId;
this.physicalNetworkId = physicalNetworkId; this.physicalNetworkId = physicalNetworkId;
this.sourceNetworkId = sourceNetworkId; this.sourceNetworkId = sourceNetworkId;
this.vlanId = vlanDbId; vlanId = vlanDbId;
this.portable = portable; this.portable = portable;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
public long getMacAddress() { public long getMacAddress() {
@ -161,7 +163,7 @@ public class IPAddressVO implements IpAddress {
} }
public void setDataCenterId(long dcId) { public void setDataCenterId(long dcId) {
this.dataCenterId = dcId; dataCenterId = dcId;
} }
@Override @Override
@ -185,7 +187,7 @@ public class IPAddressVO implements IpAddress {
} }
public void setAssociatedWithNetworkId(Long networkId) { public void setAssociatedWithNetworkId(Long networkId) {
this.associatedWithNetworkId = networkId; associatedWithNetworkId = networkId;
} }
@Override @Override
@ -203,11 +205,11 @@ public class IPAddressVO implements IpAddress {
} }
public void setAllocatedToAccountId(Long accountId) { public void setAllocatedToAccountId(Long accountId) {
this.allocatedToAccountId = accountId; allocatedToAccountId = accountId;
} }
public void setAllocatedInDomainId(Long domainId) { public void setAllocatedInDomainId(Long domainId) {
this.allocatedInDomainId = domainId; allocatedInDomainId = domainId;
} }
public void setSourceNat(boolean sourceNat) { public void setSourceNat(boolean sourceNat) {
@ -220,16 +222,16 @@ public class IPAddressVO implements IpAddress {
} }
public void setAllocatedTime(Date allocated) { public void setAllocatedTime(Date allocated) {
this.allocatedTime = allocated; allocatedTime = allocated;
} }
@Override @Override
public long getVlanId() { public long getVlanId() {
return this.vlanId; return vlanId;
} }
public void setVlanId(long vlanDbId) { public void setVlanId(long vlanDbId) {
this.vlanId = vlanDbId; vlanId = vlanDbId;
} }
@Override @Override
@ -281,7 +283,7 @@ public class IPAddressVO implements IpAddress {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
public void setUuid(String uuid) { public void setUuid(String uuid) {
@ -303,7 +305,7 @@ public class IPAddressVO implements IpAddress {
} }
public void setSystem(boolean isSystem) { public void setSystem(boolean isSystem) {
this.system = isSystem; system = isSystem;
} }
@Override @Override
@ -346,4 +348,9 @@ public class IPAddressVO implements IpAddress {
public void setDisplay(boolean display) { public void setDisplay(boolean display) {
this.display = display; this.display = display;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.IpAddress;
}
} }

View File

@ -25,6 +25,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.network.MonitoringService; import com.cloud.network.MonitoringService;
@Entity @Entity
@ -116,4 +118,9 @@ public class MonitoringServiceVO implements MonitoringService {
public String getProcessName() { public String getProcessName() {
return processName; return processName;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.MonitorService;
}
} }

View File

@ -30,6 +30,7 @@ import javax.persistence.TableGenerator;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.network.Network; import com.cloud.network.Network;
import com.cloud.network.Networks.BroadcastDomainType; import com.cloud.network.Networks.BroadcastDomainType;
@ -167,7 +168,7 @@ public class NetworkVO implements Network {
Long networkACLId; Long networkACLId;
public NetworkVO() { public NetworkVO() {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
/** /**
@ -193,8 +194,8 @@ public class NetworkVO implements Network {
} else { } else {
this.state = state; this.state = state;
} }
this.id = -1; id = -1;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
public NetworkVO(long id, Network that, long offeringId, String guruName, long domainId, long accountId, long related, String name, String displayText, 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, aclType,
specifyIpRanges, specifyIpRanges,
vpcId); vpcId);
this.gateway = that.getGateway(); gateway = that.getGateway();
this.cidr = that.getCidr(); cidr = that.getCidr();
this.networkCidr = that.getNetworkCidr(); networkCidr = that.getNetworkCidr();
this.broadcastUri = that.getBroadcastUri(); broadcastUri = that.getBroadcastUri();
this.broadcastDomainType = that.getBroadcastDomainType(); broadcastDomainType = that.getBroadcastDomainType();
this.guruName = guruName; this.guruName = guruName;
this.state = that.getState(); state = that.getState();
if (state == null) { if (state == null) {
state = State.Allocated; state = State.Allocated;
} }
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.ip6Gateway = that.getIp6Gateway(); ip6Gateway = that.getIp6Gateway();
this.ip6Cidr = that.getIp6Cidr(); ip6Cidr = that.getIp6Cidr();
} }
/** /**
@ -260,7 +261,7 @@ public class NetworkVO implements Network {
this.displayText = displayText; this.displayText = displayText;
this.aclType = aclType; this.aclType = aclType;
this.networkDomain = networkDomain; this.networkDomain = networkDomain;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.guestType = guestType; this.guestType = guestType;
this.specifyIpRanges = specifyIpRanges; this.specifyIpRanges = specifyIpRanges;
this.vpcId = vpcId; this.vpcId = vpcId;
@ -436,7 +437,7 @@ public class NetworkVO implements Network {
} }
public void setDns1(String dns) { public void setDns1(String dns) {
this.dns1 = dns; dns1 = dns;
} }
public String getDns2() { public String getDns2() {
@ -444,7 +445,7 @@ public class NetworkVO implements Network {
} }
public void setDns2(String dns) { public void setDns2(String dns) {
this.dns2 = dns; dns2 = dns;
} }
@Override @Override
@ -492,19 +493,19 @@ public class NetworkVO implements Network {
return false; return false;
} }
NetworkVO that = (NetworkVO)obj; NetworkVO that = (NetworkVO)obj;
if (this.trafficType != that.trafficType) { if (trafficType != that.trafficType) {
return false; 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; return false;
} }
if (this.cidr == null && that.cidr == null) { if (cidr == null && that.cidr == null) {
return true; return true;
} }
return NetUtils.isNetworkAWithinNetworkB(this.cidr, that.cidr); return NetUtils.isNetworkAWithinNetworkB(cidr, that.cidr);
} }
@Override @Override
@ -516,7 +517,7 @@ public class NetworkVO implements Network {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
public void setUuid(String uuid) { public void setUuid(String uuid) {
@ -583,4 +584,9 @@ public class NetworkVO implements Network {
public Long getNetworkACLId() { public Long getNetworkACLId() {
return networkACLId; return networkACLId;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Network;
}
} }

View File

@ -25,6 +25,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.network.RemoteAccessVpn; import com.cloud.network.RemoteAccessVpn;
@Entity @Entity
@ -69,19 +71,19 @@ public class RemoteAccessVpnVO implements RemoteAccessVpn {
protected boolean display = true; protected boolean display = true;
public RemoteAccessVpnVO() { 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) { public RemoteAccessVpnVO(long accountId, long domainId, Long networkId, long publicIpId, Long vpcId, String localIp, String ipRange, String presharedKey) {
this.accountId = accountId; this.accountId = accountId;
this.serverAddressId = publicIpId; serverAddressId = publicIpId;
this.ipRange = ipRange; this.ipRange = ipRange;
this.ipsecPresharedKey = presharedKey; ipsecPresharedKey = presharedKey;
this.localIp = localIp; this.localIp = localIp;
this.domainId = domainId; this.domainId = domainId;
this.networkId = networkId; this.networkId = networkId;
this.state = State.Added; state = State.Added;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.vpcId = vpcId; this.vpcId = vpcId;
} }
@ -164,4 +166,9 @@ public class RemoteAccessVpnVO implements RemoteAccessVpn {
public boolean isDisplay() { public boolean isDisplay() {
return display; return display;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.RemoteAccessVpn;
}
} }

View File

@ -26,6 +26,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.network.Site2SiteCustomerGateway; import com.cloud.network.Site2SiteCustomerGateway;
import com.cloud.utils.db.Encrypt; import com.cloud.utils.db.Encrypt;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@ -92,7 +94,7 @@ public class Site2SiteCustomerGatewayVO implements Site2SiteCustomerGateway {
this.ikeLifetime = ikeLifetime; this.ikeLifetime = ikeLifetime;
this.espLifetime = espLifetime; this.espLifetime = espLifetime;
this.dpd = dpd; this.dpd = dpd;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
} }
@ -206,4 +208,9 @@ public class Site2SiteCustomerGatewayVO implements Site2SiteCustomerGateway {
public long getAccountId() { public long getAccountId() {
return accountId; return accountId;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Site2SiteCustomerGateway;
}
} }

View File

@ -28,6 +28,7 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.api.InternalIdentity; import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.network.Site2SiteVpnConnection; 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) { public Site2SiteVpnConnectionVO(long accountId, long domainId, long vpnGatewayId, long customerGatewayId, boolean passive) {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.setVpnGatewayId(vpnGatewayId); setVpnGatewayId(vpnGatewayId);
this.setCustomerGatewayId(customerGatewayId); setCustomerGatewayId(customerGatewayId);
this.setState(State.Pending); setState(State.Pending);
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.passive = passive; this.passive = passive;
@ -171,4 +172,9 @@ public class Site2SiteVpnConnectionVO implements Site2SiteVpnConnection, Interna
public boolean isDisplay() { public boolean isDisplay() {
return display; return display;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Site2SiteVpnConnection;
}
} }

View File

@ -26,6 +26,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.network.Site2SiteVpnGateway; import com.cloud.network.Site2SiteVpnGateway;
import com.cloud.utils.db.GenericDao; 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) { public Site2SiteVpnGatewayVO(long accountId, long domainId, long addrId, long vpcId) {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.setAddrId(addrId); setAddrId(addrId);
this.setVpcId(vpcId); setVpcId(vpcId);
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
} }
@ -128,4 +130,9 @@ public class Site2SiteVpnGatewayVO implements Site2SiteVpnGateway {
public boolean isDisplay() { public boolean isDisplay() {
return display; return display;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Site2SiteVpnGateway;
}
} }

View File

@ -23,6 +23,8 @@ import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.network.lb.SslCert; import com.cloud.network.lb.SslCert;
import com.cloud.utils.db.Encrypt; import com.cloud.utils.db.Encrypt;
@ -61,18 +63,18 @@ public class SslCertVO implements SslCert {
String fingerPrint; String fingerPrint;
public SslCertVO() { 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) { 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.key = key;
this.chain = chain; this.chain = chain;
this.password = password; this.password = password;
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.fingerPrint = fingerPrint; this.fingerPrint = fingerPrint;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
// Getters // Getters
@ -120,4 +122,10 @@ public class SslCertVO implements SslCert {
public String getFingerPrint() { public String getFingerPrint() {
return fingerPrint; return fingerPrint;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.SSLCert;
}
} }

View File

@ -34,6 +34,8 @@ import javax.persistence.InheritanceType;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
import com.cloud.utils.net.NetUtils; import com.cloud.utils.net.NetUtils;
@ -191,7 +193,7 @@ public class FirewallRuleVO implements FirewallRule {
} }
protected FirewallRuleVO() { 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, 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.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.sourceIpAddressId = ipAddressId; sourceIpAddressId = ipAddressId;
this.sourcePortStart = portStart; sourcePortStart = portStart;
this.sourcePortEnd = portEnd; sourcePortEnd = portEnd;
this.protocol = protocol; this.protocol = protocol;
this.purpose = purpose; this.purpose = purpose;
this.networkId = networkId; this.networkId = networkId;
this.state = State.Staged; state = State.Staged;
this.icmpCode = icmpCode; this.icmpCode = icmpCode;
this.icmpType = icmpType; this.icmpType = icmpType;
this.sourceCidrs = sourceCidrs; this.sourceCidrs = sourceCidrs;
@ -218,8 +220,8 @@ public class FirewallRuleVO implements FirewallRule {
} }
this.related = related; this.related = related;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.type = FirewallRuleType.User; type = FirewallRuleType.User;
this.trafficType = trafficType; this.trafficType = trafficType;
} }
@ -256,7 +258,7 @@ public class FirewallRuleVO implements FirewallRule {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
public void setUuid(String uuid) { public void setUuid(String uuid) {
@ -280,4 +282,10 @@ public class FirewallRuleVO implements FirewallRule {
public boolean isDisplay() { public boolean isDisplay() {
return display; return display;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.FirewallRule;
}
} }

View File

@ -25,6 +25,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
@Entity @Entity
@Table(name = ("security_group")) @Table(name = ("security_group"))
public class SecurityGroupVO implements SecurityGroup { public class SecurityGroupVO implements SecurityGroup {
@ -49,7 +51,7 @@ public class SecurityGroupVO implements SecurityGroup {
private String uuid; private String uuid;
public SecurityGroupVO() { public SecurityGroupVO() {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
public SecurityGroupVO(String name, String description, long domainId, long accountId) { public SecurityGroupVO(String name, String description, long domainId, long accountId) {
@ -57,7 +59,7 @@ public class SecurityGroupVO implements SecurityGroup {
this.description = description; this.description = description;
this.domainId = domainId; this.domainId = domainId;
this.accountId = accountId; this.accountId = accountId;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
@Override @Override
@ -87,10 +89,15 @@ public class SecurityGroupVO implements SecurityGroup {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
public void setUuid(String uuid) { public void setUuid(String uuid) {
this.uuid = uuid; this.uuid = uuid;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.SecurityGroup;
}
} }

View File

@ -28,6 +28,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@Entity @Entity
@ -64,7 +66,7 @@ public class StaticRouteVO implements StaticRoute {
Date created; Date created;
protected StaticRouteVO() { protected StaticRouteVO() {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
/** /**
@ -78,11 +80,11 @@ public class StaticRouteVO implements StaticRoute {
super(); super();
this.vpcGatewayId = vpcGatewayId; this.vpcGatewayId = vpcGatewayId;
this.cidr = cidr; this.cidr = cidr;
this.state = State.Staged; state = State.Staged;
this.vpcId = vpcId; this.vpcId = vpcId;
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
@Override @Override
@ -107,7 +109,7 @@ public class StaticRouteVO implements StaticRoute {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
@Override @Override
@ -135,4 +137,9 @@ public class StaticRouteVO implements StaticRoute {
buf.append(uuid).append("|").append(cidr).append("|").append(vpcGatewayId).append("]"); buf.append(uuid).append("|").append(cidr).append("|").append(vpcGatewayId).append("]");
return buf.toString(); return buf.toString();
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.StaticRoute;
}
} }

View File

@ -28,6 +28,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@Entity @Entity
@ -90,7 +92,7 @@ public class VpcGatewayVO implements VpcGateway {
long networkACLId; long networkACLId;
protected VpcGatewayVO() { protected VpcGatewayVO() {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
/** /**
@ -117,10 +119,10 @@ public class VpcGatewayVO implements VpcGateway {
this.broadcastUri = broadcastUri; this.broadcastUri = broadcastUri;
this.gateway = gateway; this.gateway = gateway;
this.netmask = netmask; this.netmask = netmask;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.state = State.Creating; state = State.Creating;
this.sourceNat = sourceNat; this.sourceNat = sourceNat;
this.networkACLId = networkACLId; this.networkACLId = networkACLId;
@ -128,7 +130,7 @@ public class VpcGatewayVO implements VpcGateway {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
@Override @Override
@ -204,7 +206,7 @@ public class VpcGatewayVO implements VpcGateway {
@Override @Override
public boolean getSourceNat() { public boolean getSourceNat() {
return this.sourceNat; return sourceNat;
} }
public void setNetworkACLId(long networkACLId) { public void setNetworkACLId(long networkACLId) {
@ -215,4 +217,9 @@ public class VpcGatewayVO implements VpcGateway {
public long getNetworkACLId() { public long getNetworkACLId() {
return networkACLId; return networkACLId;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.VpcGateway;
}
} }

View File

@ -26,6 +26,8 @@ import javax.persistence.Enumerated;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@Entity @Entity
@ -80,7 +82,7 @@ public class VpcVO implements Vpc {
protected boolean display = true; protected boolean display = true;
public VpcVO() { 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) { 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.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.cidr = cidr; this.cidr = cidr;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.state = State.Enabled; state = State.Enabled;
this.networkDomain = networkDomain; this.networkDomain = networkDomain;
this.vpcOfferingId = vpcOffId; vpcOfferingId = vpcOffId;
} }
@Override @Override
@ -194,4 +196,9 @@ public class VpcVO implements Vpc {
public boolean isDisplay() { public boolean isDisplay() {
return display; return display;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Vpc;
}
} }

View File

@ -28,6 +28,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@Entity @Entity
@ -64,16 +66,16 @@ public class ProjectInvitationVO implements ProjectInvitation {
private String uuid; private String uuid;
protected ProjectInvitationVO() { protected ProjectInvitationVO() {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
public ProjectInvitationVO(long projectId, Long accountId, Long domainId, String email, String token) { public ProjectInvitationVO(long projectId, Long accountId, Long domainId, String email, String token) {
this.forAccountId = accountId; forAccountId = accountId;
this.inDomainId = domainId; inDomainId = domainId;
this.projectId = projectId; this.projectId = projectId;
this.email = email; this.email = email;
this.token = token; this.token = token;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
@Override @Override
@ -129,7 +131,7 @@ public class ProjectInvitationVO implements ProjectInvitation {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
public void setUuid(String uuid) { public void setUuid(String uuid) {
@ -145,4 +147,9 @@ public class ProjectInvitationVO implements ProjectInvitation {
public long getAccountId() { public long getAccountId() {
return forAccountId == null ? -1 : forAccountId; return forAccountId == null ? -1 : forAccountId;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.ProjectInvitation;
}
} }

View File

@ -30,6 +30,8 @@ import javax.persistence.Table;
import com.google.gson.annotations.Expose; import com.google.gson.annotations.Expose;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@ -93,12 +95,12 @@ public class SnapshotVO implements Snapshot {
String uuid; String uuid;
public SnapshotVO() { 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, public SnapshotVO(long dcId, long accountId, long domainId, Long volumeId, Long diskOfferingId, String name, short snapshotType, String typeDescription, long size,
HypervisorType hypervisorType) { HypervisorType hypervisorType) {
this.dataCenterId = dcId; dataCenterId = dcId;
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.volumeId = volumeId; this.volumeId = volumeId;
@ -107,10 +109,10 @@ public class SnapshotVO implements Snapshot {
this.snapshotType = snapshotType; this.snapshotType = snapshotType;
this.typeDescription = typeDescription; this.typeDescription = typeDescription;
this.size = size; this.size = size;
this.state = State.Allocated; state = State.Allocated;
this.hypervisorType = hypervisorType; this.hypervisorType = hypervisorType;
this.version = "2.2"; version = "2.2";
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
@Override @Override
@ -229,10 +231,15 @@ public class SnapshotVO implements Snapshot {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
public void setUuid(String uuid) { public void setUuid(String uuid) {
this.uuid = uuid; this.uuid = uuid;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Snapshot;
}
} }

View File

@ -31,6 +31,8 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.TemplateType; import com.cloud.storage.Storage.TemplateType;
@ -632,4 +634,8 @@ public class VMTemplateVO implements VirtualMachineTemplate {
this.updated = updated; this.updated = updated;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.VirtualMachineTemplate;
}
} }

View File

@ -32,6 +32,8 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.storage.Storage.StoragePoolType; import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.utils.NumbersUtil; import com.cloud.utils.NumbersUtil;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@ -164,18 +166,18 @@ public class VolumeVO implements Volume {
// Real Constructor // Real Constructor
public VolumeVO(Type type, String name, long dcId, long domainId, long accountId, long diskOfferingId, long size, Long minIops, Long maxIops, String iScsiName) { 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.name = name;
this.dataCenterId = dcId; dataCenterId = dcId;
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.size = size; this.size = size;
this.minIops = minIops; this.minIops = minIops;
this.maxIops = maxIops; this.maxIops = maxIops;
this._iScsiName = iScsiName; _iScsiName = iScsiName;
this.diskOfferingId = diskOfferingId; this.diskOfferingId = diskOfferingId;
this.state = State.Allocated; state = State.Allocated;
this.uuid = UUID.randomUUID().toString(); 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, 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.size = size;
this.minIops = minIops; this.minIops = minIops;
this.maxIops = maxIops; this.maxIops = maxIops;
this._iScsiName = iScsiName; _iScsiName = iScsiName;
this.podId = podId; this.podId = podId;
this.dataCenterId = dcId; dataCenterId = dcId;
this.volumeType = vType; volumeType = vType;
this.state = Volume.State.Allocated; state = Volume.State.Allocated;
this.recreatable = false; recreatable = false;
this.uuid = UUID.randomUUID().toString(); 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) { 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.folder = folder;
this.path = path; this.path = path;
this.size = size; this.size = size;
this.minIops = null; minIops = null;
this.maxIops = null; maxIops = null;
this._iScsiName = null; _iScsiName = null;
this.podId = podId; this.podId = podId;
this.dataCenterId = dcId; dataCenterId = dcId;
this.volumeType = vType; volumeType = vType;
this.state = Volume.State.Allocated; state = Volume.State.Allocated;
this.recreatable = false; recreatable = false;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
// Copy Constructor // Copy Constructor
@ -232,34 +234,34 @@ public class VolumeVO implements Volume {
that.getMaxIops(), that.getMaxIops(),
that.get_iScsiName(), that.get_iScsiName(),
that.getVolumeType()); that.getVolumeType());
this.recreatable = that.isRecreatable(); recreatable = that.isRecreatable();
this.state = that.getState(); state = that.getState();
this.size = that.getSize(); size = that.getSize();
this.minIops = that.getMinIops(); minIops = that.getMinIops();
this.maxIops = that.getMaxIops(); maxIops = that.getMaxIops();
this._iScsiName = that.get_iScsiName(); _iScsiName = that.get_iScsiName();
this.diskOfferingId = that.getDiskOfferingId(); diskOfferingId = that.getDiskOfferingId();
this.poolId = that.getPoolId(); poolId = that.getPoolId();
this.attached = that.getAttached(); attached = that.getAttached();
this.chainInfo = that.getChainInfo(); chainInfo = that.getChainInfo();
this.templateId = that.getTemplateId(); templateId = that.getTemplateId();
this.deviceId = that.getDeviceId(); deviceId = that.getDeviceId();
this.format = that.getFormat(); format = that.getFormat();
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
@Override @Override
public long getUpdatedCount() { public long getUpdatedCount() {
return this.updatedCount; return updatedCount;
} }
@Override @Override
public void incrUpdatedCount() { public void incrUpdatedCount() {
this.updatedCount++; updatedCount++;
} }
public void decrUpdatedCount() { public void decrUpdatedCount() {
this.updatedCount--; updatedCount--;
} }
@Override @Override
@ -481,7 +483,7 @@ public class VolumeVO implements Volume {
@Override @Override
public Date getAttached() { public Date getAttached() {
return this.attached; return attached;
} }
public void setAttached(Date attached) { public void setAttached(Date attached) {
@ -490,7 +492,7 @@ public class VolumeVO implements Volume {
@Override @Override
public String getChainInfo() { public String getChainInfo() {
return this.chainInfo; return chainInfo;
} }
public void setChainInfo(String chainInfo) { public void setChainInfo(String chainInfo) {
@ -498,11 +500,11 @@ public class VolumeVO implements Volume {
} }
public Long getLastPoolId() { public Long getLastPoolId() {
return this.lastPoolId; return lastPoolId;
} }
public void setLastPoolId(Long poolId) { public void setLastPoolId(Long poolId) {
this.lastPoolId = poolId; lastPoolId = poolId;
} }
@Override @Override
@ -521,17 +523,17 @@ public class VolumeVO implements Volume {
@Override @Override
public String getReservationId() { public String getReservationId() {
return this.reservationId; return reservationId;
} }
@Override @Override
public void setReservationId(String reserv) { public void setReservationId(String reserv) {
this.reservationId = reserv; reservationId = reserv;
} }
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
public void setUuid(String uuid) { public void setUuid(String uuid) {
@ -540,11 +542,11 @@ public class VolumeVO implements Volume {
@Override @Override
public String get_iScsiName() { public String get_iScsiName() {
return this._iScsiName; return _iScsiName;
} }
public void set_iScsiName(String iScsiName) { public void set_iScsiName(String iScsiName) {
this._iScsiName = iScsiName; _iScsiName = iScsiName;
} }
@Override @Override
@ -571,11 +573,11 @@ public class VolumeVO implements Volume {
@Override @Override
public Long getVmSnapshotChainSize() { public Long getVmSnapshotChainSize() {
return this.vmSnapshotChainSize; return vmSnapshotChainSize;
} }
public Long getIsoId() { public Long getIsoId() {
return this.isoId; return isoId;
} }
public void setIsoId(Long isoId) { public void setIsoId(Long isoId) {
@ -596,4 +598,9 @@ public class VolumeVO implements Volume {
public Integer getHypervisorSnapshotReserve() { public Integer getHypervisorSnapshotReserve() {
return hypervisorSnapshotReserve; return hypervisorSnapshotReserve;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Volume;
}
} }

View File

@ -27,6 +27,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.server.ResourceTag; import com.cloud.server.ResourceTag;
@Entity @Entity
@ -67,7 +69,7 @@ public class ResourceTagVO implements ResourceTag {
String customer; String customer;
protected ResourceTagVO() { protected ResourceTagVO() {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
/** /**
@ -88,7 +90,7 @@ public class ResourceTagVO implements ResourceTag {
this.accountId = accountId; this.accountId = accountId;
this.resourceId = resourceId; this.resourceId = resourceId;
this.resourceType = resourceType; this.resourceType = resourceType;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.customer = customer; this.customer = customer;
this.resourceUuid = resourceUuid; this.resourceUuid = resourceUuid;
} }
@ -161,4 +163,9 @@ public class ResourceTagVO implements ResourceTag {
public String getResourceUuid() { public String getResourceUuid() {
return resourceUuid; return resourceUuid;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.ResourceTag;
}
} }

View File

@ -28,6 +28,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@Entity @Entity
@ -70,12 +72,12 @@ public class AccountVO implements Account {
boolean isDefault; boolean isDefault;
public AccountVO() { public AccountVO() {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
public AccountVO(long id) { public AccountVO(long id) {
this.id = 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) { 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.domainId = domainId;
this.networkDomain = networkDomain; this.networkDomain = networkDomain;
this.type = type; this.type = type;
this.state = State.enabled; state = State.enabled;
this.uuid = uuid; this.uuid = uuid;
} }
@ -175,7 +177,7 @@ public class AccountVO implements Account {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
public void setUuid(String uuid) { public void setUuid(String uuid) {
@ -186,4 +188,10 @@ public class AccountVO implements Account {
public boolean isDefault() { public boolean isDefault() {
return isDefault; return isDefault;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Account;
}
} }

View File

@ -24,6 +24,8 @@ import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.apache.cloudstack.acl.IAMEntityType;
@Entity @Entity
@Table(name = "ssh_keypairs") @Table(name = "ssh_keypairs")
public class SSHKeyPairVO implements SSHKeyPair { public class SSHKeyPairVO implements SSHKeyPair {
@ -114,4 +116,8 @@ public class SSHKeyPairVO implements SSHKeyPair {
this.privateKey = privateKey; this.privateKey = privateKey;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.SSHKeyPair;
}
} }

View File

@ -28,6 +28,8 @@ import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.SecondaryTable; import javax.persistence.SecondaryTable;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@Entity @Entity
@ -63,7 +65,7 @@ public class InstanceGroupVO implements InstanceGroup {
public InstanceGroupVO(String name, long accountId) { public InstanceGroupVO(String name, long accountId) {
this.name = name; this.name = name;
this.accountId = accountId; this.accountId = accountId;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
protected InstanceGroupVO() { protected InstanceGroupVO() {
@ -105,7 +107,7 @@ public class InstanceGroupVO implements InstanceGroup {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
public void setUuid(String uuid) { public void setUuid(String uuid) {
@ -116,4 +118,9 @@ public class InstanceGroupVO implements InstanceGroup {
public Short getAccountType() { public Short getAccountType() {
return accountType; return accountType;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.InstanceGroup;
}
} }

View File

@ -36,6 +36,8 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.db.Encrypt; import com.cloud.utils.db.Encrypt;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@ -183,27 +185,27 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
public VMInstanceVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId, public VMInstanceVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId,
long domainId, long accountId, boolean haEnabled) { long domainId, long accountId, boolean haEnabled) {
this.id = id; this.id = id;
this.hostName = name != null ? name : this.uuid; hostName = name != null ? name : uuid;
if (vmTemplateId != null) { if (vmTemplateId != null) {
this.templateId = vmTemplateId; templateId = vmTemplateId;
} }
this.instanceName = instanceName; this.instanceName = instanceName;
this.type = type; this.type = type;
this.guestOSId = guestOSId; this.guestOSId = guestOSId;
this.haEnabled = haEnabled; this.haEnabled = haEnabled;
this.vncPassword = Long.toHexString(new Random().nextLong()); vncPassword = Long.toHexString(new Random().nextLong());
this.state = State.Stopped; state = State.Stopped;
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.serviceOfferingId = serviceOfferingId; this.serviceOfferingId = serviceOfferingId;
this.hypervisorType = hypervisorType; this.hypervisorType = hypervisorType;
this.limitCpuUse = false; limitCpuUse = false;
} }
public VMInstanceVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId, public VMInstanceVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId,
long domainId, long accountId, boolean haEnabled, boolean limitResourceUse, Long diskOfferingId) { long domainId, long accountId, boolean haEnabled, boolean limitResourceUse, Long diskOfferingId) {
this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled); this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
this.limitCpuUse = limitResourceUse; limitCpuUse = limitResourceUse;
this.diskOfferingId = diskOfferingId; this.diskOfferingId = diskOfferingId;
} }
@ -324,11 +326,11 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
} }
public Date getProxyAssignTime() { public Date getProxyAssignTime() {
return this.proxyAssignTime; return proxyAssignTime;
} }
public void setProxyAssignTime(Date time) { public void setProxyAssignTime(Date time) {
this.proxyAssignTime = time; proxyAssignTime = time;
} }
@Override @Override
@ -412,7 +414,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
} }
public void setPodId(long podId) { public void setPodId(long podId) {
this.podIdToDeployIn = podId; podIdToDeployIn = podId;
} }
public void setPrivateMacAddress(String privateMacAddress) { public void setPrivateMacAddress(String privateMacAddress) {
@ -436,7 +438,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
} }
public String getReservationId() { public String getReservationId() {
return this.reservationId; return reservationId;
} }
@Override @Override
@ -500,7 +502,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
} }
public Boolean isDynamicallyScalable() { public Boolean isDynamicallyScalable() {
return this.dynamicallyScalable; return dynamicallyScalable;
} }
public VirtualMachine.PowerState getPowerState() { public VirtualMachine.PowerState getPowerState() {
@ -535,4 +537,8 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
powerHostId = hostId; powerHostId = hostId;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.VirtualMachine;
}
} }

View File

@ -28,6 +28,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
import com.cloud.utils.net.NetUtils; import com.cloud.utils.net.NetUtils;
import com.cloud.vm.NicIpAlias; import com.cloud.vm.NicIpAlias;
@ -39,18 +41,18 @@ public class NicIpAliasVO implements NicIpAlias {
public NicIpAliasVO(Long nicId, String ipaddr, Long vmId, Long accountId, Long domainId, Long networkId, String gateway, String netmask) { public NicIpAliasVO(Long nicId, String ipaddr, Long vmId, Long accountId, Long domainId, Long networkId, String gateway, String netmask) {
this.nicId = nicId; this.nicId = nicId;
this.vmId = vmId; this.vmId = vmId;
this.ip4Address = ipaddr; ip4Address = ipaddr;
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.networkId = networkId; this.networkId = networkId;
this.netmask = netmask; this.netmask = netmask;
this.gateway = gateway; this.gateway = gateway;
this.state = NicIpAlias.state.active; state = NicIpAlias.state.active;
String cidr = NetUtils.getCidrFromGatewayAndNetmask(gateway, netmask); String cidr = NetUtils.getCidrFromGatewayAndNetmask(gateway, netmask);
String[] cidrPair = cidr.split("\\/"); String[] cidrPair = cidr.split("\\/");
String cidrAddress = cidrPair[0]; String cidrAddress = cidrPair[0];
long cidrSize = Long.parseLong(cidrPair[1]); long cidrSize = Long.parseLong(cidrPair[1]);
this.startIpOfSubnet = NetUtils.getIpRangeStartIpFromCidr(cidrAddress, cidrSize); startIpOfSubnet = NetUtils.getIpRangeStartIpFromCidr(cidrAddress, cidrSize);
} }
protected NicIpAliasVO() { protected NicIpAliasVO() {
@ -199,7 +201,7 @@ public class NicIpAliasVO implements NicIpAlias {
} }
public void setAliasCount(long count) { public void setAliasCount(long count) {
this.aliasCount = count; aliasCount = count;
} }
public void setNetmask(String netmask) { public void setNetmask(String netmask) {
@ -232,4 +234,8 @@ public class NicIpAliasVO implements NicIpAlias {
return startIpOfSubnet; return startIpOfSubnet;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.NicIpAlias;
}
} }

View File

@ -26,6 +26,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
import com.cloud.vm.NicSecondaryIp; import com.cloud.vm.NicSecondaryIp;
@ -36,7 +38,7 @@ public class NicSecondaryIpVO implements NicSecondaryIp {
public NicSecondaryIpVO(long nicId, String ipaddr, long vmId, long accountId, long domainId, long networkId) { public NicSecondaryIpVO(long nicId, String ipaddr, long vmId, long accountId, long domainId, long networkId) {
this.nicId = nicId; this.nicId = nicId;
this.vmId = vmId; this.vmId = vmId;
this.ip4Address = ipaddr; ip4Address = ipaddr;
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.networkId = networkId; this.networkId = networkId;
@ -124,4 +126,9 @@ public class NicSecondaryIpVO implements NicSecondaryIp {
public long getVmId() { public long getVmId() {
return vmId; return vmId;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.NicSecondaryIp;
}
} }

View File

@ -33,6 +33,7 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotOptions; import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotOptions;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@ -133,10 +134,10 @@ public class VMSnapshotVO implements VMSnapshot {
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.vmId = vmId; this.vmId = vmId;
this.state = State.Allocated; state = State.Allocated;
this.description = description; this.description = description;
this.name = vmSnapshotName; name = vmSnapshotName;
this.displayName = vsDisplayName; displayName = vsDisplayName;
this.type = type; this.type = type;
this.current = current; this.current = current;
} }
@ -227,7 +228,7 @@ public class VMSnapshotVO implements VMSnapshot {
@Override @Override
public void incrUpdatedCount() { public void incrUpdatedCount() {
this.updatedCount++; updatedCount++;
} }
@Override @Override
@ -243,4 +244,9 @@ public class VMSnapshotVO implements VMSnapshot {
public void setRemoved(Date removed) { public void setRemoved(Date removed) {
this.removed = removed; this.removed = removed;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.VMSnapshot;
}
} }

View File

@ -28,6 +28,7 @@ import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.IAMEntityType;
@Entity @Entity
@Table(name = ("affinity_group")) @Table(name = ("affinity_group"))
@ -60,7 +61,7 @@ public class AffinityGroupVO implements AffinityGroup {
ControlledEntity.ACLType aclType; ControlledEntity.ACLType aclType;
public AffinityGroupVO() { public AffinityGroupVO() {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
public AffinityGroupVO(String name, String type, String description, long domainId, long accountId, ACLType aclType) { public AffinityGroupVO(String name, String type, String description, long domainId, long accountId, ACLType aclType) {
@ -68,7 +69,7 @@ public class AffinityGroupVO implements AffinityGroup {
this.description = description; this.description = description;
this.domainId = domainId; this.domainId = domainId;
this.accountId = accountId; this.accountId = accountId;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.type = type; this.type = type;
this.aclType = aclType; this.aclType = aclType;
} }
@ -100,7 +101,7 @@ public class AffinityGroupVO implements AffinityGroup {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
public void setUuid(String uuid) { public void setUuid(String uuid) {
@ -124,4 +125,9 @@ public class AffinityGroupVO implements AffinityGroup {
return buf.toString(); return buf.toString();
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.AffinityGroup;
}
} }

View File

@ -37,6 +37,8 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.db.Encrypt; import com.cloud.utils.db.Encrypt;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@ -179,28 +181,28 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
public VMEntityVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId, public VMEntityVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId,
long domainId, long accountId, boolean haEnabled, Long diskOfferingId) { long domainId, long accountId, boolean haEnabled, Long diskOfferingId) {
this.id = id; this.id = id;
this.hostName = name != null ? name : this.uuid; hostName = name != null ? name : uuid;
if (vmTemplateId != null) { if (vmTemplateId != null) {
this.templateId = vmTemplateId; templateId = vmTemplateId;
} }
this.instanceName = instanceName; this.instanceName = instanceName;
this.type = type; this.type = type;
this.guestOSId = guestOSId; this.guestOSId = guestOSId;
this.haEnabled = haEnabled; this.haEnabled = haEnabled;
this.vncPassword = Long.toHexString(new Random().nextLong()); vncPassword = Long.toHexString(new Random().nextLong());
this.state = State.Stopped; state = State.Stopped;
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.serviceOfferingId = serviceOfferingId; this.serviceOfferingId = serviceOfferingId;
this.hypervisorType = hypervisorType; this.hypervisorType = hypervisorType;
this.limitCpuUse = false; limitCpuUse = false;
this.diskOfferingId = diskOfferingId; this.diskOfferingId = diskOfferingId;
} }
public VMEntityVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId, public VMEntityVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId,
long domainId, long accountId, boolean haEnabled, boolean limitResourceUse) { long domainId, long accountId, boolean haEnabled, boolean limitResourceUse) {
this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled, null); this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled, null);
this.limitCpuUse = limitResourceUse; limitCpuUse = limitResourceUse;
} }
protected VMEntityVO() { protected VMEntityVO() {
@ -316,11 +318,11 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
} }
public Date getProxyAssignTime() { public Date getProxyAssignTime() {
return this.proxyAssignTime; return proxyAssignTime;
} }
public void setProxyAssignTime(Date time) { public void setProxyAssignTime(Date time) {
this.proxyAssignTime = time; proxyAssignTime = time;
} }
@Override @Override
@ -396,7 +398,7 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
} }
public void setPodId(long podId) { public void setPodId(long podId) {
this.podIdToDeployIn = podId; podIdToDeployIn = podId;
} }
public void setPrivateMacAddress(String privateMacAddress) { public void setPrivateMacAddress(String privateMacAddress) {
@ -404,7 +406,7 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
} }
public void setDataCenterId(long dataCenterId) { public void setDataCenterId(long dataCenterId) {
this.dataCenterIdToDeployIn = dataCenterId; dataCenterIdToDeployIn = dataCenterId;
} }
public boolean isRemoved() { public boolean isRemoved() {
@ -420,7 +422,7 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
} }
public String getReservationId() { public String getReservationId() {
return this.reservationId; return reservationId;
} }
@Override @Override
@ -535,4 +537,8 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
this.vmReservation = vmReservation; this.vmReservation = vmReservation;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.VirtualMachine;
}
} }

View File

@ -28,6 +28,8 @@ import javax.persistence.GenerationType;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.region.ha.GlobalLoadBalancerRule; import com.cloud.region.ha.GlobalLoadBalancerRule;
@Entity @Entity
@ -74,21 +76,21 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule {
GlobalLoadBalancerRule.State state; GlobalLoadBalancerRule.State state;
public GlobalLoadBalancerRuleVO() { public GlobalLoadBalancerRuleVO() {
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
} }
public GlobalLoadBalancerRuleVO(String name, String description, String gslbDomain, String algorithm, String persistence, String serviceType, int regionId, public GlobalLoadBalancerRuleVO(String name, String description, String gslbDomain, String algorithm, String persistence, String serviceType, int regionId,
long accountId, long domainId, State state) { long accountId, long domainId, State state) {
this.name = name; this.name = name;
this.description = description; this.description = description;
this.region = regionId; region = regionId;
this.algorithm = algorithm; this.algorithm = algorithm;
this.gslbDomain = gslbDomain; this.gslbDomain = gslbDomain;
this.persistence = persistence; this.persistence = persistence;
this.accountId = accountId; this.accountId = accountId;
this.domainId = domainId; this.domainId = domainId;
this.serviceType = serviceType; this.serviceType = serviceType;
this.uuid = UUID.randomUUID().toString(); uuid = UUID.randomUUID().toString();
this.state = state; this.state = state;
} }
@ -163,7 +165,7 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule {
@Override @Override
public String getUuid() { public String getUuid() {
return this.uuid; return uuid;
} }
public void setUuid(String uuid) { public void setUuid(String uuid) {
@ -187,4 +189,9 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule {
public GlobalLoadBalancerRule.State getState() { public GlobalLoadBalancerRule.State getState() {
return state; return state;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.GlobalLoadBalancerRule;
}
} }

View File

@ -25,6 +25,7 @@ import javax.inject.Inject;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
@ -436,4 +437,8 @@ public class TemplateObject implements TemplateInfo {
return true; return true;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.VirtualMachineTemplate;
}
} }

View File

@ -24,6 +24,7 @@ import javax.inject.Inject;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
@ -380,4 +381,9 @@ public class SnapshotObject implements SnapshotInfo {
} }
return true; return true;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Snapshot;
}
} }

View File

@ -23,6 +23,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity; import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo; import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
import org.apache.cloudstack.storage.image.datastore.ImageStoreInfo; import org.apache.cloudstack.storage.image.datastore.ImageStoreInfo;
@ -285,4 +286,8 @@ public class TemplateEntityImpl implements TemplateEntity {
return 0; return 0;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.VirtualMachineTemplate;
}
} }

View File

@ -21,6 +21,7 @@ import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.engine.cloud.entity.api.SnapshotEntity; import org.apache.cloudstack.engine.cloud.entity.api.SnapshotEntity;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
@ -183,4 +184,8 @@ public class SnapshotEntityImpl implements SnapshotEntity {
return null; return null;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Snapshot;
}
} }

View File

@ -22,9 +22,7 @@ import javax.inject.Inject;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.cloud.storage.DiskOfferingVO; import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.storage.dao.DiskOfferingDao;
import com.cloud.vm.VirtualMachine;
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
@ -43,9 +41,11 @@ import com.cloud.agent.api.to.DataTO;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.offering.DiskOffering.DiskCacheMode; import com.cloud.offering.DiskOffering.DiskCacheMode;
import com.cloud.storage.DataStoreRole; import com.cloud.storage.DataStoreRole;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Volume; import com.cloud.storage.Volume;
import com.cloud.storage.VolumeVO; import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.DiskOfferingDao;
import com.cloud.storage.dao.VolumeDao; import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.component.ComponentContext; import com.cloud.utils.component.ComponentContext;
import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.exception.CloudRuntimeException;
@ -53,6 +53,7 @@ import com.cloud.utils.fsm.NoTransitionException;
import com.cloud.utils.fsm.StateMachine2; import com.cloud.utils.fsm.StateMachine2;
import com.cloud.utils.storage.encoding.EncodingType; import com.cloud.utils.storage.encoding.EncodingType;
import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.dao.VMInstanceDao; import com.cloud.vm.dao.VMInstanceDao;
public class VolumeObject implements VolumeInfo { public class VolumeObject implements VolumeInfo {
@ -89,7 +90,7 @@ public class VolumeObject implements VolumeInfo {
@Override @Override
public String getAttachedVmName() { public String getAttachedVmName() {
Long vmId = this.volumeVO.getInstanceId(); Long vmId = volumeVO.getInstanceId();
if (vmId != null) { if (vmId != null) {
VMInstanceVO vm = vmInstanceDao.findById(vmId); VMInstanceVO vm = vmInstanceDao.findById(vmId);
@ -103,7 +104,7 @@ public class VolumeObject implements VolumeInfo {
@Override @Override
public VirtualMachine getAttachedVM() { public VirtualMachine getAttachedVM() {
Long vmId = this.volumeVO.getInstanceId(); Long vmId = volumeVO.getInstanceId();
if (vmId != null) { if (vmId != null) {
VMInstanceVO vm = vmInstanceDao.findById(vmId); VMInstanceVO vm = vmInstanceDao.findById(vmId);
return vm; return vm;
@ -179,7 +180,7 @@ public class VolumeObject implements VolumeInfo {
result = _volStateMachine.transitTo(volumeVO, event, null, volumeDao); result = _volStateMachine.transitTo(volumeVO, event, null, volumeDao);
volumeVO = volumeDao.findById(volumeVO.getId()); volumeVO = volumeDao.findById(volumeVO.getId());
} catch (NoTransitionException e) { } catch (NoTransitionException e) {
String errorMessage = "Failed to transit volume: " + this.getVolumeId() + ", due to: " + e.toString(); String errorMessage = "Failed to transit volume: " + getVolumeId() + ", due to: " + e.toString();
s_logger.debug(errorMessage); s_logger.debug(errorMessage);
throw new CloudRuntimeException(errorMessage); throw new CloudRuntimeException(errorMessage);
} }
@ -246,25 +247,25 @@ public class VolumeObject implements VolumeInfo {
@Override @Override
public long getId() { public long getId() {
return this.volumeVO.getId(); return volumeVO.getId();
} }
@Override @Override
public boolean isAttachedVM() { public boolean isAttachedVM() {
return (this.volumeVO.getInstanceId() == null) ? false : true; return (volumeVO.getInstanceId() == null) ? false : true;
} }
@Override @Override
public String getUri() { public String getUri() {
if (this.dataStore == null) { if (dataStore == null) {
throw new CloudRuntimeException("datastore must be set before using this object"); throw new CloudRuntimeException("datastore must be set before using this object");
} }
DataObjectInStore obj = objectInStoreMgr.findObject(this.volumeVO.getId(), DataObjectType.VOLUME, this.dataStore.getId(), this.dataStore.getRole()); DataObjectInStore obj = objectInStoreMgr.findObject(volumeVO.getId(), DataObjectType.VOLUME, dataStore.getId(), dataStore.getRole());
if (obj.getState() != ObjectInDataStoreStateMachine.State.Ready) { if (obj.getState() != ObjectInDataStoreStateMachine.State.Ready) {
return this.dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.SIZE + "=" + this.volumeVO.getSize() + "&" + return dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.SIZE + "=" + volumeVO.getSize() + "&" +
EncodingType.NAME + "=" + this.volumeVO.getName(); EncodingType.NAME + "=" + volumeVO.getName();
} else { } else {
return this.dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.PATH + "=" + obj.getInstallPath(); return dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.PATH + "=" + obj.getInstallPath();
} }
} }
@ -275,19 +276,19 @@ public class VolumeObject implements VolumeInfo {
@Override @Override
public void processEvent(ObjectInDataStoreStateMachine.Event event) { public void processEvent(ObjectInDataStoreStateMachine.Event event) {
if (this.dataStore == null) { if (dataStore == null) {
return; return;
} }
try { try {
Volume.Event volEvent = null; Volume.Event volEvent = null;
if (this.dataStore.getRole() == DataStoreRole.ImageCache) { if (dataStore.getRole() == DataStoreRole.ImageCache) {
objectInStoreMgr.update(this, event); objectInStoreMgr.update(this, event);
return; return;
} }
if (this.dataStore.getRole() == DataStoreRole.Image) { if (dataStore.getRole() == DataStoreRole.Image) {
objectInStoreMgr.update(this, event); objectInStoreMgr.update(this, event);
if (this.volumeVO.getState() == Volume.State.Migrating || this.volumeVO.getState() == Volume.State.Copying || if (volumeVO.getState() == Volume.State.Migrating || volumeVO.getState() == Volume.State.Copying ||
this.volumeVO.getState() == Volume.State.Uploaded || this.volumeVO.getState() == Volume.State.Expunged) { volumeVO.getState() == Volume.State.Uploaded || volumeVO.getState() == Volume.State.Expunged) {
return; return;
} }
if (event == ObjectInDataStoreStateMachine.Event.CreateOnlyRequested) { if (event == ObjectInDataStoreStateMachine.Event.CreateOnlyRequested) {
@ -316,14 +317,14 @@ public class VolumeObject implements VolumeInfo {
} else if (event == ObjectInDataStoreStateMachine.Event.ResizeRequested) { } else if (event == ObjectInDataStoreStateMachine.Event.ResizeRequested) {
volEvent = Volume.Event.ResizeRequested; volEvent = Volume.Event.ResizeRequested;
} }
this.stateTransit(volEvent); stateTransit(volEvent);
} catch (Exception e) { } catch (Exception e) {
s_logger.debug("Failed to update state", e); s_logger.debug("Failed to update state", e);
throw new CloudRuntimeException("Failed to update state:" + e.toString()); throw new CloudRuntimeException("Failed to update state:" + e.toString());
} finally { } finally {
// in case of OperationFailed, expunge the entry // in case of OperationFailed, expunge the entry
if (event == ObjectInDataStoreStateMachine.Event.OperationFailed && if (event == ObjectInDataStoreStateMachine.Event.OperationFailed &&
(this.volumeVO.getState() != Volume.State.Copying && this.volumeVO.getState() != Volume.State.Uploaded)) { (volumeVO.getState() != Volume.State.Copying && volumeVO.getState() != Volume.State.Uploaded)) {
objectInStoreMgr.deleteIfNotReady(this); objectInStoreMgr.deleteIfNotReady(this);
} }
} }
@ -347,25 +348,25 @@ public class VolumeObject implements VolumeInfo {
@Override @Override
public String getName() { public String getName() {
return this.volumeVO.getName(); return volumeVO.getName();
} }
@Override @Override
public Long getInstanceId() { public Long getInstanceId() {
return this.volumeVO.getInstanceId(); return volumeVO.getInstanceId();
} }
@Override @Override
public String getFolder() { public String getFolder() {
return this.volumeVO.getFolder(); return volumeVO.getFolder();
} }
@Override @Override
public String getPath() { public String getPath() {
if (this.dataStore.getRole() == DataStoreRole.Primary) { if (dataStore.getRole() == DataStoreRole.Primary) {
return this.volumeVO.getPath(); return volumeVO.getPath();
} else { } else {
DataObjectInStore objInStore = this.objectInStoreMgr.findObject(this, dataStore); DataObjectInStore objInStore = objectInStoreMgr.findObject(this, dataStore);
if (objInStore != null) { if (objInStore != null) {
return objInStore.getInstallPath(); return objInStore.getInstallPath();
} else { } else {
@ -376,121 +377,121 @@ public class VolumeObject implements VolumeInfo {
@Override @Override
public Long getPodId() { public Long getPodId() {
return this.volumeVO.getPodId(); return volumeVO.getPodId();
} }
@Override @Override
public long getDataCenterId() { public long getDataCenterId() {
return this.volumeVO.getDataCenterId(); return volumeVO.getDataCenterId();
} }
@Override @Override
public Type getVolumeType() { public Type getVolumeType() {
return this.volumeVO.getVolumeType(); return volumeVO.getVolumeType();
} }
@Override @Override
public Long getPoolId() { public Long getPoolId() {
return this.volumeVO.getPoolId(); return volumeVO.getPoolId();
} }
@Override @Override
public Date getAttached() { public Date getAttached() {
return this.volumeVO.getAttached(); return volumeVO.getAttached();
} }
@Override @Override
public Long getDeviceId() { public Long getDeviceId() {
return this.volumeVO.getDeviceId(); return volumeVO.getDeviceId();
} }
@Override @Override
public Date getCreated() { public Date getCreated() {
return this.volumeVO.getCreated(); return volumeVO.getCreated();
} }
@Override @Override
public Long getDiskOfferingId() { public Long getDiskOfferingId() {
return this.volumeVO.getDiskOfferingId(); return volumeVO.getDiskOfferingId();
} }
@Override @Override
public String getChainInfo() { public String getChainInfo() {
return this.volumeVO.getChainInfo(); return volumeVO.getChainInfo();
} }
@Override @Override
public boolean isRecreatable() { public boolean isRecreatable() {
return this.volumeVO.isRecreatable(); return volumeVO.isRecreatable();
} }
@Override @Override
public long getUpdatedCount() { public long getUpdatedCount() {
return this.volumeVO.getUpdatedCount(); return volumeVO.getUpdatedCount();
} }
@Override @Override
public void incrUpdatedCount() { public void incrUpdatedCount() {
this.volumeVO.incrUpdatedCount(); volumeVO.incrUpdatedCount();
} }
@Override @Override
public Date getUpdated() { public Date getUpdated() {
return this.volumeVO.getUpdated(); return volumeVO.getUpdated();
} }
@Override @Override
public String getReservationId() { public String getReservationId() {
return this.volumeVO.getReservationId(); return volumeVO.getReservationId();
} }
@Override @Override
public void setReservationId(String reserv) { public void setReservationId(String reserv) {
this.volumeVO.setReservationId(reserv); volumeVO.setReservationId(reserv);
} }
@Override @Override
public long getAccountId() { public long getAccountId() {
return this.volumeVO.getAccountId(); return volumeVO.getAccountId();
} }
@Override @Override
public long getDomainId() { public long getDomainId() {
return this.volumeVO.getDomainId(); return volumeVO.getDomainId();
} }
@Override @Override
public Long getTemplateId() { public Long getTemplateId() {
return this.volumeVO.getTemplateId(); return volumeVO.getTemplateId();
} }
@Override @Override
public void addPayload(Object data) { public void addPayload(Object data) {
this.payload = data; payload = data;
} }
@Override @Override
public Object getpayload() { public Object getpayload() {
return this.payload; return payload;
} }
public VolumeVO getVolume() { public VolumeVO getVolume() {
return this.volumeVO; return volumeVO;
} }
@Override @Override
public HypervisorType getHypervisorType() { public HypervisorType getHypervisorType() {
return this.volumeDao.getHypervisorType(this.volumeVO.getId()); return volumeDao.getHypervisorType(volumeVO.getId());
} }
@Override @Override
public Long getLastPoolId() { public Long getLastPoolId() {
return this.volumeVO.getLastPoolId(); return volumeVO.getLastPoolId();
} }
@Override @Override
public DataTO getTO() { public DataTO getTO() {
DataTO to = this.getDataStore().getDriver().getTO(this); DataTO to = getDataStore().getDriver().getTO(this);
if (to == null) { if (to == null) {
to = new VolumeObjectTO(this); to = new VolumeObjectTO(this);
} }
@ -500,10 +501,10 @@ public class VolumeObject implements VolumeInfo {
@Override @Override
public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer) { public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer) {
try { try {
if (this.dataStore.getRole() == DataStoreRole.Primary) { if (dataStore.getRole() == DataStoreRole.Primary) {
if (answer instanceof CopyCmdAnswer) { if (answer instanceof CopyCmdAnswer) {
CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer; CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer;
VolumeVO vol = this.volumeDao.findById(this.getId()); VolumeVO vol = volumeDao.findById(getId());
VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData(); VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData();
vol.setPath(newVol.getPath()); vol.setPath(newVol.getPath());
if (newVol.getSize() != null) { if (newVol.getSize() != null) {
@ -512,17 +513,17 @@ public class VolumeObject implements VolumeInfo {
if (newVol.getFormat() != null) { if (newVol.getFormat() != null) {
vol.setFormat(newVol.getFormat()); vol.setFormat(newVol.getFormat());
} }
vol.setPoolId(this.getDataStore().getId()); vol.setPoolId(getDataStore().getId());
volumeDao.update(vol.getId(), vol); volumeDao.update(vol.getId(), vol);
} else if (answer instanceof CreateObjectAnswer) { } else if (answer instanceof CreateObjectAnswer) {
CreateObjectAnswer createAnswer = (CreateObjectAnswer)answer; CreateObjectAnswer createAnswer = (CreateObjectAnswer)answer;
VolumeObjectTO newVol = (VolumeObjectTO)createAnswer.getData(); VolumeObjectTO newVol = (VolumeObjectTO)createAnswer.getData();
VolumeVO vol = this.volumeDao.findById(this.getId()); VolumeVO vol = volumeDao.findById(getId());
vol.setPath(newVol.getPath()); vol.setPath(newVol.getPath());
if (newVol.getSize() != null) { if (newVol.getSize() != null) {
vol.setSize(newVol.getSize()); vol.setSize(newVol.getSize());
} }
vol.setPoolId(this.getDataStore().getId()); vol.setPoolId(getDataStore().getId());
if (newVol.getFormat() != null) { if (newVol.getFormat() != null) {
vol.setFormat(newVol.getFormat()); vol.setFormat(newVol.getFormat());
} }
@ -532,19 +533,19 @@ public class VolumeObject implements VolumeInfo {
// image store or imageCache store // image store or imageCache store
if (answer instanceof DownloadAnswer) { if (answer instanceof DownloadAnswer) {
DownloadAnswer dwdAnswer = (DownloadAnswer)answer; DownloadAnswer dwdAnswer = (DownloadAnswer)answer;
VolumeDataStoreVO volStore = this.volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId()); VolumeDataStoreVO volStore = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
volStore.setInstallPath(dwdAnswer.getInstallPath()); volStore.setInstallPath(dwdAnswer.getInstallPath());
volStore.setChecksum(dwdAnswer.getCheckSum()); volStore.setChecksum(dwdAnswer.getCheckSum());
this.volumeStoreDao.update(volStore.getId(), volStore); volumeStoreDao.update(volStore.getId(), volStore);
} else if (answer instanceof CopyCmdAnswer) { } else if (answer instanceof CopyCmdAnswer) {
CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer; CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer;
VolumeDataStoreVO volStore = this.volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId()); VolumeDataStoreVO volStore = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData(); VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData();
volStore.setInstallPath(newVol.getPath()); volStore.setInstallPath(newVol.getPath());
if (newVol.getSize() != null) { if (newVol.getSize() != null) {
volStore.setSize(newVol.getSize()); volStore.setSize(newVol.getSize());
} }
this.volumeStoreDao.update(volStore.getId(), volStore); volumeStoreDao.update(volStore.getId(), volStore);
} }
} }
} catch (RuntimeException ex) { } catch (RuntimeException ex) {
@ -559,12 +560,12 @@ public class VolumeObject implements VolumeInfo {
@Override @Override
public void incRefCount() { public void incRefCount() {
if (this.dataStore == null) { if (dataStore == null) {
return; return;
} }
if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) { if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId()); VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
store.incrRefCnt(); store.incrRefCnt();
store.setLastUpdated(new Date()); store.setLastUpdated(new Date());
volumeStoreDao.update(store.getId(), store); volumeStoreDao.update(store.getId(), store);
@ -573,11 +574,11 @@ public class VolumeObject implements VolumeInfo {
@Override @Override
public void decRefCount() { public void decRefCount() {
if (this.dataStore == null) { if (dataStore == null) {
return; return;
} }
if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) { if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId()); VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
store.decrRefCnt(); store.decrRefCnt();
store.setLastUpdated(new Date()); store.setLastUpdated(new Date());
volumeStoreDao.update(store.getId(), store); volumeStoreDao.update(store.getId(), store);
@ -586,11 +587,11 @@ public class VolumeObject implements VolumeInfo {
@Override @Override
public Long getRefCount() { public Long getRefCount() {
if (this.dataStore == null) { if (dataStore == null) {
return null; return null;
} }
if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) { if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId()); VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
return store.getRefCnt(); return store.getRefCnt();
} }
return null; return null;
@ -599,45 +600,45 @@ public class VolumeObject implements VolumeInfo {
@Override @Override
public void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer answer) { public void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer answer) {
try { try {
if (this.dataStore.getRole() == DataStoreRole.Primary) { if (dataStore.getRole() == DataStoreRole.Primary) {
if (answer instanceof CopyCmdAnswer) { if (answer instanceof CopyCmdAnswer) {
CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer; CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer;
VolumeVO vol = this.volumeDao.findById(this.getId()); VolumeVO vol = volumeDao.findById(getId());
VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData(); VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData();
vol.setPath(newVol.getPath()); vol.setPath(newVol.getPath());
if (newVol.getSize() != null) { if (newVol.getSize() != null) {
vol.setSize(newVol.getSize()); vol.setSize(newVol.getSize());
} }
vol.setPoolId(this.getDataStore().getId()); vol.setPoolId(getDataStore().getId());
volumeDao.update(vol.getId(), vol); volumeDao.update(vol.getId(), vol);
} else if (answer instanceof CreateObjectAnswer) { } else if (answer instanceof CreateObjectAnswer) {
CreateObjectAnswer createAnswer = (CreateObjectAnswer)answer; CreateObjectAnswer createAnswer = (CreateObjectAnswer)answer;
VolumeObjectTO newVol = (VolumeObjectTO)createAnswer.getData(); VolumeObjectTO newVol = (VolumeObjectTO)createAnswer.getData();
VolumeVO vol = this.volumeDao.findById(this.getId()); VolumeVO vol = volumeDao.findById(getId());
vol.setPath(newVol.getPath()); vol.setPath(newVol.getPath());
if (newVol.getSize() != null) { if (newVol.getSize() != null) {
vol.setSize(newVol.getSize()); vol.setSize(newVol.getSize());
} }
vol.setPoolId(this.getDataStore().getId()); vol.setPoolId(getDataStore().getId());
volumeDao.update(vol.getId(), vol); volumeDao.update(vol.getId(), vol);
} }
} else { } else {
// image store or imageCache store // image store or imageCache store
if (answer instanceof DownloadAnswer) { if (answer instanceof DownloadAnswer) {
DownloadAnswer dwdAnswer = (DownloadAnswer)answer; DownloadAnswer dwdAnswer = (DownloadAnswer)answer;
VolumeDataStoreVO volStore = this.volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId()); VolumeDataStoreVO volStore = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
volStore.setInstallPath(dwdAnswer.getInstallPath()); volStore.setInstallPath(dwdAnswer.getInstallPath());
volStore.setChecksum(dwdAnswer.getCheckSum()); volStore.setChecksum(dwdAnswer.getCheckSum());
this.volumeStoreDao.update(volStore.getId(), volStore); volumeStoreDao.update(volStore.getId(), volStore);
} else if (answer instanceof CopyCmdAnswer) { } else if (answer instanceof CopyCmdAnswer) {
CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer; CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer;
VolumeDataStoreVO volStore = this.volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId()); VolumeDataStoreVO volStore = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData(); VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData();
volStore.setInstallPath(newVol.getPath()); volStore.setInstallPath(newVol.getPath());
if (newVol.getSize() != null) { if (newVol.getSize() != null) {
volStore.setSize(newVol.getSize()); volStore.setSize(newVol.getSize());
} }
this.volumeStoreDao.update(volStore.getId(), volStore); volumeStoreDao.update(volStore.getId(), volStore);
} }
} }
} catch (RuntimeException ex) { } catch (RuntimeException ex) {
@ -652,7 +653,7 @@ public class VolumeObject implements VolumeInfo {
@Override @Override
public ImageFormat getFormat() { public ImageFormat getFormat() {
return this.volumeVO.getFormat(); return volumeVO.getFormat();
} }
@Override @Override
@ -665,6 +666,11 @@ public class VolumeObject implements VolumeInfo {
@Override @Override
public Long getVmSnapshotChainSize() { public Long getVmSnapshotChainSize() {
return this.volumeVO.getVmSnapshotChainSize(); return volumeVO.getVmSnapshotChainSize();
}
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Volume;
} }
} }

View File

@ -24,6 +24,7 @@ import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine;
@ -192,4 +193,9 @@ public class AffinityGroupJoinVO extends BaseViewVO implements ControlledViewEnt
return aclType; return aclType;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.AffinityGroup;
}
} }

View File

@ -26,6 +26,8 @@ import javax.persistence.Enumerated;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.network.Network.GuestType; import com.cloud.network.Network.GuestType;
import com.cloud.network.Networks.TrafficType; import com.cloud.network.Networks.TrafficType;
import com.cloud.network.router.VirtualRouter; import com.cloud.network.router.VirtualRouter;
@ -510,4 +512,10 @@ public class DomainRouterJoinVO extends BaseViewVO implements ControlledViewEnti
public VirtualRouter.Role getRole() { public VirtualRouter.Role getRole() {
return role; return role;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.VirtualMachine;
}
} }

View File

@ -25,6 +25,8 @@ import javax.persistence.Enumerated;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.event.Event.State; import com.cloud.event.Event.State;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@ -223,4 +225,10 @@ public class EventJoinVO extends BaseViewVO implements ControlledViewEntity {
public boolean getDisplayEvent() { public boolean getDisplayEvent() {
return displayEvent; return displayEvent;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Event;
}
} }

View File

@ -23,6 +23,8 @@ import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@Entity @Entity
@ -156,4 +158,10 @@ public class InstanceGroupJoinVO extends BaseViewVO implements ControlledViewEnt
public Date getCreated() { public Date getCreated() {
return created; return created;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.InstanceGroup;
}
} }

View File

@ -25,6 +25,8 @@ import javax.persistence.Enumerated;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.projects.ProjectInvitation.State; import com.cloud.projects.ProjectInvitation.State;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@ -160,4 +162,10 @@ public class ProjectInvitationJoinVO extends BaseViewVO implements ControlledVie
public String getDomainPath() { public String getDomainPath() {
return domainPath; return domainPath;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.ProjectInvitation;
}
} }

View File

@ -23,6 +23,8 @@ import javax.persistence.Enumerated;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.server.ResourceTag.ResourceObjectType; import com.cloud.server.ResourceTag.ResourceObjectType;
@Entity @Entity
@ -178,4 +180,10 @@ public class ResourceTagJoinVO extends BaseViewVO implements ControlledViewEntit
public String getCustomer() { public String getCustomer() {
return customer; return customer;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.ResourceTag;
}
} }

View File

@ -23,6 +23,8 @@ import javax.persistence.Enumerated;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.network.security.SecurityRule.SecurityRuleType; import com.cloud.network.security.SecurityRule.SecurityRuleType;
import com.cloud.server.ResourceTag.ResourceObjectType; import com.cloud.server.ResourceTag.ResourceObjectType;
@ -302,4 +304,10 @@ public class SecurityGroupJoinVO extends BaseViewVO implements ControlledViewEnt
public String getTagCustomer() { public String getTagCustomer() {
return tagCustomer; return tagCustomer;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.SecurityGroup;
}
} }

View File

@ -27,7 +27,7 @@ import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import com.cloud.template.VirtualMachineTemplate.State; import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine; import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
@ -35,6 +35,7 @@ import com.cloud.server.ResourceTag.ResourceObjectType;
import com.cloud.storage.ScopeType; import com.cloud.storage.ScopeType;
import com.cloud.storage.Storage; import com.cloud.storage.Storage;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status; import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.template.VirtualMachineTemplate.State;
import com.cloud.utils.db.GenericDao; import com.cloud.utils.db.GenericDao;
@Entity @Entity
@ -539,4 +540,10 @@ public class TemplateJoinVO extends BaseViewVO implements ControlledViewEntity {
} }
public State getTemplateState() { return templateState; } public State getTemplateState() { return templateState; }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.VirtualMachineTemplate;
}
} }

View File

@ -28,6 +28,8 @@ import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient; import javax.persistence.Transient;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.Network.GuestType; import com.cloud.network.Network.GuestType;
import com.cloud.network.Networks.TrafficType; import com.cloud.network.Networks.TrafficType;
@ -909,4 +911,10 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity {
public String getDetailValue() { public String getDetailValue() {
return detailValue; return detailValue;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.VirtualMachine;
}
} }

View File

@ -27,6 +27,8 @@ import javax.persistence.Table;
import javax.persistence.Temporal; import javax.persistence.Temporal;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.server.ResourceTag.ResourceObjectType; import com.cloud.server.ResourceTag.ResourceObjectType;
import com.cloud.storage.Storage; import com.cloud.storage.Storage;
@ -573,4 +575,10 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity {
public String getChainInfo() { public String getChainInfo() {
return chainInfo; return chainInfo;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Volume;
}
} }

View File

@ -22,6 +22,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.cloudstack.acl.ControlledEntity; import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.api.InternalIdentity; import org.apache.cloudstack.api.InternalIdentity;
import com.cloud.api.ApiDBUtils; import com.cloud.api.ApiDBUtils;
@ -63,7 +64,7 @@ public class SecurityGroupResultObject implements ControlledEntity, InternalIden
this.domainId = domainId; this.domainId = domainId;
this.accountId = accountId; this.accountId = accountId;
this.accountName = accountName; this.accountName = accountName;
this.securityGroupRules = ingressRules; securityGroupRules = ingressRules;
} }
@Override @Override
@ -209,4 +210,9 @@ public class SecurityGroupResultObject implements ControlledEntity, InternalIden
} }
return resultObjects; return resultObjects;
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.SecurityGroup;
}
} }

View File

@ -16,6 +16,8 @@
// under the License. // under the License.
package com.cloud.network.vpc; package com.cloud.network.vpc;
import org.apache.cloudstack.acl.IAMEntityType;
public class PrivateGatewayProfile implements PrivateGateway { public class PrivateGatewayProfile implements PrivateGateway {
VpcGateway vpcGateway; VpcGateway vpcGateway;
long physicalNetworkId; long physicalNetworkId;
@ -110,4 +112,8 @@ public class PrivateGatewayProfile implements PrivateGateway {
return vpcGateway.getNetworkACLId(); return vpcGateway.getNetworkACLId();
} }
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.VpcGateway;
}
} }