Removed a bunch of InternalErrorException

This commit is contained in:
Alex Huang 2010-11-02 08:53:04 -07:00 committed by root
parent 3348b56ab7
commit 3279c26796
9 changed files with 167 additions and 155 deletions

View File

@ -61,9 +61,9 @@ import org.libvirt.Network;
import org.libvirt.NodeInfo;
import org.libvirt.StoragePool;
import org.libvirt.StoragePoolInfo;
import org.libvirt.StoragePoolInfo.StoragePoolState;
import org.libvirt.StorageVol;
import org.libvirt.StorageVolInfo;
import org.libvirt.StoragePoolInfo.StoragePoolState;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.AttachIsoCommand;
@ -152,9 +152,9 @@ import com.cloud.agent.resource.computing.LibvirtVMDef.guestDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.guestResourceDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.inputDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.interfaceDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.interfaceDef.hostNicType;
import com.cloud.agent.resource.computing.LibvirtVMDef.serialDef;
import com.cloud.agent.resource.computing.LibvirtVMDef.termPolicy;
import com.cloud.agent.resource.computing.LibvirtVMDef.interfaceDef.hostNicType;
import com.cloud.agent.resource.virtualnetwork.VirtualRoutingResource;
import com.cloud.exception.InternalErrorException;
import com.cloud.host.Host.Type;
@ -163,18 +163,18 @@ import com.cloud.network.NetworkEnums.RouterPrivateIpStrategy;
import com.cloud.resource.ServerResource;
import com.cloud.resource.ServerResourceBase;
import com.cloud.storage.Storage;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StorageLayer;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.Volume;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.Volume.VolumeType;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.template.Processor;
import com.cloud.storage.template.Processor.FormatInfo;
import com.cloud.storage.template.QCOW2Processor;
import com.cloud.storage.template.TemplateInfo;
import com.cloud.storage.template.TemplateLocation;
import com.cloud.storage.template.Processor.FormatInfo;
import com.cloud.utils.NumbersUtil;
import com.cloud.utils.Pair;
import com.cloud.utils.PropertiesUtil;

View File

