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 org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.Mode;
import com.cloud.network.Networks.TrafficType;
@ -275,4 +277,9 @@ public class NetworkProfile implements Network {
public String getIp6Cidr() {
return ip6Cidr;
}
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Network;
}
}

View File

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

View File

@ -29,4 +29,5 @@ public interface ControlledEntity extends OwnedBy, PartOf {
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.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
@ -32,7 +35,6 @@ import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.FirewallResponse;
import org.apache.cloudstack.api.response.NetworkResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
@ -275,7 +277,7 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F
@Override
public String getEventDescription() {
Network network = _networkService.getNetwork(networkId);
return ("Creating firewall rule for network: " + network + " for protocol:" + this.getProtocol());
return ("Creating firewall rule for network: " + network + " for protocol:" + getProtocol());
}
@Override
@ -354,4 +356,9 @@ public class CreateEgressFirewallRuleCmd extends BaseAsyncCreateCmd implements F
}
}
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.FirewallRule;
}
}

View File

@ -19,6 +19,9 @@ package org.apache.cloudstack.api.command.user.firewall;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.acl.RoleType;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiCommandJobType;
@ -31,7 +34,6 @@ import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.FirewallResponse;
import org.apache.cloudstack.api.response.IPAddressResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.log4j.Logger;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
@ -266,7 +268,7 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
@Override
public String getEventDescription() {
IpAddress ip = _networkService.getIp(ipAddressId);
return ("Creating firewall rule for Ip: " + ip.getAddress() + " for protocol:" + this.getProtocol());
return ("Creating firewall rule for Ip: " + ip.getAddress() + " for protocol:" + getProtocol());
}
@Override
@ -346,4 +348,10 @@ public class CreateFirewallRuleCmd extends BaseAsyncCreateCmd implements Firewal
return true;
}
}
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.FirewallRule;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,6 +36,8 @@ import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.db.Encrypt;
import com.cloud.utils.db.GenericDao;
@ -183,27 +185,27 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
public VMInstanceVO(long id, long serviceOfferingId, String name, String instanceName, Type type, Long vmTemplateId, HypervisorType hypervisorType, long guestOSId,
long domainId, long accountId, boolean haEnabled) {
this.id = id;
this.hostName = name != null ? name : this.uuid;
hostName = name != null ? name : uuid;
if (vmTemplateId != null) {
this.templateId = vmTemplateId;
templateId = vmTemplateId;
}
this.instanceName = instanceName;
this.type = type;
this.guestOSId = guestOSId;
this.haEnabled = haEnabled;
this.vncPassword = Long.toHexString(new Random().nextLong());
this.state = State.Stopped;
vncPassword = Long.toHexString(new Random().nextLong());
state = State.Stopped;
this.accountId = accountId;
this.domainId = domainId;
this.serviceOfferingId = serviceOfferingId;
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,
long domainId, long accountId, boolean haEnabled, boolean limitResourceUse, Long diskOfferingId) {
this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled);
this.limitCpuUse = limitResourceUse;
limitCpuUse = limitResourceUse;
this.diskOfferingId = diskOfferingId;
}
@ -324,11 +326,11 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
}
public Date getProxyAssignTime() {
return this.proxyAssignTime;
return proxyAssignTime;
}
public void setProxyAssignTime(Date time) {
this.proxyAssignTime = time;
proxyAssignTime = time;
}
@Override
@ -412,7 +414,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
}
public void setPodId(long podId) {
this.podIdToDeployIn = podId;
podIdToDeployIn = podId;
}
public void setPrivateMacAddress(String privateMacAddress) {
@ -436,7 +438,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
}
public String getReservationId() {
return this.reservationId;
return reservationId;
}
@Override
@ -500,7 +502,7 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
}
public Boolean isDynamicallyScalable() {
return this.dynamicallyScalable;
return dynamicallyScalable;
}
public VirtualMachine.PowerState getPowerState() {
@ -535,4 +537,8 @@ public class VMInstanceVO implements VirtualMachine, FiniteStateObject<State, Vi
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.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao;
import com.cloud.utils.net.NetUtils;
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) {
this.nicId = nicId;
this.vmId = vmId;
this.ip4Address = ipaddr;
ip4Address = ipaddr;
this.accountId = accountId;
this.domainId = domainId;
this.networkId = networkId;
this.netmask = netmask;
this.gateway = gateway;
this.state = NicIpAlias.state.active;
state = NicIpAlias.state.active;
String cidr = NetUtils.getCidrFromGatewayAndNetmask(gateway, netmask);
String[] cidrPair = cidr.split("\\/");
String cidrAddress = cidrPair[0];
long cidrSize = Long.parseLong(cidrPair[1]);
this.startIpOfSubnet = NetUtils.getIpRangeStartIpFromCidr(cidrAddress, cidrSize);
startIpOfSubnet = NetUtils.getIpRangeStartIpFromCidr(cidrAddress, cidrSize);
}
protected NicIpAliasVO() {
@ -199,7 +201,7 @@ public class NicIpAliasVO implements NicIpAlias {
}
public void setAliasCount(long count) {
this.aliasCount = count;
aliasCount = count;
}
public void setNetmask(String netmask) {
@ -232,4 +234,8 @@ public class NicIpAliasVO implements NicIpAlias {
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.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao;
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) {
this.nicId = nicId;
this.vmId = vmId;
this.ip4Address = ipaddr;
ip4Address = ipaddr;
this.accountId = accountId;
this.domainId = domainId;
this.networkId = networkId;
@ -124,4 +126,9 @@ public class NicSecondaryIpVO implements NicSecondaryIp {
public long getVmId() {
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.Transient;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.engine.subsystem.api.storage.VMSnapshotOptions;
import com.cloud.utils.db.GenericDao;
@ -133,10 +134,10 @@ public class VMSnapshotVO implements VMSnapshot {
this.accountId = accountId;
this.domainId = domainId;
this.vmId = vmId;
this.state = State.Allocated;
state = State.Allocated;
this.description = description;
this.name = vmSnapshotName;
this.displayName = vsDisplayName;
name = vmSnapshotName;
displayName = vsDisplayName;
this.type = type;
this.current = current;
}
@ -227,7 +228,7 @@ public class VMSnapshotVO implements VMSnapshot {
@Override
public void incrUpdatedCount() {
this.updatedCount++;
updatedCount++;
}
@Override
@ -243,4 +244,9 @@ public class VMSnapshotVO implements VMSnapshot {
public void setRemoved(Date 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 org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.IAMEntityType;
@Entity
@Table(name = ("affinity_group"))
@ -60,7 +61,7 @@ public class AffinityGroupVO implements AffinityGroup {
ControlledEntity.ACLType aclType;
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) {
@ -68,7 +69,7 @@ public class AffinityGroupVO implements AffinityGroup {
this.description = description;
this.domainId = domainId;
this.accountId = accountId;
this.uuid = UUID.randomUUID().toString();
uuid = UUID.randomUUID().toString();
this.type = type;
this.aclType = aclType;
}
@ -100,7 +101,7 @@ public class AffinityGroupVO implements AffinityGroup {
@Override
public String getUuid() {
return this.uuid;
return uuid;
}
public void setUuid(String uuid) {
@ -124,4 +125,9 @@ public class AffinityGroupVO implements AffinityGroup {
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.Transient;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.utils.db.Encrypt;
import com.cloud.utils.db.GenericDao;
@ -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,
long domainId, long accountId, boolean haEnabled, Long diskOfferingId) {
this.id = id;
this.hostName = name != null ? name : this.uuid;
hostName = name != null ? name : uuid;
if (vmTemplateId != null) {
this.templateId = vmTemplateId;
templateId = vmTemplateId;
}
this.instanceName = instanceName;
this.type = type;
this.guestOSId = guestOSId;
this.haEnabled = haEnabled;
this.vncPassword = Long.toHexString(new Random().nextLong());
this.state = State.Stopped;
vncPassword = Long.toHexString(new Random().nextLong());
state = State.Stopped;
this.accountId = accountId;
this.domainId = domainId;
this.serviceOfferingId = serviceOfferingId;
this.hypervisorType = hypervisorType;
this.limitCpuUse = false;
limitCpuUse = false;
this.diskOfferingId = diskOfferingId;
}
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) {
this(id, serviceOfferingId, name, instanceName, type, vmTemplateId, hypervisorType, guestOSId, domainId, accountId, haEnabled, null);
this.limitCpuUse = limitResourceUse;
limitCpuUse = limitResourceUse;
}
protected VMEntityVO() {
@ -316,11 +318,11 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
}
public Date getProxyAssignTime() {
return this.proxyAssignTime;
return proxyAssignTime;
}
public void setProxyAssignTime(Date time) {
this.proxyAssignTime = time;
proxyAssignTime = time;
}
@Override
@ -396,7 +398,7 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
}
public void setPodId(long podId) {
this.podIdToDeployIn = podId;
podIdToDeployIn = podId;
}
public void setPrivateMacAddress(String privateMacAddress) {
@ -404,7 +406,7 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
}
public void setDataCenterId(long dataCenterId) {
this.dataCenterIdToDeployIn = dataCenterId;
dataCenterIdToDeployIn = dataCenterId;
}
public boolean isRemoved() {
@ -420,7 +422,7 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
}
public String getReservationId() {
return this.reservationId;
return reservationId;
}
@Override
@ -535,4 +537,8 @@ public class VMEntityVO implements VirtualMachine, FiniteStateObject<State, Virt
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.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.region.ha.GlobalLoadBalancerRule;
@Entity
@ -74,21 +76,21 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule {
GlobalLoadBalancerRule.State state;
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,
long accountId, long domainId, State state) {
this.name = name;
this.description = description;
this.region = regionId;
region = regionId;
this.algorithm = algorithm;
this.gslbDomain = gslbDomain;
this.persistence = persistence;
this.accountId = accountId;
this.domainId = domainId;
this.serviceType = serviceType;
this.uuid = UUID.randomUUID().toString();
uuid = UUID.randomUUID().toString();
this.state = state;
}
@ -163,7 +165,7 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule {
@Override
public String getUuid() {
return this.uuid;
return uuid;
}
public void setUuid(String uuid) {
@ -187,4 +189,9 @@ public class GlobalLoadBalancerRuleVO implements GlobalLoadBalancerRule {
public GlobalLoadBalancerRule.State getState() {
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.cloudstack.acl.IAMEntityType;
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.ObjectInDataStoreStateMachine;
@ -436,4 +437,8 @@ public class TemplateObject implements TemplateInfo {
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.cloudstack.acl.IAMEntityType;
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.ObjectInDataStoreStateMachine;
@ -380,4 +381,9 @@ public class SnapshotObject implements SnapshotInfo {
}
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.Map;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.engine.cloud.entity.api.TemplateEntity;
import org.apache.cloudstack.engine.subsystem.api.storage.TemplateInfo;
import org.apache.cloudstack.storage.image.datastore.ImageStoreInfo;
@ -285,4 +286,8 @@ public class TemplateEntityImpl implements TemplateEntity {
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.Map;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.engine.cloud.entity.api.SnapshotEntity;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
@ -183,4 +184,8 @@ public class SnapshotEntityImpl implements SnapshotEntity {
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 com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.dao.DiskOfferingDao;
import com.cloud.vm.VirtualMachine;
import org.apache.cloudstack.acl.IAMEntityType;
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.ObjectInDataStoreStateMachine;
@ -43,9 +41,11 @@ import com.cloud.agent.api.to.DataTO;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.offering.DiskOffering.DiskCacheMode;
import com.cloud.storage.DataStoreRole;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Volume;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.dao.DiskOfferingDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.utils.component.ComponentContext;
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.storage.encoding.EncodingType;
import com.cloud.vm.VMInstanceVO;
import com.cloud.vm.VirtualMachine;
import com.cloud.vm.dao.VMInstanceDao;
public class VolumeObject implements VolumeInfo {
@ -89,7 +90,7 @@ public class VolumeObject implements VolumeInfo {
@Override
public String getAttachedVmName() {
Long vmId = this.volumeVO.getInstanceId();
Long vmId = volumeVO.getInstanceId();
if (vmId != null) {
VMInstanceVO vm = vmInstanceDao.findById(vmId);
@ -103,7 +104,7 @@ public class VolumeObject implements VolumeInfo {
@Override
public VirtualMachine getAttachedVM() {
Long vmId = this.volumeVO.getInstanceId();
Long vmId = volumeVO.getInstanceId();
if (vmId != null) {
VMInstanceVO vm = vmInstanceDao.findById(vmId);
return vm;
@ -179,7 +180,7 @@ public class VolumeObject implements VolumeInfo {
result = _volStateMachine.transitTo(volumeVO, event, null, volumeDao);
volumeVO = volumeDao.findById(volumeVO.getId());
} 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);
throw new CloudRuntimeException(errorMessage);
}
@ -246,25 +247,25 @@ public class VolumeObject implements VolumeInfo {
@Override
public long getId() {
return this.volumeVO.getId();
return volumeVO.getId();
}
@Override
public boolean isAttachedVM() {
return (this.volumeVO.getInstanceId() == null) ? false : true;
return (volumeVO.getInstanceId() == null) ? false : true;
}
@Override
public String getUri() {
if (this.dataStore == null) {
if (dataStore == null) {
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) {
return this.dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.SIZE + "=" + this.volumeVO.getSize() + "&" +
EncodingType.NAME + "=" + this.volumeVO.getName();
return dataStore.getUri() + "&" + EncodingType.OBJTYPE + "=" + DataObjectType.VOLUME + "&" + EncodingType.SIZE + "=" + volumeVO.getSize() + "&" +
EncodingType.NAME + "=" + volumeVO.getName();
} 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
public void processEvent(ObjectInDataStoreStateMachine.Event event) {
if (this.dataStore == null) {
if (dataStore == null) {
return;
}
try {
Volume.Event volEvent = null;
if (this.dataStore.getRole() == DataStoreRole.ImageCache) {
if (dataStore.getRole() == DataStoreRole.ImageCache) {
objectInStoreMgr.update(this, event);
return;
}
if (this.dataStore.getRole() == DataStoreRole.Image) {
if (dataStore.getRole() == DataStoreRole.Image) {
objectInStoreMgr.update(this, event);
if (this.volumeVO.getState() == Volume.State.Migrating || this.volumeVO.getState() == Volume.State.Copying ||
this.volumeVO.getState() == Volume.State.Uploaded || this.volumeVO.getState() == Volume.State.Expunged) {
if (volumeVO.getState() == Volume.State.Migrating || volumeVO.getState() == Volume.State.Copying ||
volumeVO.getState() == Volume.State.Uploaded || volumeVO.getState() == Volume.State.Expunged) {
return;
}
if (event == ObjectInDataStoreStateMachine.Event.CreateOnlyRequested) {
@ -316,14 +317,14 @@ public class VolumeObject implements VolumeInfo {
} else if (event == ObjectInDataStoreStateMachine.Event.ResizeRequested) {
volEvent = Volume.Event.ResizeRequested;
}
this.stateTransit(volEvent);
stateTransit(volEvent);
} catch (Exception e) {
s_logger.debug("Failed to update state", e);
throw new CloudRuntimeException("Failed to update state:" + e.toString());
} finally {
// in case of OperationFailed, expunge the entry
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);
}
}
@ -347,25 +348,25 @@ public class VolumeObject implements VolumeInfo {
@Override
public String getName() {
return this.volumeVO.getName();
return volumeVO.getName();
}
@Override
public Long getInstanceId() {
return this.volumeVO.getInstanceId();
return volumeVO.getInstanceId();
}
@Override
public String getFolder() {
return this.volumeVO.getFolder();
return volumeVO.getFolder();
}
@Override
public String getPath() {
if (this.dataStore.getRole() == DataStoreRole.Primary) {
return this.volumeVO.getPath();
if (dataStore.getRole() == DataStoreRole.Primary) {
return volumeVO.getPath();
} else {
DataObjectInStore objInStore = this.objectInStoreMgr.findObject(this, dataStore);
DataObjectInStore objInStore = objectInStoreMgr.findObject(this, dataStore);
if (objInStore != null) {
return objInStore.getInstallPath();
} else {
@ -376,121 +377,121 @@ public class VolumeObject implements VolumeInfo {
@Override
public Long getPodId() {
return this.volumeVO.getPodId();
return volumeVO.getPodId();
}
@Override
public long getDataCenterId() {
return this.volumeVO.getDataCenterId();
return volumeVO.getDataCenterId();
}
@Override
public Type getVolumeType() {
return this.volumeVO.getVolumeType();
return volumeVO.getVolumeType();
}
@Override
public Long getPoolId() {
return this.volumeVO.getPoolId();
return volumeVO.getPoolId();
}
@Override
public Date getAttached() {
return this.volumeVO.getAttached();
return volumeVO.getAttached();
}
@Override
public Long getDeviceId() {
return this.volumeVO.getDeviceId();
return volumeVO.getDeviceId();
}
@Override
public Date getCreated() {
return this.volumeVO.getCreated();
return volumeVO.getCreated();
}
@Override
public Long getDiskOfferingId() {
return this.volumeVO.getDiskOfferingId();
return volumeVO.getDiskOfferingId();
}
@Override
public String getChainInfo() {
return this.volumeVO.getChainInfo();
return volumeVO.getChainInfo();
}
@Override
public boolean isRecreatable() {
return this.volumeVO.isRecreatable();
return volumeVO.isRecreatable();
}
@Override
public long getUpdatedCount() {
return this.volumeVO.getUpdatedCount();
return volumeVO.getUpdatedCount();
}
@Override
public void incrUpdatedCount() {
this.volumeVO.incrUpdatedCount();
volumeVO.incrUpdatedCount();
}
@Override
public Date getUpdated() {
return this.volumeVO.getUpdated();
return volumeVO.getUpdated();
}
@Override
public String getReservationId() {
return this.volumeVO.getReservationId();
return volumeVO.getReservationId();
}
@Override
public void setReservationId(String reserv) {
this.volumeVO.setReservationId(reserv);
volumeVO.setReservationId(reserv);
}
@Override
public long getAccountId() {
return this.volumeVO.getAccountId();
return volumeVO.getAccountId();
}
@Override
public long getDomainId() {
return this.volumeVO.getDomainId();
return volumeVO.getDomainId();
}
@Override
public Long getTemplateId() {
return this.volumeVO.getTemplateId();
return volumeVO.getTemplateId();
}
@Override
public void addPayload(Object data) {
this.payload = data;
payload = data;
}
@Override
public Object getpayload() {
return this.payload;
return payload;
}
public VolumeVO getVolume() {
return this.volumeVO;
return volumeVO;
}
@Override
public HypervisorType getHypervisorType() {
return this.volumeDao.getHypervisorType(this.volumeVO.getId());
return volumeDao.getHypervisorType(volumeVO.getId());
}
@Override
public Long getLastPoolId() {
return this.volumeVO.getLastPoolId();
return volumeVO.getLastPoolId();
}
@Override
public DataTO getTO() {
DataTO to = this.getDataStore().getDriver().getTO(this);
DataTO to = getDataStore().getDriver().getTO(this);
if (to == null) {
to = new VolumeObjectTO(this);
}
@ -500,10 +501,10 @@ public class VolumeObject implements VolumeInfo {
@Override
public void processEvent(ObjectInDataStoreStateMachine.Event event, Answer answer) {
try {
if (this.dataStore.getRole() == DataStoreRole.Primary) {
if (dataStore.getRole() == DataStoreRole.Primary) {
if (answer instanceof CopyCmdAnswer) {
CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer;
VolumeVO vol = this.volumeDao.findById(this.getId());
VolumeVO vol = volumeDao.findById(getId());
VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData();
vol.setPath(newVol.getPath());
if (newVol.getSize() != null) {
@ -512,17 +513,17 @@ public class VolumeObject implements VolumeInfo {
if (newVol.getFormat() != null) {
vol.setFormat(newVol.getFormat());
}
vol.setPoolId(this.getDataStore().getId());
vol.setPoolId(getDataStore().getId());
volumeDao.update(vol.getId(), vol);
} else if (answer instanceof CreateObjectAnswer) {
CreateObjectAnswer createAnswer = (CreateObjectAnswer)answer;
VolumeObjectTO newVol = (VolumeObjectTO)createAnswer.getData();
VolumeVO vol = this.volumeDao.findById(this.getId());
VolumeVO vol = volumeDao.findById(getId());
vol.setPath(newVol.getPath());
if (newVol.getSize() != null) {
vol.setSize(newVol.getSize());
}
vol.setPoolId(this.getDataStore().getId());
vol.setPoolId(getDataStore().getId());
if (newVol.getFormat() != null) {
vol.setFormat(newVol.getFormat());
}
@ -532,19 +533,19 @@ public class VolumeObject implements VolumeInfo {
// image store or imageCache store
if (answer instanceof DownloadAnswer) {
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.setChecksum(dwdAnswer.getCheckSum());
this.volumeStoreDao.update(volStore.getId(), volStore);
volumeStoreDao.update(volStore.getId(), volStore);
} else if (answer instanceof CopyCmdAnswer) {
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();
volStore.setInstallPath(newVol.getPath());
if (newVol.getSize() != null) {
volStore.setSize(newVol.getSize());
}
this.volumeStoreDao.update(volStore.getId(), volStore);
volumeStoreDao.update(volStore.getId(), volStore);
}
}
} catch (RuntimeException ex) {
@ -559,12 +560,12 @@ public class VolumeObject implements VolumeInfo {
@Override
public void incRefCount() {
if (this.dataStore == null) {
if (dataStore == null) {
return;
}
if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId());
if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
store.incrRefCnt();
store.setLastUpdated(new Date());
volumeStoreDao.update(store.getId(), store);
@ -573,11 +574,11 @@ public class VolumeObject implements VolumeInfo {
@Override
public void decRefCount() {
if (this.dataStore == null) {
if (dataStore == null) {
return;
}
if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId());
if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
store.decrRefCnt();
store.setLastUpdated(new Date());
volumeStoreDao.update(store.getId(), store);
@ -586,11 +587,11 @@ public class VolumeObject implements VolumeInfo {
@Override
public Long getRefCount() {
if (this.dataStore == null) {
if (dataStore == null) {
return null;
}
if (this.dataStore.getRole() == DataStoreRole.Image || this.dataStore.getRole() == DataStoreRole.ImageCache) {
VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(this.dataStore.getId(), this.getId());
if (dataStore.getRole() == DataStoreRole.Image || dataStore.getRole() == DataStoreRole.ImageCache) {
VolumeDataStoreVO store = volumeStoreDao.findByStoreVolume(dataStore.getId(), getId());
return store.getRefCnt();
}
return null;
@ -599,45 +600,45 @@ public class VolumeObject implements VolumeInfo {
@Override
public void processEventOnly(ObjectInDataStoreStateMachine.Event event, Answer answer) {
try {
if (this.dataStore.getRole() == DataStoreRole.Primary) {
if (dataStore.getRole() == DataStoreRole.Primary) {
if (answer instanceof CopyCmdAnswer) {
CopyCmdAnswer cpyAnswer = (CopyCmdAnswer)answer;
VolumeVO vol = this.volumeDao.findById(this.getId());
VolumeVO vol = volumeDao.findById(getId());
VolumeObjectTO newVol = (VolumeObjectTO)cpyAnswer.getNewData();
vol.setPath(newVol.getPath());
if (newVol.getSize() != null) {
vol.setSize(newVol.getSize());
}
vol.setPoolId(this.getDataStore().getId());
vol.setPoolId(getDataStore().getId());
volumeDao.update(vol.getId(), vol);
} else if (answer instanceof CreateObjectAnswer) {
CreateObjectAnswer createAnswer = (CreateObjectAnswer)answer;
VolumeObjectTO newVol = (VolumeObjectTO)createAnswer.getData();
VolumeVO vol = this.volumeDao.findById(this.getId());
VolumeVO vol = volumeDao.findById(getId());
vol.setPath(newVol.getPath());
if (newVol.getSize() != null) {
vol.setSize(newVol.getSize());
}
vol.setPoolId(this.getDataStore().getId());
vol.setPoolId(getDataStore().getId());
volumeDao.update(vol.getId(), vol);
}
} else {
// image store or imageCache store
if (answer instanceof DownloadAnswer) {
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.setChecksum(dwdAnswer.getCheckSum());
this.volumeStoreDao.update(volStore.getId(), volStore);
volumeStoreDao.update(volStore.getId(), volStore);
} else if (answer instanceof CopyCmdAnswer) {
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();
volStore.setInstallPath(newVol.getPath());
if (newVol.getSize() != null) {
volStore.setSize(newVol.getSize());
}
this.volumeStoreDao.update(volStore.getId(), volStore);
volumeStoreDao.update(volStore.getId(), volStore);
}
}
} catch (RuntimeException ex) {
@ -652,7 +653,7 @@ public class VolumeObject implements VolumeInfo {
@Override
public ImageFormat getFormat() {
return this.volumeVO.getFormat();
return volumeVO.getFormat();
}
@Override
@ -665,6 +666,11 @@ public class VolumeObject implements VolumeInfo {
@Override
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 org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.vm.VirtualMachine;
@ -192,4 +193,9 @@ public class AffinityGroupJoinVO extends BaseViewVO implements ControlledViewEnt
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.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.network.Network.GuestType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.router.VirtualRouter;
@ -510,4 +512,10 @@ public class DomainRouterJoinVO extends BaseViewVO implements ControlledViewEnti
public VirtualRouter.Role getRole() {
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.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.event.Event.State;
import com.cloud.utils.db.GenericDao;
@ -223,4 +225,10 @@ public class EventJoinVO extends BaseViewVO implements ControlledViewEntity {
public boolean getDisplayEvent() {
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.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.utils.db.GenericDao;
@Entity
@ -156,4 +158,10 @@ public class InstanceGroupJoinVO extends BaseViewVO implements ControlledViewEnt
public Date getCreated() {
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.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.projects.ProjectInvitation.State;
import com.cloud.utils.db.GenericDao;
@ -160,4 +162,10 @@ public class ProjectInvitationJoinVO extends BaseViewVO implements ControlledVie
public String getDomainPath() {
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.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.server.ResourceTag.ResourceObjectType;
@Entity
@ -178,4 +180,10 @@ public class ResourceTagJoinVO extends BaseViewVO implements ControlledViewEntit
public String getCustomer() {
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.Table;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.network.security.SecurityRule.SecurityRuleType;
import com.cloud.server.ResourceTag.ResourceObjectType;
@ -302,4 +304,10 @@ public class SecurityGroupJoinVO extends BaseViewVO implements ControlledViewEnt
public String getTagCustomer() {
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.TemporalType;
import com.cloud.template.VirtualMachineTemplate.State;
import org.apache.cloudstack.acl.IAMEntityType;
import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
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.Storage;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.template.VirtualMachineTemplate.State;
import com.cloud.utils.db.GenericDao;
@Entity
@ -539,4 +540,10 @@ public class TemplateJoinVO extends BaseViewVO implements ControlledViewEntity {
}
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.Transient;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.Network.GuestType;
import com.cloud.network.Networks.TrafficType;
@ -909,4 +911,10 @@ public class UserVmJoinVO extends BaseViewVO implements ControlledViewEntity {
public String getDetailValue() {
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.TemporalType;
import org.apache.cloudstack.acl.IAMEntityType;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.server.ResourceTag.ResourceObjectType;
import com.cloud.storage.Storage;
@ -573,4 +575,10 @@ public class VolumeJoinVO extends BaseViewVO implements ControlledViewEntity {
public String getChainInfo() {
return chainInfo;
}
@Override
public IAMEntityType getEntityType() {
return IAMEntityType.Volume;
}
}

View File

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

View File

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