More stuff to Projects feature - added support for adding resources (vms, templates, isos) to the project

This commit is contained in:
alena 2011-09-30 16:30:46 -07:00
parent 998568283c
commit 25c2734e03
117 changed files with 1375 additions and 2050 deletions

View File

@ -46,12 +46,11 @@ public interface SecurityChecker extends Adapter {
* Checks if the account owns the object.
*
* @param caller account to check against.
* @param accessType TODO
* @param object object that the account is trying to access.
* @return true if access allowed. false if this adapter cannot authenticate ownership.
* @throws PermissionDeniedException if this adapter is suppose to authenticate ownership and the check failed.
*/
boolean checkAccess(Account caller, Domain domain, AccessType accessType) throws PermissionDeniedException;
boolean checkAccess(Account caller, Domain domain) throws PermissionDeniedException;
/**
* Checks if the user belongs to an account that owns the object.

View File

@ -18,7 +18,6 @@
package com.cloud.agent.api;
import java.util.HashMap;
import java.util.Map;
import com.cloud.utils.Pair;
import com.cloud.vm.VirtualMachine.State;

View File

@ -17,9 +17,6 @@
package com.cloud.agent.api;
import java.util.Map;
import com.cloud.vm.VirtualMachine.State;
public class ClusterSyncCommand extends Command implements CronCommand {
int _interval;

View File

@ -261,6 +261,7 @@ public class ApiConstants {
public static final String HYPERVISOR_VERSION = "hypervisorversion";
public static final String MAX_GUESTS_LIMIT = "maxguestslimit";
public static final String PROJECT_ID = "projectid";
public static final String PROJECT_IDS = "projectids";
public static final String PROJECT = "project";
public static final String ROLE = "role";
public static final String USER = "user";

View File

@ -35,7 +35,6 @@ import com.cloud.domain.Domain;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.NetworkService;
@ -56,7 +55,6 @@ import com.cloud.user.Account;
import com.cloud.user.AccountService;
import com.cloud.user.DomainService;
import com.cloud.user.ResourceLimitService;
import com.cloud.user.UserContext;
import com.cloud.utils.Pair;
import com.cloud.utils.component.ComponentLocator;
import com.cloud.vm.BareMetalVmService;
@ -194,124 +192,6 @@ public abstract class BaseCmd {
return formattedString;
}
protected Account getValidOwner(String accountName, Long domainId) {
Account owner = null;
if (accountName != null) {
owner = _responseGenerator.findAccountByNameDomain(accountName, domainId);
} else {
owner = UserContext.current().getCaller();
}
if (owner == null) {
throw new InvalidParameterValueException("Invalid value for owner specified: " + accountName);
}
if (owner.getState() == Account.State.disabled || owner.getState() == Account.State.locked) {
throw new PermissionDeniedException("Account disabled.");
}
return owner;
}
public Map<String, Object> validateParams(Map<String, String> params, boolean decode) {
// List<Pair<Enum, Boolean>> properties = getProperties();
// step 1 - all parameter names passed in will be converted to lowercase
Map<String, Object> processedParams = lowercaseParams(params, decode);
return processedParams;
/*
// step 2 - make sure all required params exist, and all existing params adhere to the appropriate data type
Map<String, Object> validatedParams = new HashMap<String, Object>();
for (Pair<Enum, Boolean> propertyPair : properties) {
Properties prop = (Properties)propertyPair.first();
Object param = processedParams.get(prop.getName());
// possible validation errors are
// - NULL (not specified)
// - MALFORMED
if (param != null) {
short propertyType = prop.getDataType();
String decodedParam = null;
if ((propertyType != TYPE_OBJECT) && (propertyType != TYPE_OBJECT_MAP)) {
decodedParam = (String)param;
if (decode) {
try {
decodedParam = URLDecoder.decode((String)param, "UTF-8");
} catch (UnsupportedEncodingException usex) {
s_logger.warn(prop.getName() + " could not be decoded, value = " + param);
throw new ServerApiException(PARAM_ERROR, prop.getName() + " could not be decoded");
}
}
}
switch (propertyType) {
case TYPE_INT:
try {
validatedParams.put(prop.getName(), Integer.valueOf(Integer.parseInt(decodedParam)));
} catch (NumberFormatException ex) {
s_logger.warn(prop.getName() + " (type is int) is malformed, value = " + decodedParam);
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, prop.getName() + " is malformed");
}
break;
case TYPE_LONG:
try {
validatedParams.put(prop.getName(), Long.valueOf(Long.parseLong(decodedParam)));
} catch (NumberFormatException ex) {
s_logger.warn(prop.getName() + " (type is long) is malformed, value = " + decodedParam);
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, prop.getName() + " is malformed");
}
break;
case TYPE_DATE:
try {
synchronized(_format) { // SimpleDataFormat is not thread safe, synchronize on it to avoid parse errors
validatedParams.put(prop.getName(), _format.parse(decodedParam));
}
} catch (ParseException ex) {
s_logger.warn(prop.getName() + " (type is date) is malformed, value = " + decodedParam);
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, prop.getName() + " uses an unsupported date format");
}
break;
case TYPE_TZDATE:
try {
validatedParams.put(prop.getName(), DateUtil.parseTZDateString(decodedParam));
} catch (ParseException ex) {
s_logger.warn(prop.getName() + " (type is date) is malformed, value = " + decodedParam);
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, prop.getName() + " uses an unsupported date format");
}
break;
case TYPE_FLOAT:
try {
validatedParams.put(prop.getName(), Float.valueOf(Float.parseFloat(decodedParam)));
} catch (NumberFormatException ex) {
s_logger.warn(prop.getName() + " (type is float) is malformed, value = " + decodedParam);
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, prop.getName() + " is malformed");
}
break;
case TYPE_BOOLEAN:
validatedParams.put(prop.getName(), Boolean.valueOf(Boolean.parseBoolean(decodedParam)));
break;
case TYPE_STRING:
validatedParams.put(prop.getName(), decodedParam);
break;
default:
validatedParams.put(prop.getName(), param);
break;
}
} else if (propertyPair.second().booleanValue() == true) {
s_logger.warn("missing parameter, " + prop.getTagName() + " is not specified");
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, prop.getTagName() + " is not specified");
}
}
return validatedParams;
*/
}
private Map<String, Object> lowercaseParams(Map<String, String> params, boolean decode) {
Map<String, Object> lowercaseParams = new HashMap<String, Object>();
for (String key : params.keySet()) {
lowercaseParams.put(key.toLowerCase(), params.get(key));
}
return lowercaseParams;
}
// FIXME: move this to a utils method so that maps can be unpacked and integer/long values can be appropriately cast
@SuppressWarnings({"unchecked", "rawtypes"})
public Map<String, Object> unpackParams(Map<String, String> params) {
@ -584,7 +464,7 @@ public abstract class BaseCmd {
}
Domain domain = _domainService.getDomain(domainId);
if (domain == null || domain.getType() == Domain.Type.Project) {
if (domain == null) {
throw new InvalidParameterValueException("Unable to find domain by id=" + domainId);
}

View File

@ -28,7 +28,6 @@ import com.cloud.api.ServerApiException;
import com.cloud.api.response.SuccessResponse;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.projects.Project;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@Implementation(description="Adds acoount to a project", responseObject=SuccessResponse.class)

View File

@ -20,6 +20,7 @@ package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseAsyncCreateCmd;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
@ -41,16 +42,19 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name="username", type=CommandType.STRING, required=true, description="username for the vpn user")
@Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="username for the vpn user")
private String userName;
@Parameter(name="password", type=CommandType.STRING, required=true, description="password for the username")
@Parameter(name=ApiConstants.PASSWORD, type=CommandType.STRING, required=true, description="password for the username")
private String password;
@Parameter(name="account", type=CommandType.STRING, description="an optional account for the vpn user. Must be used with domainId.")
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the vpn user. Must be used with domainId.")
private String accountName;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="add vpn user to the specific project")
private Long projectId;
@Parameter(name="domainid", type=CommandType.LONG, description="an optional domainId for the vpn user. If the account parameter is used, domainId must also be used.")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the vpn user. If the account parameter is used, domainId must also be used.")
private Long domainId;
/////////////////////////////////////////////////////
@ -69,17 +73,13 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
@ -93,21 +93,12 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
if (userAccount != null) {
return userAccount.getId();
}
}
Long accountId = getAccountId(accountName, domainId, projectId);
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
if (account != null) {
return account.getId();
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
return accountId;
}
@Override
@ -115,8 +106,6 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
return "Add Remote Access VPN user for account " + getEntityOwnerId() + " username= " + getUserName();
}
@Override
public String getEventType() {
return EventTypes.EVENT_VPN_USER_ADD;
@ -145,13 +134,8 @@ public class AddVpnUserCmd extends BaseAsyncCreateCmd {
@Override
public void create() {
Account owner = null;
if (accountName != null) {
owner = _responseGenerator.findAccountByNameDomain(accountName, domainId);
} else {
owner = UserContext.current().getCaller();
}
Account owner = _accountService.getAccount(getEntityOwnerId());
VpnUser vpnUser = _ravService.addVpnUser(owner.getId(), userName, password);
if (vpnUser == null) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add vpn user");

View File

@ -42,7 +42,6 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.IpAddress;
import com.cloud.network.Network;
import com.cloud.network.Networks.TrafficType;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@Implementation(description="Acquires and associates a public IP to an account.", responseObject=IPAddressResponse.class)
@ -65,7 +64,9 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="The network this ip address should be associated to.")
private Long networkId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="Deploy vm for the project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -96,7 +97,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
DataCenter zone = _configService.getZone(getZoneId());
if (zone.getNetworkType() == NetworkType.Advanced) {
List<? extends Network> networks = _networkService.getVirtualNetworksOwnedByAccountInZone(getAccountName(), getDomainId(), getZoneId());
List<? extends Network> networks = _networkService.getVirtualNetworksOwnedByAccountInZone(getZoneId(), _accountService.getAccount(getEntityOwnerId()));
if (networks.size() == 0) {
String domain = _domainService.getDomain(getDomainId()).getName();
throw new InvalidParameterValueException("Account name=" + getAccountName() + " domain=" + domain + " doesn't have virtual networks in zone=" + zone.getName());
@ -116,8 +117,12 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
@Override
public long getEntityOwnerId() {
Account caller = UserContext.current().getCaller();
return _accountService.finalizeOwner(caller, accountName, domainId).getAccountId();
Long accountId = getAccountId(accountName, domainId, projectId);
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
return accountId;
}
@Override

View File

@ -93,7 +93,7 @@ public class AttachIsoCmd extends BaseAsyncCmd {
@Override
public void execute(){
UserContext.current().setEventDetails("Vm Id: " +getVirtualMachineId()+ " ISO Id: "+getId());
boolean result = _templateService.attachIso(this);
boolean result = _templateService.attachIso(id, virtualMachineId);
if (result) {
UserVm userVm = _responseGenerator.findUserVmById(virtualMachineId);
if (userVm != null) {

View File

@ -32,6 +32,7 @@ import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.IngressRuleResponse;
import com.cloud.api.response.SecurityGroupResponse;
import com.cloud.async.AsyncJob;
@ -77,9 +78,12 @@ public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd {
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the security group. If the account parameter is used, domainId must also be used.")
private Long domainId;
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the virtual machine. Must be used with domainId.")
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the security group. Must be used with domainId.")
private String accountName;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="an optional project of the security group")
private Long projectId;
@Parameter(name=ApiConstants.SECURITY_GROUP_ID, type=CommandType.LONG, description="The ID of the security group. Mutually exclusive with securityGroupName parameter")
private Long securityGroupId;
@ -160,19 +164,12 @@ public class AuthorizeSecurityGroupIngressCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
if (userAccount != null) {
return userAccount.getId();
} else {
throw new InvalidParameterValueException("Unable to find account by name " + accountName + " in domain " + domainId);
}
}
Long accountId = getAccountId(accountName, domainId, projectId);
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
return account.getId();
return accountId;
}
@Override

View File

@ -37,7 +37,6 @@ import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.IpAddress;
import com.cloud.network.lb.LoadBalancingRule;
import com.cloud.network.rules.LoadBalancer;
import com.cloud.user.Account;
import com.cloud.user.UserContext;

View File

@ -27,6 +27,7 @@ import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.NetworkResponse;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
@ -73,6 +74,9 @@ public class CreateNetworkCmd extends BaseCmd {
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="account who will own the network")
private String accountName;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="an optional project for the ssh key")
private Long projectId;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a network")
private Long domainId;
@ -152,6 +156,10 @@ public class CreateNetworkCmd extends BaseCmd {
return networkDomain;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@ -163,21 +171,12 @@ public class CreateNetworkCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
if (userAccount != null) {
return userAccount.getId();
}
}
Long accountId = getAccountId(accountName, domainId, projectId);
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
if (account != null) {
return account.getId();
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
return accountId;
}
@Override

View File

@ -45,7 +45,7 @@ public class CreateProjectCmd extends BaseCmd {
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="account who will own the project")
private String accountName;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="domain ID of the account owning a project")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, required=true, description="domain ID of the account owning a project")
private Long domainId;
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="name of the project")
@ -88,7 +88,7 @@ public class CreateProjectCmd extends BaseCmd {
}
if (accountName != null) {
return _accountService.finalizeOwner(caller, accountName, domainId).getId();
return _accountService.finalizeOwner(caller, accountName, domainId, null).getId();
}
return caller.getId();

View File

@ -27,7 +27,6 @@ import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.RemoteAccessVpnResponse;
import com.cloud.event.EventTypes;
import com.cloud.exception.InvalidParameterValueException;
@ -35,8 +34,6 @@ import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.IpAddress;
import com.cloud.network.RemoteAccessVpn;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@Implementation(description="Creates a l2tp/ipsec remote access vpn", responseObject=RemoteAccessVpnResponse.class)
public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
@ -53,10 +50,12 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
@Parameter(name="iprange", type=CommandType.STRING, required=false, description="the range of ip addresses to allocate to vpn clients. The first ip in the range will be taken by the vpn server")
private String ipRange;
@Parameter(name="account", type=CommandType.STRING, description="an optional account for the VPN. Must be used with domainId.")
@Deprecated
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the VPN. Must be used with domainId.")
private String accountName;
@Parameter(name="domainid", type=CommandType.LONG, description="an optional domainId for the VPN. If the account parameter is used, domainId must also be used.")
@Deprecated
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the VPN. If the account parameter is used, domainId must also be used.")
private Long domainId;
@Parameter(name = ApiConstants.OPEN_FIREWALL, type = CommandType.BOOLEAN, description = "if true, firewall rule for source/end pubic port is automatically created; if false - firewall rule has to be created explicitely. Has value true by default")
@ -106,21 +105,13 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
if (userAccount != null) {
return userAccount.getId();
}
}
}
if (account != null) {
return account.getId();
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
IpAddress ip = _networkService.getIp(publicIpId);
if (ip == null) {
throw new InvalidParameterValueException("Unable to find ip address by id=" + publicIpId);
}
return ip.getAccountId();
}
@Override

View File