@ -35,7 +35,6 @@ import com.cloud.dc.HostPodVO;
import com.cloud.dc.PodCluster;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.DiscoveryException;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.host.Host;
@ -153,7 +152,6 @@ public interface AgentManager extends Manager {
* Obtains statistics for a host; vCPU utilisation, memory utilisation, and network utilisation
* @param hostId
* @return HostStats
* @throws InternalErrorException
*/
HostStats getHostStatistics(long hostId);

View File

@ -25,7 +25,6 @@ import com.cloud.api.BaseCmd;
import com.cloud.async.AsyncJobManager;
import com.cloud.async.AsyncJobResult;
import com.cloud.async.AsyncJobVO;
import com.cloud.exception.InternalErrorException;
import com.cloud.serializer.GsonHelper;
import com.cloud.server.ManagementServer;
import com.cloud.vm.ConsoleProxyVO;
@ -34,7 +33,8 @@ import com.google.gson.Gson;
public class StartConsoleProxyExecutor extends VMOperationExecutor {
public static final Logger s_logger = Logger.getLogger(StartConsoleProxyExecutor.class.getName());
public boolean execute() {
@Override
public boolean execute() {
Gson gson = GsonHelper.getBuilder().create();
AsyncJobManager asyncMgr = getAsyncJobMgr();
AsyncJobVO job = getJob();
@ -52,9 +52,6 @@ public class StartConsoleProxyExecutor extends VMOperationExecutor {
else
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
"operation failed");
} catch (InternalErrorException e) {
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
e.getMessage());
} catch(Exception e) {
s_logger.warn("Unable to start console proxy " + param.getVmId() + ":" + e.getMessage(), e);
asyncMgr.completeAsyncJob(getJob().getId(), AsyncJobResult.STATUS_FAILED, BaseCmd.INTERNAL_ERROR,
@ -64,12 +61,15 @@ public class StartConsoleProxyExecutor extends VMOperationExecutor {
}
}
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {
@Override
public void processAnswer(VMOperationListener listener, long agentId, long seq, Answer answer) {
}
public void processDisconnect(VMOperationListener listener, long agentId) {
@Override
public void processDisconnect(VMOperationListener listener, long agentId) {
}
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
@Override
public void processTimeout(VMOperationListener listener, long agentId, long seq) {
}
}

View File

@ -38,11 +38,9 @@ import com.cloud.api.commands.UpdateZoneCmd;
import com.cloud.dc.DataCenterVO;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.VlanVO;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.service.ServiceOfferingVO;
import com.cloud.storage.DiskOfferingVO;
import com.cloud.utils.component.Manager;
@ -59,16 +57,16 @@ public interface ConfigurationManager extends Manager {
* @param name
* @param value
*/
void updateConfiguration(long userId, String name, String value) throws InvalidParameterValueException, InternalErrorException;
void updateConfiguration(long userId, String name, String value);
/**
* Updates a configuration entry with a new value
* @param cmd - the command wrapping name and value parameters
* @return true or false
* @throws InvalidParameterValueException, InternalErrorException
* @throws ,
*/
boolean updateConfiguration(UpdateCfgCmd cmd) throws InvalidParameterValueException, InternalErrorException;
boolean updateConfiguration(UpdateCfgCmd cmd);
/**
* Creates a new service offering
@ -90,7 +88,7 @@ public interface ConfigurationManager extends Manager {
* @param cmd the command object that specifies the name, number of cpu cores, amount of RAM, etc. for the service offering
* @return the newly created service offering if successful, null otherwise
*/
ServiceOfferingVO createServiceOffering(CreateServiceOfferingCmd cmd) throws InvalidParameterValueException;
ServiceOfferingVO createServiceOffering(CreateServiceOfferingCmd cmd);
/**
* Updates a service offering
@ -110,24 +108,24 @@ public interface ConfigurationManager extends Manager {
* Updates a disk offering
* @param cmd - the command specifying diskOfferingId, name, description, tags
* @return updated disk offering
* @throws InvalidParameterValueException
* @throws
*/
DiskOfferingVO updateDiskOffering(UpdateDiskOfferingCmd cmd) throws InvalidParameterValueException;
DiskOfferingVO updateDiskOffering(UpdateDiskOfferingCmd cmd);
/**
* Deletes a disk offering
* @param cmd - the command specifying disk offering id
* @return true or false
* @throws InvalidParameterValueException
* @throws
*/
boolean deleteDiskOffering(DeleteDiskOfferingCmd cmd) throws InvalidParameterValueException;
boolean deleteDiskOffering(DeleteDiskOfferingCmd cmd);
/**
* Deletes a service offering
* @param userId
* @param serviceOfferingId
*/
boolean deleteServiceOffering(DeleteServiceOfferingCmd cmd) throws InvalidParameterValueException;
boolean deleteServiceOffering(DeleteServiceOfferingCmd cmd);
/**
* Creates a new disk offering
@ -139,7 +137,7 @@ public interface ConfigurationManager extends Manager {
* @param size
* @return ID
*/
DiskOfferingVO createDiskOffering(CreateDiskOfferingCmd cmd) throws InvalidParameterValueException;
DiskOfferingVO createDiskOffering(CreateDiskOfferingCmd cmd);
/**
* Creates a new disk offering
@ -150,7 +148,7 @@ public interface ConfigurationManager extends Manager {
* @param tags
* @return newly created disk offering
*/
DiskOfferingVO createDiskOffering(long domainId, String name, String description, int numGibibytes, String tags) throws InvalidParameterValueException;
DiskOfferingVO createDiskOffering(long domainId, String name, String description, int numGibibytes, String tags);
/**
* Creates a new pod
@ -163,16 +161,16 @@ public interface ConfigurationManager extends Manager {
* @param endIp
* @return Pod
*/
HostPodVO createPod(long userId, String podName, long zoneId, String gateway, String cidr, String startIp, String endIp) throws InvalidParameterValueException, InternalErrorException;
HostPodVO createPod(long userId, String podName, long zoneId, String gateway, String cidr, String startIp, String endIp);
/**
* Creates a new pod based on the parameters specified in the command object
* @param cmd the command object that specifies the name, zone, gateway, cidr, and ip range for the pod
* @return the new pod if successful, null otherwise
* @throws InvalidParameterValueException
* @throws InternalErrorException
* @throws
* @throws
*/
HostPodVO createPod(CreatePodCmd cmd) throws InvalidParameterValueException, InternalErrorException;
HostPodVO createPod(CreatePodCmd cmd);
/**
* Edits a pod in the database. Will not allow you to edit pods that are being used anywhere in the system.
@ -183,27 +181,27 @@ public interface ConfigurationManager extends Manager {
* @param startIp
* @param endIp
* @return Pod
* @throws InternalErrorException
* @throws InvalidParameterValueException
* @throws
* @throws
*/
HostPodVO editPod(UpdatePodCmd cmd) throws InvalidParameterValueException, InternalErrorException;
HostPodVO editPod(UpdatePodCmd cmd);
/**
* Deletes a pod from the database. Will not allow you to delete pods that are being used anywhere in the system.
* @param cmd - the command containing podId
* @return true or false
* @throws InvalidParameterValueException, InternalErrorException
* @throws ,
*/
boolean deletePod(DeletePodCmd cmd) throws InvalidParameterValueException, InternalErrorException;
boolean deletePod(DeletePodCmd cmd);
/**
* Creates a new zone
* @param cmd
* @return the zone if successful, null otherwise
* @throws InvalidParameterValueException
* @throws InternalErrorException
* @throws
* @throws
*/
DataCenterVO createZone(CreateZoneCmd cmd) throws InvalidParameterValueException, InternalErrorException;
DataCenterVO createZone(CreateZoneCmd cmd);
/**
* Creates a new zone
@ -216,24 +214,24 @@ public interface ConfigurationManager extends Manager {
* @param vnetRange
* @param guestCidr
* @return
* @throws InvalidParameterValueException
* @throws InternalErrorException
* @throws
* @throws
*/
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr, String domain, Long domainId) throws InvalidParameterValueException, InternalErrorException;
DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr, String domain, Long domainId);
/**
* Edits a zone in the database. Will not allow you to edit DNS values if there are VMs in the specified zone.
* @param UpdateZoneCmd
* @return Updated zone
*/
DataCenterVO editZone(UpdateZoneCmd cmd) throws InvalidParameterValueException, InternalErrorException;
DataCenterVO editZone(UpdateZoneCmd cmd);
/**
* Deletes a zone from the database. Will not allow you to delete zones that are being used anywhere in the system.
* @param userId
* @param zoneId
*/
void deleteZone(DeleteZoneCmd cmd) throws InvalidParameterValueException, InternalErrorException;
void deleteZone(DeleteZoneCmd cmd);
/**
* Associates an ip address list to an account. The list of ip addresses are all addresses associated with the given vlan id.
@ -242,11 +240,9 @@ public interface ConfigurationManager extends Manager {
* @param zoneId
* @param vlanId
* @throws InsufficientAddressCapacityException
* @throws InvalidParameterValueException
* @throws InternalErrorException
* @throws
*/
public void associateIpAddressListToAccount(long userId, long accountId, long zoneId, Long vlanId) throws InsufficientAddressCapacityException,
InvalidParameterValueException, InternalErrorException;
public void associateIpAddressListToAccount(long userId, long accountId, long zoneId, Long vlanId) throws InsufficientAddressCapacityException, ConcurrentOperationException;
/**
* Adds a VLAN to the database, along with an IP address range. Can add three types of VLANs: (1) zone-wide VLANs on the virtual public network (2) pod-wide direct attached VLANs (3) account-specific direct attached VLANs
@ -260,11 +256,11 @@ public interface ConfigurationManager extends Manager {
* @param gateway
* @param startIP
* @param endIP
* @throws InvalidParameterValueException
* @throws
* @return The new VlanVO object
*/
VlanVO createVlanAndPublicIpRange(CreateVlanIpRangeCmd cmd) throws InvalidParameterValueException, InternalErrorException, InsufficientCapacityException;
// VlanVO createVlanAndPublicIpRange(long userId, VlanType vlanType, Long zoneId, Long accountId, Long podId, String vlanId, String vlanGateway, String vlanNetmask, String startIP, String endIP) throws InvalidParameterValueException, InternalErrorException;
VlanVO createVlanAndPublicIpRange(CreateVlanIpRangeCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException;
// VlanVO createVlanAndPublicIpRange(long userId, VlanType vlanType, Long zoneId, Long accountId, Long podId, String vlanId, String vlanGateway, String vlanNetmask, String startIP, String endIP) throws , ;
/**
* Deletes a VLAN from the database, along with all of its IP addresses. Will not delete VLANs that have allocated IP addresses.
@ -272,8 +268,8 @@ public interface ConfigurationManager extends Manager {
* @param vlanDbId
* @return success/failure
*/
boolean deleteVlanAndPublicIpRange(long userId, long vlanDbId) throws InvalidParameterValueException;
boolean deleteVlanIpRange(DeleteVlanIpRangeCmd cmd) throws InvalidParameterValueException;
boolean deleteVlanAndPublicIpRange(long userId, long vlanDbId);
boolean deleteVlanIpRange(DeleteVlanIpRangeCmd cmd);
/**
* Adds/deletes private IPs
@ -282,9 +278,9 @@ public interface ConfigurationManager extends Manager {
* @param startIP
* @param endIP
* @return Message to display to user
* @throws InvalidParameterValueException if unable to add private ip range
* @throws if unable to add private ip range
*/
String changePrivateIPRange(boolean add, long podId, String startIP, String endIP) throws InvalidParameterValueException;
String changePrivateIPRange(boolean add, long podId, String startIP, String endIP);
/**
* Converts a comma separated list of tags to a List
@ -303,7 +299,7 @@ public interface ConfigurationManager extends Manager {
/**
* Persists a config value via the API call
* @param cmd - the command that wraps instance, component, category, name, value, description parameters
* @throws InvalidParameterValueException, InternalErrorException
* @throws ,
* @return true or false
*/
boolean addConfig(AddConfigCmd cmd);

View File

@ -69,9 +69,9 @@ import com.cloud.event.EventTypes;
import com.cloud.event.EventUtils;
import com.cloud.event.EventVO;
import com.cloud.event.dao.EventDao;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.NetworkManager;
@ -94,6 +94,7 @@ import com.cloud.utils.NumbersUtil;
import com.cloud.utils.component.Inject;
import com.cloud.utils.db.DB;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.net.NetUtils;
import com.cloud.vm.ConsoleProxyVO;
import com.cloud.vm.DomainRouterVO;
@ -162,7 +163,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
}
@Override
public void updateConfiguration(long userId, String name, String value) throws InvalidParameterValueException, InternalErrorException {
public void updateConfiguration(long userId, String name, String value) {
if (value != null && (value.trim().isEmpty() || value.equals("null"))) {
value = null;
}
@ -176,14 +177,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
if (!_configDao.update(name, value)) {
s_logger.error("Failed to update configuration option, name: " + name + ", value:" + value);
throw new InternalErrorException("Failed to update configuration value. Please contact Cloud Support.");
throw new CloudRuntimeException("Failed to update configuration value. Please contact Cloud Support.");
}
saveConfigurationEvent(userId, null, EventTypes.EVENT_CONFIGURATION_VALUE_EDIT, "Successfully edited configuration value.", "name=" + name, "value=" + value);
}
@Override
public boolean updateConfiguration(UpdateCfgCmd cmd) throws InvalidParameterValueException, InternalErrorException{
public boolean updateConfiguration(UpdateCfgCmd cmd) {
Long userId = UserContext.current().getUserId();
String name = cmd.getCfgName();
String value = cmd.getValue();
@ -288,14 +289,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
}
@DB
protected void checkIfPodIsDeletable(long podId) throws InternalErrorException {
protected void checkIfPodIsDeletable(long podId) {
List<List<String>> tablesToCheck = new ArrayList<List<String>>();
HostPodVO pod = _podDao.findById(podId);
// Check if there are allocated private IP addresses in the pod
if (_privateIpAddressDao.countIPs(podId, pod.getDataCenterId(), true) != 0) {
throw new InternalErrorException("There are private IP addresses allocated for this pod");
throw new CloudRuntimeException("There are private IP addresses allocated for this pod");
}
List<String> volumes = new ArrayList<String>();
@ -344,10 +345,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
stmt.setLong(1, podId);
ResultSet rs = stmt.executeQuery();
if (rs != null && rs.next()) {
throw new InternalErrorException("The pod cannot be edited because " + errorMsg);
throw new CloudRuntimeException("The pod cannot be edited because " + errorMsg);
}
} catch (SQLException ex) {
throw new InternalErrorException("The Management Server failed to detect if pod is editable. Please contact Cloud Support.");
throw new CloudRuntimeException("The Management Server failed to detect if pod is editable. Please contact Cloud Support.");
}
}
}
@ -404,7 +405,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
@Override
@DB
public boolean deletePod(DeletePodCmd cmd) throws InvalidParameterValueException, InternalErrorException {
public boolean deletePod(DeletePodCmd cmd) {
Long podId = cmd.getId();
Long userId = 1L;
@ -432,7 +433,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
@Override
@DB
public HostPodVO editPod(UpdatePodCmd cmd) throws InvalidParameterValueException, InternalErrorException
public HostPodVO editPod(UpdatePodCmd cmd)
{
//Input validation
@ -472,7 +473,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
// If the gateway, CIDR, private IP range is being updated, check if the pod has allocated private IP addresses
if (gateway!= null || cidr != null || startIp != null || endIp != null) {
if (podHasAllocatedPrivateIPs(id)) {
throw new InternalErrorException("The specified pod has allocated private IP addresses, so its CIDR and IP address range cannot be changed.");
throw new CloudRuntimeException("The specified pod has allocated private IP addresses, so its CIDR and IP address range cannot be changed.");
}
}
@ -528,14 +529,14 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
pod.setDescription(ipRange);
if (!_podDao.update(id, pod)) {
throw new InternalErrorException("Failed to edit pod. Please contact Cloud Support.");
throw new CloudRuntimeException("Failed to edit pod. Please contact Cloud Support.");
}
txn.commit();
} catch(Exception e) {
s_logger.error("Unable to edit pod due to " + e.getMessage(), e);
txn.rollback();
throw new InternalErrorException("Failed to edit pod. Please contact Cloud Support.");
throw new CloudRuntimeException("Failed to edit pod. Please contact Cloud Support.");
}
saveConfigurationEvent(userId, null, EventTypes.EVENT_POD_EDIT, "Successfully edited pod. New pod name is: " + name + " and new zone name is: " + zone.getName() + ".", "podId=" + pod.getId(), "dcId=" + zone.getId(), "gateway=" + gateway, "cidr=" + cidr, "startIp=" + startIp, "endIp=" + endIp);
@ -544,7 +545,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
}
@Override
public HostPodVO createPod(CreatePodCmd cmd) throws InvalidParameterValueException, InternalErrorException {
public HostPodVO createPod(CreatePodCmd cmd) {
String cidr = cmd.getCidr();
String endIp = cmd.getEndIp();
String gateway = cmd.getGateway();
@ -571,7 +572,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
}
@Override @DB
public HostPodVO createPod(long userId, String podName, long zoneId, String gateway, String cidr, String startIp, String endIp) throws InvalidParameterValueException, InternalErrorException {
public HostPodVO createPod(long userId, String podName, long zoneId, String gateway, String cidr, String startIp, String endIp) {
checkPodAttributes(-1, podName, zoneId, gateway, cidr, startIp, endIp, true);
String cidrAddress = getCidrAddress(cidr);
@ -601,7 +602,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
if (_podDao.persist(pod) == null) {
txn.rollback();
throw new InternalErrorException("Failed to create new pod. Please contact Cloud Support.");
throw new CloudRuntimeException("Failed to create new pod. Please contact Cloud Support.");
}
if (startIp != null) {
@ -618,7 +619,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
} catch(Exception e) {
txn.rollback();
s_logger.error("Unable to create new pod due to " + e.getMessage(), e);
throw new InternalErrorException("Failed to create new pod. Please contact Cloud Support.");
throw new CloudRuntimeException("Failed to create new pod. Please contact Cloud Support.");
}
DataCenterVO zone = _zoneDao.findById(zoneId);
@ -627,17 +628,17 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
return pod;
}
private boolean zoneHasVMs(long zoneId) throws InternalErrorException {
private boolean zoneHasVMs(long zoneId) {
List<VMInstanceVO> vmInstances = _vmInstanceDao.listByZoneId(zoneId);
return !vmInstances.isEmpty();
}
private boolean zoneHasAllocatedVnets(long zoneId) throws InternalErrorException {
private boolean zoneHasAllocatedVnets(long zoneId) {
return !_zoneDao.listAllocatedVnets(zoneId).isEmpty();
}
@DB
protected void checkIfZoneIsDeletable(long zoneId) throws InternalErrorException {
protected void checkIfZoneIsDeletable(long zoneId) {
List<List<String>> tablesToCheck = new ArrayList<List<String>>();
List<String> alert = new ArrayList<String>();
@ -707,10 +708,10 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
stmt.setLong(1, zoneId);
ResultSet rs = stmt.executeQuery();
if (rs != null && rs.next()) {
throw new InternalErrorException("The zone is not deletable because " + errorMsg);
throw new CloudRuntimeException("The zone is not deletable because " + errorMsg);
}
} catch (SQLException ex) {
throw new InternalErrorException("The Management Server failed to detect if zone is deletable. Please contact Cloud Support.");
throw new CloudRuntimeException("The Management Server failed to detect if zone is deletable. Please contact Cloud Support.");
}
}
@ -776,7 +777,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
@Override
@DB
public void deleteZone(DeleteZoneCmd cmd) throws InvalidParameterValueException, InternalErrorException {
public void deleteZone(DeleteZoneCmd cmd) {
Long userId = UserContext.current().getUserId();
Long zoneId = cmd.getId();
@ -803,7 +804,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
}
@Override
public DataCenterVO editZone(UpdateZoneCmd cmd) throws InvalidParameterValueException, InternalErrorException {
public DataCenterVO editZone(UpdateZoneCmd cmd) {
//Parameter validation as from execute() method in V1
Long zoneId = cmd.getId();
String zoneName = cmd.getZoneName();
@ -838,7 +839,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
// If the Vnet range is being changed, make sure there are no allocated VNets
if (vnetRange != null) {
if (zoneHasAllocatedVnets(zoneId)) {
throw new InternalErrorException("The vlan range is not editable because there are allocated vlans.");
throw new CloudRuntimeException("The vlan range is not editable because there are allocated vlans.");
}
}
@ -885,7 +886,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
}
if (!_zoneDao.update(zoneId, zone)) {
throw new InternalErrorException("Failed to edit zone. Please contact Cloud Support.");
throw new CloudRuntimeException("Failed to edit zone. Please contact Cloud Support.");
}
if (vnetRange != null) {
@ -945,7 +946,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
}
@Override @DB
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr, String domain, Long domainId) throws InvalidParameterValueException, InternalErrorException {
public DataCenterVO createZone(long userId, String zoneName, String dns1, String dns2, String internalDns1, String internalDns2, String vnetRange, String guestCidr, String domain, Long domainId) {
int vnetStart, vnetEnd;
if (vnetRange != null) {
String[] tokens = vnetRange.split("-");
@ -991,7 +992,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
}
@Override
public DataCenterVO createZone(CreateZoneCmd cmd) throws InvalidParameterValueException, InternalErrorException {
public DataCenterVO createZone(CreateZoneCmd cmd) {
// grab parameters from the command
Long userId = UserContext.current().getUserId();
String zoneName = cmd.getZoneName();
@ -1289,7 +1290,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
}
@Override
public VlanVO createVlanAndPublicIpRange(CreateVlanIpRangeCmd cmd) throws InvalidParameterValueException, InternalErrorException, InsufficientCapacityException {
public VlanVO createVlanAndPublicIpRange(CreateVlanIpRangeCmd cmd) throws InsufficientCapacityException, ConcurrentOperationException {
Long userId = UserContext.current().getUserId();
if (userId == null) {
userId = Long.valueOf(User.UID_SYSTEM);
@ -1335,7 +1336,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
{
if(_configDao.getValue("xen.public.network.device") == null || _configDao.getValue("xen.public.network.device").equals(""))
{
throw new InternalErrorException("For adding an untagged IP range, please set up xen.public.network.device");
throw new CloudRuntimeException("For adding an untagged IP range, please set up xen.public.network.device");
}
}
@ -1496,12 +1497,12 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
if(!savePublicIPRangeForAccount(startIP, endIP, zoneId, vlan.getId(), account.getId(), account.getDomainId())) {
deletePublicIPRange(vlan.getId());
_vlanDao.expunge(vlan.getId());
throw new InternalErrorException("Failed to save IP range. Please contact Cloud Support."); //It can be Direct IP or Public IP.
throw new CloudRuntimeException("Failed to save IP range. Please contact Cloud Support."); //It can be Direct IP or Public IP.
}
}else if (!savePublicIPRange(startIP, endIP, zoneId, vlan.getId())) {
deletePublicIPRange(vlan.getId());
_vlanDao.expunge(vlan.getId());
throw new InternalErrorException("Failed to save IP range. Please contact Cloud Support."); //It can be Direct IP or Public IP.
throw new CloudRuntimeException("Failed to save IP range. Please contact Cloud Support."); //It can be Direct IP or Public IP.
}
if (account != null) {
@ -1536,7 +1537,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
@Override @DB
public void associateIpAddressListToAccount(long userId, long accountId, long zoneId, Long vlanId) throws InsufficientAddressCapacityException,
InvalidParameterValueException, InternalErrorException {
ConcurrentOperationException {
Transaction txn = Transaction.currentTxn();
AccountVO account = null;
@ -1546,7 +1547,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
account = _accountDao.acquire(accountId);
if (account == null) {
s_logger.warn("Unable to lock account: " + accountId);
throw new InternalErrorException("Unable to acquire account lock");
throw new ConcurrentOperationException("Unable to acquire account lock");
}
s_logger.debug("Associate IP address lock acquired");
@ -1590,19 +1591,19 @@ public class ConfigurationManagerImpl implements ConfigurationManager {
for(String ip : ipAddrsList){
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_NET_IP_ASSIGN, "Unable to assign public IP " +ip, params);
}
throw new InternalErrorException(errorMsg);
throw new CloudRuntimeException(errorMsg);
}
txn.commit();
for(String ip : ipAddrsList){
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, EventTypes.EVENT_NET_IP_ASSIGN, "Successfully assigned account IP " +ip, params);
}
}
} catch (InternalErrorException iee) {
s_logger.error("Associate IP threw an InternalErrorException.", iee);
} catch (CloudRuntimeException iee) {
s_logger.error("Associate IP threw an CloudRuntimeException.", iee);
throw iee;
} catch (Throwable t) {
s_logger.error("Associate IP address threw an exception.", t);
throw new InternalErrorException("Associate IP address exception");
throw new CloudRuntimeException("Associate IP address exception");
} finally {
if (account != null) {
_accountDao.release(accountId);

View File

@ -36,7 +36,6 @@ import com.cloud.dc.HostPodVO;
import com.cloud.deploy.DeployDestination;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientStorageCapacityException;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
@ -205,7 +204,7 @@ public interface StorageManager extends Manager {
* @param destPoolClusterId
* @return VolumeVO
*/
VolumeVO moveVolume(VolumeVO volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId) throws InternalErrorException;
VolumeVO moveVolume(VolumeVO volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId);
/**
* Creates the database object for a volume based on the given criteria
@ -214,7 +213,7 @@ public interface StorageManager extends Manager {
* @throws InvalidParameterValueException
* @throws PermissionDeniedException
*/
VolumeVO allocVolume(CreateVolumeCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, ResourceAllocationException;
VolumeVO allocVolume(CreateVolumeCmd cmd) throws ResourceAllocationException;
/**
* Creates the volume based on the given criteria
@ -314,7 +313,7 @@ public interface StorageManager extends Manager {
* @return success or failure
* @throws InvalidParameterValueException
*/
public boolean preparePrimaryStorageForMaintenance(PreparePrimaryStorageForMaintenanceCmd cmd) throws InvalidParameterValueException;
public boolean preparePrimaryStorageForMaintenance(PreparePrimaryStorageForMaintenanceCmd cmd);
/**
* Complete maintenance for primary storage
@ -322,7 +321,7 @@ public interface StorageManager extends Manager {
* @return the primary storage pool
* @throws InvalidParameterValueException
*/
public StoragePoolVO cancelPrimaryStorageForMaintenance(CancelPrimaryStorageMaintenanceCmd cmd) throws InvalidParameterValueException;
public StoragePoolVO cancelPrimaryStorageForMaintenance(CancelPrimaryStorageMaintenanceCmd cmd);
public StoragePoolVO updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException;

View File

@ -96,7 +96,6 @@ import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.DiscoveryException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientStorageCapacityException;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.PermissionDeniedException;
@ -1566,7 +1565,7 @@ public class StorageManagerImpl implements StorageManager {
}
@Override
public VolumeVO moveVolume(VolumeVO volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId) throws InternalErrorException {
public VolumeVO moveVolume(VolumeVO volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId) {
// Find a destination storage pool with the specified criteria
DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId());
DiskProfile dskCh = new DiskProfile(volume.getId(), volume.getVolumeType(), volume.getName(), diskOffering.getId(), diskOffering.getDiskSizeInBytes(), diskOffering.getTagsArray(), diskOffering.getUseLocalStorage(), diskOffering.isRecreatable(), null);
@ -1575,7 +1574,7 @@ public class StorageManagerImpl implements StorageManager {
StoragePoolVO destPool = findStoragePool(dskCh, destPoolDataCenter, destPoolPod, destPoolClusterId, null, null, null, new HashSet<StoragePool>());
if (destPool == null) {
throw new InternalErrorException("Failed to find a storage pool with enough capacity to move the volume to.");
throw new CloudRuntimeException("Failed to find a storage pool with enough capacity to move the volume to.");
}
StoragePoolVO srcPool = _storagePoolDao.findById(volume.getPoolId());
@ -1587,9 +1586,9 @@ public class StorageManagerImpl implements StorageManager {
Long destHostId = findHostIdForStoragePool(destPool);
if (sourceHostId == null) {
throw new InternalErrorException("Failed to find a host where the source storage pool is visible.");
throw new CloudRuntimeException("Failed to find a host where the source storage pool is visible.");
} else if (destHostId == null) {
throw new InternalErrorException("Failed to find a host where the dest storage pool is visible.");
throw new CloudRuntimeException("Failed to find a host where the dest storage pool is visible.");
}
// Copy the volume from the source storage pool to secondary storage
@ -1597,7 +1596,7 @@ public class StorageManagerImpl implements StorageManager {
CopyVolumeAnswer cvAnswer = (CopyVolumeAnswer) _agentMgr.easySend(sourceHostId, cvCmd);
if (cvAnswer == null || !cvAnswer.getResult()) {
throw new InternalErrorException("Failed to copy the volume from the source primary storage pool to secondary storage.");
throw new CloudRuntimeException("Failed to copy the volume from the source primary storage pool to secondary storage.");
}
secondaryStorageVolumePath = cvAnswer.getVolumePath();
@ -1608,7 +1607,7 @@ public class StorageManagerImpl implements StorageManager {
cvAnswer = (CopyVolumeAnswer) _agentMgr.easySend(destHostId, cvCmd);
if (cvAnswer == null || !cvAnswer.getResult()) {
throw new InternalErrorException("Failed to copy the volume from secondary storage to the destination primary storage pool.");
throw new CloudRuntimeException("Failed to copy the volume from secondary storage to the destination primary storage pool.");
}
String destPrimaryStorageVolumePath = cvAnswer.getVolumePath();
@ -1619,7 +1618,7 @@ public class StorageManagerImpl implements StorageManager {
Answer destroyAnswer = _agentMgr.easySend(sourceHostId, cmd);
if (destroyAnswer == null || !destroyAnswer.getResult()) {
throw new InternalErrorException("Failed to delete the volume from the source primary storage pool.");
throw new CloudRuntimeException("Failed to delete the volume from the source primary storage pool.");
}
volume.setPath(destPrimaryStorageVolumePath);
@ -1636,7 +1635,7 @@ public class StorageManagerImpl implements StorageManager {
@Override
public VolumeVO allocVolume(CreateVolumeCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, ResourceAllocationException {
// FIXME: some of the scheduled event stuff might be missing here...
Account account = (Account)UserContext.current().getAccount();
Account account = UserContext.current().getAccount();
String accountName = cmd.getAccountName();
Long domainId = cmd.getDomainId();
Account targetAccount = null;
@ -1662,7 +1661,7 @@ public class StorageManagerImpl implements StorageManager {
// check if the volume can be created for the user
// Check that the resource limit for volumes won't be exceeded
if (_accountMgr.resourceLimitExceeded((Account)targetAccount, ResourceType.volume)) {
if (_accountMgr.resourceLimitExceeded(targetAccount, ResourceType.volume)) {
ResourceAllocationException rae = new ResourceAllocationException("Maximum number of volumes for account: " + targetAccount.getAccountName() + " has been exceeded.");
rae.setResourceType("volume");
throw rae;
@ -2426,7 +2425,7 @@ public class StorageManagerImpl implements StorageManager {
primaryStorage.setStatus(Status.ErrorInMaintenance);
_storagePoolDao.persist(primaryStorage);
return primaryStorage;
} catch (InternalErrorException e) {
} catch (CloudRuntimeException e) {
s_logger.warn("Error changing consoleproxy.restart back to false at end of cancel maintenance:"+e);
primaryStorage.setStatus(Status.ErrorInMaintenance);
_storagePoolDao.persist(primaryStorage);
@ -2458,7 +2457,7 @@ public class StorageManagerImpl implements StorageManager {
@Override
public boolean deleteVolume(DeleteVolumeCmd cmd) throws InvalidParameterValueException {
Account account = (Account) UserContext.current().getAccount();
Account account = UserContext.current().getAccount();
Long volumeId = cmd.getId();
boolean isAdmin;

View File

@ -117,7 +117,6 @@ import com.cloud.event.dao.EventDao;
import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.OperationTimedoutException;
import com.cloud.exception.PermissionDeniedException;
@ -358,7 +357,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
}
@Override
public void attachVolumeToVM(AttachVolumeCmd command) throws InternalErrorException, InvalidParameterValueException, PermissionDeniedException {
public void attachVolumeToVM(AttachVolumeCmd command) {
Long vmId = command.getVirtualMachineId();
Long volumeId = command.getId();
Long deviceId = command.getDeviceId();
@ -450,7 +449,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
VolumeVO rootVolumeOfVm = null;
List<VolumeVO> rootVolumesOfVm = _volsDao.findByInstanceAndType(vmId, VolumeType.ROOT);
if (rootVolumesOfVm.size() != 1) {
throw new InternalErrorException("The VM " + vm.getName() + " has more than one ROOT volume and is in an invalid state. Please contact Cloud Support.");
throw new CloudRuntimeException("The VM " + vm.getName() + " has more than one ROOT volume and is in an invalid state. Please contact Cloud Support.");
} else {
rootVolumeOfVm = rootVolumesOfVm.get(0);
}
@ -469,7 +468,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
volume = _storageMgr.createVolume(volume, vm, rootDiskTmplt, dcVO, pod, rootDiskPool.getClusterId(), svo, diskVO, new ArrayList<StoragePoolVO>(), volume.getSize(), rootDiskHyperType);
if (volume == null) {
throw new InternalErrorException("Failed to create volume when attaching it to VM: " + vm.getName());
throw new CloudRuntimeException("Failed to create volume when attaching it to VM: " + vm.getName());
}
}
@ -517,7 +516,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
} else {
poolType = "zone";
}
throw new InternalErrorException("There are no storage pools in the VM's " + poolType + " with all of the volume's tags (" + volumeDiskOffering.getTags() + ").");
throw new CloudRuntimeException("There are no storage pools in the VM's " + poolType + " with all of the volume's tags (" + volumeDiskOffering.getTags() + ").");
} else {
Long sourcePoolDcId = sourcePool.getDataCenterId();
Long sourcePoolPodId = sourcePool.getPodId();
@ -562,7 +561,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
try {
answer = (AttachVolumeAnswer)_agentMgr.send(hostId, cmd);
} catch (Exception e) {
throw new InternalErrorException(errorMsg + " due to: " + e.getMessage());
throw new CloudRuntimeException(errorMsg + " due to: " + e.getMessage());
}
}
@ -591,12 +590,12 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
if (details != null && !details.isEmpty())
errorMsg += "; " + details;
}
throw new InternalErrorException(errorMsg);
throw new CloudRuntimeException(errorMsg);
}
}
@Override
public VolumeResponse detachVolumeFromVM(DetachVolumeCmd cmmd) throws InternalErrorException, InvalidParameterValueException {
public VolumeResponse detachVolumeFromVM(DetachVolumeCmd cmmd) {
Account account = UserContext.current().getAccount();
if ((cmmd.getId() == null && cmmd.getDeviceId() == null && cmmd.getVirtualMachineId() == null) ||
(cmmd.getId() != null && (cmmd.getDeviceId() != null || cmmd.getVirtualMachineId() != null)) ||
@ -691,7 +690,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
try {
answer = _agentMgr.send(vm.getHostId(), cmd);
} catch (Exception e) {
throw new InternalErrorException(errorMsg + " due to: " + e.getMessage());
throw new CloudRuntimeException(errorMsg + " due to: " + e.getMessage());
}
}
@ -733,7 +732,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
errorMsg += "; " + details;
}
throw new InternalErrorException(errorMsg);
throw new CloudRuntimeException(errorMsg);
}
}
@ -1440,7 +1439,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
}
@Override
public HashMap<Long, VmStatsEntry> getVirtualMachineStatistics(long hostId, String hostName, List<Long> vmIds) throws InternalErrorException {
public HashMap<Long, VmStatsEntry> getVirtualMachineStatistics(long hostId, String hostName, List<Long> vmIds) throws CloudRuntimeException {
HashMap<Long, VmStatsEntry> vmStatsById = new HashMap<Long, VmStatsEntry>();
if (vmIds.isEmpty()) {
@ -1476,7 +1475,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
}
@DB
protected String acquireGuestIpAddress(long dcId, long accountId, UserVmVO userVm) throws InternalErrorException {
protected String acquireGuestIpAddress(long dcId, long accountId, UserVmVO userVm) throws CloudRuntimeException {
boolean routerLock = false;
DomainRouterVO router = _routerDao.findBy(accountId, dcId);
long routerId = router.getId();
@ -1485,7 +1484,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
txn.start();
router = _routerDao.acquire(routerId);
if (router == null) {
throw new InternalErrorException("Unable to lock up the router:" + routerId);
throw new CloudRuntimeException("Unable to lock up the router:" + routerId);
}
routerLock = true;
List<UserVmVO> userVms = _vmDao.listByAccountAndDataCenter(accountId, dcId);
@ -1559,7 +1558,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
}
@Override @DB
public UserVmVO createVirtualMachine(Long vmId, long userId, AccountVO account, DataCenterVO dc, ServiceOfferingVO offering, VMTemplateVO template, DiskOfferingVO diskOffering, String displayName, String userData, List<StoragePoolVO> avoids, long startEventId, long size) throws InternalErrorException, ResourceAllocationException {
public UserVmVO createVirtualMachine(Long vmId, long userId, AccountVO account, DataCenterVO dc, ServiceOfferingVO offering, VMTemplateVO template, DiskOfferingVO diskOffering, String displayName, String userData, List<StoragePoolVO> avoids, long startEventId, long size) throws CloudRuntimeException, ResourceAllocationException {
long accountId = account.getId();
long dataCenterId = dc.getId();
long serviceOfferingId = offering.getId();
@ -1574,7 +1573,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
DomainRouterVO router = _routerDao.findBy(accountId, dataCenterId, Role.DHCP_FIREWALL_LB_PASSWD_USERDATA);
if (router == null) {
throw new InternalErrorException("Cannot find a router for account (" + accountId + "/" +
throw new CloudRuntimeException("Cannot find a router for account (" + accountId + "/" +
account.getAccountName() + ") in " + dataCenterId);
}
@ -1583,7 +1582,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
if (template != null) {
guestOSId = template.getGuestOSId();
} else {
throw new InternalErrorException("No template or ISO was specified for the VM.");
throw new CloudRuntimeException("No template or ISO was specified for the VM.");
}
long numVolumes = -1;
Transaction txn = Transaction.currentTxn();
@ -1594,7 +1593,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
account = _accountDao.lock(accountId, true);
if (account == null) {
throw new InternalErrorException("Unable to lock up the account: " + accountId);
throw new CloudRuntimeException("Unable to lock up the account: " + accountId);
}
// First check that the maximum number of UserVMs for the given accountId will not be exceeded
@ -1886,7 +1885,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
// }
@Override @DB
public boolean recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationException, InternalErrorException {
public boolean recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationException, CloudRuntimeException {
Long vmId = cmd.getId();
Account accountHandle = UserContext.current().getAccount();
@ -1939,7 +1938,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
//if the account is deleted, throw error
if(account.getRemoved()!=null)
throw new InternalErrorException("Unable to recover VM as the account is deleted");
throw new CloudRuntimeException("Unable to recover VM as the account is deleted");
// First check that the maximum number of UserVMs for the given accountId will not be exceeded
if (_accountMgr.resourceLimitExceeded(account, ResourceType.user_vm)) {
@ -2609,7 +2608,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
}
@Override @DB
public VMTemplateVO createPrivateTemplate(CreateTemplateCmd command) throws InternalErrorException {
public VMTemplateVO createPrivateTemplate(CreateTemplateCmd command) throws CloudRuntimeException {
Long userId = UserContext.current().getUserId();
if (userId == null) {
userId = User.UID_SYSTEM;
@ -2638,7 +2637,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
s_logger.info(msg);
}
throw new InternalErrorException(msg);
throw new CloudRuntimeException(msg);
}
SnapshotCommand cmd = null;
@ -2759,7 +2758,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
@DB
@Override
public UserVmVO createDirectlyAttachedVM(Long vmId, long userId, AccountVO account, DataCenterVO dc, ServiceOfferingVO offering, VMTemplateVO template, DiskOfferingVO diskOffering, String displayName, String userData, List<StoragePoolVO> a, List<NetworkGroupVO> networkGroups, long startEventId, long size) throws InternalErrorException, ResourceAllocationException {
public UserVmVO createDirectlyAttachedVM(Long vmId, long userId, AccountVO account, DataCenterVO dc, ServiceOfferingVO offering, VMTemplateVO template, DiskOfferingVO diskOffering, String displayName, String userData, List<StoragePoolVO> a, List<NetworkGroupVO> networkGroups, long startEventId, long size) throws CloudRuntimeException, ResourceAllocationException {
long accountId = account.getId();
long dataCenterId = dc.getId();
@ -2780,7 +2779,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
if (template != null) {
guestOSId = template.getGuestOSId();
} else {
throw new InternalErrorException("No template or ISO was specified for the VM.");
throw new CloudRuntimeException("No template or ISO was specified for the VM.");
}
Transaction txn = Transaction.currentTxn();
@ -2788,7 +2787,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
account = _accountDao.lock(accountId, true);
if (account == null) {
throw new InternalErrorException("Unable to lock up the account: " + accountId);
throw new CloudRuntimeException("Unable to lock up the account: " + accountId);
}
// First check that the maximum number of UserVMs for the given accountId will not be exceeded
@ -2970,7 +2969,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
else
{
s_logger.debug("failed to create VM instance : " + name);
throw new InternalErrorException("We could not find a suitable pool for creating this directly attached vm");
throw new CloudRuntimeException("We could not find a suitable pool for creating this directly attached vm");
}
_accountMgr.decrementResourceCount(account.getId(), ResourceType.user_vm);
@ -3012,7 +3011,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
@DB
@Override
public UserVmVO createDirectlyAttachedVMExternal(Long vmId, long userId, AccountVO account, DataCenterVO dc, ServiceOfferingVO offering, VMTemplateVO template, DiskOfferingVO diskOffering, String displayName, String userData, List<StoragePoolVO> a, List<NetworkGroupVO> networkGroups, long startEventId, long size) throws InternalErrorException, ResourceAllocationException {
public UserVmVO createDirectlyAttachedVMExternal(Long vmId, long userId, AccountVO account, DataCenterVO dc, ServiceOfferingVO offering, VMTemplateVO template, DiskOfferingVO diskOffering, String displayName, String userData, List<StoragePoolVO> a, List<NetworkGroupVO> networkGroups, long startEventId, long size) throws CloudRuntimeException, ResourceAllocationException {
long accountId = account.getId();
long dataCenterId = dc.getId();
long serviceOfferingId = offering.getId();
@ -3032,7 +3031,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
if (template != null) {
guestOSId = template.getGuestOSId();
} else {
throw new InternalErrorException("No template or ISO was specified for the VM.");
throw new CloudRuntimeException("No template or ISO was specified for the VM.");
}
boolean isIso = Storage.ImageFormat.ISO.equals(template.getFormat());
@ -3045,7 +3044,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, VirtualM
account = _accountDao.lock(accountId, true);
if (account == null) {
throw new InternalErrorException("Unable to lock up the account: " + accountId);
throw new CloudRuntimeException("Unable to lock up the account: " + accountId);
}
// First check that the maximum number of UserVMs for the given accountId will not be exceeded

View File

@ -17,7 +17,6 @@
*/
package com.cloud.vm;
import com.cloud.api.ServerApiException;
import com.cloud.api.commands.AttachVolumeCmd;
import com.cloud.api.commands.CreateTemplateCmd;
import com.cloud.api.commands.CreateVMGroupCmd;
@ -47,7 +46,6 @@ import com.cloud.exception.StorageUnavailableException;
import com.cloud.storage.VMTemplateVO;
import com.cloud.uservm.UserVm;
import com.cloud.utils.component.Manager;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.exception.ExecutionException;
public interface UserVmService extends Manager {
@ -70,7 +68,7 @@ public interface UserVmService extends Manager {
* @param cmd - the command specifying volumeId and vmId
* @throws InternalErrorException, InvalidParameterValueException, PermissionDeniedException
*/
void attachVolumeToVM(AttachVolumeCmd cmd) throws InternalErrorException, InvalidParameterValueException, PermissionDeniedException;
void attachVolumeToVM(AttachVolumeCmd cmd);
/**
* Detaches the specified volume from the VM it is currently attached to.
@ -79,16 +77,16 @@ public interface UserVmService extends Manager {
* @throws InternalErrorException
* @throws InvalidParameterValueException
*/
VolumeResponse detachVolumeFromVM(DetachVolumeCmd cmmd) throws InternalErrorException, InvalidParameterValueException;
VolumeResponse detachVolumeFromVM(DetachVolumeCmd cmmd);
UserVmVO startVirtualMachine(StartVMCmd cmd) throws StorageUnavailableException, ExecutionException, ConcurrentOperationException;
UserVmVO stopVirtualMachine(StopVMCmd cmd) throws ServerApiException;
UserVmVO stopVirtualMachine(StopVMCmd cmd);
UserVm rebootVirtualMachine(RebootVMCmd cmd);
@Deprecated
OperationResponse executeRebootVM(RebootVMExecutor executor, VMOperationParam param);
boolean recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationException, InternalErrorException;
boolean recoverVirtualMachine(RecoverVMCmd cmd) throws ResourceAllocationException;
/**
* Create a template database record in preparation for creating a private template.
@ -97,7 +95,7 @@ public interface UserVmService extends Manager {
* @return the vm template object if successful, null otherwise
* @throws InvalidParameterValueException, PermissionDeniedException
*/
VMTemplateVO createPrivateTemplateRecord(CreateTemplateCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
VMTemplateVO createPrivateTemplateRecord(CreateTemplateCmd cmd);
/**
* Creates a private template from a snapshot of a VM
@ -105,21 +103,43 @@ public interface UserVmService extends Manager {
* @return a template if successfully created, null otherwise
* @throws InvalidParameterValueException
*/
VMTemplateVO createPrivateTemplate(CreateTemplateCmd cmd) throws InternalErrorException;
VMTemplateVO createPrivateTemplate(CreateTemplateCmd cmd);
void updateVirtualMachine(UpdateVMCmd cmd);
UserVm createVirtualMachine(DeployVm2Cmd cmd) throws InvalidParameterValueException, PermissionDeniedException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, CloudRuntimeException;
/**
* Creates a User VM in the database and returns the VM to the caller.
*
* @param cmd Command to deploy.
* @return UserVm object if successful.
*
* @throws InsufficientCapacityException if there is insufficient capacity to deploy the VM.
* @throws ConcurrentOperationException if there are multiple users working on the same VM or in the same environment.
* @throws ResourceUnavailableException if the resources required to deploy the VM is not currently available.
* @throws PermissionDeniedException if the caller doesn't have any access rights to the VM.
* @throws InvalidParameterValueException if the parameters are incorrect.
*/
UserVm createVirtualMachine(DeployVm2Cmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
/**
* Starts the virtual machine created from createVirtualMachine.
*
* @param cmd Command to deploy.
* @return UserVm object if successful.
* @throws InsufficientCapacityException if there is insufficient capacity to deploy the VM.
* @throws ConcurrentOperationException if there are multiple users working on the same VM.
* @throws ResourceUnavailableException if the resources required the deploy the VM is not currently available.
*/
UserVm startVirtualMachine(DeployVm2Cmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException;
UserVm startVirtualMachine(DeployVm2Cmd cmd) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException, CloudRuntimeException;
/**
* Creates a vm group.
* @param name - name of the group
* @param accountId - accountId
*/
InstanceGroupVO createVmGroup(CreateVMGroupCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
InstanceGroupVO createVmGroup(CreateVMGroupCmd cmd);
boolean deleteVmGroup(DeleteVMGroupCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
boolean deleteVmGroup(DeleteVMGroupCmd cmd);
/**
* upgrade the service offering of the virtual machine
@ -127,5 +147,5 @@ public interface UserVmService extends Manager {
* @return the vm
* @throws InvalidParameterValueException
*/
UserVm upgradeVirtualMachine(UpgradeVMCmd cmd) throws ServerApiException, InvalidParameterValueException;
UserVm upgradeVirtualMachine(UpgradeVMCmd cmd);
}