mirror of https://github.com/apache/cloudstack.git
Bug 13127: API error text refer to database ids instead of uuids
Bug CS-14448: Wrong error message on using the createVlanIpRange cmd Cherry-picking from master for bug 14448 into 3.0.x. Resolved conflicts encountered during cherry-picking. Description: Adding overloaded addProxyObject() function to CloudException and RuntimeCloudException classes and using this function to stuff exceptions with IDs, to reduce code footprint. Conflicts: server/src/com/cloud/network/NetworkManagerImpl.java server/src/com/cloud/resource/ResourceManagerImpl.java
This commit is contained in:
parent
7860b78049
commit
e03ed60540
|
|
@ -504,24 +504,12 @@ public abstract class BaseCmd {
|
|||
return project.getProjectAccountId();
|
||||
} else {
|
||||
PermissionDeniedException ex = new PermissionDeniedException("Can't add resources to the project with specified projectId in state=" + project.getState() + " as it's no longer active");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(project);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, projectId, "projectId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
} else {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project with specified projectId");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(project);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, projectId, "projectId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,14 +98,7 @@ public class AddAccountToProjectCmd extends BaseAsyncCmd {
|
|||
//verify input parameters
|
||||
if (project == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project with specified id");
|
||||
// getProject() returns an object of type ProjectVO.
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(project);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, projectId, "projectId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -106,7 +106,9 @@ public class CreateSnapshotPolicyCmd extends BaseCmd {
|
|||
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
||||
Project project = _projectService.findByProjectAccountId(volume.getAccountId());
|
||||
if (project.getState() != Project.State.Active) {
|
||||
throw new PermissionDeniedException("Can't add resources to the project id=" + project.getId() + " in state=" + project.getState() + " as it's no longer active");
|
||||
PermissionDeniedException ex = new PermissionDeniedException("Can't add resources to the specified project id in state=" + project.getState() + " as it's no longer active");
|
||||
ex.addProxyObject(project, project.getId(), "projectId");
|
||||
throw ex;
|
||||
}
|
||||
} else if (account.getState() == Account.State.disabled) {
|
||||
throw new PermissionDeniedException("The owner of template is disabled: " + account);
|
||||
|
|
|
|||
|
|
@ -204,7 +204,8 @@ import com.cloud.user.UserContext;
|
|||
if (account.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
||||
Project project = _projectService.findByProjectAccountId(accountId);
|
||||
if (project.getState() != Project.State.Active) {
|
||||
throw new PermissionDeniedException("Can't add resources to the project id=" + project.getId() + " in state=" + project.getState() + " as it's no longer active");
|
||||
PermissionDeniedException ex = new PermissionDeniedException("Can't add resources to the specified project id in state=" + project.getState() + " as it's no longer active");
|
||||
ex.addProxyObject(project, project.getId(), "projectId");
|
||||
}
|
||||
} else if (account.getState() == Account.State.disabled) {
|
||||
throw new PermissionDeniedException("The owner of template is disabled: " + account);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package com.cloud.exception;
|
|||
import com.cloud.utils.IdentityProxy;
|
||||
import java.util.ArrayList;
|
||||
import com.cloud.utils.exception.CSExceptionErrorCode;
|
||||
import com.cloud.utils.AnnotationHelper;
|
||||
|
||||
/**
|
||||
* CloudException is a generic exception class that has an IdentityProxy
|
||||
|
|
@ -49,6 +50,15 @@ public class CloudException extends Exception {
|
|||
setCSErrorCode(CSExceptionErrorCode.getCSErrCode(this.getClass().getName()));
|
||||
}
|
||||
|
||||
public void addProxyObject(Object voObj, Long id, String idFieldName) {
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(voObj);
|
||||
if (tablename != null) {
|
||||
addProxyObject(tablename, id, idFieldName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public CloudException() {
|
||||
super();
|
||||
setCSErrorCode(CSExceptionErrorCode.getCSErrCode(this.getClass().getName()));
|
||||
|
|
|
|||
|
|
@ -491,7 +491,9 @@ public class ClusteredAgentManagerImpl extends AgentManagerImpl implements Clust
|
|||
}
|
||||
}
|
||||
if (agent == null) {
|
||||
throw new AgentUnavailableException("Host is not in the right state: " + host.getStatus() , hostId);
|
||||
AgentUnavailableException ex = new AgentUnavailableException("Host with specified id is not in the right state: " + host.getStatus(), hostId);
|
||||
ex.addProxyObject(host, hostId, "hostId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
return agent;
|
||||
|
|
|
|||
|
|
@ -60,7 +60,9 @@ public class BareMetalPingServiceImpl extends BareMetalPxeServiceBase implements
|
|||
|
||||
List<HostVO> pxeServers = _resourceMgr.listAllUpAndEnabledHosts(Host.Type.PxeServer, null, podId, zoneId);
|
||||
if (pxeServers.size() != 0) {
|
||||
throw new InvalidParameterValueException("Already had a PXE server in Pod: " + podId + " zone: " + zoneId);
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Already had a PXE server in Pod with specified podId and zone with specified zoneId");
|
||||
ex.addProxyObject("pod", podId, "podId");
|
||||
ex.addProxyObject(zone, zoneId, "zoneId");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -163,7 +163,9 @@ public class BareMetalVmManagerImpl extends UserVmManagerImpl implements BareMet
|
|||
}
|
||||
|
||||
if (pxes.size() > 1) {
|
||||
throw new CloudRuntimeException("Multiple PXE servers found in Pod " + host.getPodId() + " Zone " + host.getDataCenterId());
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Multiple PXE servers found in Pod " + host.getPodId() + " in Zone with specified id");
|
||||
ex.addProxyObject("data_center", host.getDataCenterId(), "zoneId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
HostVO pxe = pxes.get(0);
|
||||
|
|
|
|||
|
|
@ -1034,13 +1034,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) {
|
||||
// zone is of type DataCenter. See DataCenterVO.java.
|
||||
PermissionDeniedException ex = new PermissionDeniedException("Cannot perform this operation, zone with specified id is currently disabled");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(zone);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, zone.getId(), "zoneId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(zone, zone.getId(), "zoneId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -1651,19 +1645,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
|
||||
if (errorIfAlreadySetup) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Found existing network configuration (with specified id) for offering (with specified id)");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(offering);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, offering.getId(), "offeringId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
tablename = AnnotationHelper.getTableName(configs.get(0));
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, configs.get(0).getId(), "networkConfigId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(offering, offering.getId(), "offeringId");
|
||||
ex.addProxyObject(configs.get(0), configs.get(0).getId(), "networkConfigId");
|
||||
throw ex;
|
||||
} else {
|
||||
return configs;
|
||||
|
|
@ -1679,19 +1662,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
|
||||
if (errorIfAlreadySetup) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Found existing network configuration (with specified id) for offering (with specified id)");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(offering);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, offering.getId(), "offeringId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
tablename = AnnotationHelper.getTableName(configs.get(0));
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, configs.get(0).getId(), "networkConfigId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(offering, offering.getId(), "offeringId");
|
||||
ex.addProxyObject(configs.get(0), configs.get(0).getId(), "networkConfigId");
|
||||
throw ex;
|
||||
} else {
|
||||
return configs;
|
||||
|
|
@ -1742,12 +1714,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (networks.size() < 1) {
|
||||
// see networkOfferingVO.java
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Unable to convert network offering with specified id to network profile");
|
||||
String tablename = AnnotationHelper.getTableName(offering);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, offering.getId(), "networkOfferingId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(offering, offering.getId(), "offeringId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -2093,12 +2060,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
if (!element.implement(network, offering, dest, context)) {
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Failed to implement provider " + element.getProvider().getName() + " for network with specified id");
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, network.getId(), "networkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(network, network.getId(), "networkId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
@ -2399,27 +2361,17 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
}
|
||||
|
||||
// Check for account wide pool. It will have an entry for account_vlan_map.
|
||||
if (_accountVlanMapDao.findAccountVlanMap(ipVO.getAllocatedToAccountId(), ipVO.getVlanId()) != null) {
|
||||
if (_accountVlanMapDao.findAccountVlanMap(ipVO.getAllocatedToAccountId(), ipVO.getVlanId()) != null) {
|
||||
//see IPaddressVO.java
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Sepcified IP address uuid belongs to Account wide IP pool and cannot be disassociated");
|
||||
String tablename = AnnotationHelper.getTableName(ipVO);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, ipVO.getId(), "systemIpAddrId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(ipVO, ipVO.getId(), "systemIpAddrId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
// don't allow releasing system ip address
|
||||
if (ipVO.getSystem()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Can't release system IP address with specified id");
|
||||
String tablename = AnnotationHelper.getTableName(ipVO);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, ipVO.getId(), "systemIpAddrId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(ipVO, ipVO.getId(), "systemIpAddrId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -2603,13 +2555,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (ntwkOff == null || ntwkOff.isSystemOnly()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find network offering by specified id");
|
||||
if (ntwkOff != null) {
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(ntwkOff);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, networkOfferingId, "networkOfferingId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(ntwkOff, networkOfferingId, "networkOfferingId");
|
||||
throw ex;
|
||||
}
|
||||
throw ex;
|
||||
|
|
@ -2636,13 +2582,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) {
|
||||
// See DataCenterVO.java
|
||||
PermissionDeniedException ex = new PermissionDeniedException("Cannot perform this operation since specified Zone is currently disabled");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(zone);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, zoneId, "zoneId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(zone, zoneId, "zoneId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -2801,12 +2741,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
// Can add vlan range only to the network which allows it
|
||||
if (createVlan && !ntwkOff.getSpecifyIpRanges()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Network offering with specified id doesn't support adding multiple ip ranges");
|
||||
String tablename = AnnotationHelper.getTableName(ntwkOff);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, ntwkOff.getId(), "networkOfferingId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(ntwkOff, ntwkOff.getId(), "networkOfferingId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -2894,13 +2829,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (ntwkOff.getState() != NetworkOffering.State.Enabled) {
|
||||
// see NetworkOfferingVO
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Can't use specified network offering id as its stat is not " + NetworkOffering.State.Enabled);
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(networkOfferingId);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, networkOfferingId, "networkOfferingId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(ntwkOff, ntwkOff.getId(), "networkOfferingId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -3189,13 +3118,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (!_projectMgr.canAccessProjectAccount(caller, project.getProjectAccountId())) {
|
||||
// getProject() returns type ProjectVO.
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Account " + caller + " cannot access specified project id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(project);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, projectId, "projectId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
permittedAccounts.add(project.getProjectAccountId());
|
||||
|
|
@ -3434,24 +3357,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
// see NetworkVO.java
|
||||
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find network with specified id");
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, networkId, "networkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(network, networkId, "networkId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
// don't allow to delete system network
|
||||
if (isNetworkSystem(network)) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Network with specified id is system and can't be removed");
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, network.getId(), "networkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(network, network.getId(), "networkId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -3905,12 +3818,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
NetworkVO network = _networksDao.findById(networkId);
|
||||
if (network == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Network with specified id doesn't exist");
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, networkId, "networkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(network, networkId, "networkId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -4649,26 +4557,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId);
|
||||
if (networkOffering == null || networkOffering.isSystemOnly()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find network offering with specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(networkOffering);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, networkOfferingId, "networkOfferingId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(networkOffering, networkOfferingId, "networkOfferingId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
// network offering should be in Enabled state
|
||||
if (networkOffering.getState() != NetworkOffering.State.Enabled) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Network offering with specified id is not in " + NetworkOffering.State.Enabled + " state, can't upgrade to it");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(networkOffering);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, networkOfferingId, "networkOfferingId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(networkOffering, networkOfferingId, "networkOfferingId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -4680,13 +4576,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (changeCidr) {
|
||||
if (!checkForNonStoppedVmInNetwork(network.getId())) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("All user vm of network of specified id should be stopped before changing CIDR!");
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
// We could use network.getId() instead of networkId too.
|
||||
ex.addProxyObject(tablename, networkId, "networkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(network, networkId, "networkId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
@ -4741,13 +4631,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (!shutdownNetworkElementsAndResources(context, true, network)) {
|
||||
s_logger.warn("Failed to shutdown the network elements and resources as a part of network restart: " + network);
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Failed to shutdown the network elements and resources as a part of update to network of specified id");
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
// We could use network.getId() instead of networkId too.
|
||||
ex.addProxyObject(tablename, networkId, "networkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(network, networkId, "networkId");
|
||||
throw ex;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -4757,25 +4641,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
if (!shutdownNetwork(network.getId(), context, true)) {
|
||||
s_logger.warn("Failed to shutdown the network as a part of update to network with specified id");
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Failed to shutdown the network as a part of update of specified network id");
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
// We could use network.getId() instead of networkId too.
|
||||
ex.addProxyObject(tablename, networkId, "networkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(network, networkId, "networkId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Failed to shutdown the network elements and resources as a part of update to network with specified id; network is in wrong state: " + network.getState());
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
// We could use network.getId() instead of networkId too.
|
||||
ex.addProxyObject(tablename, networkId, "networkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(network, networkId, "networkId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
@ -4786,13 +4658,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
boolean validStateToImplement = (networkState == Network.State.Implemented || networkState == Network.State.Setup || networkState == Network.State.Allocated);
|
||||
if (restartNetwork && !validStateToImplement) {
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Failed to implement the network elements and resources as a part of update to network with specified id; network is in wrong state: " + networkState);
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
// We could use network.getId() instead of networkId too.
|
||||
ex.addProxyObject(tablename, networkId, "networkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(network, networkId, "networkId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -4842,13 +4708,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
} catch (Exception ex) {
|
||||
s_logger.warn("Failed to implement network " + network + " elements and resources as a part of network update due to ", ex);
|
||||
CloudRuntimeException e = new CloudRuntimeException("Failed to implement network (with specified id) elements and resources as a part of network update");
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
// We could use network.getId() instead of networkId too.
|
||||
e.addProxyObject(tablename, networkId, "networkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
e.addProxyObject(network, networkId, "networkId");
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
|
@ -5379,12 +5239,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
PhysicalNetworkVO network = _physicalNetworkDao.findById(id);
|
||||
if (network == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Physical Network with specified id doesn't exist in the system");
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, id, "physicalNetworkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(network, id, "physicalNetworkId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -5392,12 +5247,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
DataCenter zone = _dcDao.findById(network.getDataCenterId());
|
||||
if (zone == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Zone with id=" + network.getDataCenterId() + " doesn't exist in the system");
|
||||
String tablename = AnnotationHelper.getTableName(zone);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, network.getDataCenterId(), "dataCenterId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(zone, network.getDataCenterId(), "dataCenterId");
|
||||
throw ex;
|
||||
}
|
||||
if (newVnetRangeString != null) {
|
||||
|
|
@ -5531,12 +5381,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
PhysicalNetworkVO pNetwork = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
if (pNetwork == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Physical Network with specified id doesn't exist in the system");
|
||||
String tablename = AnnotationHelper.getTableName(pNetwork);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, physicalNetworkId, "physicalNetworkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(pNetwork, physicalNetworkId, "physicalNetworkId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -5723,12 +5568,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
PhysicalNetworkVO network = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
if (network == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Physical Network with specified id doesn't exist in the system");
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, physicalNetworkId, "physicalNetworkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(network, physicalNetworkId, "physicalNetworkId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -5737,12 +5577,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
PhysicalNetworkVO destNetwork = _physicalNetworkDao.findById(destinationPhysicalNetworkId);
|
||||
if (destNetwork == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Destination Physical Network with specified id doesn't exist in the system");
|
||||
String tablename = AnnotationHelper.getTableName(destNetwork);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, destinationPhysicalNetworkId, "destinationPhysicalNetworkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(destNetwork, destinationPhysicalNetworkId, "destinationPhysicalNetworkId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -411,13 +411,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
UserVm vm = _vmDao.findById(instanceId);
|
||||
if (vm == null || vm.getState() == State.Destroyed || vm.getState() == State.Expunging) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Invalid instance id specified");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, instanceId, "instanceId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, instanceId, "instanceId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -439,13 +433,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
|
||||
if (nicInSameNetwork == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("VM " + instanceId + " cannot be added because it doesn't belong in the same network.");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, instanceId, "instanceId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, instanceId, "instanceId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -491,13 +479,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
|
||||
if(!success){
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Failed to add specified loadbalancerruleid for vms " + instanceIds);
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(loadBalancer);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, loadBalancerId, "loadBalancerId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(loadBalancer, loadBalancerId, "loadBalancerId");
|
||||
// TBD: Also pack in the instanceIds in the exception using the right VO object or table name.
|
||||
throw ex;
|
||||
}
|
||||
|
|
@ -537,13 +519,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
if (!applyLoadBalancerConfig(loadBalancerId)) {
|
||||
s_logger.warn("Failed to remove load balancer rule id " + loadBalancerId + " for vms " + instanceIds);
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Failed to remove specified load balancer rule id for vms " + instanceIds);
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(loadBalancer);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, loadBalancerId, "loadBalancerId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(loadBalancer, loadBalancerId, "loadBalancerId");
|
||||
throw ex;
|
||||
}
|
||||
success = true;
|
||||
|
|
@ -565,13 +541,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
}
|
||||
if(!success){
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Failed to remove specified load balancer rule id for vms " + instanceIds);
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(loadBalancer);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, loadBalancerId, "loadBalancerId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(loadBalancer, loadBalancerId, "loadBalancerId");
|
||||
throw ex;
|
||||
}
|
||||
return success;
|
||||
|
|
@ -804,23 +774,11 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
// make sure ip address exists
|
||||
if (ipAddr == null || !ipAddr.readyToUse()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to create load balancer rule, invalid IP address id specified");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(ipAddr);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, sourceIpId, "sourceIpId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(ipAddr, sourceIpId, "sourceIpId");
|
||||
throw ex;
|
||||
} else if (ipAddr.isOneToOneNat()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to create load balancer rule; specified sourceip id has static nat enabled");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(ipAddr);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, sourceIpId, "sourceIpId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(ipAddr, sourceIpId, "sourceIpId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -830,13 +788,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
networkId = ipAddr.getAssociatedWithNetworkId();
|
||||
if (networkId == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to create load balancer rule ; specified sourceip id is not associated with any network");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(ipAddr);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, sourceIpId, "sourceIpId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(ipAddr, sourceIpId, "sourceIpId");
|
||||
throw ex;
|
||||
|
||||
}
|
||||
|
|
@ -847,15 +799,8 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
|
|||
// verify that lb service is supported by the network
|
||||
if (!_networkMgr.areServicesSupportedInNetwork(network.getId(), Service.Lb)) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("LB service is not supported in specified network id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, networkId, "networkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(network, networkId, "networkId");
|
||||
throw ex;
|
||||
|
||||
}
|
||||
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
|
|
|||
|
|
@ -1062,26 +1062,14 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
|
||||
if (ipAddress.getSystem()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Can't disable static nat for system IP address with specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(ipAddress);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, ipId, "ipId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(ipAddress, ipId, "ipId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
Long vmId = ipAddress.getAssociatedWithVmId();
|
||||
if (vmId == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Specified IP address id is not associated with any vm Id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(ipAddress);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, ipId, "ipId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(ipAddress, ipId, "ipId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -1107,13 +1095,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
|
||||
if (!ipAddress.isOneToOneNat()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("One to one nat is not enabled for the specified ip id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(ipAddress);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, ipId, "ipId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(ipAddress, ipId, "ipId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -1176,13 +1158,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
|
||||
if (ip == null || !ip.isOneToOneNat() || ip.getAssociatedWithVmId() == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Source ip address of the specified firewall rule id is not static nat enabled");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(ruleVO);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, rule.getId(), "ruleId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(ruleVO, rule.getId(), "ruleId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -1215,14 +1191,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
|||
UserVmVO vm = _vmDao.findById(sourceIp.getAssociatedWithVmId());
|
||||
Network network = _networkMgr.getNetwork(networkId);
|
||||
if (network == null) {
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Unable to find an ip address to map to specified vm id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vm.getId(), "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Unable to find an ip address to map to specified vm id");
|
||||
ex.addProxyObject(vm, vm.getId(), "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -586,27 +586,15 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
|||
Project project = getProject(projectId);
|
||||
|
||||
if (project == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project with specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(project);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, projectId, "projectId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project with specified id");
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
//User can be added to Active project only
|
||||
if (project.getState() != Project.State.Active) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Can't add account to the specified project id in state=" + project.getState() + " as it's no longer active");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(project);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, projectId, "projectId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -681,13 +669,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
|||
|
||||
if (project == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project with specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(project);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, projectId, "projectId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -706,26 +688,15 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
|||
ProjectAccount projectAccount = _projectAccountDao.findByProjectIdAccountId(projectId, account.getId());
|
||||
if (projectAccount == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Account " + accountName + " is not assigned to the project with specified id");
|
||||
// Use the projectVO object and nt the projectAccount object to inject the projectId.
|
||||
String tablename = AnnotationHelper.getTableName(project);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, projectId, "projectId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
// Use the projectVO object and not the projectAccount object to inject the projectId.
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
//can't remove the owner of the project
|
||||
if (projectAccount.getAccountRole() == Role.Admin) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to delete account " + accountName + " from the project with specified id as the account is the owner of the project");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(project);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, projectId, "projectId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -982,13 +953,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
|||
|
||||
if (project == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project with specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(project);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, projectId, "projectId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -1030,13 +995,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
|||
//verify input parameters
|
||||
if (project == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project with specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(project);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, projectId, "projectId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -1047,13 +1006,7 @@ public class ProjectManagerImpl implements ProjectManager, Manager{
|
|||
return _projectDao.findById(projectId);
|
||||
} else {
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Failed to suspend project with specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(project);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, projectId, "projectId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -344,26 +344,14 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
DataCenterVO zone = _dcDao.findById(dcId);
|
||||
if (zone == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Can't find zone by the id specified");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(zone);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, dcId, "dcId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(zone, dcId, "dcId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
Account account = UserContext.current().getCaller();
|
||||
if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(account.getType())) {
|
||||
PermissionDeniedException ex = new PermissionDeniedException("Cannot perform this operation, Zone with specified id is currently disabled");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(zone);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, dcId, "dcId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(zone, dcId, "dcId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -372,28 +360,14 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
throw new InvalidParameterValueException("Can't find pod with specified podId " + podId);
|
||||
}
|
||||
|
||||
// Check if the pod exists in the system
|
||||
// check if pod belongs to the zone
|
||||
if (!Long.valueOf(pod.getDataCenterId()).equals(dcId)) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Pod with specified id doesn't belong to the zone " + dcId);
|
||||
// Get the pod VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(pod);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, podId, "podId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
// Get the zone VO object's table name.
|
||||
tablename = AnnotationHelper.getTableName(zone);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, dcId, "dcId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(pod, podId, "podId");
|
||||
ex.addProxyObject(zone, dcId, "dcId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
||||
// Verify cluster information and create a new cluster if needed
|
||||
if (clusterName == null || clusterName.isEmpty()) {
|
||||
throw new InvalidParameterValueException("Please specify cluster name");
|
||||
|
|
@ -449,19 +423,8 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
// no longer tolerate exception during the cluster creation phase
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Unable to create cluster " + clusterName + " in pod and data center with specified ids", e);
|
||||
// Get the pod VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(pod);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, podId, "podId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
// Get the zone VO object's table name.
|
||||
tablename = AnnotationHelper.getTableName(zone);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, dcId, "dcId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(pod, podId, "podId");
|
||||
ex.addProxyObject(zone, dcId, "dcId");
|
||||
throw ex;
|
||||
}
|
||||
clusterId = cluster.getId();
|
||||
|
|
@ -651,26 +614,14 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
ClusterVO cluster = _clusterDao.findById(clusterId);
|
||||
if (cluster == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("can not find cluster for specified clusterId");
|
||||
// Get the cluster VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(cluster);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, clusterId, "clusterId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(cluster, clusterId, "clusterId");
|
||||
throw ex;
|
||||
} else {
|
||||
if (cluster.getGuid() == null) {
|
||||
List<HostVO> hosts = listAllHostsInCluster(clusterId);
|
||||
if (!hosts.isEmpty()) {
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Guid is not updated for cluster with specified cluster id; need to wait for hosts in this cluster to come up");
|
||||
// Get the cluster VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(cluster);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, clusterId, "clusterId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(cluster, clusterId, "clusterId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
@ -710,13 +661,7 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
Account account = UserContext.current().getCaller();
|
||||
if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(account.getType())) {
|
||||
PermissionDeniedException ex = new PermissionDeniedException("Cannot perform this operation, Zone with specified id is currently disabled");
|
||||
// Get the zone VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(zone);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, dcId, "dcId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(zone, dcId, "dcId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -729,19 +674,8 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
// check if pod belongs to the zone
|
||||
if (!Long.valueOf(pod.getDataCenterId()).equals(dcId)) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Pod with specified podId" + podId + " doesn't belong to the zone with specified zoneId" + dcId);
|
||||
// Get the pod VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(pod);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, podId, "podId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
tablename = AnnotationHelper.getTableName(zone);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, dcId, "dcId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(pod, podId, "podId");
|
||||
ex.addProxyObject(zone, dcId, "dcId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
@ -797,19 +731,8 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
|||
cluster = _clusterDao.findBy(clusterName, podId);
|
||||
if (cluster == null) {
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Unable to create cluster " + clusterName + " in pod with specified podId and data center with specified dcID", e);
|
||||
// Get the pod VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(pod);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, podId, "podId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
tablename = AnnotationHelper.getTableName(zone);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, dcId, "dcId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(pod, podId, "podId");
|
||||
ex.addProxyObject(zone, dcId, "dcId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -679,13 +679,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
UserVmVO vmInstance = _userVmDao.findById(vmId);
|
||||
if ((vmInstance == null) || (vmInstance.getRemoved() != null)) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a virtual machine with specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vmInstance);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vmInstance, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -757,13 +751,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
UserVmVO vmInstance = _userVmDao.findById(vmId);
|
||||
if ((vmInstance == null) || (vmInstance.getRemoved() != null)) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a virtual machine with id " + vmId);
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vmInstance);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vmInstance, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -908,13 +896,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
VMInstanceVO vm = _vmInstanceDao.findById(vmId);
|
||||
if (vm == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find the VM with specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
// business logic
|
||||
|
|
@ -923,13 +905,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
s_logger.debug("VM is not Running, unable to migrate the vm" + vm);
|
||||
}
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("VM is not Running, unable to migrate the vm with specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -955,19 +931,8 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
s_logger.debug("Unable to find the host with id: " + srcHostId + " of this VM:" + vm);
|
||||
}
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find the host (with specified id) of VM with specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(srcHost);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, srcHostId, "hostId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(srcHost, srcHostId, "hostId");
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
Long cluster = srcHost.getClusterId();
|
||||
|
|
@ -1147,7 +1112,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
}
|
||||
Account account = _accountDao.findActiveAccount(accountName, domainId);
|
||||
if (account == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find account " + accountName + " in specified domain");
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find account " + accountName + " in specified domain");
|
||||
// Since we don't have a DomainVO object here, we directly set tablename to "domain".
|
||||
String tablename = "domain";
|
||||
ex.addProxyObject(tablename, domainId, "domainId");
|
||||
|
|
@ -1170,13 +1135,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
Project project = _projectMgr.getProject(projectId);
|
||||
if (project == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find project by id " + projectId);
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(project);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, projectId, "projectId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(project, projectId, "projectId");
|
||||
throw ex;
|
||||
}
|
||||
accountId = project.getProjectAccountId();
|
||||
|
|
@ -1345,25 +1304,13 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
if (isIso && template.getFormat() != ImageFormat.ISO) {
|
||||
s_logger.error("Template Id " + templateId + " is not an ISO");
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Specified Template Id is not an ISO");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(template);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, templateId, "templateId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(template, templateId, "templateId");
|
||||
throw ex;
|
||||
}// If ISO not requested then it shouldn't be an ISO.
|
||||
if (!isIso && template.getFormat() == ImageFormat.ISO) {
|
||||
s_logger.error("Incorrect format of the template id " + templateId);
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Incorrect format " + template.getFormat() + " of the specified template id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(template);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, templateId, "templateId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(template, templateId, "templateId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
@ -1443,26 +1390,14 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
VMTemplateVO template = _templateDao.findById(id);
|
||||
if (template == null || template.getRemoved() != null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find template/iso with specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(template);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, id, "templateId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(template, id, "templateId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
// Don't allow to modify system template
|
||||
if (id == Long.valueOf(1)) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to update template/iso of specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(template);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, id, "templateId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(template, id, "templateId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -1994,13 +1929,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
DomainVO domain = _domainDao.findById(domainId);
|
||||
if (domain == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find domain with specified domain id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(domain);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, domainId, "domainId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(domain, domainId, "domainId");
|
||||
throw ex;
|
||||
} else if (domain.getParent() == null && domainName != null) {
|
||||
// check if domain is ROOT domain - and deny to edit it with the new name
|
||||
|
|
@ -2021,13 +1950,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
|
||||
if (!domains.isEmpty() && !sameDomain) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Failed to update specified domain id with name '" + domainName + "' since it already exists in the system");
|
||||
// Get the domainVO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(domain);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, domainId, "domainId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from domainVO proxy cglib object\n");
|
||||
}
|
||||
ex.addProxyObject(domain, domainId, "domainId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
@ -2733,13 +2656,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(instanceId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
|
||||
if (systemVm == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a system vm of specified instanceId");
|
||||
// Get the VMInstanceVO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(systemVm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, instanceId, "instanceId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from VMInstanceVO proxy cglib object\n");
|
||||
}
|
||||
ex.addProxyObject(systemVm, instanceId, "instanceId");
|
||||
throw ex;
|
||||
}
|
||||
return systemVm.getType();
|
||||
|
|
@ -2751,13 +2668,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(vmId, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
|
||||
if (systemVm == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId");
|
||||
// Get the VMInstanceVO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(systemVm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from VMInstanceVO proxy cglib object\n");
|
||||
}
|
||||
ex.addProxyObject(systemVm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -2767,13 +2678,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
return startSecondaryStorageVm(vmId);
|
||||
} else {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a system vm with specified vmId");
|
||||
// Get the VMInstanceVO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(systemVm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from VMInstanceVO proxy cglib object\n");
|
||||
}
|
||||
ex.addProxyObject(systemVm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
@ -2786,13 +2691,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(id, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
|
||||
if (systemVm == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId");
|
||||
// Get the VMInstanceVO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(systemVm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, id, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from VMInstanceVO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(systemVm, id, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -2814,13 +2713,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
|
||||
if (systemVm == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId");
|
||||
// Get the VMInstanceVO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(systemVm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, cmd.getId(), "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from VMInstanceVO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(systemVm, cmd.getId(), "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -2837,13 +2730,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
|
||||
if (systemVm == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a system vm with specified vmId");
|
||||
// Get the VMInstanceVO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(systemVm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, cmd.getId(), "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from VMInstanceVO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(systemVm, cmd.getId(), "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -2881,13 +2768,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
User user = _accountMgr.getUserIncludingRemoved(userId);
|
||||
if ((user == null) || (user.getRemoved() != null)) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find active user of specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(user);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, userId, "userId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(user, userId, "userId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -2973,13 +2854,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
VolumeVO volume = _volumeDao.findById(volumeId);
|
||||
if (volume == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find volume with specified volumeId");
|
||||
// Get the VolumeVO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(volume);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, volumeId, "volumeId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from VolumeVO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(volume, volumeId, "volumeId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -2996,32 +2871,19 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
if (volume.getInstanceId() != null && ApiDBUtils.findVMInstanceById(volume.getInstanceId()).getState() != State.Stopped) {
|
||||
s_logger.debug("Invalid state of the volume with ID: " + volumeId + ". It should be either detached or the VM should be in stopped state.");
|
||||
PermissionDeniedException ex = new PermissionDeniedException("Invalid state of the volume with specified ID. It should be either detached or the VM should be in stopped state.");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(volume);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, volumeId, "volumeId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from VolumeVO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(volume, volumeId, "volumeId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
if (volume.getVolumeType() != Volume.Type.DATADISK) { // Datadisk dont have any template dependence.
|
||||
|
||||
VMTemplateVO template = ApiDBUtils.findTemplateById(volume.getTemplateId());
|
||||
if (template != null) { // For ISO based volumes template = null and we allow extraction of all ISO based
|
||||
// volumes
|
||||
if (template != null) { // For ISO based volumes template = null and we allow extraction of all ISO based volumes
|
||||
boolean isExtractable = template.isExtractable() && template.getTemplateType() != Storage.TemplateType.SYSTEM;
|
||||
if (!isExtractable && account != null && account.getType() != Account.ACCOUNT_TYPE_ADMIN) { // Global
|
||||
// admins are always allowed to extract
|
||||
PermissionDeniedException ex = new PermissionDeniedException("The volume with specified volumeId is not allowed to be extracted");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(volume);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, volumeId, "volumeId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from VolumeVO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(volume, volumeId, "volumeId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
@ -3158,13 +3020,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
InstanceGroupVO group = _vmGroupDao.findById(groupId.longValue());
|
||||
if (group == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a vm group with specified groupId");
|
||||
// Get the VolumeVO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(group);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, groupId, "groupId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from InstanceGroupVO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(group, groupId, "groupId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -3388,13 +3244,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
SSHKeyPairVO s = _sshKeyPairDao.findByName(owner.getAccountId(), owner.getDomainId(), cmd.getName());
|
||||
if (s == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("A key pair with name '" + cmd.getName() + "' does not exist for account " + owner.getAccountName() + " in specified domain id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(owner);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, owner.getDomainId(), "domainId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(owner, owner.getDomainId(), "domainId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -3477,13 +3327,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
UserVmVO vm = _userVmDao.findById(cmd.getId());
|
||||
if (vm == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("No VM with specified id found.");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, cmd.getId(), "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, cmd.getId(), "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -3494,13 +3338,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
String password = vm.getDetail("Encrypted.Password");
|
||||
if (password == null || password.equals("")) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("No password for VM with specified id found.");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, cmd.getId(), "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, cmd.getId(), "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -3606,13 +3444,7 @@ public class ManagementServerImpl implements ManagementServer {
|
|||
|
||||
if (hpvCapabilities == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find the hypervisor capabilities for specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(hpvCapabilities);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, id, "Id");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(hpvCapabilities, id, "Id");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2835,13 +2835,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
UserVmVO vm = _vmDao.findById(vmId);
|
||||
if (vm == null || vm.getRemoved() != null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find a virtual machine with specified vmId");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -2860,13 +2854,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
status = _itMgr.destroy(vm, userCaller, caller);
|
||||
} catch (OperationTimedoutException e) {
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Unable to destroy with specified vmId", e);
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -2887,13 +2875,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
return _vmDao.findById(vmId);
|
||||
} else {
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Failed to destroy vm with specified vmId");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
@ -3099,17 +3081,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
|
||||
@Override
|
||||
public HypervisorType getHypervisorTypeOfUserVM(long vmid) {
|
||||
UserVmVO userVm = _vmDao.findById(vmid);
|
||||
public HypervisorType getHypervisorTypeOfUserVM(long vmId) {
|
||||
UserVmVO userVm = _vmDao.findById(vmId);
|
||||
if (userVm == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a virtual machine with id " + vmid);
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(userVm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmid, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find a virtual machine with specified id");
|
||||
ex.addProxyObject(userVm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -3146,13 +3122,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
|
||||
if (vm.getState() != State.Stopped) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("VM is not Stopped, unable to migrate the vm having the specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -3196,13 +3166,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
s_logger.debug("VM is not Running, unable to migrate the vm " + vm);
|
||||
}
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("VM is not Running, unable to migrate the vm with specified id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
if (!vm.getHypervisorType().equals(HypervisorType.XenServer) && !vm.getHypervisorType().equals(HypervisorType.VMware) && !vm.getHypervisorType().equals(HypervisorType.KVM) && !vm.getHypervisorType().equals(HypervisorType.Ovm)) {
|
||||
|
|
@ -3274,13 +3238,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
s_logger.debug("VM is Running, unable to move the vm " + vm);
|
||||
}
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("VM is Running, unable to move the vm with specified vmId");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, cmd.getVmId(), "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, cmd.getVmId(), "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -3291,13 +3249,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
//don't allow to move the vm from the project
|
||||
if (oldAccount.getType() == Account.ACCOUNT_TYPE_PROJECT) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Specified Vm id belongs to the project and can't be moved");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, cmd.getVmId(), "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, cmd.getVmId(), "vmId");
|
||||
throw ex;
|
||||
}
|
||||
Account newAccount = _accountService.getActiveAccountByName(cmd.getAccountName(), cmd.getDomainId());
|
||||
|
|
@ -3486,13 +3438,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
NetworkVO network = _networkDao.findById(networkId);
|
||||
if (network == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find specified network id");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, networkId, "networkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(network, networkId, "networkId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -3502,13 +3448,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
NetworkOffering networkOffering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
|
||||
if (networkOffering.isSystemOnly()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Specified Network id is system only and can't be used for vm deployment");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(network);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, networkId, "networkId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(network, networkId, "networkId");
|
||||
throw ex;
|
||||
}
|
||||
applicableNetworks.add(network);
|
||||
|
|
@ -3582,13 +3522,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
UserVmVO vm = _vmDao.findById(vmId);
|
||||
if (vm == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Cann not find VM with ID " + vmId);
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -3612,13 +3546,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
List<VolumeVO> rootVols = _volsDao.findByInstance(vmId);
|
||||
if (rootVols.isEmpty()) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Can not find root volume for VM " + vmId);
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -3627,19 +3555,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
VMTemplateVO template = _templateDao.findById(templateId);
|
||||
if (template == null) {
|
||||
InvalidParameterValueException ex = new InvalidParameterValueException("Cannot find template for specified volumeid and vmId");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
tablename = AnnotationHelper.getTableName(root);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, root.getId(), "volumeId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
ex.addProxyObject(root, root.getId(), "volumeId");
|
||||
throw ex;
|
||||
}
|
||||
|
||||
|
|
@ -3649,13 +3566,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
} catch (ResourceUnavailableException e) {
|
||||
s_logger.debug("Stop vm " + vmId + " failed", e);
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Stop vm failed for specified vmId");
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
@ -3678,13 +3589,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
} catch (Exception e) {
|
||||
s_logger.debug("Unable to start VM " + vmId, e);
|
||||
CloudRuntimeException ex = new CloudRuntimeException("Unable to start VM with specified id" + e.getMessage());
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(vm);
|
||||
if (tablename != null) {
|
||||
ex.addProxyObject(tablename, vmId, "vmId");
|
||||
} else {
|
||||
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
|
||||
}
|
||||
ex.addProxyObject(vm, vmId, "vmId");
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
*/
|
||||
package com.cloud.utils.exception;
|
||||
|
||||
import com.cloud.utils.AnnotationHelper;
|
||||
import com.cloud.utils.IdentityProxy;
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
|
@ -52,6 +53,15 @@ public class RuntimeCloudException extends RuntimeException {
|
|||
super(message, cause);
|
||||
setCSErrorCode(CSExceptionErrorCode.getCSErrCode(this.getClass().getName()));
|
||||
}
|
||||
|
||||
public void addProxyObject(Object voObj, Long id, String idFieldName) {
|
||||
// Get the VO object's table name.
|
||||
String tablename = AnnotationHelper.getTableName(voObj);
|
||||
if (tablename != null) {
|
||||
addProxyObject(tablename, id, idFieldName);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public RuntimeCloudException() {
|
||||
super();
|
||||
|
|
|
|||
Loading…
Reference in New Issue