@ -25,7 +25,6 @@ import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.response.SSHKeyPairResponse;
import com.cloud.user.Account;
import com.cloud.user.SSHKeyPair;
import com.cloud.user.UserContext;
@ -48,6 +47,9 @@ public class CreateSSHKeyPairCmd extends BaseCmd {
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the ssh key. If the account parameter is used, domainId must also be used.")
private Long domainId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="an optional project for the ssh key")
private Long projectId;
/////////////////////////////////////////////////////
@ -66,20 +68,22 @@ public class CreateSSHKeyPairCmd extends BaseCmd {
return domainId;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if (account != null) {
return account.getId();
Long accountId = getAccountId(accountName, domainId, projectId);
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
return accountId;
}
@Override
public void execute() {

View File

@ -24,6 +24,7 @@ import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.SecurityGroupResponse;
import com.cloud.network.security.SecurityGroup;
import com.cloud.user.Account;
@ -49,7 +50,10 @@ public class CreateSecurityGroupCmd extends BaseCmd {
private String description;
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="name of the security group")
private String securityGroupName;
private String securityGroupName;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="Deploy vm for the project")
private Long projectId;
/////////////////////////////////////////////////////
@ -70,6 +74,10 @@ public class CreateSecurityGroupCmd extends BaseCmd {
public String getSecurityGroupName() {
return securityGroupName;
}
public Long getProjectId() {
return projectId;
}

View File

@ -25,7 +25,6 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.InstanceGroupResponse;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
import com.cloud.vm.InstanceGroup;
@ -47,6 +46,9 @@ public class CreateVMGroupCmd extends BaseCmd{
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID of account owning the instance group")
private Long domainId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="The project of the instance group")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -63,6 +65,10 @@ public class CreateVMGroupCmd extends BaseCmd{
public Long getDomainId() {
return domainId;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
@ -75,21 +81,12 @@ public class CreateVMGroupCmd extends BaseCmd{
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
if (userAccount != null) {
return userAccount.getId();
}
}
Long accountId = getAccountId(accountName, domainId, projectId);
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
if (account != null) {
return account.getId();
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
return accountId;
}
@Override

View File

@ -26,6 +26,7 @@ import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.VolumeResponse;
import com.cloud.async.AsyncJob;
import com.cloud.event.EventTypes;
@ -45,13 +46,16 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account associated with the disk volume. Must be used with the domainId parameter.")
private String accountName;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="the project associated with the volume. Mutually exclusive with account parameter")
private Long projectId;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID associated with the disk offering. If used with the account parameter returns the disk volume associated with the account for the specified domain.")
private Long domainId;
@Parameter(name=ApiConstants.DISK_OFFERING_ID,required = false, type=CommandType.LONG, description="the ID of the disk offering. Either diskOfferingId or snapshotId must be passed in.")
private Long diskOfferingId;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID associated with the disk offering. If used with the account parameter returns the disk volume associated with the account for the specified domain.")
private Long domainId;
@Parameter(name=ApiConstants.NAME, type=CommandType.STRING, required=true, description="the name of the disk volume")
private String volumeName;
@ -97,6 +101,9 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
return zoneId;
}
private Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
@ -116,21 +123,12 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
if (userAccount != null) {
return userAccount.getId();
}
}
Long accountId = getAccountId(accountName, domainId, projectId);
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
if (account != null) {
return account.getId();
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
return accountId;
}
@Override

View File

@ -47,6 +47,9 @@ public class DeleteSSHKeyPairCmd extends BaseCmd {
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID associated with the keypair")
private Long domainId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="the project associated with keypair")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -62,8 +65,11 @@ public class DeleteSSHKeyPairCmd extends BaseCmd {
public Long getDomainId() {
return domainId;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -10,7 +10,6 @@ import com.cloud.api.ServerApiException;
import com.cloud.api.response.SuccessResponse;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceInUseException;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@Implementation(description="Deletes security group", responseObject=SuccessResponse.class)
@ -27,6 +26,9 @@ public class DeleteSecurityGroupCmd extends BaseCmd {
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID of account owning the security group")
private Long domainId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="the project of the security group")
private Long projectId;
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="The ID of the security group. Mutually exclusive with name parameter")
private Long id;
@ -46,6 +48,10 @@ public class DeleteSecurityGroupCmd extends BaseCmd {
public Long getDomainId() {
return domainId;
}
public Long getProjectId() {
return projectId;
}
public Long getId() {
if (id != null && name != null) {
@ -79,19 +85,12 @@ public class DeleteSecurityGroupCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
if (userAccount != null) {
return userAccount.getId();
} else {
throw new InvalidParameterValueException("Unable to find account by name " + accountName + " in domain " + domainId);
}
}
Long accountId = getAccountId(accountName, domainId, projectId);
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
return account.getId();
return accountId;
}
@Override

View File

@ -94,7 +94,7 @@ public class DeleteSnapshotCmd extends BaseAsyncCmd {
@Override
public void execute(){
UserContext.current().setEventDetails("Snapshot Id: "+getId());
boolean result = _snapshotService.deleteSnapshot(this);
boolean result = _snapshotService.deleteSnapshot(getId());
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);

View File

@ -1,4 +1,5 @@
/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
@ -79,7 +80,7 @@ public class DeleteVolumeCmd extends BaseCmd {
@Override
public void execute() throws ConcurrentOperationException {
UserContext.current().setEventDetails("Volume Id: "+getId());
boolean result = _storageService.deleteVolume(this);
boolean result = _storageService.deleteVolume(id);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);

View File

@ -82,7 +82,7 @@ public class DetachIsoCmd extends BaseAsyncCmd {
@Override
public void execute(){
boolean result = _templateService.detachIso(this);
boolean result = _templateService.detachIso(virtualMachineId);
if (result) {
UserVm userVm = _entityMgr.findById(UserVm.class, virtualMachineId);
UserVmResponse response = _responseGenerator.createUserVmResponse("virtualmachine", userVm).get(0);

View File

@ -45,7 +45,6 @@ public class DisassociateIPAddrCmd extends BaseAsyncCmd {
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="the id of the public ip address to disassociate")
private Long id;
// unexposed parameter needed for events logging
@Parameter(name=ApiConstants.ACCOUNT_ID, type=CommandType.LONG, expose=false)
private Long ownerId;
@ -69,7 +68,7 @@ public class DisassociateIPAddrCmd extends BaseAsyncCmd {
@Override
public void execute(){
UserContext.current().setEventDetails("Ip Id: "+getIpAddressId());
boolean result = _networkService.disassociateIpAddress(this);
boolean result = _networkService.disassociateIpAddress(id);
if (result) {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);

View File

@ -67,7 +67,7 @@ public class GetCloudIdentifierCmd extends BaseCmd {
@Override
public void execute(){
ArrayList<String> result = _mgr.getCloudIdentifierResponse(this);
ArrayList<String> result = _mgr.getCloudIdentifierResponse(userid);
CloudIdentifierResponse response = new CloudIdentifierResponse();
if (result != null) {
response.setCloudIdentifier(result.get(0));

View File

@ -37,7 +37,7 @@ public class ListAsyncJobsCmd extends BaseListCmd {
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account associated with the async job. Must be used with the domainId parameter.")
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account associated with the async job (this account is the job initiator). Must be used with the domainId parameter.")
private String accountName;
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID associated with the async job. If used with the account parameter, returns async jobs for the account in the specified domain.")

View File

@ -50,6 +50,9 @@ public class ListFirewallRulesCmd extends BaseListCmd {
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID. If used with the account parameter, lists firewall rules for the specified account in this domain.")
private Long domainId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list firewall rules by project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -70,6 +73,10 @@ public class ListFirewallRulesCmd extends BaseListCmd {
public Long getId() {
return id;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -26,6 +26,7 @@ import com.cloud.api.ApiConstants;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.FirewallRuleResponse;
import com.cloud.api.response.IpForwardingRuleResponse;
import com.cloud.api.response.ListResponse;
@ -56,6 +57,9 @@ public class ListIpForwardingRulesCmd extends BaseListCmd {
@Parameter(name=ApiConstants.VIRTUAL_MACHINE_ID, type=CommandType.LONG, description="Lists all rules applied to the specified Vm.")
private Long vmId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list static nat rules by project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -90,9 +94,13 @@ public class ListIpForwardingRulesCmd extends BaseListCmd {
return vmId;
}
private Long getProjectId() {
return projectId;
}
@Override
public void execute(){
List<? extends FirewallRule> result = _rulesService.searchStaticNatRules(publicIpAddressId, id, vmId, this.getStartIndex(), this.getPageSizeVal(), this.getAccountName(), this.getDomainId());
List<? extends FirewallRule> result = _rulesService.searchStaticNatRules(publicIpAddressId, id, vmId, this.getStartIndex(), this.getPageSizeVal(), this.getAccountName(), this.getDomainId(), this.getProjectId());
ListResponse<IpForwardingRuleResponse> response = new ListResponse<IpForwardingRuleResponse>();
List<IpForwardingRuleResponse> ipForwardingResponses = new ArrayList<IpForwardingRuleResponse>();
for (FirewallRule rule : result) {

View File

@ -79,6 +79,9 @@ public class ListIsosCmd extends BaseListCmd {
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the ID of the zone")
private Long zoneId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list isos by project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -124,6 +127,10 @@ public class ListIsosCmd extends BaseListCmd {
return zoneId;
}
public Long getProjectId() {
return projectId;
}
public boolean listInReadyState() {
Account account = UserContext.current().getCaller();
// It is account specific if account is admin type and domainId and accountName are not null

View File

@ -27,6 +27,7 @@ import com.cloud.api.ApiConstants;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.ListResponse;
import com.cloud.api.response.LoadBalancerResponse;
import com.cloud.network.rules.LoadBalancer;
@ -61,6 +62,9 @@ public class ListLoadBalancerRulesCmd extends BaseListCmd {
@Parameter(name = ApiConstants.ZONE_ID, type = CommandType.LONG, description = "the availability zone ID")
private Long zoneId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list port forwarding rules by project")
private Long projectId;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
@ -93,6 +97,10 @@ public class ListLoadBalancerRulesCmd extends BaseListCmd {
public Long getZoneId() {
return zoneId;
}
public Long getProjectId() {
return projectId;
}
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////

View File

@ -27,6 +27,7 @@ import com.cloud.api.ApiConstants;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.ListResponse;
import com.cloud.api.response.NetworkResponse;
import com.cloud.network.Network;
@ -66,6 +67,9 @@ public class ListNetworksCmd extends BaseListCmd {
@Parameter(name=ApiConstants.TRAFFIC_TYPE, type=CommandType.STRING, description="type of the traffic")
private String trafficType;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list networks by project id")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -106,6 +110,10 @@ public class ListNetworksCmd extends BaseListCmd {
public String getTrafficType() {
return trafficType;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -50,6 +50,9 @@ public class ListPortForwardingRulesCmd extends BaseListCmd {
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID. If used with the account parameter, lists port forwarding rules for the specified account in this domain.")
private Long domainId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list port forwarding rules by project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -70,6 +73,10 @@ public class ListPortForwardingRulesCmd extends BaseListCmd {
public Long getId() {
return id;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -68,6 +68,9 @@ public class ListPublicIpAddressesCmd extends BaseListCmd {
@Parameter(name=ApiConstants.FOR_LOAD_BALANCING, type=CommandType.BOOLEAN, description="list only ips used for load balancing")
private Boolean forLoadBalancing;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list ips by project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -103,6 +106,10 @@ public class ListPublicIpAddressesCmd extends BaseListCmd {
public Long getZoneId() {
return zoneId;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -41,14 +41,17 @@ public class ListRemoteAccessVpnsCmd extends BaseListCmd {
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name="account", type=CommandType.STRING, description="the account of the remote access vpn. Must be used with the domainId parameter.")
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account of the remote access vpn. Must be used with the domainId parameter.")
private String accountName;
@Parameter(name="domainid", type=CommandType.LONG, description="the domain ID of the remote access vpn rule. If used with the account parameter, lists remote access vpns for the account in the specified domain.")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID of the remote access vpn rule. If used with the account parameter, lists remote access vpns for the account in the specified domain.")
private Long domainId;
@Parameter(name=ApiConstants.PUBLIC_IP_ID, type=CommandType.LONG, required=true, description="public ip address id of the vpn server")
private Long publicIpId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list remote access vpn by project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -65,6 +68,10 @@ public class ListRemoteAccessVpnsCmd extends BaseListCmd {
public Long getPublicIpId() {
return publicIpId;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -68,6 +68,9 @@ public class ListRoutersCmd extends BaseListCmd {
@Parameter(name=ApiConstants.NETWORK_ID, type=CommandType.LONG, description="list by network id")
private Long networkId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list firewall rules by project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -108,6 +111,10 @@ public class ListRoutersCmd extends BaseListCmd {
public Long getNetworkId() {
return networkId;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -25,6 +25,7 @@ import com.cloud.api.ApiConstants;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.ListResponse;
import com.cloud.api.response.SecurityGroupResponse;
import com.cloud.async.AsyncJob;
@ -53,7 +54,10 @@ public class ListSecurityGroupsCmd extends BaseListCmd {
private Long virtualMachineId;
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="list the security group by the id provided")
private Long id;
private Long id;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list security groups by project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -77,6 +81,10 @@ public class ListSecurityGroupsCmd extends BaseListCmd {
public Long getId(){
return id;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////

View File

@ -26,7 +26,6 @@ import com.cloud.api.ApiConstants;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.ListResponse;
import com.cloud.api.response.SnapshotResponse;
import com.cloud.async.AsyncJob;
@ -65,6 +64,10 @@ public class ListSnapshotsCmd extends BaseListCmd {
@Parameter(name=ApiConstants.IS_RECURSIVE, type=CommandType.BOOLEAN, description="defaults to false, but if true, lists all snapshots from the parent specified by the domain id till leaves.")
private Boolean recursive;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list snapshots by project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -99,8 +102,12 @@ public class ListSnapshotsCmd extends BaseListCmd {
public Boolean isRecursive() {
return recursive;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -99,7 +99,7 @@ public class ListTemplateOrIsoPermissionsCmd extends BaseCmd {
List<String> accountNames = _mgr.listTemplatePermissions(this);
Account account = UserContext.current().getCaller();
boolean isAdmin = ((account == null) || isAdmin(account.getType()));
boolean isAdmin = (isAdmin(account.getType()));
TemplatePermissionsResponse response = _responseGenerator.createTemplatePermissionsResponse(accountNames, id, isAdmin);
response.setResponseName(getCommandName());

View File

@ -70,6 +70,9 @@ public class ListTemplatesCmd extends BaseListCmd {
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="list templates by zoneId")
private Long zoneId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list templates by project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -103,6 +106,10 @@ public class ListTemplatesCmd extends BaseListCmd {
return zoneId;
}
public Long getProjectId() {
return projectId;
}
public boolean listInReadyState() {
Account account = UserContext.current().getCaller();

View File

@ -26,6 +26,7 @@ import com.cloud.api.ApiConstants;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.InstanceGroupResponse;
import com.cloud.api.response.ListResponse;
import com.cloud.vm.InstanceGroup;
@ -51,6 +52,9 @@ public class ListVMGroupsCmd extends BaseListCmd {
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID. If used with the account parameter, lists virtual machines for the specified account in this domain.")
private Long domainId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list instance group belonging to the specified project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -71,6 +75,10 @@ public class ListVMGroupsCmd extends BaseListCmd {
public Long getDomainId() {
return domainId;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -25,7 +25,6 @@ import com.cloud.api.ApiConstants;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.ListResponse;
import com.cloud.api.response.UserVmResponse;
import com.cloud.async.AsyncJob;

View File

@ -71,6 +71,9 @@ public class ListVolumesCmd extends BaseListCmd {
@Parameter(name=ApiConstants.IS_RECURSIVE, type=CommandType.BOOLEAN, description="defaults to false, but if true, lists all volumes from the parent specified by the domain id till leaves.")
private Boolean recursive;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list firewall rules by project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -115,6 +118,10 @@ public class ListVolumesCmd extends BaseListCmd {
return recursive;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////

View File

@ -23,6 +23,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
@ -40,17 +41,20 @@ public class ListVpnUsersCmd extends BaseListCmd {
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name="account", type=CommandType.STRING, description="the account of the remote access vpn. Must be used with the domainId parameter.")
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="the account of the remote access vpn. Must be used with the domainId parameter.")
private String accountName;
@Parameter(name="domainid", type=CommandType.LONG, description="the domain ID of the remote access vpn. If used with the account parameter, lists remote access vpns for the account in the specified domain.")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="the domain ID of the remote access vpn. If used with the account parameter, lists remote access vpns for the account in the specified domain.")
private Long domainId;
@Parameter(name="id", type=CommandType.LONG, description="the ID of the vpn user")
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the ID of the vpn user")
private Long id;
@Parameter(name="username", type=CommandType.STRING, description="the username of the vpn user.")
@Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, description="the username of the vpn user.")
private String userName;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="list firewall rules by project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -71,6 +75,9 @@ public class ListVpnUsersCmd extends BaseListCmd {
return userName;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////

View File

@ -76,7 +76,7 @@ public class PrepareTemplateCmd extends BaseCmd {
public void execute() {
ListResponse<TemplateResponse> response = new ListResponse<TemplateResponse>();
VirtualMachineTemplate vmTemplate = _templateService.prepareTemplate(this);
VirtualMachineTemplate vmTemplate = _templateService.prepareTemplate(templateId, zoneId);
List<TemplateResponse> templateResponses = _responseGenerator.createTemplateResponses(vmTemplate.getId(), zoneId, true);
response.setResponses(templateResponses);
response.setResponseName(getCommandName());

View File

@ -26,6 +26,7 @@ import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.ListResponse;
import com.cloud.api.response.TemplateResponse;
import com.cloud.exception.InvalidParameterValueException;
@ -80,6 +81,9 @@ public class RegisterIsoCmd extends BaseCmd {
@Parameter(name=ApiConstants.CHECKSUM, type=CommandType.STRING, description="the MD5 checksum value of this ISO")
private String checksum;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="Register iso for the project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -141,22 +145,15 @@ public class RegisterIsoCmd extends BaseCmd {
return s_name;
}
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if (isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
if (userAccount != null) {
return userAccount.getId();
} else {
throw new InvalidParameterValueException("Unable to find account by name " + getAccountName() + " in domain " + getDomainId());
}
}
@Override
public long getEntityOwnerId() {
Long accountId = getAccountId(accountName, domainId, projectId);
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
return account.getId();
}
return accountId;
}
@Override
public void execute() throws ResourceAllocationException{

View File

@ -24,9 +24,7 @@ import com.cloud.api.ApiConstants;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.SSHKeyPairResponse;
import com.cloud.user.Account;
import com.cloud.user.SSHKeyPair;
import com.cloud.user.UserContext;
@ -53,6 +51,9 @@ public class RegisterSSHKeyPairCmd extends BaseCmd {
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the ssh key. If the account parameter is used, domainId must also be used.")
private Long domainId;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="an optional project for the ssh key")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
@ -73,19 +74,22 @@ public class RegisterSSHKeyPairCmd extends BaseCmd {
return domainId;
}
public Long getProjectId() {
return projectId;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if (account != null) {
return account.getId();
Long accountId = getAccountId(accountName, domainId, projectId);
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
return accountId;
}
@Override

View File

@ -27,6 +27,7 @@ import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.BaseCmd.CommandType;
import com.cloud.api.response.ListResponse;
import com.cloud.api.response.TemplateResponse;
import com.cloud.async.AsyncJob;
@ -95,7 +96,10 @@ public class RegisterTemplateCmd extends BaseCmd {
private String checksum;
@Parameter(name=ApiConstants.TEMPLATE_TAG, type=CommandType.STRING, description="the tag for this template.")
private String templateTag;
private String templateTag;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="Register template for the project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -183,19 +187,12 @@ public class RegisterTemplateCmd extends BaseCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if (isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
if (userAccount != null) {
return userAccount.getId();
} else {
throw new InvalidParameterValueException("Unable to find account by name " + getAccountName() + " in domain " + getDomainId());
}
}
Long accountId = getAccountId(accountName, domainId, projectId);
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
return account.getId();
return accountId;
}
@Override

View File

@ -20,6 +20,7 @@ package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseAsyncCmd;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
@ -39,13 +40,16 @@ public class RemoveVpnUserCmd extends BaseAsyncCmd {
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name="username", type=CommandType.STRING, required=true, description="username for the vpn user")
@Parameter(name=ApiConstants.USERNAME, type=CommandType.STRING, required=true, description="username for the vpn user")
private String userName;
@Parameter(name="account", type=CommandType.STRING, description="an optional account for the vpn user. Must be used with domainId.")
@Parameter(name=ApiConstants.ACCOUNT, type=CommandType.STRING, description="an optional account for the vpn user. Must be used with domainId.")
private String accountName;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="remove vpn user from the project")
private Long projectId;
@Parameter(name="domainid", type=CommandType.LONG, description="an optional domainId for the vpn user. If the account parameter is used, domainId must also be used.")
@Parameter(name=ApiConstants.DOMAIN_ID, type=CommandType.LONG, description="an optional domainId for the vpn user. If the account parameter is used, domainId must also be used.")
private Long domainId;
/////////////////////////////////////////////////////
@ -65,8 +69,8 @@ public class RemoveVpnUserCmd extends BaseAsyncCmd {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
public Long getProjecId() {
return projectId;
}
@ -81,21 +85,12 @@ public class RemoveVpnUserCmd extends BaseAsyncCmd {
@Override
public long getEntityOwnerId() {
Account account = UserContext.current().getCaller();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = _responseGenerator.findAccountByNameDomain(accountName, domainId);
if (userAccount != null) {
return userAccount.getId();
}
}
Long accountId = getAccountId(accountName, domainId, projectId);
if (accountId == null) {
return UserContext.current().getCaller().getId();
}
if (account != null) {
return account.getId();
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
return accountId;
}
@Override
@ -111,7 +106,7 @@ public class RemoveVpnUserCmd extends BaseAsyncCmd {
@Override
public void execute(){
Account owner = getValidOwner(accountName, domainId);
Account owner = _accountService.getAccount(getEntityOwnerId());
boolean result = _ravService.removeVpnUser(owner.getId(), userName);
if (!result) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to remove vpn user");

View File

@ -102,7 +102,7 @@ public class StartRouterCmd extends BaseAsyncCmd {
@Override
public void execute() throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException{
UserContext.current().setEventDetails("Router Id: "+getId());
VirtualRouter result = _routerService.startRouter(this);
VirtualRouter result = _routerService.startRouter(id);
if (result != null){
DomainRouterResponse routerResponse = _responseGenerator.createDomainRouterResponse(result);
routerResponse.setResponseName(getCommandName());

View File

@ -18,7 +18,11 @@
package com.cloud.api.commands;
import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
@ -29,8 +33,6 @@ import com.cloud.api.response.ResourceCountResponse;
import com.cloud.configuration.ResourceCount;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
import java.util.ArrayList;
import java.util.List;
@Implementation(description="Recalculate and update resource count for an account or domain.", responseObject=ResourceCountResponse.class)
@ -57,6 +59,9 @@ public class UpdateResourceCountCmd extends BaseCmd {
"3 - Snapshot. Number of snapshots a user can create." +
"4 - Template. Number of templates that a user can register/create.")
private Integer resourceType;
@Parameter(name=ApiConstants.PROJECT_ID, type=CommandType.LONG, description="Update resource limits for project")
private Long projectId;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
@ -104,7 +109,7 @@ public class UpdateResourceCountCmd extends BaseCmd {
@Override
public void execute(){
List<? extends ResourceCount> result = _resourceLimitService.recalculateResourceCount(this);
List<? extends ResourceCount> result = _resourceLimitService.recalculateResourceCount(getAccountId(accountName, domainId, projectId), getDomainId(), getResourceType());
if ((result != null) && (result.size()>0)){
ListResponse<ResourceCountResponse> response = new ListResponse<ResourceCountResponse>();

View File

@ -25,6 +25,7 @@ import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseCmd;
import com.cloud.api.Parameter;
import com.cloud.exception.InvalidParameterValueException;
public abstract class UpdateTemplateOrIsoPermissionsCmd extends BaseCmd {
public Logger s_logger = getLogger();
@ -51,13 +52,20 @@ public abstract class UpdateTemplateOrIsoPermissionsCmd extends BaseCmd {
@Parameter(name = ApiConstants.OP, type = CommandType.STRING, description = "permission operator (add, remove, reset)")
private String operation;
@Parameter(name = ApiConstants.PROJECT_IDS, type = CommandType.LIST, collectionType = CommandType.LONG, description = "a comma delimited list of projects. If specified, \"op\" parameter has to be passed in.")
private List<Long> projectIds;
// ///////////////////////////////////////////////////
// ///////////////// Accessors ///////////////////////
// ///////////////////////////////////////////////////
public List<String> getAccountNames() {
return accountNames;
if (accountNames != null && projectIds != null) {
throw new InvalidParameterValueException("Accounts and projectIds can't be specified together");
}
return accountNames;
}
public Long getId() {
@ -79,6 +87,13 @@ public abstract class UpdateTemplateOrIsoPermissionsCmd extends BaseCmd {
public String getOperation() {
return operation;
}
public List<Long> getProjectIds() {
if (accountNames != null && projectIds != null) {
throw new InvalidParameterValueException("Accounts and projectIds can't be specified together");
}
return projectIds;
}
// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////

View File

@ -24,7 +24,8 @@ import com.cloud.serializer.Param;
import com.cloud.vm.VirtualMachine.State;
import com.google.gson.annotations.SerializedName;
public class DomainRouterResponse extends BaseResponse {
@SuppressWarnings("unused")
public class DomainRouterResponse extends BaseResponse implements ControlledEntityResponse{
@SerializedName(ApiConstants.ID) @Param(description="the id of the router")
private Long id;
@ -94,8 +95,7 @@ public class DomainRouterResponse extends BaseResponse {
@SerializedName("guestnetworkid") @Param(description="the ID of the corresponding guest network")
private Long guestNetworkId;
@SerializedName("templateid") @Param(description="the template ID for the router")
@SerializedName(ApiConstants.TEMPLATE_ID) @Param(description="the template ID for the router")
private Long templateId;
@SerializedName(ApiConstants.CREATED) @Param(description="the date and time the router was created")
@ -106,6 +106,12 @@ public class DomainRouterResponse extends BaseResponse {
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the account associated with the router")
private String accountName;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the ipaddress")
private Long projectId;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the address")
private String projectName;
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain ID associated with the router")
private Long domainId;
@ -144,262 +150,137 @@ public class DomainRouterResponse extends BaseResponse {
this.id = id;
}
public Long getZoneId() {
return zoneId;
}
public void setZoneId(Long zoneId) {
this.zoneId = zoneId;
}
public String getZoneName() {
return zoneName;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public String getDns1() {
return dns1;
}
public void setDns1(String dns1) {
this.dns1 = dns1;
}
public String getDns2() {
return dns2;
}
public void setDns2(String dns2) {
this.dns2 = dns2;
}
public String getNetworkDomain() {
return networkDomain;
}
public void setNetworkDomain(String networkDomain) {
this.networkDomain = networkDomain;
}
public String getGateway() {
return gateway;
}
public void setGateway(String gateway) {
this.gateway = gateway;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getPodId() {
return podId;
}
public void setPodId(Long podId) {
this.podId = podId;
}
public Long getHostId() {
return hostId;
}
public void setHostId(Long hostId) {
this.hostId = hostId;
}
public String getHostName() {
return hostName;
}
public void setHostName(String hostName) {
this.hostName = hostName;
}
public String getPublicIp() {
return publicIp;
}
public void setPublicIp(String publicIp) {
this.publicIp = publicIp;
}
public String getPublicMacAddress() {
return publicMacAddress;
}
public void setPublicMacAddress(String publicMacAddress) {
this.publicMacAddress = publicMacAddress;
}
public String getPublicNetmask() {
return publicNetmask;
}
public void setPublicNetmask(String publicNetmask) {
this.publicNetmask = publicNetmask;
}
public String getGuestIpAddress() {
return guestIpAddress;
}
public void setGuestIpAddress(String guestIpAddress) {
this.guestIpAddress = guestIpAddress;
}
public String getGuestMacAddress() {
return guestMacAddress;
}
public void setGuestMacAddress(String guestMacAddress) {
this.guestMacAddress = guestMacAddress;
}
public String getGuestNetmask() {
return guestNetmask;
}
public void setGuestNetmask(String guestNetmask) {
this.guestNetmask = guestNetmask;
}
public Long getTemplateId() {
return templateId;
}
public void setTemplateId(Long templateId) {
this.templateId = templateId;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public State getState() {
return state;
}
public void setState(State state) {
this.state = state;
}
public String getAccountName() {
return accountName;
}
@Override
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public Long getDomainId() {
return domainId;
}
@Override
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
public String getDomainName() {
return domainName;
}
@Override
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public Long getPublicNetworkId() {
return publicNetworkId;
}
public void setPublicNetworkId(Long publicNetworkId) {
this.publicNetworkId = publicNetworkId;
}
public Long getGuestNetworkId() {
return guestNetworkId;
}
public void setGuestNetworkId(Long guestNetworkId) {
this.guestNetworkId = guestNetworkId;
}
public String getLinkLocalIp() {
return linkLocalIp;
}
public void setLinkLocalIp(String linkLocalIp) {
this.linkLocalIp = linkLocalIp;
}
public String getLinkLocalMacAddress() {
return linkLocalMacAddress;
}
public void setLinkLocalMacAddress(String linkLocalMacAddress) {
this.linkLocalMacAddress = linkLocalMacAddress;
}
public String getLinkLocalNetmask() {
return linkLocalNetmask;
}
public void setLinkLocalNetmask(String linkLocalNetmask) {
this.linkLocalNetmask = linkLocalNetmask;
}
public Long getLinkLocalNetworkId() {
return linkLocalNetworkId;
}
public void setLinkLocalNetworkId(Long linkLocalNetworkId) {
this.linkLocalNetworkId = linkLocalNetworkId;
}
public Long getServiceOfferingId() {
return serviceOfferingId;
}
public void setServiceOfferingId(Long serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
public String getServiceOfferingName() {
return serviceOfferingName;
}
public void setServiceOfferingName(String serviceOfferingName) {
this.serviceOfferingName = serviceOfferingName;
}
public String getRedundantState() {
return redundantState;
}
public void setRedundantState(String redundantState) {
this.redundantState = redundantState;
}
public boolean getIsRedundantRouter() {
return isRedundantRouter;
}
public void setIsRedundantRouter(boolean isRedundantRouter) {
this.isRedundantRouter = isRedundantRouter;
}
public String getTemplateVersion() {
return this.templateVersion;
}
@ -415,4 +296,13 @@ public class DomainRouterResponse extends BaseResponse {
public void setScriptsVersion(String scriptsVersion) {
this.scriptsVersion = scriptsVersion;
}
@Override
public void setProjectId(Long projectId) {
this.projectId = projectId;
}
@Override
public void setProjectName(String projectName) {
this.projectName = projectName;
}
}

View File

@ -21,7 +21,7 @@ import com.cloud.api.ApiConstants;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class FirewallRuleResponse extends BaseResponse {
public class FirewallRuleResponse extends BaseResponse{
@SerializedName(ApiConstants.ID) @Param(description="the ID of the port forwarding rule")
private Long id;
@ -55,7 +55,7 @@ public class FirewallRuleResponse extends BaseResponse {
@SerializedName(ApiConstants.IP_ADDRESS) @Param(description="the public ip address for the port forwarding rule")
private String publicIpAddress;
@SerializedName("state") @Param(description="the state of the rule")
@SerializedName(ApiConstants.STATE) @Param(description="the state of the rule")
private String state;
@SerializedName(ApiConstants.CIDR_LIST) @Param(description="the cidr list to forward traffic from")

View File

@ -23,17 +23,18 @@ import com.cloud.api.ApiConstants;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class IPAddressResponse extends BaseResponse {
@SerializedName("id") @Param(description="public IP address id")
@SuppressWarnings("unused")
public class IPAddressResponse extends BaseResponse implements ControlledEntityResponse {
@SerializedName(ApiConstants.ID) @Param(description="public IP address id")
private Long id;
@SerializedName("ipaddress") @Param(description="public IP address")
@SerializedName(ApiConstants.IP_ADDRESS) @Param(description="public IP address")
private String ipAddress;
@SerializedName("allocated") @Param(description="date the public IP address was acquired")
private Date allocated;
@SerializedName("zoneid") @Param(description="the ID of the zone the public IP address belongs to")
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the ID of the zone the public IP address belongs to")
private Long zoneId;
@SerializedName("zonename") @Param(description="the name of the zone the public IP address belongs to")
@ -42,19 +43,25 @@ public class IPAddressResponse extends BaseResponse {
@SerializedName("issourcenat") @Param(description="true if the IP address is a source nat address, false otherwise")
private Boolean sourceNat;
@SerializedName("account") @Param(description="the account the public IP address is associated with")
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the account the public IP address is associated with")
private String accountName;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the ipaddress")
private Long projectId;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the address")
private String projectName;
@SerializedName("domainid") @Param(description="the domain ID the public IP address is associated with")
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain ID the public IP address is associated with")
private Long domainId;
@SerializedName("domain") @Param(description="the domain the public IP address is associated with")
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain the public IP address is associated with")
private String domainName;
@SerializedName("forvirtualnetwork") @Param(description="the virtual network for the IP address")
@SerializedName(ApiConstants.FOR_VIRTUAL_NETWORK) @Param(description="the virtual network for the IP address")
private Boolean forVirtualNetwork;
@SerializedName("vlanid") @Param(description="the ID of the VLAN associated with the IP address")
@SerializedName(ApiConstants.VLAN_ID) @Param(description="the ID of the VLAN associated with the IP address")
private Long vlanId;
@SerializedName("vlanname") @Param(description="the VLAN associated with the IP address")
@ -63,7 +70,7 @@ public class IPAddressResponse extends BaseResponse {
@SerializedName("isstaticnat") @Param(description="true if this ip is for static nat, false otherwise")
private Boolean staticNat;
@SerializedName("virtualmachineid") @Param(description="virutal machine id the ip address is assigned to (not null only for static nat Ip)")
@SerializedName(ApiConstants.VIRTUAL_MACHINE_ID) @Param(description="virutal machine id the ip address is assigned to (not null only for static nat Ip)")
private Long virtualMachineId;
@SerializedName("virtualmachinename") @Param(description="virutal machine name the ip address is assigned to (not null only for static nat Ip)")
@ -75,7 +82,7 @@ public class IPAddressResponse extends BaseResponse {
@SerializedName("associatednetworkid") @Param(description="the ID of the Network associated with the IP address")
private Long associatedNetworkId;
@SerializedName("networkid") @Param(description="the ID of the Network where ip belongs to")
@SerializedName(ApiConstants.NETWORK_ID) @Param(description="the ID of the Network where ip belongs to")
private Long networkId;
@SerializedName(ApiConstants.STATE) @Param(description="State of the ip address. Can be: Allocatin, Allocated and Releasing")
@ -84,141 +91,73 @@ public class IPAddressResponse extends BaseResponse {
@SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the volume")
private Long jobId;
@SerializedName("jobstatus") @Param(description="shows the current pending asynchronous job status")
@SerializedName(ApiConstants.JOB_STATUS) @Param(description="shows the current pending asynchronous job status")
private Integer jobStatus;
public String getIpAddress() {
return ipAddress;
}
public void setIpAddress(String ipAddress) {
this.ipAddress = ipAddress;
}
public Date getAllocated() {
return allocated;
}
public void setAllocated(Date allocated) {
this.allocated = allocated;
}
public Long getZoneId() {
return zoneId;
}
public void setZoneId(Long zoneId) {
this.zoneId = zoneId;
}
public String getZoneName() {
return zoneName;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public Boolean getSourceNat() {
return sourceNat;
}
public void setSourceNat(Boolean sourceNat) {
this.sourceNat = sourceNat;
}
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public Long getDomainId() {
return domainId;
}
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
public String getDomainName() {
return domainName;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public Boolean getForVirtualNetwork() {
return forVirtualNetwork;
}
public void setForVirtualNetwork(Boolean forVirtualNetwork) {
this.forVirtualNetwork = forVirtualNetwork;
}
public Long getVlanId() {
return vlanId;
}
public void setVlanId(Long vlanId) {
this.vlanId = vlanId;
}
public String getVlanName() {
return vlanName;
}
public void setVlanName(String vlanName) {
this.vlanName = vlanName;
}
public Boolean getStaticNat() {
return staticNat;
}
public void setStaticNat(Boolean staticNat) {
this.staticNat = staticNat;
}
public Long getAssociatedNetworkId() {
return associatedNetworkId;
}
public void setAssociatedNetworkId(Long networkId) {
this.associatedNetworkId = networkId;
}
public Long getNetworkId() {
return networkId;
}
public void setNetworkId(Long networkId) {
this.networkId = networkId;
}
public Long getVirtualMachineId() {
return virtualMachineId;
}
public void setVirtualMachineId(Long virtualMachineId) {
this.virtualMachineId = virtualMachineId;
}
public String getVirtualMachineName() {
return virtualMachineName;
}
public void setVirtualMachineName(String virtualMachineName) {
this.virtualMachineName = virtualMachineName;
}
public String getVirtualMachineDisplayName() {
return virtualMachineDisplayName;
}
public void setVirtualMachineDisplayName(String virtualMachineDisplayName) {
this.virtualMachineDisplayName = virtualMachineDisplayName;
}
@ -231,10 +170,6 @@ public class IPAddressResponse extends BaseResponse {
this.id = id;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
@ -263,4 +198,14 @@ public class IPAddressResponse extends BaseResponse {
public void setJobStatus(Integer jobStatus) {
this.jobStatus = jobStatus;
}
@Override
public void setProjectId(Long projectId) {
this.projectId = projectId;
}
@Override
public void setProjectName(String projectName) {
this.projectName = projectName;
}
}

View File

@ -24,7 +24,8 @@ import com.cloud.api.ApiConstants;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class InstanceGroupResponse extends BaseResponse {
@SuppressWarnings("unused")
public class InstanceGroupResponse extends BaseResponse implements ControlledEntityResponse{
@SerializedName(ApiConstants.ID) @Param(description="the id of the instance group")
private Long id;
@ -36,6 +37,12 @@ public class InstanceGroupResponse extends BaseResponse {
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the account owning the instance group")
private String accountName;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the group")
private Long projectId;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the group")
private String projectName;
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain ID of the instance group")
private Long domainId;
@ -43,51 +50,40 @@ public class InstanceGroupResponse extends BaseResponse {
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the instance group")
private String domainName;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getAccountName() {
return accountName;
}
@Override
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public Long getDomainId() {
return domainId;
}
@Override
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
public String getDomainName() {
return domainName;
}
@Override
public void setDomainName(String domainName) {
this.domainName = domainName;
}
@Override
public void setProjectId(Long projectId) {
this.projectId = projectId;
}
@Override
public void setProjectName(String projectName) {
this.projectName = projectName;
}
}

View File

@ -49,7 +49,7 @@ public class IpForwardingRuleResponse extends BaseResponse {
@SerializedName(ApiConstants.END_PORT) @Param(description="the end port of the rule")
private Integer endPort;
@SerializedName("state") @Param(description="state of the ip forwarding rule")
@SerializedName(ApiConstants.STATE) @Param(description="state of the ip forwarding rule")
private String state;
public Long getId() {

View File

@ -21,16 +21,17 @@ import com.cloud.api.ApiConstants;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class LoadBalancerResponse extends BaseResponse {
@SerializedName("id")
@SuppressWarnings("unused")
public class LoadBalancerResponse extends BaseResponse implements ControlledEntityResponse {
@SerializedName(ApiConstants.ID)
@Param(description = "the load balancer rule ID")
private Long id;
@SerializedName("name")
@SerializedName(ApiConstants.NAME)
@Param(description = "the name of the load balancer")
private String name;
@SerializedName("description")
@SerializedName(ApiConstants.DESCRIPTION)
@Param(description = "the description of the load balancer")
private String description;
@ -42,34 +43,40 @@ public class LoadBalancerResponse extends BaseResponse {
@Param(description = "the public ip address")
private String publicIp;
@SerializedName("publicport")
@SerializedName(ApiConstants.PUBLIC_PORT)
@Param(description = "the public port")
private String publicPort;
@SerializedName("privateport")
@SerializedName(ApiConstants.PRIVATE_PORT)
@Param(description = "the private port")
private String privatePort;
@SerializedName("algorithm")
@SerializedName(ApiConstants.ALGORITHM)
@Param(description = "the load balancer algorithm (source, roundrobin, leastconn)")
private String algorithm;
@SerializedName(ApiConstants.CIDR_LIST) @Param(description="the cidr list to forward traffic from")
private String cidrList;
@SerializedName("account")
@SerializedName(ApiConstants.ACCOUNT)
@Param(description = "the account of the load balancer rule")
private String accountName;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the load balancer")
private Long projectId;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the load balancer")
private String projectName;
@SerializedName("domainid")
@SerializedName(ApiConstants.DOMAIN_ID)
@Param(description = "the domain ID of the load balancer rule")
private Long domainId;
@SerializedName("domain")
@SerializedName(ApiConstants.DOMAIN)
@Param(description = "the domain of the load balancer rule")
private String domainName;
@SerializedName("state")
@SerializedName(ApiConstants.STATE)
@Param(description = "the state of the rule")
private String state;
@ -77,115 +84,70 @@ public class LoadBalancerResponse extends BaseResponse {
@Param(description = "the id of the zone the rule belongs to")
private Long zoneId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getPublicIp() {
return publicIp;
}
public void setPublicIp(String publicIp) {
this.publicIp = publicIp;
}
public String getPublicPort() {
return publicPort;
}
public void setPublicPort(String publicPort) {
this.publicPort = publicPort;
}
public String getPrivatePort() {
return privatePort;
}
public void setPrivatePort(String privatePort) {
this.privatePort = privatePort;
}
public String getCidrList() {
return cidrList;
}
public void setCidrList(String cidrs) {
this.cidrList = cidrs;
}
public String getAlgorithm() {
return algorithm;
}
public void setAlgorithm(String algorithm) {
this.algorithm = algorithm;
}
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public Long getDomainId() {
return domainId;
}
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
public String getDomainName() {
return domainName;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public Long getPublicIpId() {
return publicIpId;
}
public void setPublicIpId(Long publicIpId) {
this.publicIpId = publicIpId;
}
public Long getZoneId() {
return zoneId;
}
public void setZoneId(Long zoneId) {
this.zoneId = zoneId;
}
@Override
public void setProjectId(Long projectId) {
this.projectId = projectId;
}
@Override
public void setProjectName(String projectName) {
this.projectName = projectName;
}
}

View File

@ -24,36 +24,37 @@ import com.cloud.api.ApiConstants;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class NetworkResponse extends BaseResponse{
@SuppressWarnings("unused")
public class NetworkResponse extends BaseResponse implements ControlledEntityResponse{
@SerializedName("id") @Param(description="the id of the network")
@SerializedName(ApiConstants.ID) @Param(description="the id of the network")
private Long id;
@SerializedName("name") @Param(description="the name of the network")
@SerializedName(ApiConstants.NAME) @Param(description="the name of the network")
private String name;
@SerializedName("displaytext") @Param(description="the displaytext of the network")
@SerializedName(ApiConstants.DISPLAY_TEXT) @Param(description="the displaytext of the network")
private String displaytext;
@SerializedName("broadcastdomaintype") @Param(description="Broadcast domain type of the network")
private String broadcastDomainType;
@SerializedName("traffictype") @Param(description="the traffic type of the network")
@SerializedName(ApiConstants.TRAFFIC_TYPE) @Param(description="the traffic type of the network")
private String trafficType;
@SerializedName("gateway") @Param(description="the network's gateway")
@SerializedName(ApiConstants.GATEWAY) @Param(description="the network's gateway")
private String gateway;
@SerializedName("netmask") @Param(description="the network's netmask")
@SerializedName(ApiConstants.NETMASK) @Param(description="the network's netmask")
private String netmask;
@SerializedName("startip") @Param(description="the start ip of the network")
@SerializedName(ApiConstants.START_IP) @Param(description="the start ip of the network")
private String startIp;
@SerializedName("endip") @Param(description="the end ip of the network")
@SerializedName(ApiConstants.END_IP) @Param(description="the end ip of the network")
private String endIp;
@SerializedName("zoneid") @Param(description="zone id of the network")
@SerializedName(ApiConstants.ZONE_ID) @Param(description="zone id of the network")
private Long zoneId;
@SerializedName("networkofferingid") @Param(description="network offering id the network is created from")
@ -68,13 +69,13 @@ public class NetworkResponse extends BaseResponse{
@SerializedName("networkofferingavailability") @Param(description="availability of the network offering the network is created from")
private String networkOfferingAvailability;
@SerializedName("isshared") @Param(description="true if network is shared, false otherwise")
@SerializedName(ApiConstants.IS_SHARED) @Param(description="true if network is shared, false otherwise")
private Boolean isShared;
@SerializedName("issystem") @Param(description="true if network is system, false otherwise")
@SerializedName(ApiConstants.IS_SYSTEM) @Param(description="true if network is system, false otherwise")
private Boolean isSystem;
@SerializedName("state") @Param(description="state of the network")
@SerializedName(ApiConstants.STATE) @Param(description="state of the network")
private String state;
@SerializedName("related") @Param(description="related to what other network configuration")
@ -83,20 +84,26 @@ public class NetworkResponse extends BaseResponse{
@SerializedName("broadcasturi") @Param(description="broadcast uri of the network")
private String broadcastUri;
@SerializedName("dns1") @Param(description="the first DNS for the network")
@SerializedName(ApiConstants.DNS1) @Param(description="the first DNS for the network")
private String dns1;
@SerializedName("dns2") @Param(description="the second DNS for the network")
@SerializedName(ApiConstants.DNS2) @Param(description="the second DNS for the network")
private String dns2;
@SerializedName("type") @Param(description="the type of the network")
@SerializedName(ApiConstants.TYPE) @Param(description="the type of the network")
private String type;
@SerializedName("vlan") @Param(description="the vlan of the network")
@SerializedName(ApiConstants.VLAN) @Param(description="the vlan of the network")
private String vlan;
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the owner of the network")
private String accountName;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the ipaddress")
private Long projectId;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the address")
private String projectName;
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain id of the network owner")
private Long domainId;
@ -118,243 +125,123 @@ public class NetworkResponse extends BaseResponse{
@SerializedName(ApiConstants.TAGS) @Param(description="comma separated tag")
private String tags;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getBroadcastDomainType() {
return broadcastDomainType;
}
public void setBroadcastDomainType(String broadcastDomainType) {
this.broadcastDomainType = broadcastDomainType;
}
public String getTrafficType() {
return trafficType;
}
public void setTrafficType(String trafficType) {
this.trafficType = trafficType;
}
public String getGateway() {
return gateway;
}
public void setGateway(String gateway) {
this.gateway = gateway;
}
public String getNetmask() {
return netmask;
}
public void setNetmask(String netmask) {
this.netmask = netmask;
}
public Long getZoneId() {
return zoneId;
}
public void setZoneId(Long zoneId) {
this.zoneId = zoneId;
}
public Long getNetworkOfferingId() {
return networkOfferingId;
}
public void setNetworkOfferingId(Long networkOfferingId) {
this.networkOfferingId = networkOfferingId;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public Long getRelated() {
return related;
}
public void setRelated(Long related) {
this.related = related;
}
public String getBroadcastUri() {
return broadcastUri;
}
public void setBroadcastUri(String broadcastUri) {
this.broadcastUri = broadcastUri;
}
public String getDns1() {
return dns1;
}
public void setDns1(String dns1) {
this.dns1 = dns1;
}
public String getDns2() {
return dns2;
}
public void setDns2(String dns2) {
this.dns2 = dns2;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public Long getDomainId() {
return domainId;
}
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
public String getNetworkOfferingName() {
return networkOfferingName;
}
public void setNetworkOfferingName(String networkOfferingName) {
this.networkOfferingName = networkOfferingName;
}
public String getNetworkOfferingDisplayText() {
return networkOfferingDisplayText;
}
public void setNetworkOfferingDisplayText(String networkOfferingDisplayText) {
this.networkOfferingDisplayText = networkOfferingDisplayText;
}
public String getDisplaytext() {
return displaytext;
}
public void setDisplaytext(String displaytext) {
this.displaytext = displaytext;
}
public Boolean getIsShared() {
return isShared;
}
public void setIsShared(Boolean isShared) {
this.isShared = isShared;
}
public String getStartIp() {
return startIp;
}
public void setStartIp(String startIp) {
this.startIp = startIp;
}
public String getEndIp() {
return endIp;
}
public void setEndIp(String endIp) {
this.endIp = endIp;
}
public String getVlan() {
return vlan;
}
public void setVlan(String vlan) {
this.vlan = vlan;
}
public Boolean getIsSystem() {
return isSystem;
}
public void setIsSystem(Boolean isSystem) {
this.isSystem = isSystem;
}
public String getDomain() {
return domain;
}
public void setDomain(String domain) {
public void setDomainName(String domain) {
this.domain = domain;
}
public String getNetworkOfferingAvailability() {
return networkOfferingAvailability;
}
public void setNetworkOfferingAvailability(String networkOfferingAvailability) {
this.networkOfferingAvailability = networkOfferingAvailability;
}
public List<ServiceResponse> getServices() {
return services;
}
public void setServices(List<ServiceResponse> services) {
this.services = services;
}
public Boolean getIsDefault() {
return isDefault;
}
public void setIsDefault(Boolean isDefault) {
this.isDefault = isDefault;
}
public String getNetworkDomain() {
return networkDomain;
}
public void setNetworkDomain(String networkDomain) {
this.networkDomain = networkDomain;
}
public Boolean getIsSecurityGroupEnabled() {
return this.isSecurityGroupEnabled;
}
public void setIsSecurityGroupEnabled(Boolean sgEnabled) {
this.isSecurityGroupEnabled = sgEnabled;
}
@ -372,4 +259,16 @@ public class NetworkResponse extends BaseResponse{
this.tags = buf.delete(buf.length()-1, buf.length()).toString();
}
@Override
public void setProjectId(Long projectId) {
this.projectId = projectId;
}
@Override
public void setProjectName(String projectName) {
this.projectName = projectName;
}
}

View File

@ -21,7 +21,8 @@ import com.cloud.api.ApiConstants;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class RemoteAccessVpnResponse extends BaseResponse {
@SuppressWarnings("unused")
public class RemoteAccessVpnResponse extends BaseResponse implements ControlledEntityResponse{
@SerializedName(ApiConstants.PUBLIC_IP_ID) @Param(description="the public ip address of the vpn server")
private Long publicIpId;
@ -35,82 +36,64 @@ public class RemoteAccessVpnResponse extends BaseResponse {
@SerializedName("presharedkey") @Param(description="the ipsec preshared key")
private String presharedKey;
@SerializedName("account") @Param(description="the account of the remote access vpn")
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the account of the remote access vpn")
private String accountName;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the vpn")
private Long projectId;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the vpn")
private String projectName;
@SerializedName("domainid") @Param(description="the domain id of the account of the remote access vpn")
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain id of the account of the remote access vpn")
private long domainId;
@SerializedName("domainname") @Param(description="the domain name of the account of the remote access vpn")
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the account of the remote access vpn")
private String domainName;
@SerializedName("state") @Param(description="the state of the rule")
@SerializedName(ApiConstants.STATE) @Param(description="the state of the rule")
private String state;
public String getAccountName() {
return accountName;
}
public String getPublicIp() {
return publicIp;
}
public void setPublicIp(String publicIp) {
this.publicIp = publicIp;
}
public String getIpRange() {
return ipRange;
}
public void setIpRange(String ipRange) {
this.ipRange = ipRange;
}
public String getPresharedKey() {
return presharedKey;
}
public void setPresharedKey(String presharedKey) {
this.presharedKey = presharedKey;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public void setDomainId(long domainId) {
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
public void setDomainName(String name) {
this.domainName = name;
}
public long getDomainId() {
return domainId;
}
public String getDomainName() {
return domainName;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public Long getPublicIpId() {
return publicIpId;
}
public void setPublicIpId(Long publicIpId) {
this.publicIpId = publicIpId;
}
@Override
public void setProjectId(Long projectId) {
this.projectId = projectId;
}
@Override
public void setProjectName(String projectName) {
this.projectName = projectName;
}
}

View File

@ -23,29 +23,36 @@ import com.cloud.api.ApiConstants;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class SecurityGroupResponse extends BaseResponse {
@SerializedName("id") @Param(description="the ID of the security group")
@SuppressWarnings("unused")
public class SecurityGroupResponse extends BaseResponse implements ControlledEntityResponse{
@SerializedName(ApiConstants.ID) @Param(description="the ID of the security group")
private Long id;
@SerializedName("name") @Param(description="the name of the security group")
@SerializedName(ApiConstants.NAME) @Param(description="the name of the security group")
private String name;
@SerializedName("description") @Param(description="the description of the security group")
@SerializedName(ApiConstants.DESCRIPTION) @Param(description="the description of the security group")
private String description;
@SerializedName("account") @Param(description="the account owning the security group")
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the account owning the security group")
private String accountName;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the group")
private Long projectId;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the group")
private String projectName;
@SerializedName("domainid") @Param(description="the domain ID of the security group")
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain ID of the security group")
private Long domainId;
@SerializedName("domain") @Param(description="the domain name of the security group")
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the security group")
private String domainName;
@SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the volume")
private Long jobId;
@SerializedName("jobstatus") @Param(description="shows the current pending asynchronous job status")
@SerializedName(ApiConstants.JOB_STATUS) @Param(description="shows the current pending asynchronous job status")
private Integer jobStatus;
@SerializedName("ingressrule") @Param(description="the list of ingress rules associated with the security group", responseObject = IngressRuleResponse.class)
@ -53,63 +60,35 @@ public class SecurityGroupResponse extends BaseResponse {
@SerializedName("egressrule") @Param(description="the list of ingress rules associated with the security group", responseObject = EgressRuleResponse.class)
private List<EgressRuleResponse> egressRules;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
public Long getId() {
return id;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public Long getDomainId() {
return domainId;
}
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
public String getDomainName() {
return domainName;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public List<IngressRuleResponse> getIngressRules() {
return ingressRules;
}
public List<EgressRuleResponse> getEgressRules() {
return egressRules;
}
public void setIngressRules(List<IngressRuleResponse> ingressRules) {
this.ingressRules = ingressRules;
}
@ -167,4 +146,14 @@ public class SecurityGroupResponse extends BaseResponse {
return false;
return true;
}
@Override
public void setProjectId(Long projectId) {
this.projectId = projectId;
}
@Override
public void setProjectName(String projectName) {
this.projectName = projectName;
}
}

View File

@ -24,32 +24,39 @@ import com.cloud.serializer.Param;
import com.cloud.storage.Snapshot;
import com.google.gson.annotations.SerializedName;
public class SnapshotResponse extends BaseResponse {
@SerializedName("id")
@SuppressWarnings("unused")
public class SnapshotResponse extends BaseResponse implements ControlledEntityResponse {
@SerializedName(ApiConstants.ID)
@Param(description = "ID of the snapshot")
private Long id;
@SerializedName("account")
@SerializedName(ApiConstants.ACCOUNT)
@Param(description = "the account associated with the snapshot")
private String accountName;
@SerializedName("domainid")
@SerializedName(ApiConstants.DOMAIN_ID)
@Param(description = "the domain ID of the snapshot's account")
private Long domainId;
@SerializedName("domain")
@SerializedName(ApiConstants.DOMAIN)
@Param(description = "the domain name of the snapshot's account")
private String domainName;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the snapshot")
private Long projectId;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the snapshot")
private String projectName;
@SerializedName("snapshottype")
@SerializedName(ApiConstants.SNAPSHOT_TYPE)
@Param(description = "the type of the snapshot")
private String snapshotType;
@SerializedName("volumeid")
@SerializedName(ApiConstants.VOLUME_ID)
@Param(description = "ID of the disk volume")
private Long volumeId;
@SerializedName("volumename")
@SerializedName(ApiConstants.VOLUME_NAME)
@Param(description = "name of the disk volume")
private String volumeName;
@ -57,23 +64,23 @@ public class SnapshotResponse extends BaseResponse {
@Param(description = "type of the disk volume")
private String volumeType;
@SerializedName("created")
@SerializedName(ApiConstants.CREATED)
@Param(description = " the date the snapshot was created")
private Date created;
@SerializedName("name")
@SerializedName(ApiConstants.NAME)
@Param(description = "name of the snapshot")
private String name;
@SerializedName("jobid")
@SerializedName(ApiConstants.JOB_ID)
@Param(description = "the job ID associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job.")
private Long jobId;
@SerializedName("jobstatus")
@SerializedName(ApiConstants.JOB_STATUS)
@Param(description = "the job status associated with the snapshot. This is only displayed if the snapshot listed is part of a currently running asynchronous job.")
private Integer jobStatus;
@SerializedName("intervaltype")
@SerializedName(ApiConstants.INTERVAL_TYPE)
@Param(description = "valid types are hourly, daily, weekly, monthy, template, and none.")
private String intervalType;
@ -85,8 +92,8 @@ public class SnapshotResponse extends BaseResponse {
public Long getObjectId() {
return getId();
}
public Long getId() {
private Long getId() {
return id;
}
@ -110,58 +117,30 @@ public class SnapshotResponse extends BaseResponse {
this.domainId = domainId;
}
public String getDomainName() {
return domainName;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public String getSnapshotType() {
return snapshotType;
}
public void setSnapshotType(String snapshotType) {
this.snapshotType = snapshotType;
}
public Long getVolumeId() {
return volumeId;
}
public void setVolumeId(Long volumeId) {
this.volumeId = volumeId;
}
public String getVolumeName() {
return volumeName;
}
public void setVolumeName(String volumeName) {
this.volumeName = volumeName;
}
public String getVolumeType() {
return volumeType;
}
public void setVolumeType(String volumeType) {
this.volumeType = volumeType;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@ -186,19 +165,21 @@ public class SnapshotResponse extends BaseResponse {
this.jobStatus = jobStatus;
}
public String getIntervalType() {
return intervalType;
}
public void setIntervalType(String intervalType) {
this.intervalType = intervalType;
}
public Snapshot.Status getState() {
return state;
}
public void setState(Snapshot.Status state) {
this.state = state;
}
@Override
public void setProjectId(Long projectId) {
this.projectId = projectId;
}
@Override
public void setProjectName(String projectName) {
this.projectName = projectName;
}
}

View File

@ -19,51 +19,45 @@ package com.cloud.api.response;
import java.util.List;
import com.cloud.api.ApiConstants;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
@SuppressWarnings("unused")
public class TemplatePermissionsResponse extends BaseResponse {
@SerializedName("id") @Param(description="the template ID")
@SerializedName(ApiConstants.ID) @Param(description="the template ID")
private Long id;
@SerializedName("ispublic") @Param(description="true if this template is a public template, false otherwise")
@SerializedName(ApiConstants.IS_PUBLIC) @Param(description="true if this template is a public template, false otherwise")
private Boolean publicTemplate;
@SerializedName("domainid") @Param(description="the ID of the domain to which the template belongs")
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the ID of the domain to which the template belongs")
private Long domainId;
@SerializedName("account") @Param(description="the list of accounts the template is available for")
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the list of accounts the template is available for")
private List<String> accountNames;
public Long getId() {
return id;
}
@SerializedName(ApiConstants.PROJECT_IDS) @Param(description="the list of projects the template is available for")
private List<Long> projectIds;
public void setId(Long id) {
this.id = id;
}
public Boolean getPublicTemplate() {
return publicTemplate;
}
public void setPublicTemplate(Boolean publicTemplate) {
this.publicTemplate = publicTemplate;
}
public Long getDomainId() {
return domainId;
}
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
public List<String> getAccountNames() {
return accountNames;
}
public void setAccountNames(List<String> accountNames) {
this.accountNames = accountNames;
}
public void setProjectIds(List<Long> projectIds) {
this.projectIds = projectIds;
}
}

View File

@ -24,91 +24,92 @@ import com.cloud.serializer.Param;
import com.cloud.storage.Storage.ImageFormat;
import com.google.gson.annotations.SerializedName;
public class TemplateResponse extends BaseResponse {
@SerializedName("id") @Param(description="the template ID")
@SuppressWarnings("unused")
public class TemplateResponse extends BaseResponse implements ControlledEntityResponse {
@SerializedName(ApiConstants.ID) @Param(description="the template ID")
private long id;
@SerializedName("name") @Param(description="the template name")
@SerializedName(ApiConstants.NAME) @Param(description="the template name")
private String name;
@SerializedName("displaytext") @Param(description="the template display text")
@SerializedName(ApiConstants.DISPLAY_TEXT) @Param(description="the template display text")
private String displayText;
@SerializedName("ispublic") // propName="public" (FIXME: this used to be part of Param annotation, do we need it?)
@SerializedName(ApiConstants.IS_PUBLIC) // propName="public" (FIXME: this used to be part of Param annotation, do we need it?)
@Param(description="true if this template is a public template, false otherwise")
private boolean isPublic;
@SerializedName("created") @Param(description="the date this template was created")
@SerializedName(ApiConstants.CREATED) @Param(description="the date this template was created")
private Date created;
@SerializedName("removed") @Param(description="the date this template was removed")
private Date removed;
@SerializedName("isready") // propName="ready" (FIXME: this used to be part of Param annotation, do we need it?)
@SerializedName(ApiConstants.IS_READY) // propName="ready" (FIXME: this used to be part of Param annotation, do we need it?)
@Param(description="true if the template is ready to be deployed from, false otherwise.")
private boolean isReady;
@SerializedName("passwordenabled") @Param(description="true if the reset password feature is enabled, false otherwise")
@SerializedName(ApiConstants.PASSWORD_ENABLED) @Param(description="true if the reset password feature is enabled, false otherwise")
private Boolean passwordEnabled;
@SerializedName("format") @Param(description="the format of the template.")
@SerializedName(ApiConstants.FORMAT) @Param(description="the format of the template.")
private ImageFormat format;
@SerializedName("bootable") @Param(description="true if the ISO is bootable, false otherwise")
@SerializedName(ApiConstants.BOOTABLE) @Param(description="true if the ISO is bootable, false otherwise")
private Boolean bootable;
@SerializedName("isfeatured") @Param(description="true if this template is a featured template, false otherwise")
@SerializedName(ApiConstants.IS_FEATURED) @Param(description="true if this template is a featured template, false otherwise")
private boolean featured;
@SerializedName("crossZones") @Param(description="true if the template is managed across all Zones, false otherwise")
private boolean crossZones;
@SerializedName("ostypeid") @Param(description="the ID of the OS type for this template.")
@SerializedName(ApiConstants.OS_TYPE_ID) @Param(description="the ID of the OS type for this template.")
private Long osTypeId;
@SerializedName("ostypename") @Param(description="the name of the OS type for this template.")
private String osTypeName;
@SerializedName("accountid") @Param(description="the account id to which the template belongs")
@SerializedName(ApiConstants.ACCOUNT_ID) @Param(description="the account id to which the template belongs")
private Long accountId;
@SerializedName("account") @Param(description="the account name to which the template belongs")
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the account name to which the template belongs")
private String account;
@SerializedName("zoneid") @Param(description="the ID of the zone for this template")
@SerializedName(ApiConstants.ZONE_ID) @Param(description="the ID of the zone for this template")
private Long zoneId;
@SerializedName("zonename") @Param(description="the name of the zone for this template")
private String zoneName;
@SerializedName("status") @Param(description="the status of the template")
@SerializedName(ApiConstants.STATUS) @Param(description="the status of the template")
private String status;
@SerializedName("size") @Param(description="the size of the template")
@SerializedName(ApiConstants.SIZE) @Param(description="the size of the template")
private Long size;
@SerializedName("templatetype") @Param(description="the type of the template")
private String templateType;
@SerializedName("hypervisor") @Param(description="the hypervisor on which the template runs")
@SerializedName(ApiConstants.HYPERVISOR) @Param(description="the hypervisor on which the template runs")
private String hypervisor;
@SerializedName("jobid") @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the template")
@SerializedName(ApiConstants.JOB_ID) @Param(description="shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the template")
private Long jobId;
@SerializedName("jobstatus") @Param(description="shows the current pending asynchronous job status")
@SerializedName(ApiConstants.JOB_STATUS) @Param(description="shows the current pending asynchronous job status")
private Integer jobStatus;
@SerializedName("domain") @Param(description="the name of the domain to which the template belongs")
@SerializedName(ApiConstants.DOMAIN) @Param(description="the name of the domain to which the template belongs")
private String domainName;
@SerializedName("domainid") @Param(description="the ID of the domain to which the template belongs")
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the ID of the domain to which the template belongs")
private Long domainId;
@SerializedName("isextractable") @Param(description="true if the template is extractable, false otherwise")
@SerializedName(ApiConstants.IS_EXTRACTABLE) @Param(description="true if the template is extractable, false otherwise")
private Boolean extractable;
@SerializedName("checksum") @Param(description="checksum of the template")
@SerializedName(ApiConstants.CHECKSUM) @Param(description="checksum of the template")
private String checksum;
@SerializedName("sourcetemplateid") @Param(description="the template ID of the parent template if present")
@ -120,274 +121,169 @@ public class TemplateResponse extends BaseResponse {
@SerializedName("hostname") @Param(description="the name of the secondary storage host for the template")
private String hostName;
@SerializedName("templatetag") @Param(description="the tag of this template")
@SerializedName(ApiConstants.TEMPLATE_TAG) @Param(description="the tag of this template")
private String templateTag;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the template")
private Long projectId;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the template")
private String projectName;
@Override
public Long getObjectId() {
return getId();
}
public Long getZoneId() {
return zoneId;
public Long getId() {
return id;
}
public void setZoneId(Long zoneId) {
this.zoneId = zoneId;
}
public String getZoneName() {
return zoneName;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public Long getAccountId() {
return accountId;
}
public void setAccountId(Long accountId) {
this.accountId = accountId;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
public void setAccountName(String account) {
this.account = account;
}
public Long getOsTypeId() {
return osTypeId;
}
public void setOsTypeId(Long osTypeId) {
this.osTypeId = osTypeId;
}
public String getOsTypeName() {
return osTypeName;
}
public void setOsTypeName(String osTypeName) {
this.osTypeName = osTypeName;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDisplayText() {
return displayText;
}
public void setDisplayText(String displayText) {
this.displayText = displayText;
}
public boolean isPublic() {
return isPublic;
}
public void setPublic(boolean isPublic) {
this.isPublic = isPublic;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public Date getRemoved() {
return removed;
}
public void setRemoved(Date removed) {
this.removed = removed;
}
public boolean isReady() {
return isReady;
}
public void setReady(boolean isReady) {
this.isReady = isReady;
}
public boolean isPasswordEnabled() {
return passwordEnabled;
}
public void setPasswordEnabled(boolean passwordEnabled) {
this.passwordEnabled = passwordEnabled;
}
public ImageFormat getFormat() {
return format;
}
public void setFormat(ImageFormat format) {
this.format = format;
}
public Boolean isBootable() {
return bootable;
}
public void setBootable(Boolean bootable) {
this.bootable = bootable;
}
public boolean isFeatured() {
return featured;
}
public void setFeatured(boolean featured) {
this.featured = featured;
}
public boolean isCrossZones() {
return crossZones;
}
public void setCrossZones(boolean crossZones) {
this.crossZones = crossZones;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public Long getSize() {
return size;
}
public void setSize(Long size) {
this.size = size;
}
public String getTemplateType() {
return templateType;
}
public void setTemplateType(String templateType) {
this.templateType = templateType;
}
public String getHypervisor() {
return hypervisor;
}
public void setHypervisor(String hypervisor) {
this.hypervisor = hypervisor;
}
public Long getJobId() {
return jobId;
}
public void setJobId(Long jobId) {
this.jobId = jobId;
}
public Integer getJobStatus() {
return jobStatus;
}
public void setJobStatus(Integer jobStatus) {
this.jobStatus = jobStatus;
}
public long getDomainId() {
return domainId;
}
public String getDomainName(){
return domainName;
}
@Override
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public void setDomainId(long domainId) {
@Override
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
public Boolean isExtractable() {
return extractable;
}
public void setExtractable(Boolean extractable) {
this.extractable = extractable;
}
public String getChecksum() {
return checksum;
}
public void setChecksum(String checksum) {
this.checksum = checksum;
}
public Long getSourceTemplateId() {
return sourcetemplateId;
}
public void setSourceTemplateId(Long sourcetemplateId) {
this.sourcetemplateId = sourcetemplateId;
}
public Long getHostId() {
return hostId;
}
public void setHostId(Long hostId) {
this.hostId = hostId;
}
public String getHostName() {
return hostName;
}
public void setHostName(String hostName) {
this.hostName = hostName;
}
public String getTemplateTag() {
return templateTag;
}
public void setTemplateTag(String templateTag) {
this.templateTag = templateTag;
}
}
@Override
public void setProjectId(Long projectId) {
this.projectId = projectId;
}
@Override
public void setProjectName(String projectName) {
this.projectName = projectName;
}
}

View File

@ -23,7 +23,8 @@ import com.cloud.api.ApiConstants;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class VolumeResponse extends BaseResponse {
@SuppressWarnings("unused")
public class VolumeResponse extends BaseResponse implements ControlledEntityResponse{
@SerializedName(ApiConstants.ID)
@Param(description = "ID of the disk volume")
private Long id;
@ -32,7 +33,7 @@ public class VolumeResponse extends BaseResponse {
@Param(description = "shows the current pending asynchronous job ID. This tag is not returned if no current pending jobs are acting on the volume")
private Long jobId;
@SerializedName("jobstatus")
@SerializedName(ApiConstants.JOB_STATUS)
@Param(description = "shows the current pending asynchronous job status")
private Integer jobStatus;
@ -87,6 +88,12 @@ public class VolumeResponse extends BaseResponse {
@SerializedName(ApiConstants.ACCOUNT)
@Param(description = "the account associated with the disk volume")
private String accountName;
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the vpn")
private Long projectId;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the vpn")
private String projectName;
@SerializedName(ApiConstants.DOMAIN_ID)
@Param(description = "the ID of the domain associated with the disk volume")
@ -189,219 +196,121 @@ public class VolumeResponse extends BaseResponse {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getZoneId() {
return zoneId;
}
public void setZoneId(Long zoneId) {
this.zoneId = zoneId;
}
public String getZoneName() {
return zoneName;
}
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public String getVolumeType() {
return volumeType;
}
public void setVolumeType(String volumeType) {
this.volumeType = volumeType;
}
public Long getDeviceId() {
return deviceId;
}
public void setDeviceId(Long deviceId) {
this.deviceId = deviceId;
}
public Long getVirtualMachineId() {
return virtualMachineId;
}
public void setVirtualMachineId(Long virtualMachineId) {
this.virtualMachineId = virtualMachineId;
}
public String getVirtualMachineName() {
return virtualMachineName;
}
public void setVirtualMachineName(String virtualMachineName) {
this.virtualMachineName = virtualMachineName;
}
public String getVirtualMachineDisplayName() {
return virtualMachineDisplayName;
}
public void setVirtualMachineDisplayName(String virtualMachineDisplayName) {
this.virtualMachineDisplayName = virtualMachineDisplayName;
}
public String getVirtualMachineState() {
return virtualMachineState;
}
public void setVirtualMachineState(String virtualMachineState) {
this.virtualMachineState = virtualMachineState;
}
public Long getSize() {
return size;
}
public void setSize(Long size) {
this.size = size;
}
public Date getCreated() {
return created;
}
public void setCreated(Date created) {
this.created = created;
}
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public Long getDomainId() {
return domainId;
}
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
public String getDomainName() {
return domainName;
}
public void setDomainName(String domainName) {
this.domainName = domainName;
}
public String getStorageType() {
return storageType;
}
public void setStorageType(String storageType) {
this.storageType = storageType;
}
public String getHypervisor() {
return hypervisor;
}
public void setHypervisor(String hypervisor) {
this.hypervisor = hypervisor;
}
public Long getDiskOfferingId() {
return diskOfferingId;
}
public void setDiskOfferingId(Long diskOfferingId) {
this.diskOfferingId = diskOfferingId;
}
public String getDiskOfferingName() {
return diskOfferingName;
}
public void setDiskOfferingName(String diskOfferingName) {
this.diskOfferingName = diskOfferingName;
}
public String getDiskOfferingDisplayText() {
return diskOfferingDisplayText;
}
public void setDiskOfferingDisplayText(String diskOfferingDisplayText) {
this.diskOfferingDisplayText = diskOfferingDisplayText;
}
public String getStoragePoolName() {
return storagePoolName;
}
public void setStoragePoolName(String storagePoolName) {
this.storagePoolName = storagePoolName;
}
public Long getSnapshotId() {
return snapshotId;
}
public void setSnapshotId(Long snapshotId) {
this.snapshotId = snapshotId;
}
public Date getAttached() {
return attached;
}
public void setAttached(Date attached) {
this.attached = attached;
}
public Long getServiceOfferingId() {
return serviceOfferingId;
}
public void setServiceOfferingId(Long serviceOfferingId) {
this.serviceOfferingId = serviceOfferingId;
}
public String getServiceOfferingName() {
return serviceOfferingName;
}
public void setServiceOfferingName(String serviceOfferingName) {
this.serviceOfferingName = serviceOfferingName;
}
public String getServiceOfferingDisplayText() {
return serviceOfferingDisplayText;
}
public void setServiceOfferingDisplayText(String serviceOfferingDisplayText) {
this.serviceOfferingDisplayText = serviceOfferingDisplayText;
}
public Boolean getExtractable() {
return extractable;
}
public void setExtractable(Boolean extractable) {
this.extractable = extractable;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
@Override
public void setProjectId(Long projectId) {
this.projectId = projectId;
}
@Override
public void setProjectName(String projectName) {
this.projectName = projectName;
}
}

View File

@ -17,64 +17,62 @@
*/
package com.cloud.api.response;
import com.cloud.api.ApiConstants;
import com.cloud.serializer.Param;
import com.google.gson.annotations.SerializedName;
public class VpnUsersResponse extends BaseResponse {
@SerializedName("id") @Param(description="the vpn userID")
@SuppressWarnings("unused")
public class VpnUsersResponse extends BaseResponse implements ControlledEntityResponse{
@SerializedName(ApiConstants.ID) @Param(description="the vpn userID")
private Long id;
@SerializedName("username") @Param(description="the username of the vpn user")
@SerializedName(ApiConstants.USERNAME) @Param(description="the username of the vpn user")
private String userName;
@SerializedName("account") @Param(description="the account of the remote access vpn")
@SerializedName(ApiConstants.ACCOUNT) @Param(description="the account of the remote access vpn")
private String accountName;
@SerializedName("domainid") @Param(description="the domain id of the account of the remote access vpn")
@SerializedName(ApiConstants.DOMAIN_ID) @Param(description="the domain id of the account of the remote access vpn")
private long domainId;
@SerializedName("domainname") @Param(description="the domain name of the account of the remote access vpn")
@SerializedName(ApiConstants.DOMAIN) @Param(description="the domain name of the account of the remote access vpn")
private String domainName;
public String getAccountName() {
return accountName;
}
public Long getId() {
return id;
}
@SerializedName(ApiConstants.PROJECT_ID) @Param(description="the project id of the vpn")
private Long projectId;
@SerializedName(ApiConstants.PROJECT) @Param(description="the project name of the vpn")
private String projectName;
public void setId(Long id) {
this.id = id;
}
public String getUserName() {
return userName;
}
public void setUserName(String name) {
this.userName = name;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public void setDomainId(long domainId) {
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
public void setDomainName(String name) {
this.domainName = name;
}
@Override
public void setProjectId(Long projectId) {
this.projectId = projectId;
}
public long getDomainId() {
return domainId;
}
@Override
public void setProjectName(String projectName) {
this.projectName = projectName;
}
public String getDomainName() {
return domainName;
}
}

View File

@ -30,10 +30,6 @@ import com.cloud.user.OwnedBy;
*/
public interface Domain extends OwnedBy {
public static final long ROOT_DOMAIN = 1L;
public enum Type {
Normal,
Project,
}
enum State {Active, Inactive};
@ -64,6 +60,4 @@ public interface Domain extends OwnedBy {
void setState(State state);
String getNetworkDomain();
Type getType();
}

View File

@ -22,7 +22,6 @@ import java.util.Map;
import com.cloud.api.commands.AssociateIPAddrCmd;
import com.cloud.api.commands.CreateNetworkCmd;
import com.cloud.api.commands.DisassociateIPAddrCmd;
import com.cloud.api.commands.ListNetworksCmd;
import com.cloud.api.commands.RestartNetworkCmd;
import com.cloud.exception.ConcurrentOperationException;
@ -38,7 +37,7 @@ import com.cloud.user.Account;
public interface NetworkService {
List<? extends Network> getVirtualNetworksOwnedByAccountInZone(String accountName, long domainId, long zoneId);
List<? extends Network> getVirtualNetworksOwnedByAccountInZone(long zoneId, Account owner);
List<? extends NetworkOffering> listNetworkOfferings();
@ -55,7 +54,7 @@ public interface NetworkService {
*/
IpAddress associateIP(AssociateIPAddrCmd cmd) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException, ResourceUnavailableException;
boolean disassociateIpAddress(DisassociateIPAddrCmd cmd);
boolean disassociateIpAddress(long ipAddressId);
Network createNetwork(CreateNetworkCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException;

View File

@ -17,7 +17,6 @@
*/
package com.cloud.network;
import com.cloud.api.commands.StartRouterCmd;
import com.cloud.api.commands.UpgradeRouterCmd;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
@ -51,7 +50,7 @@ public interface VirtualNetworkApplianceService{
*/
VirtualRouter stopRouter(long routerId, boolean forced) throws ResourceUnavailableException, ConcurrentOperationException;
VirtualRouter startRouter(StartRouterCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException;
VirtualRouter startRouter(long id) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException;
VirtualRouter destroyRouter(long routerId) throws ResourceUnavailableException, ConcurrentOperationException;
}

View File

@ -25,7 +25,7 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.user.Account;
public interface RulesService {
List<? extends FirewallRule> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId);
List<? extends FirewallRule> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId, Long projectId);
/**
* Creates a port forwarding rule between two ip addresses or between

View File

@ -38,8 +38,6 @@ public interface Project extends PartOf{
long getProjectAccountId();
long getProjectDomainId();
State getState();
void setState(State state);

View File

@ -11,6 +11,4 @@ public interface ProjectAccount {
Role getAccountRole();
long getProjectAccountId();
long getProjectDomainId();
}

View File

@ -44,8 +44,6 @@ public interface ProjectService {
boolean unassignAccountFromProject(long projectId, long accountId);
Project findByProjectDomainId(long projectDomainId);
Project findByProjectAccountId(long projectAccountId);
Project findByNameAndDomainId(String name, long domainId);

View File

@ -29,7 +29,6 @@ import com.cloud.api.commands.CreateSSHKeyPairCmd;
import com.cloud.api.commands.DeleteSSHKeyPairCmd;
import com.cloud.api.commands.DestroySystemVmCmd;
import com.cloud.api.commands.ExtractVolumeCmd;
import com.cloud.api.commands.GetCloudIdentifierCmd;
import com.cloud.api.commands.GetVMPasswordCmd;
import com.cloud.api.commands.ListAccountsCmd;
import com.cloud.api.commands.ListAlertsCmd;
@ -351,7 +350,7 @@ public interface ManagementService {
* -- id for the user
* @return -- ArrayList of <CloudId+Signature>
*/
ArrayList<String> getCloudIdentifierResponse(GetCloudIdentifierCmd cmd);
ArrayList<String> getCloudIdentifierResponse(long userId);
boolean updateTemplatePermissions(UpdateTemplatePermissionsCmd cmd);

View File

@ -23,7 +23,6 @@ import com.cloud.api.commands.CancelPrimaryStorageMaintenanceCmd;
import com.cloud.api.commands.CreateStoragePoolCmd;
import com.cloud.api.commands.CreateVolumeCmd;
import com.cloud.api.commands.DeletePoolCmd;
import com.cloud.api.commands.DeleteVolumeCmd;
import com.cloud.api.commands.PreparePrimaryStorageForMaintenanceCmd;
import com.cloud.api.commands.UpdateStoragePoolCmd;
import com.cloud.exception.ConcurrentOperationException;
@ -67,7 +66,7 @@ public interface StorageService {
*/
Volume createVolume(CreateVolumeCmd cmd);
boolean deleteVolume(DeleteVolumeCmd cmd) throws ConcurrentOperationException;
boolean deleteVolume(long volumeId) throws ConcurrentOperationException;
/**
* Delete the storage pool

View File

@ -20,7 +20,6 @@ package com.cloud.storage.snapshot;
import java.util.List;
import com.cloud.api.commands.CreateSnapshotPolicyCmd;
import com.cloud.api.commands.DeleteSnapshotCmd;
import com.cloud.api.commands.DeleteSnapshotPoliciesCmd;
import com.cloud.api.commands.ListRecurringSnapshotScheduleCmd;
import com.cloud.api.commands.ListSnapshotPoliciesCmd;
@ -44,8 +43,9 @@ public interface SnapshotService {
/**
* Delete specified snapshot from the specified. If no other policies are assigned it calls destroy snapshot. This will be
* used for manual snapshots too.
* @param snapshotId TODO
*/
boolean deleteSnapshot(DeleteSnapshotCmd cmd);
boolean deleteSnapshot(long snapshotId);
/**
* Creates a policy with specified schedule. maxSnaps specifies the number of most recent snapshots that are to be retained.

View File

@ -19,14 +19,11 @@ package com.cloud.template;
import java.net.URISyntaxException;
import com.cloud.api.commands.AttachIsoCmd;
import com.cloud.api.commands.CopyTemplateCmd;
import com.cloud.api.commands.DeleteIsoCmd;
import com.cloud.api.commands.DeleteTemplateCmd;
import com.cloud.api.commands.DetachIsoCmd;
import com.cloud.api.commands.ExtractIsoCmd;
import com.cloud.api.commands.ExtractTemplateCmd;
import com.cloud.api.commands.PrepareTemplateCmd;
import com.cloud.api.commands.RegisterIsoCmd;
import com.cloud.api.commands.RegisterTemplateCmd;
import com.cloud.exception.InternalErrorException;
@ -41,11 +38,11 @@ public interface TemplateService {
VirtualMachineTemplate copyTemplate(CopyTemplateCmd cmd) throws StorageUnavailableException, ResourceAllocationException;
VirtualMachineTemplate prepareTemplate(PrepareTemplateCmd cmd) ;
VirtualMachineTemplate prepareTemplate(long templateId, long zoneId) ;
boolean detachIso(DetachIsoCmd cmd);
boolean detachIso(long vmId);
boolean attachIso(AttachIsoCmd cmd);
boolean attachIso(long isoId, long vmId);
/**
* Deletes a template

View File

@ -17,6 +17,8 @@
*/
package com.cloud.user;
import java.util.List;
import com.cloud.api.commands.DeleteUserCmd;
import com.cloud.api.commands.RegisterCmd;
import com.cloud.api.commands.UpdateAccountCmd;
@ -134,9 +136,9 @@ public interface AccountService {
boolean isAdmin(short accountType);
Account finalizeOwner(Account caller, String accountName, Long domainId);
Account finalizeOwner(Account caller, String accountName, Long domainId, Long projectId);
Pair<String, Long> finalizeAccountDomainForList(Account caller, String accountName, Long domainId);
Pair<List<Long>,Long> finalizeAccountDomainForList(Account caller, String accountName, Long domainId, Long projectId);
Account getActiveAccountByName(String accountName, Long domainId);

View File

@ -19,7 +19,6 @@ package com.cloud.user;
import java.util.List;
import com.cloud.api.commands.UpdateResourceCountCmd;
import com.cloud.configuration.Resource.ResourceType;
import com.cloud.configuration.ResourceCount;
import com.cloud.configuration.ResourceLimit;
@ -41,12 +40,12 @@ public interface ResourceLimitService {
/**
* Updates an existing resource count details for the account/domain
*
* @param cmd
* the command that wraps the domainId, accountId, resource type parameters
* @param accountId TODO
* @param domainId TODO
* @param typeId TODO
* @return the updated/created resource counts
*/
List<? extends ResourceCount> recalculateResourceCount(UpdateResourceCountCmd cmd);
List<? extends ResourceCount> recalculateResourceCount(Long accountId, Long domainId, Integer typeId);
/**
* Search for resource limits for the given id and/or account and/or type and/or domain.

View File

@ -53,30 +53,12 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
}
@Override
public boolean checkAccess(Account caller, Domain domain, AccessType accessType) throws PermissionDeniedException {
public boolean checkAccess(Account caller, Domain domain) throws PermissionDeniedException {
if (caller.getState() != Account.State.enabled) {
throw new PermissionDeniedException(caller + " is disabled.");
}
long domainId = domain.getId();
if (domain.getType() == Domain.Type.Project) {
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL) {
if (accessType != null && accessType == AccessType.ModifyProject) {
if (!_projectMgr.canModifyProjectDomain(caller, domainId)) {
throw new PermissionDeniedException(caller + " does not have permission to operate within " + domain);
}
} else if (!_projectMgr.canAccessDomain(caller, domainId)){
throw new PermissionDeniedException(caller + " does not have permission to operate within " + domain);
}
return true;
}
//need to check the domain the project belongs to
Project project = _projectMgr.findByProjectDomainId(domainId);
domainId = project.getDomainId();
}
if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL) {
if (caller.getDomainId() != domainId) {
throw new PermissionDeniedException(caller + " does not have permission to operate within " + domain);
@ -94,7 +76,7 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
throw new PermissionDeniedException(user + " is no longer active.");
}
Account account = _accountDao.findById(user.getAccountId());
return checkAccess(account, domain, null);
return checkAccess(account, domain);
}
@Override
@ -135,7 +117,7 @@ public class DomainChecker extends AdapterBase implements SecurityChecker {
if (!_projectMgr.canModifyProjectAccount(caller, account.getId())) {
throw new PermissionDeniedException(caller + " does not have permission to operate with resource " + entity);
}
} else if (!_projectMgr.canAccessAccount(caller, account.getId())){
} else if (!_projectMgr.canAccessProjectAccount(caller, account.getId())){
throw new PermissionDeniedException(caller + " does not have permission to operate with resource " + entity);
}
} else {

View File

@ -637,10 +637,6 @@ public class ApiDBUtils {
return _projectMgr.getProjectOwner(projectId);
}
public static Project findProjectByProjectDomainId(long projectDomainId) {
return _projectMgr.findByProjectDomainId(projectDomainId);
}
public static Project findProjectByProjectAccountId(long projectAccountId) {
return _projectMgr.findByProjectAccountId(projectAccountId);
}

View File

@ -464,13 +464,8 @@ public class ApiResponseHelper implements ResponseGenerator {
public SnapshotResponse createSnapshotResponse(Snapshot snapshot) {
SnapshotResponse snapshotResponse = new SnapshotResponse();
snapshotResponse.setId(snapshot.getId());
Account acct = ApiDBUtils.findAccountById(Long.valueOf(snapshot.getAccountId()));
if (acct != null) {
snapshotResponse.setAccountName(acct.getAccountName());
snapshotResponse.setDomainId(acct.getDomainId());
snapshotResponse.setDomainName(ApiDBUtils.findDomainById(acct.getDomainId()).getName());
}
populateOwner(snapshotResponse, snapshot);
VolumeVO volume = findVolumeById(snapshot.getVolumeId());
String snapshotTypeStr = snapshot.getType().name();
@ -660,12 +655,7 @@ public class ApiResponseHelper implements ResponseGenerator {
ipResponse.setSourceNat(ipAddress.isSourceNat());
// get account information
Account accountTemp = ApiDBUtils.findAccountById(ipAddress.getAllocatedToAccountId());
if (accountTemp != null) {
ipResponse.setAccountName(accountTemp.getAccountName());
ipResponse.setDomainId(accountTemp.getDomainId());
ipResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
populateOwner(ipResponse, ipAddress);
ipResponse.setForVirtualNetwork(forVirtualNetworks);
ipResponse.setStaticNat(ipAddress.isOneToOneNat());
@ -730,14 +720,7 @@ public class ApiResponseHelper implements ResponseGenerator {
stateToSet = "Deleting";
}
lbResponse.setState(stateToSet);
Account accountTemp = ApiDBUtils.findAccountById(loadBalancer.getAccountId());
if (accountTemp != null) {
lbResponse.setAccountName(accountTemp.getAccountName());
lbResponse.setDomainId(accountTemp.getDomainId());
lbResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
populateOwner(lbResponse, loadBalancer);
lbResponse.setZoneId(publicIp.getDataCenterId());
lbResponse.setObjectName("loadbalancer");
@ -878,12 +861,7 @@ public class ApiResponseHelper implements ResponseGenerator {
volResponse.setCreated(volume.getCreated());
volResponse.setState(volume.getState().toString());
Account accountTemp = ApiDBUtils.findAccountById(volume.getAccountId());
if (accountTemp != null) {
volResponse.setAccountName(accountTemp.getAccountName());
volResponse.setDomainId(accountTemp.getDomainId());
volResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
populateOwner(volResponse, volume);
String storageType;
try {
@ -941,13 +919,9 @@ public class ApiResponseHelper implements ResponseGenerator {
groupResponse.setId(group.getId());
groupResponse.setName(group.getName());
groupResponse.setCreated(group.getCreated());
populateOwner(groupResponse, group);
Account accountTemp = ApiDBUtils.findAccountById(group.getAccountId());
if (accountTemp != null) {
groupResponse.setAccountName(accountTemp.getAccountName());
groupResponse.setDomainId(accountTemp.getDomainId());
groupResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
groupResponse.setObjectName("instancegroup");
return groupResponse;
}
@ -977,7 +951,6 @@ public class ApiResponseHelper implements ResponseGenerator {
}
StorageStats stats = ApiDBUtils.getStoragePoolStatistics(pool.getId());
Long capacity = pool.getCapacityBytes();
long allocatedSize = ApiDBUtils.getStorageCapacitybyPool(pool.getId(),Capacity.CAPACITY_TYPE_STORAGE_ALLOCATED);
poolResponse.setDiskSizeTotal(pool.getCapacityBytes());
poolResponse.setDiskSizeAllocated(allocatedSize);
@ -1180,12 +1153,7 @@ public class ApiResponseHelper implements ResponseGenerator {
routerResponse.setServiceOfferingId(offering.getId());
routerResponse.setServiceOfferingName(offering.getName());
Account accountTemp = ApiDBUtils.findAccountById(router.getAccountId());
if (accountTemp != null) {
routerResponse.setAccountName(accountTemp.getAccountName());
routerResponse.setDomainId(accountTemp.getDomainId());
routerResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
populateOwner(routerResponse, router);
List<NicProfile> nicProfiles = ApiDBUtils.getNics(router);
for (NicProfile singleNicProfile : nicProfiles) {
@ -1328,12 +1296,7 @@ public class ApiResponseHelper implements ResponseGenerator {
vpnResponse.setId(vpnUser.getId());
vpnResponse.setUserName(vpnUser.getUsername());
Account accountTemp = ApiDBUtils.findAccountById(vpnUser.getAccountId());
if (accountTemp != null) {
vpnResponse.setAccountName(accountTemp.getAccountName());
vpnResponse.setDomainId(accountTemp.getDomainId());
vpnResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
populateOwner(vpnResponse, vpnUser);
vpnResponse.setObjectName("vpnuser");
return vpnResponse;
@ -1348,11 +1311,8 @@ public class ApiResponseHelper implements ResponseGenerator {
vpnResponse.setPresharedKey(vpn.getIpsecPresharedKey());
vpnResponse.setDomainId(vpn.getDomainId());
Account accountTemp = ApiDBUtils.findAccountById(vpn.getAccountId());
if (accountTemp != null) {
vpnResponse.setAccountName(accountTemp.getAccountName());
vpnResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
populateOwner(vpnResponse, vpn);
vpnResponse.setState(vpn.getState().toString());
vpnResponse.setObjectName("remoteaccessvpn");
@ -1379,11 +1339,9 @@ public class ApiResponseHelper implements ResponseGenerator {
// add account ID and name
Account owner = ApiDBUtils.findAccountById(result.getAccountId());
if (owner != null) {
response.setAccount(owner.getAccountName());
response.setDomainId(owner.getDomainId());
response.setDomainName(ApiDBUtils.findDomainById(owner.getDomainId()).getName());
}
populateAccount(response, owner.getId());
populateDomain(response, owner.getDomainId());
response.setObjectName("iso");
return response;
}
@ -1444,15 +1402,9 @@ public class ApiResponseHelper implements ResponseGenerator {
templateResponse.setOsTypeName("");
}
// add account ID and name
Account owner = ApiDBUtils.findAccountById(template.getAccountId());
if (owner != null) {
templateResponse.setAccount(owner.getAccountName());
templateResponse.setDomainId(owner.getDomainId());
templateResponse.setDomainName(ApiDBUtils.findDomainById(owner.getDomainId()).getName());
}
Account account = ApiDBUtils.findAccountByIdIncludingRemoved(template.getAccountId());
populateAccount(templateResponse, account.getId());
populateDomain(templateResponse, account.getDomainId());
DataCenterVO datacenter = ApiDBUtils.findZoneById(zoneId);
@ -1460,14 +1412,14 @@ public class ApiResponseHelper implements ResponseGenerator {
templateResponse.setZoneId(zoneId);
templateResponse.setZoneName(datacenter.getName());
Account account = UserContext.current().getCaller();
Account caller = UserContext.current().getCaller();
boolean isAdmin = false;
if ((account == null) || BaseCmd.isAdmin(account.getType())) {
if ((caller == null) || BaseCmd.isAdmin(caller.getType())) {
isAdmin = true;
}
// If the user is an Admin, add the template download status
if (isAdmin || account.getId() == template.getAccountId()) {
if (isAdmin || caller.getId() == template.getAccountId()) {
// add download status
if (templateHostRef.getDownloadState() != Status.DOWNLOADED) {
String templateStatus = "Processing";
@ -1525,7 +1477,7 @@ public class ApiResponseHelper implements ResponseGenerator {
isoResponse.setPasswordEnabled(false);
Account owner = ApiDBUtils.findAccountById(iso.getAccountId());
if (owner != null) {
isoResponse.setAccount(owner.getAccountName());
isoResponse.setAccountName(owner.getAccountName());
isoResponse.setDomainId(owner.getDomainId());
isoResponse.setDomainName(ApiDBUtils.findDomainById(owner.getDomainId()).getName());
}
@ -1581,7 +1533,7 @@ public class ApiResponseHelper implements ResponseGenerator {
// add account ID and name
Account owner = ApiDBUtils.findAccountById(iso.getAccountId());
if (owner != null) {
isoResponse.setAccount(owner.getAccountName());
isoResponse.setAccountName(owner.getAccountName());
isoResponse.setDomainId(owner.getDomainId());
// TODO: implement
isoResponse.setDomainName(ApiDBUtils.findDomainById(owner.getDomainId()).getName());
@ -1641,6 +1593,9 @@ public class ApiResponseHelper implements ResponseGenerator {
netGrpResponse.setName(networkGroup.getName());
netGrpResponse.setDescription(networkGroup.getDescription());
netGrpResponse.setAccountName(networkGroup.getAccountName());
populateOwner(netGrpResponse, networkGroup);
netGrpResponse.setDomainId(networkGroup.getDomainId());
netGrpResponse.setDomainName(ApiDBUtils.findDomainById(networkGroup.getDomainId()).getName());
@ -1960,9 +1915,9 @@ public class ApiResponseHelper implements ResponseGenerator {
public TemplatePermissionsResponse createTemplatePermissionsResponse(List<String> accountNames, Long id, boolean isAdmin) {
Long templateOwnerDomain = null;
VirtualMachineTemplate template = ApiDBUtils.findTemplateById(id);
Account templateOwner = ApiDBUtils.findAccountById(template.getAccountId());
if (isAdmin) {
// FIXME: we have just template id and need to get template owner from that
Account templateOwner = ApiDBUtils.findAccountById(template.getAccountId());
if (templateOwner != null) {
templateOwnerDomain = templateOwner.getDomainId();
}
@ -1974,8 +1929,29 @@ public class ApiResponseHelper implements ResponseGenerator {
if (isAdmin && (templateOwnerDomain != null)) {
response.setDomainId(templateOwnerDomain);
}
response.setAccountNames(accountNames);
//Set accounts
List<Long> projectIds = new ArrayList<Long>();
List<String> regularAccounts = new ArrayList<String>();
for (String accountName : accountNames) {
Account account = ApiDBUtils.findAccountByNameDomain(accountName, templateOwner.getDomainId());
if (account.getType() != Account.ACCOUNT_TYPE_PROJECT) {
regularAccounts.add(accountName);
} else {
//convert account to projectIds
Project project = ApiDBUtils.findProjectByProjectAccountId(account.getId());
projectIds.add(project.getId());
}
}
if (!projectIds.isEmpty()) {
response.setProjectIds(projectIds);
}
if (!regularAccounts.isEmpty()) {
response.setAccountNames(regularAccounts);
}
response.setObjectName("templatepermission");
return response;
}
@ -2252,20 +2228,14 @@ public class ApiResponseHelper implements ResponseGenerator {
}
}
response.setServices(serviceResponses);
Account account = ApiDBUtils.findAccountById(network.getAccountId());
if (account != null && !network.getIsShared()) {
response.setAccountName(account.getAccountName());
Domain domain = ApiDBUtils.findDomainById(account.getDomainId());
response.setDomainId(domain.getId());
response.setDomain(domain.getName());
}
populateOwner(response, network);
Long dedicatedDomainId = ApiDBUtils.getDedicatedNetworkDomain(network.getId());
if (dedicatedDomainId != null) {
Domain domain = ApiDBUtils.findDomainById(dedicatedDomainId);
response.setDomainId(dedicatedDomainId);
response.setDomain(domain.getName());
response.setDomainName(domain.getName());
}
response.setObjectName("network");
@ -2486,11 +2456,6 @@ public class ApiResponseHelper implements ResponseGenerator {
private void populateDomain(ControlledEntityResponse response, long domainId) {
Domain domain = ApiDBUtils.findDomainById(domainId);
if (domain.getType() == Domain.Type.Project) {
Project project = ApiDBUtils.findProjectByProjectDomainId(domainId);
domain = ApiDBUtils.findDomainById(project.getDomainId());
}
response.setDomainId(domain.getId());
response.setDomainName(domain.getName());

View File

@ -23,13 +23,14 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.cloud.acl.ControlledEntity;
import com.cloud.api.ApiDBUtils;
import com.cloud.network.security.SecurityGroup;
import com.cloud.network.security.SecurityGroupRules;
import com.cloud.serializer.Param;
import com.cloud.user.Account;
public class SecurityGroupResultObject {
public class SecurityGroupResultObject implements ControlledEntity{
@Param(name = "id")
private Long id;
@ -40,10 +41,10 @@ public class SecurityGroupResultObject {
private String description;
@Param(name = "domainid")
private Long domainId;
private long domainId;
@Param(name = "accountid")
private Long accountId;
private long accountId;
@Param(name = "accountname")
private String accountName = null;
@ -54,7 +55,7 @@ public class SecurityGroupResultObject {
public SecurityGroupResultObject() {
}
public SecurityGroupResultObject(Long id, String name, String description, Long domainId, Long accountId, String accountName, List<IngressRuleResultObject> ingressRules) {
public SecurityGroupResultObject(Long id, String name, String description, long domainId, long accountId, String accountName, List<IngressRuleResultObject> ingressRules) {
this.id = id;
this.name = name;
this.description = description;
@ -88,7 +89,7 @@ public class SecurityGroupResultObject {
this.description = description;
}
public Long getDomainId() {
public long getDomainId() {
return domainId;
}
@ -96,7 +97,7 @@ public class SecurityGroupResultObject {
this.domainId = domainId;
}
public Long getAccountId() {
public long getAccountId() {
return accountId;
}

View File

@ -2072,7 +2072,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
if (associateIpRangeToAccount) {
_networkMgr.associateIpAddressListToAccount(userId, account.getId(), zoneId, vlan.getId(), network);
if (network == null) {
List<? extends Network> networks = _networkMgr.getVirtualNetworksOwnedByAccountInZone(account.getAccountName(), account.getDomainId(), zoneId);
List<? extends Network> networks = _networkMgr.getVirtualNetworksOwnedByAccountInZone(zoneId, account);
network = networks.get(0);
}
if (network == null) {

View File

@ -22,8 +22,6 @@ import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@ -68,10 +66,6 @@ public class DomainVO implements Domain {
@Column(name="network_domain")
private String networkDomain;
@Column(name="type")
@Enumerated(value=EnumType.STRING)
private Domain.Type type = Domain.Type.Normal;
public DomainVO() {}
@ -89,14 +83,6 @@ public class DomainVO implements Domain {
this.state = Domain.State.Active;
this.networkDomain = networkDomain;
}
public DomainVO(String name, long owner, Long parentId, String networkDomain, Domain.Type type) {
this(name, owner, parentId, networkDomain);
if (type != null) {
this.type = type;
}
}
@Override
@ -200,11 +186,6 @@ public class DomainVO implements Domain {
public void setNetworkDomain(String domainSuffix) {
this.networkDomain = domainSuffix;
}
@Override
public Domain.Type getType() {
return type;
}
}

View File

@ -44,7 +44,6 @@ import com.cloud.agent.api.to.NicTO;
import com.cloud.alert.AlertManager;
import com.cloud.api.commands.AssociateIPAddrCmd;
import com.cloud.api.commands.CreateNetworkCmd;
import com.cloud.api.commands.DisassociateIPAddrCmd;
import com.cloud.api.commands.ListNetworksCmd;
import com.cloud.api.commands.RestartNetworkCmd;
import com.cloud.capacity.dao.CapacityDao;
@ -115,6 +114,8 @@ import com.cloud.offering.NetworkOffering.Availability;
import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.offerings.dao.NetworkOfferingDao;
import com.cloud.org.Grouping;
import com.cloud.projects.Project;
import com.cloud.projects.ProjectManager;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
import com.cloud.user.AccountVO;
@ -229,6 +230,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
ResourceLimitService _resourceLimitMgr;
@Inject DomainRouterDao _routerDao;
@Inject DomainManager _domainMgr;
@Inject ProjectManager _projectMgr;
private final HashMap<String, NetworkOfferingVO> _systemNetworks = new HashMap<String, NetworkOfferingVO>(5);
@ -529,11 +531,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
@Override
public List<? extends Network> getVirtualNetworksOwnedByAccountInZone(String accountName, long domainId, long zoneId) {
Account owner = _accountMgr.getActiveAccountByName(accountName, domainId);
if (owner == null) {
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId + ", permission denied");
}
public List<? extends Network> getVirtualNetworksOwnedByAccountInZone(long zoneId, Account owner) {
return _networksDao.listBy(owner.getId(), zoneId, GuestIpType.Virtual);
}
@ -1400,11 +1398,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_NET_IP_RELEASE, eventDescription = "disassociating Ip", async = true)
public boolean disassociateIpAddress(DisassociateIPAddrCmd cmd) {
public boolean disassociateIpAddress(long ipAddressId) {
Long userId = UserContext.current().getCallerUserId();
Account caller = UserContext.current().getCaller();
Long ipAddressId = cmd.getIpAddressId();
// Verify input parameters
IPAddressVO ipVO = _ipAddressDao.findById(ipAddressId);
@ -1417,6 +1413,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return true;
}
//verify permissions
if (ipVO.getAllocatedToAccountId() != null) {
_accountMgr.checkAccess(caller, null, ipVO);
}
@ -1569,7 +1566,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
Account owner = null;
if (cmd.getAccountName() != null && cmd.getDomainId() != null) {
owner = _accountMgr.finalizeOwner(caller, cmd.getAccountName(), cmd.getDomainId());
owner = _accountMgr.finalizeOwner(caller, cmd.getAccountName(), cmd.getDomainId(), cmd.getProjectId());
} else {
owner = caller;
}
@ -1837,7 +1834,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
Boolean isSystem = cmd.getIsSystem();
Boolean isShared = cmd.getIsShared();
Boolean isDefault = cmd.isDefault();
Long accountId = null;
Long projectId = cmd.getProjectId();
List<Long> permittedAccounts = new ArrayList<Long>();
String path = null;
Long sharedNetworkDomainId = null;
@ -1866,14 +1864,29 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
_accountMgr.checkAccess(caller, null, owner);
accountId = owner.getId();
permittedAccounts.add(owner.getId());
}
}
if (!_accountMgr.isAdmin(caller.getType())) {
accountId = caller.getId();
permittedAccounts.add(caller.getId());
}
//set project information
if (projectId != null) {
permittedAccounts.clear();
Project project = _projectMgr.getProject(projectId);
if (project == null) {
throw new InvalidParameterValueException("Unable to find project by id " + projectId);
}
if (!_projectMgr.canAccessProjectAccount(caller, project.getProjectAccountId())) {
throw new InvalidParameterValueException("Account " + caller + " can't access project id=" + projectId);
}
permittedAccounts.add(project.getProjectAccountId());
} else if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL){
permittedAccounts.addAll(_projectMgr.listPermittedProjectAccounts(caller.getId()));
}
path = _domainDao.findById(caller.getDomainId()).getPath();
if ((isSystem == null || !isSystem) && (isShared == null || isShared)) {
@ -1923,8 +1936,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
//if user requested only domain specific networks, don't return account/zone wide networks
if (accountId != null || (domainId == null && accountName == null)) {
networksToReturn.addAll(listAccountSpecificAndZoneLevelNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, type, isDefault, trafficType, isShared), searchFilter, accountId, path));
if (!permittedAccounts.isEmpty() || (domainId == null && accountName == null && projectId == null)) {
networksToReturn.addAll(listAccountSpecificAndZoneLevelNetworks(buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, type, isDefault, trafficType, isShared), searchFilter, path, permittedAccounts));
}
return networksToReturn;
@ -1988,14 +2001,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return _networksDao.search(sc, searchFilter);
}
private List<NetworkVO> listAccountSpecificAndZoneLevelNetworks(SearchCriteria<NetworkVO> sc, Filter searchFilter, Long accountId, String path) {
private List<NetworkVO> listAccountSpecificAndZoneLevelNetworks(SearchCriteria<NetworkVO> sc, Filter searchFilter, String path, List<Long> permittedAccounts) {
SearchCriteria<NetworkVO> ssc = _networksDao.createSearchCriteria();
//account level networks
SearchCriteria<NetworkVO> accountSC = _networksDao.createSearchCriteria();
if (accountId != null) {
accountSC.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
if (!permittedAccounts.isEmpty()) {
accountSC.addAnd("accountId", SearchCriteria.Op.IN, permittedAccounts);
}
accountSC.addAnd("isShared", SearchCriteria.Op.EQ, false);
@ -2050,13 +2063,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
Account owner = _accountMgr.getAccount(network.getAccountId());
// Perform permission check
if (!_accountMgr.isAdmin(caller.getType())) {
if (network.getAccountId() != caller.getId()) {
throw new PermissionDeniedException("Account " + caller.getAccountName() + " does not own network id=" + networkId + ", permission denied");
}
} else {
_accountMgr.checkAccess(caller, null, owner);
}
_accountMgr.checkAccess(caller, null, network);
User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
ReservationContext context = new ReservationContextImpl(null, null, callerUser, owner);
@ -2694,7 +2701,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
txn.start();
if (network == null) {
List<? extends Network> networks = getVirtualNetworksOwnedByAccountInZone(owner.getAccountName(), owner.getDomainId(), zoneId);
List<? extends Network> networks = getVirtualNetworksOwnedByAccountInZone(zoneId, owner);
if (networks.size() == 0) {
createNetwork = true;
} else {
@ -2987,8 +2994,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
public boolean isNetworkAvailableInDomain(long networkId, long domainId) {
Long networkDomainId = null;
Network network = getNetwork(networkId);
if (!network.getIsShared()) {

View File

@ -191,8 +191,8 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
Long id = cmd.getId();
String path = null;
Pair<String, Long> accountDomainPair = _accountMgr.finalizeAccountDomainForList(caller, cmd.getAccountName(), cmd.getDomainId());
String accountName = accountDomainPair.first();
Pair<List<Long>, Long> accountDomainPair = _accountMgr.finalizeAccountDomainForList(caller, cmd.getAccountName(), cmd.getDomainId(), cmd.getProjectId());
List<Long> permittedAccounts = accountDomainPair.first();
Long domainId = accountDomainPair.second();
if (ipId != null) {
@ -212,7 +212,7 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
SearchBuilder<FirewallRuleVO> sb = _firewallDao.createSearchBuilder();
sb.and("id", sb.entity().getId(), Op.EQ);
sb.and("ip", sb.entity().getSourceIpAddressId(), Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), Op.IN);
sb.and("domainId", sb.entity().getDomainId(), Op.EQ);
sb.and("purpose", sb.entity().getPurpose(), Op.EQ);
@ -235,10 +235,10 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
if (domainId != null) {
sc.setParameters("domainId", domainId);
if (accountName != null) {
Account account = _accountMgr.getActiveAccountByName(accountName, domainId);
sc.setParameters("accountId", account.getId());
}
}
if (!permittedAccounts.isEmpty()) {
sc.setParameters("accountId", permittedAccounts.toArray());
}
sc.setParameters("purpose", Purpose.Firewall);
@ -449,7 +449,6 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ma
_accountMgr.checkAccess(caller, null, rule);
revokeRule(rule, caller, userId, false);
boolean success = false;

View File

@ -611,11 +611,19 @@ public class LoadBalancingRulesManagerImpl implements LoadBalancingRulesManager,
@Override
@ActionEvent(eventType = EventTypes.EVENT_LOAD_BALANCER_UPDATE, eventDescription = "updating load balancer", async = true)
public LoadBalancer updateLoadBalancerRule(UpdateLoadBalancerRuleCmd cmd) {
Account caller = UserContext.current().getCaller();
Long lbRuleId = cmd.getId();
String name = cmd.getLoadBalancerName();
String description = cmd.getDescription();
String algorithm = cmd.getAlgorithm();
LoadBalancerVO lb = _lbDao.findById(lbRuleId);
if (lb == null) {
throw new InvalidParameterValueException("Unable to find lb rule by id=" + lbRuleId);
}
//check permissions
_accountMgr.checkAccess(caller, null, lb);
if (name != null) {
lb.setName(name);
@ -703,8 +711,8 @@ public class LoadBalancingRulesManagerImpl implements LoadBalancingRulesManager,
Long zoneId = cmd.getZoneId();
String path = null;
Pair<String, Long> accountDomainPair = _accountMgr.finalizeAccountDomainForList(caller, cmd.getAccountName(), cmd.getDomainId());
String accountName = accountDomainPair.first();
Pair<List<Long>, Long> accountDomainPair = _accountMgr.finalizeAccountDomainForList(caller, cmd.getAccountName(), cmd.getDomainId(), cmd.getProjectId());
List<Long> permittedAccounts = accountDomainPair.first();
Long domainId = accountDomainPair.second();
if (caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
@ -723,7 +731,7 @@ public class LoadBalancingRulesManagerImpl implements LoadBalancingRulesManager,
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
sb.and("sourceIpAddress", sb.entity().getSourceIpAddressId(), SearchCriteria.Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.IN);
sb.and("domainId", sb.entity().getDomainId(), SearchCriteria.Op.EQ);
if (instanceId != null) {
@ -772,10 +780,10 @@ public class LoadBalancingRulesManagerImpl implements LoadBalancingRulesManager,
if (domainId != null) {
sc.setParameters("domainId", domainId);
if (accountName != null) {
Account account = _accountMgr.getActiveAccountByName(accountName, domainId);
sc.setParameters("accountId", account.getId());
}
}
if (!permittedAccounts.isEmpty()) {
sc.setParameters("accountId", permittedAccounts.toArray());
}
if (path != null) {

View File

@ -35,8 +35,8 @@ import javax.naming.ConfigurationException;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.agent.Listener;
import com.cloud.agent.AgentManager.OnError;
import com.cloud.agent.Listener;
import com.cloud.agent.api.AgentControlAnswer;
import com.cloud.agent.api.AgentControlCommand;
import com.cloud.agent.api.Answer;
@ -72,7 +72,6 @@ import com.cloud.agent.api.to.PortForwardingRuleTO;
import com.cloud.agent.api.to.StaticNatRuleTO;
import com.cloud.agent.manager.Commands;
import com.cloud.alert.AlertManager;
import com.cloud.api.commands.StartRouterCmd;
import com.cloud.api.commands.UpgradeRouterCmd;
import com.cloud.async.AsyncJobManager;
import com.cloud.capacity.dao.CapacityDao;
@ -107,7 +106,6 @@ import com.cloud.exception.InsufficientServerCapacityException;
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.host.HostVO;
@ -368,6 +366,9 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
if (router == null) {
return null;
}
_accountMgr.checkAccess(context.getCaller(), null, router);
boolean result = _itMgr.expunge(router, user, _accountMgr.getAccount(router.getAccountId()));
if (result) {
@ -381,16 +382,14 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
public VirtualRouter upgradeRouter(UpgradeRouterCmd cmd) {
Long routerId = cmd.getId();
Long serviceOfferingId = cmd.getServiceOfferingId();
Account account = UserContext.current().getCaller();
Account caller = UserContext.current().getCaller();
DomainRouterVO router = _routerDao.findById(routerId);
if (router == null) {
throw new InvalidParameterValueException("Unable to find router with id " + routerId);
}
if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), router.getDomainId())) {
throw new PermissionDeniedException("Invalid domain router id (" + routerId + ") given, unable to stop router.");
}
_accountMgr.checkAccess(caller, null, router);
if (router.getServiceOfferingId() == serviceOfferingId) {
s_logger.debug("Router: " + routerId + "already has service offering: " + serviceOfferingId);
@ -561,9 +560,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
throw new InvalidParameterValueException("Unable to find domain router with id " + routerId + ".");
}
if ((caller != null) && !_domainDao.isChildDomain(caller.getDomainId(), router.getDomainId())) {
throw new PermissionDeniedException("Unable to reboot domain router with id " + routerId + ". Permission denied");
}
_accountMgr.checkAccess(caller, null, router);
// Can reboot domain router only in Running state
if (router == null || router.getState() != State.Running) {
@ -2051,21 +2048,21 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
}
@Override @ActionEvent(eventType = EventTypes.EVENT_ROUTER_START, eventDescription = "starting router Vm", async = true)
public VirtualRouter startRouter(StartRouterCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException{
return startRouter(cmd.getId(), true);
public VirtualRouter startRouter(long id) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException{
return startRouter(id, true);
}
@Override
public VirtualRouter startRouter(long routerId, boolean restartNetwork) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException {
Account account = UserContext.current().getCaller();
User caller = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
Account caller = UserContext.current().getCaller();
User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
// verify parameters
DomainRouterVO router = _routerDao.findById(routerId);
if (router == null) {
throw new InvalidParameterValueException("Unable to find router by id " + routerId + ".");
}
_accountMgr.checkAccess(account, null, router);
_accountMgr.checkAccess(caller, null, router);
Account owner = _accountMgr.getAccount(router.getAccountId());
@ -2077,7 +2074,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
}
DeployDestination dest = new DeployDestination(dc, pod, null, null);
ReservationContext context = new ReservationContextImpl(null, null, caller, owner);
ReservationContext context = new ReservationContextImpl(null, null, callerUser, owner);
List<NicVO> nics = _nicDao.listByVmId(routerId);
@ -2095,7 +2092,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
} else {
params.put(Param.RestartNetwork, false);
}
return startVirtualRouter(router, user, account, params);
return startVirtualRouter(router, user, caller, params);
}
private void createAssociateIPCommands(final VirtualRouter router, final List<? extends PublicIpAddress> ips, Commands cmds, long vmId) {

View File

@ -145,7 +145,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
}
if (rule.getAccountId() != userVm.getAccountId()) {
throw new InvalidParameterValueException("Rule id=" + rule.getId() + " and vm id=" + userVm.getId() + " belong to different accounts");
throw new InvalidParameterValueException("New rule " + rule + " and vm id=" + userVm.getId() + " belong to different accounts");
}
}
@ -537,8 +537,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
Long id = cmd.getId();
String path = null;
Pair<String, Long> accountDomainPair = _accountMgr.finalizeAccountDomainForList(caller, cmd.getAccountName(), cmd.getDomainId());
String accountName = accountDomainPair.first();
Pair<List<Long>, Long> accountDomainPair = _accountMgr.finalizeAccountDomainForList(caller, cmd.getAccountName(), cmd.getDomainId(), cmd.getProjectId());
List<Long> permittedAccounts = accountDomainPair.first();
Long domainId = accountDomainPair.second();
if (ipId != null) {
@ -558,7 +558,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
SearchBuilder<PortForwardingRuleVO> sb = _forwardingDao.createSearchBuilder();
sb.and("id", sb.entity().getId(), Op.EQ);
sb.and("ip", sb.entity().getSourceIpAddressId(), Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), Op.IN);
sb.and("domainId", sb.entity().getDomainId(), Op.EQ);
sb.and("purpose", sb.entity().getPurpose(), Op.EQ);
@ -581,10 +581,10 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
if (domainId != null) {
sc.setParameters("domainId", domainId);
if (accountName != null) {
Account account = _accountMgr.getActiveAccountByName(accountName, domainId);
sc.setParameters("accountId", account.getId());
}
}
if (!permittedAccounts.isEmpty()) {
sc.setParameters("accountId", permittedAccounts.toArray());
}
sc.setParameters("purpose", Purpose.PortForwarding);
@ -763,12 +763,12 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
}
@Override
public List<? extends FirewallRule> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId) {
public List<? extends FirewallRule> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId, Long projectId) {
Account caller = UserContext.current().getCaller();
String path = null;
Pair<String, Long> accountDomainPair = _accountMgr.finalizeAccountDomainForList(caller, accountName, domainId);
accountName = accountDomainPair.first();
Pair<List<Long>, Long> accountDomainPair = _accountMgr.finalizeAccountDomainForList(caller, accountName, domainId, projectId);
List<Long> permittedAccounts = accountDomainPair.first();
domainId = accountDomainPair.second();
if (ipId != null) {
@ -787,7 +787,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
Filter filter = new Filter(PortForwardingRuleVO.class, "id", false, start, size);
SearchBuilder<FirewallRuleVO> sb = _firewallDao.createSearchBuilder();
sb.and("ip", sb.entity().getSourceIpAddressId(), Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), Op.IN);
sb.and("domainId", sb.entity().getDomainId(), Op.EQ);
sb.and("purpose", sb.entity().getPurpose(), Op.EQ);
sb.and("id", sb.entity().getId(), Op.EQ);
@ -817,10 +817,10 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
if (domainId != null) {
sc.setParameters("domainId", domainId);
if (accountName != null) {
Account account = _accountMgr.getActiveAccountByName(accountName, domainId);
sc.setParameters("accountId", account.getId());
}
}
if (!permittedAccounts.isEmpty()) {
sc.setParameters("accountId", permittedAccounts.toArray());
}
sc.setParameters("purpose", Purpose.StaticNat);

View File

@ -71,6 +71,8 @@ import com.cloud.network.security.dao.SecurityGroupRulesDao;
import com.cloud.network.security.dao.SecurityGroupVMMapDao;
import com.cloud.network.security.dao.SecurityGroupWorkDao;
import com.cloud.network.security.dao.VmRulesetLogDao;
import com.cloud.projects.Project;
import com.cloud.projects.ProjectManager;
import com.cloud.server.ManagementServer;
import com.cloud.user.Account;
import com.cloud.user.AccountManager;
@ -146,6 +148,8 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
AccountManager _accountMgr;
@Inject
DomainManager _domainMgr;
@Inject
ProjectManager _projectMgr;
ScheduledExecutorService _executorPool;
ScheduledExecutorService _cleanupExecutor;
@ -750,7 +754,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
public SecurityGroupVO createSecurityGroup(CreateSecurityGroupCmd cmd) throws PermissionDeniedException, InvalidParameterValueException {
String name = cmd.getSecurityGroupName();
Account caller = UserContext.current().getCaller();
Account owner = _accountMgr.finalizeOwner(caller, cmd.getAccountName(), cmd.getDomainId());
Account owner = _accountMgr.finalizeOwner(caller, cmd.getAccountName(), cmd.getDomainId(), cmd.getProjectId());
if (_securityGroupDao.isNameInUse(owner.getId(), owner.getDomainId(), cmd.getSecurityGroupName())) {
throw new InvalidParameterValueException("Unable to create security group, a group with name " + name + " already exisits.");
@ -1019,8 +1023,9 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
String accountName = cmd.getAccountName();
Long instanceId = cmd.getVirtualMachineId();
String securityGroup = cmd.getSecurityGroupName();
Long projectId = cmd.getProjectId();
Long id = cmd.getId();
Long accountId = null;
List<Long> permittedAccounts = new ArrayList<Long>();
if (instanceId != null) {
UserVmVO userVM = _userVMDao.findById(instanceId);
@ -1044,13 +1049,28 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
throw new InvalidParameterValueException("Unable to find account " + accountName + " in domain " + domainId);
}
_accountMgr.checkAccess(caller, null, account);
accountId = account.getId();
permittedAccounts.add(account.getId());
}
}
} else {
// regular user can see only his own security groups
accountId = caller.getId();
permittedAccounts.add(caller.getId());
}
//set project information
if (projectId != null) {
permittedAccounts.clear();
Project project = _projectMgr.getProject(projectId);
if (project == null) {
throw new InvalidParameterValueException("Unable to find project by id " + projectId);
}
if (!_projectMgr.canAccessProjectAccount(caller, project.getProjectAccountId())) {
throw new InvalidParameterValueException("Account " + caller + " can't access project id=" + projectId);
}
permittedAccounts.add(project.getProjectAccountId());
} else if (caller.getType() == Account.ACCOUNT_TYPE_NORMAL){
permittedAccounts.addAll(_projectMgr.listPermittedProjectAccounts(caller.getId()));
}
List<SecurityGroupRulesVO> securityRulesList = new ArrayList<SecurityGroupRulesVO>();
Filter searchFilter = new Filter(SecurityGroupVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
@ -1058,12 +1078,12 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
SearchBuilder<SecurityGroupVO> sb = _securityGroupDao.createSearchBuilder();
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.IN);
sb.and("name", sb.entity().getName(), SearchCriteria.Op.EQ);
sb.and("domainId", sb.entity().getDomainId(), SearchCriteria.Op.EQ);
// only do a recursive domain search if the search is not limited by account or instance
if ((accountId == null) && (instanceId == null) && (caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
if (permittedAccounts.isEmpty() && instanceId == null && caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
SearchBuilder<DomainVO> domainSearch = _domainDao.createSearchBuilder();
domainSearch.and("path", domainSearch.entity().getPath(), SearchCriteria.Op.LIKE);
sb.join("domainSearch", domainSearch, sb.entity().getDomainId(), domainSearch.entity().getId(), JoinBuilder.JoinType.INNER);
@ -1079,12 +1099,12 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
sc.setParameters("name", securityGroup);
}
if (accountId != null) {
sc.setParameters("accountId", accountId);
if (!permittedAccounts.isEmpty()) {
sc.setParameters("accountId", permittedAccounts.toArray());
}
// only do a recursive domain search if the search is not limited by account or instance
if ((accountId == null) && (instanceId == null) && (caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
if (permittedAccounts.isEmpty() && instanceId == null && caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
DomainVO domain = _domainDao.findById(caller.getDomainId());
sc.setJoinParameters("domainSearch", "path", domain.getPath() + "%");
}

View File

@ -262,7 +262,6 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
}
if (success) {
try {
txn.start();
_remoteAccessVpnDao.remove(ipId);
@ -278,7 +277,6 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
s_logger.warn("Unable to release the three vpn ports from the firewall rules", ex);
}
}
}
}
}
@ -456,8 +454,8 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
String path = null;
//Verify account information
Pair<String, Long> accountDomainPair = _accountMgr.finalizeAccountDomainForList(caller, cmd.getAccountName(), cmd.getDomainId());
String accountName = accountDomainPair.first();
Pair<List<Long>, Long> accountDomainPair = _accountMgr.finalizeAccountDomainForList(caller, cmd.getAccountName(), cmd.getDomainId(), null);
List<Long> permittedAccounts = accountDomainPair.first();
Long domainId = accountDomainPair.second();
@ -473,7 +471,7 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
SearchBuilder<VpnUserVO> sb = _vpnUsersDao.createSearchBuilder();
sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
sb.and("username", sb.entity().getUsername(), SearchCriteria.Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.IN);
sb.and("domainId", sb.entity().getDomainId(), SearchCriteria.Op.EQ);
sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ);
@ -499,10 +497,10 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
if (domainId != null) {
sc.setParameters("domainId", domainId);
if (accountName != null) {
Account account = _accountMgr.getActiveAccountByName(accountName, domainId);
sc.setParameters("accountId", account.getId());
}
}
if (!permittedAccounts.isEmpty()) {
sc.setParameters("accountId", permittedAccounts.toArray());
}
if (path != null) {
@ -518,8 +516,8 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
Account caller = UserContext.current().getCaller();
String path = null;
Pair<String, Long> accountDomainPair = _accountMgr.finalizeAccountDomainForList(caller, cmd.getAccountName(), cmd.getDomainId());
String accountName = accountDomainPair.first();
Pair<List<Long>, Long> accountDomainPair = _accountMgr.finalizeAccountDomainForList(caller, cmd.getAccountName(), cmd.getDomainId(), cmd.getProjectId());
List<Long> permittedAccounts = accountDomainPair.first();
Long domainId = accountDomainPair.second();
if (caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
@ -546,7 +544,7 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
Filter filter = new Filter(RemoteAccessVpnVO.class, "serverAddressId", false, cmd.getStartIndex(), cmd.getPageSizeVal());
SearchBuilder<RemoteAccessVpnVO> sb = _remoteAccessVpnDao.createSearchBuilder();
sb.and("serverAddressId", sb.entity().getServerAddressId(), Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), Op.EQ);
sb.and("accountId", sb.entity().getAccountId(), Op.IN);
sb.and("domainId", sb.entity().getDomainId(), Op.EQ);
sb.and("state", sb.entity().getState(), Op.EQ);
@ -567,10 +565,10 @@ public class RemoteAccessVpnManagerImpl implements RemoteAccessVpnService, Manag
if (domainId != null) {
sc.setParameters("domainId", domainId);
if (accountName != null) {
Account account = _accountMgr.getActiveAccountByName(accountName, domainId);
sc.setParameters("accountId", account.getId());
}
}
if (!permittedAccounts.isEmpty()) {
sc.setParameters("accountId", permittedAccounts.toArray());
}
if (path != null) {

View File

@ -51,9 +51,6 @@ public class ProjectAccountVO implements ProjectAccount{
@Column(name="project_account_id")
long projectAccountId;
@Column(name="project_domain_id")
long projectDomainId;
@Column(name=GenericDao.CREATED_COLUMN)
private Date created;
@ -66,7 +63,6 @@ public class ProjectAccountVO implements ProjectAccount{
this.accountRole = accountRole;
this.projectId = project.getId();
this.projectAccountId = project.getProjectAccountId();
this.projectDomainId = project.getProjectDomainId();
}
public long getId() {
@ -93,11 +89,6 @@ public class ProjectAccountVO implements ProjectAccount{
return projectAccountId;
}
@Override
public long getProjectDomainId() {
return projectDomainId;
}
public void setAccountRole(Role accountRole) {
this.accountRole = accountRole;
}

View File

@ -5,14 +5,10 @@ import java.util.List;
import com.cloud.user.Account;
public interface ProjectManager extends ProjectService {
boolean canAccessAccount(Account caller, long accountId);
boolean canAccessDomain(Account caller, long domainId);
boolean canAccessProjectAccount(Account caller, long accountId);
boolean canModifyProjectAccount(Account caller, long accountId);
boolean canModifyProjectDomain(Account caller, long domainId);
boolean deleteAccountFromProject(long projectId, long accountId);
List<Long> listPermittedProjectAccounts(long accountId);

View File

@ -130,7 +130,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
}
if (accountName != null) {
owner = _accountMgr.finalizeOwner(caller, accountName, domainId);
owner = _accountMgr.finalizeOwner(caller, accountName, domainId, null);
}
//don't allow 2 projects with the same name inside the same domain
@ -144,19 +144,13 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
Transaction txn = Transaction.currentTxn();
txn.start();
//Create a domain associated with the project
StringBuilder dmnNm = new StringBuilder("PrjDmn-");
dmnNm.append(name).append("-").append(owner.getDomainId());
Domain projectDomain = _domainMgr.createDomain(dmnNm.toString(), Domain.ROOT_DOMAIN, Account.ACCOUNT_ID_SYSTEM, null, Domain.Type.Project);
//Create an account associated with the project
StringBuilder acctNm = new StringBuilder("PrjAcct-");
acctNm.append(name).append("-").append(owner.getDomainId());
Account projectAccount = _accountMgr.createAccount(acctNm.toString(), Account.ACCOUNT_TYPE_PROJECT, projectDomain.getId(), null);
Account projectAccount = _accountMgr.createAccount(acctNm.toString(), Account.ACCOUNT_TYPE_PROJECT, domainId, null);
Project project = _projectDao.persist(new ProjectVO(name, displayText, owner.getDomainId(), projectAccount.getId(), projectDomain.getId()));
Project project = _projectDao.persist(new ProjectVO(name, displayText, owner.getDomainId(), projectAccount.getId()));
//assign owner to the project
assignAccountToProject(project, owner.getId(), ProjectAccount.Role.Owner);
@ -197,7 +191,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
txn.commit();
if (updateResult) {
if (!cleanupProject(project)) {
if (!cleanupProject(project, null, null)) {
s_logger.warn("Failed to cleanup project's id=" + projectId + " resources, not removing the project yet");
return false;
} else {
@ -209,7 +203,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
}
}
private boolean cleanupProject(Project project) {
private boolean cleanupProject(Project project, AccountVO caller, Long callerUserId) {
boolean result=true;
//Unassign all users from the project
@ -223,9 +217,11 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
s_logger.debug("Accounts are unassign successfully from project " + project + " as a part of project cleanup...");
}
//Delete project's domain
s_logger.debug("Deleting projects " + project + " internal domain id=" + project.getProjectDomainId() + " as a part of project cleanup...");
result = result && _domainMgr.deleteDomain(_domainDao.findById(project.getProjectDomainId()), true);
//Delete project's account
AccountVO account = _accountDao.findById(project.getProjectAccountId());
s_logger.debug("Deleting projects " + project + " internal account id=" + account.getId() + " as a part of project cleanup...");
result = result && _accountMgr.deleteAccount(account, callerUserId, caller);
return result;
}
@ -350,11 +346,6 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
return _accountMgr.getAccount(accountId);
}
@Override
public ProjectVO findByProjectDomainId(long projectDomainId) {
return _projectDao.findByProjectDomainId(projectDomainId);
}
@Override
public ProjectVO findByProjectAccountId(long projectAccountId) {
return _projectDao.findByProjectAccountId(projectAccountId);
@ -366,24 +357,31 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
}
@Override
public boolean canAccessAccount(Account caller, long accountId) {
return _projectAccountDao.canAccessAccount(caller.getId(), accountId);
}
@Override
public boolean canAccessDomain(Account caller, long domainId) {
return _projectAccountDao.canAccessDomain(caller.getId(), domainId);
public boolean canAccessProjectAccount(Account caller, long accountId) {
//ROOT admin always can access the project
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN) {
return true;
} else if (caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
Account owner = _accountMgr.getAccount(accountId);
_accountMgr.checkAccess(caller, _domainDao.findById(owner.getDomainId()), null);
return true;
}
return _projectAccountDao.canAccessProjectAccount(caller.getId(), accountId);
}
public boolean canModifyProjectAccount(Account caller, long accountId) {
//ROOT admin always can access the project
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN) {
return true;
} else if (caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN) {
Account owner = _accountMgr.getAccount(accountId);
_accountMgr.checkAccess(caller, _domainDao.findById(owner.getDomainId()), null);
return true;
}
return _projectAccountDao.canModifyProjectAccount(caller.getId(), accountId);
}
@Override
public boolean canModifyProjectDomain(Account caller, long domainId) {
return _projectAccountDao.canModifyProjectDomain(caller.getId(), domainId);
}
@Override @DB
@ActionEvent(eventType = EventTypes.EVENT_PROJECT_UPDATE, eventDescription = "updating project")
public Project updateProject(long projectId, String displayText, String newOwnerName) {
@ -397,7 +395,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
}
//verify permissions
_accountMgr.checkAccess(caller, _domainDao.findById(project.getProjectDomainId()), AccessType.ModifyProject);
_accountMgr.checkAccess(caller, _domainDao.findById(project.getDomainId()), AccessType.ModifyProject);
Transaction txn = Transaction.currentTxn();
txn.start();
@ -457,7 +455,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
}
//verify permissions
_accountMgr.checkAccess(caller, _domainDao.findById(project.getProjectDomainId()), AccessType.ModifyProject);
_accountMgr.checkAccess(caller, _domainDao.findById(project.getDomainId()), AccessType.ModifyProject);
//Check if the account already added to the project
ProjectAccount projectAccount = _projectAccountDao.findByProjectIdAccountId(projectId, account.getId());
@ -504,7 +502,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
}
//verify permissions
_accountMgr.checkAccess(caller, _domainDao.findById(project.getProjectDomainId()), AccessType.ModifyProject);
_accountMgr.checkAccess(caller, _domainDao.findById(project.getDomainId()), AccessType.ModifyProject);
//Check if the account exists in the project
ProjectAccount projectAccount = _projectAccountDao.findByProjectIdAccountId(projectId, account.getId());
@ -533,7 +531,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
}
//verify permissions
_accountMgr.checkAccess(caller, _domainDao.findById(project.getProjectDomainId()), null);
_accountMgr.checkAccess(caller, _domainDao.findById(project.getDomainId()), null);
Filter searchFilter = new Filter(ProjectAccountVO.class, "id", false, startIndex, pageSizeVal);
SearchBuilder<ProjectAccountVO> sb = _projectAccountDao.createSearchBuilder();
@ -678,7 +676,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
}
//verify permissions
_accountMgr.checkAccess(caller, _domainDao.findById(project.getProjectDomainId()), AccessType.ModifyProject);
_accountMgr.checkAccess(caller, _domainDao.findById(project.getDomainId()), AccessType.ModifyProject);
accountId = account.getId();
} else {
accountId = caller.getId();

View File

@ -50,9 +50,6 @@ public class ProjectVO implements Project{
@Column(name="project_account_id")
long projectAccountId;
@Column(name="project_domain_id")
long projectDomainId;
@Column(name=GenericDao.CREATED_COLUMN)
private Date created;
@ -66,12 +63,11 @@ public class ProjectVO implements Project{
protected ProjectVO(){
}
public ProjectVO(String name, String displayText, long domainId, long projectAccountId, long projectDomainId) {
public ProjectVO(String name, String displayText, long domainId, long projectAccountId) {
this.name = name;
this.displayText = displayText;
this.projectAccountId = projectAccountId;
this.domainId = domainId;
this.projectDomainId = projectDomainId;
this.state = State.Inactive;
}
@ -135,11 +131,6 @@ public class ProjectVO implements Project{
return projectAccountId;
}
@Override
public long getProjectDomainId() {
return projectDomainId;
}
public void setName(String name) {
this.name = name;
}

View File

@ -27,12 +27,9 @@ public interface ProjectAccountDao extends GenericDao<ProjectAccountVO, Long>{
List<ProjectAccountVO> listByProjectId(long projectId);
ProjectAccountVO findByProjectIdAccountId(long projectId, long accountId);
boolean canAccessAccount(long accountId, long projectAccountId);
boolean canAccessDomain(long accountId, long projectDomainId);
boolean canAccessProjectAccount(long accountId, long projectAccountId);
boolean canModifyProjectAccount(long accountId, long projectAccountId);
boolean canModifyProjectDomain(long accountId, long projectDomainId);
List<Long> listPermittedAccountIds(long accountId);
}

View File

@ -41,7 +41,6 @@ public class ProjectAccountDaoImpl extends GenericDaoBase<ProjectAccountVO, Long
AllFieldsSearch.and("projectId", AllFieldsSearch.entity().getProjectId(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("accountId", AllFieldsSearch.entity().getAccountId(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("projectAccountId", AllFieldsSearch.entity().getProjectAccountId(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("projectDomainId", AllFieldsSearch.entity().getProjectDomainId(), SearchCriteria.Op.EQ);
AllFieldsSearch.done();
}
@ -72,7 +71,7 @@ public class ProjectAccountDaoImpl extends GenericDaoBase<ProjectAccountVO, Long
}
@Override
public boolean canAccessAccount(long accountId, long projectAccountId) {
public boolean canAccessProjectAccount(long accountId, long projectAccountId) {
SearchCriteria<ProjectAccountVO> sc = AllFieldsSearch.create();
sc.setParameters("accountId", accountId);
sc.setParameters("projectAccountId", projectAccountId);
@ -83,19 +82,6 @@ public class ProjectAccountDaoImpl extends GenericDaoBase<ProjectAccountVO, Long
return false;
}
}
@Override
public boolean canAccessDomain(long accountId, long projectDomainId) {
SearchCriteria<ProjectAccountVO> sc = AllFieldsSearch.create();
sc.setParameters("accountId", accountId);
sc.setParameters("projectDomainId", projectDomainId);
if (findOneBy(sc) != null) {
return true;
} else {
return false;
}
}
@Override
public boolean canModifyProjectAccount(long accountId, long projectAccountId) {
@ -111,20 +97,6 @@ public class ProjectAccountDaoImpl extends GenericDaoBase<ProjectAccountVO, Long
}
}
@Override
public boolean canModifyProjectDomain(long accountId, long projectDomainId) {
SearchCriteria<ProjectAccountVO> sc = AllFieldsSearch.create();
sc.setParameters("accountId", accountId);
sc.setParameters("projectDomainId", projectDomainId);
sc.setParameters("role", ProjectAccount.Role.Owner);
if (findOneBy(sc) != null) {
return true;
} else {
return false;
}
}
@Override
public List<Long> listPermittedAccountIds(long accountId) {
List<Long> permittedAccounts = new ArrayList<Long>();

View File

@ -26,8 +26,6 @@ public interface ProjectDao extends GenericDao<ProjectVO, Long>{
Long countProjectsForDomain(long domainId);
ProjectVO findByProjectDomainId(long projectDomainId);
ProjectVO findByProjectAccountId(long projectAccountId);
}

View File

@ -23,7 +23,6 @@ public class ProjectDaoImpl extends GenericDaoBase<ProjectVO, Long> implements P
AllFieldsSearch = createSearchBuilder();
AllFieldsSearch.and("name", AllFieldsSearch.entity().getName(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("domainId", AllFieldsSearch.entity().getDomainId(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("projectDomainId", AllFieldsSearch.entity().getProjectDomainId(), SearchCriteria.Op.EQ);
AllFieldsSearch.and("projectAccountId", AllFieldsSearch.entity().getProjectAccountId(), SearchCriteria.Op.EQ);
AllFieldsSearch.done();
@ -69,14 +68,6 @@ public class ProjectDaoImpl extends GenericDaoBase<ProjectVO, Long> implements P
return customSearch(sc, null).get(0);
}
@Override
public ProjectVO findByProjectDomainId(long projectDomainId) {
SearchCriteria<ProjectVO> sc = AllFieldsSearch.create();
sc.setParameters("projectDomainId", projectDomainId);
return findOneBy(sc);
}
@Override
public ProjectVO findByProjectAccountId(long projectAccountId) {
SearchCriteria<ProjectVO> sc = AllFieldsSearch.create();

View File

@ -29,7 +29,6 @@ import org.apache.log4j.Logger;
import com.cloud.acl.SecurityChecker.AccessType;
import com.cloud.alert.AlertManager;
import com.cloud.api.commands.UpdateResourceCountCmd;
import com.cloud.configuration.Config;
import com.cloud.configuration.Resource;
import com.cloud.configuration.Resource.ResourceOwnerType;
@ -493,12 +492,8 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager{
ownerId = accountId;
} else if (domainId != null) {
Domain domain = _entityMgr.findById(Domain.class, domainId);
if (domain.getType() == Domain.Type.Project) {
_accountMgr.checkAccess(caller, domain, AccessType.ModifyProject);
} else {
_accountMgr.checkAccess(caller, domain, null);
}
_accountMgr.checkAccess(caller, domain, null);
if ((caller.getDomainId() == domainId.longValue()) && caller.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN || caller.getType() == Account.ACCOUNT_TYPE_RESOURCE_DOMAIN_ADMIN) {
// if the admin is trying to update their own domain, disallow...
@ -532,17 +527,13 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager{
}
@Override
public List<ResourceCountVO> recalculateResourceCount(UpdateResourceCountCmd cmd) throws InvalidParameterValueException, CloudRuntimeException, PermissionDeniedException{
public List<ResourceCountVO> recalculateResourceCount(Long accountId, Long domainId, Integer typeId) throws InvalidParameterValueException, CloudRuntimeException, PermissionDeniedException{
Account callerAccount = UserContext.current().getCaller();
String accountName = cmd.getAccountName();
Long domainId = cmd.getDomainId();
Long accountId = null;
long count=0;
List<ResourceCountVO> counts = new ArrayList<ResourceCountVO>();
List<ResourceType> resourceTypes = new ArrayList<ResourceType>();
ResourceType resourceType = null;
Integer typeId = cmd.getResourceType();
if (typeId != null) {
for (ResourceType type : resourceTypes) {
@ -560,15 +551,6 @@ public class ResourceLimitManagerImpl implements ResourceLimitService, Manager{
throw new InvalidParameterValueException("Please specify a valid domain ID.");
}
_accountMgr.checkAccess(callerAccount, domain, null);
if (accountName != null) {
Account userAccount = _accountMgr.getActiveAccountByName(accountName, domainId);
if (userAccount == null) {
throw new InvalidParameterValueException("unable to find account by name " + accountName + " in domain with id " + domainId);
}
accountId = userAccount.getId();
}
if (resourceType != null) {
resourceTypes.add(resourceType);

Some files were not shown because too many files have changed in this diff Show More