even more refactoring

This commit is contained in:
Alex Huang 2010-11-02 15:24:42 -07:00
parent d4b33f523d
commit 5fe5450abc
15 changed files with 350 additions and 162 deletions

View File

@ -33,10 +33,10 @@ updateResourceLimit=com.cloud.api.commands.UpdateResourceLimitCmd;3
listResourceLimits=com.cloud.api.commands.ListResourceLimitsCmd;15
#### VM commands
deployVirtualMachine=com.cloud.api.commands.DeployVMCmd;11
deployVirtualMachine=com.cloud.api.commands.DeployVm2Cmd;11
destroyVirtualMachine=com.cloud.api.commands.DestroyVMCmd;15
rebootVirtualMachine=com.cloud.api.commands.RebootVMCmd;15
startVirtualMachine=com.cloud.api.commands.StartVMCmd;15
startVirtualMachine=com.cloud.api.commands.StartVm2Cmd;15
stopVirtualMachine=com.cloud.api.commands.StopVMCmd;15
resetPasswordForVirtualMachine=com.cloud.api.commands.ResetVMPasswordCmd;15
changeServiceForVirtualMachine=com.cloud.api.commands.UpgradeVMCmd;15

View File

@ -129,9 +129,9 @@ import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand;
import com.cloud.agent.api.routing.DhcpEntryCommand;
import com.cloud.agent.api.routing.IPAssocCommand;
import com.cloud.agent.api.routing.LoadBalancerCfgCommand;
import com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand;
import com.cloud.agent.api.routing.SavePasswordCommand;
import com.cloud.agent.api.routing.SetFirewallRuleCommand;
import com.cloud.agent.api.routing.RemoteAccessVpnCfgCommand;
import com.cloud.agent.api.routing.VmDataCommand;
import com.cloud.agent.api.storage.CopyVolumeAnswer;
import com.cloud.agent.api.storage.CopyVolumeCommand;
@ -693,7 +693,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
vifr.qosAlgorithmType = "ratelimit";
vifr.qosAlgorithmParams = new HashMap<String, String>();
// convert mbs to kilobyte per second
vifr.qosAlgorithmParams.put("kbps", Integer.toString(nic.getNetworkRateMbps() * 128));
vifr.qosAlgorithmParams.put("kbps", Integer.toString(nic.getNetworkRateMbps() * 1024));
}
VIF vif = VIF.create(conn, vifr);
@ -2871,7 +2871,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR
vifr.qosAlgorithmType = "ratelimit";
vifr.qosAlgorithmParams = new HashMap<String, String>();
// convert mbs to kilobyte per second
vifr.qosAlgorithmParams.put("kbps", Integer.toString(rate * 128));
vifr.qosAlgorithmParams.put("kbps", Integer.toString(rate * 1024));
return VIF.create(conn, vifr);
}

View File

@ -0,0 +1,194 @@
/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.api.ApiConstants;
import com.cloud.api.ApiDBUtils;
import com.cloud.api.BaseAsyncCmd;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.response.UserVmResponse;
import com.cloud.event.EventTypes;
import com.cloud.offering.ServiceOffering;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VolumeVO;
import com.cloud.user.Account;
import com.cloud.uservm.UserVm;
import com.cloud.vm.InstanceGroupVO;
import com.cloud.vm.UserVmService;
@Implementation(method="startVirtualMachine", manager=UserVmService.class, description="Starts a virtual machine.")
public class StartVm2Cmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(StartVMCmd.class.getName());
private static final String s_name = "startvirtualmachineresponse";
/////////////////////////////////////////////////////
//////////////// API parameters /////////////////////
/////////////////////////////////////////////////////
@Parameter(name=ApiConstants.ID, type=CommandType.LONG, required=true, description="The ID of the virtual machine")
private Long id;
/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
public Long getId() {
return id;
}
/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public String getName() {
return s_name;
}
public static String getResultObjectName() {
return "virtualmachine";
}
@Override
public long getAccountId() {
UserVm vm = ApiDBUtils.findUserVmById(getId());
if (vm != null) {
return vm.getAccountId();
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
@Override
public String getEventType() {
return EventTypes.EVENT_VM_START;
}
@Override
public String getEventDescription() {
return "starting user vm: " + getId();
}
@Override @SuppressWarnings("unchecked")
public UserVmResponse getResponse() {
UserVm vm = (UserVm)getResponseObject();
UserVmResponse response = new UserVmResponse();
response.setId(vm.getId());
response.setName(vm.getName());
response.setCreated(vm.getCreated());
response.setZoneId(vm.getDataCenterId());
response.setZoneName(ApiDBUtils.findZoneById(vm.getDataCenterId()).getName());
response.setIpAddress(vm.getPrivateIpAddress());
response.setServiceOfferingId(vm.getServiceOfferingId());
response.setHaEnable(vm.isHaEnabled());
if (vm.getDisplayName() == null || vm.getDisplayName().length() == 0) {
response.setDisplayName(vm.getName());
} else {
response.setDisplayName(vm.getDisplayName());
}
InstanceGroupVO group = ApiDBUtils.findInstanceGroupForVM(vm.getId());
if (group != null) {
response.setGroup(group.getName());
response.setGroupId(group.getId());
}
if (vm.getState() != null) {
response.setState(vm.getState().toString());
}
Account acct = ApiDBUtils.findAccountById(vm.getAccountId());
if (acct != null) {
response.setAccountName(acct.getAccountName());
response.setDomainId(acct.getDomainId());
response.setDomainName(ApiDBUtils.findDomainById(acct.getDomainId()).getName());
}
if (BaseCmd.isAdmin(acct.getType()) && (vm.getHostId() != null)) {
response.setHostName(ApiDBUtils.findHostById(vm.getHostId()).getName());
response.setHostId(vm.getHostId());
}
String templateName = "ISO Boot";
boolean templatePasswordEnabled = false;
String templateDisplayText = "ISO Boot";
VMTemplateVO template = ApiDBUtils.findTemplateById(vm.getTemplateId());
if (template != null) {
templateName = template.getName();
templatePasswordEnabled = template.getEnablePassword();
templateDisplayText = template.getDisplayText();
if (templateDisplayText == null) {
templateDisplayText = templateName;
}
}
response.setTemplateId(vm.getTemplateId());
response.setTemplateName(templateName);
response.setTemplateDisplayText(templateDisplayText);
response.setPasswordEnabled(templatePasswordEnabled);
if (templatePasswordEnabled) {
response.setPassword(null); // FIXME: Where should password come from? In the old framework, password was always passed
// in to composeResultObject() as null, so that behavior is preserved...
} else {
response.setPassword("");
}
String isoName = null;
if (vm.getIsoId() != null) {
VMTemplateVO iso = ApiDBUtils.findTemplateById(vm.getIsoId().longValue());
if (iso != null) {
isoName = iso.getName();
}
}
response.setIsoId(vm.getIsoId());
response.setIsoName(isoName);
ServiceOffering offering = ApiDBUtils.findServiceOfferingById(vm.getServiceOfferingId());
response.setServiceOfferingId(vm.getServiceOfferingId());
response.setServiceOfferingName(offering.getName());
response.setCpuNumber(offering.getCpu());
response.setCpuSpeed(offering.getSpeed());
response.setMemory(offering.getRamSize());
VolumeVO rootVolume = ApiDBUtils.findRootVolume(vm.getId());
if (rootVolume != null) {
response.setRootDeviceId(rootVolume.getDeviceId());
StoragePoolVO storagePool = ApiDBUtils.findStoragePoolById(rootVolume.getPoolId());
response.setRootDeviceType(storagePool.getPoolType().toString());
}
response.setGuestOsId(vm.getGuestOSId());
//Network groups
response.setNetworkGroupList(ApiDBUtils.getNetworkGroupsNamesForVm(vm.getId()));
response.setResponseName(getName());
//response.setResponseName(getResultObjectName());
return response;
}
}

View File

@ -87,7 +87,6 @@ import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InsufficientNetworkCapacityException;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.OperationTimedoutException;
@ -2426,7 +2425,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
}
@Override @DB
public boolean deleteIpForwardingRule(DeleteIPForwardingRuleCmd cmd) throws PermissionDeniedException, InvalidParameterValueException {
public boolean deleteIpForwardingRule(DeleteIPForwardingRuleCmd cmd) {
Long ruleId = cmd.getId();
Long userId = UserContext.current().getUserId();
Account account = UserContext.current().getAccount();
@ -2500,7 +2499,7 @@ public class NetworkManagerImpl implements NetworkManager, DomainRouterService {
throw new InvalidParameterValueException("No such rule");
}
} else {
throw new InternalErrorException("Multiple matches. Please contact support");
throw new CloudRuntimeException("Multiple matches. Please contact support");
}
fwRule.setEnabled(false);
success = updateFirewallRule(fwRule, null, null);

View File

@ -203,7 +203,7 @@ public interface ManagementServer {
* @return UserAccount object
* @throws InvalidParameterValueException, PermissionDeniedException
*/
UserAccount disableUser(DisableUserCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;;
UserAccount disableUser(DisableUserCmd cmd);
/**
* Disables an account by accountId
@ -218,7 +218,7 @@ public interface ManagementServer {
* @return true if disable was successful, false otherwise
* @throws InvalidParameterValueException, PermissionDeniedException
*/
AccountVO disableAccount(DisableAccountCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
AccountVO disableAccount(DisableAccountCmd cmd);
/**
* Enables an account by accountId
@ -226,7 +226,7 @@ public interface ManagementServer {
* @return account object
* @throws InvalidParameterValueException, PermissionDeniedException
*/
AccountVO enableAccount(EnableAccountCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
AccountVO enableAccount(EnableAccountCmd cmd);
/**
* Locks an account by accountId. A locked account cannot access the API, but will still have running VMs/IP addresses allocated/etc.
@ -242,7 +242,7 @@ public interface ManagementServer {
* @throws InvalidParameterValueException, PermissionDeniedException
*/
AccountVO updateAccount(UpdateAccountCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
AccountVO updateAccount(UpdateAccountCmd cmd);
/**
* Enables a user
@ -250,7 +250,7 @@ public interface ManagementServer {
* @return UserAccount object
* @throws InvalidParameterValueException, PermissionDeniedException
*/
UserAccount enableUser(EnableUserCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
UserAccount enableUser(EnableUserCmd cmd);
/**
* Locks a user by userId. A locked user cannot access the API, but will still have running VMs/IP addresses allocated/etc.
@ -320,7 +320,7 @@ public interface ManagementServer {
* @param cmd
* @return List of Vlans
*/
List<VlanVO> searchForVlans(ListVlanIpRangesCmd cmd) throws InvalidParameterValueException;
List<VlanVO> searchForVlans(ListVlanIpRangesCmd cmd);
/**
* If the specified VLAN is associated with the pod, returns the pod ID. Else, returns null.
@ -383,7 +383,7 @@ public interface ManagementServer {
* @throws StorageUnavailableException
* @throws ConcurrentOperationException
*/
UserVm deployVirtualMachine(DeployVMCmd cmd) throws ResourceAllocationException, InvalidParameterValueException, InternalErrorException, InsufficientStorageCapacityException, PermissionDeniedException, ExecutionException, StorageUnavailableException, ConcurrentOperationException;
UserVm deployVirtualMachine(DeployVMCmd cmd) throws ResourceAllocationException, InsufficientStorageCapacityException, ExecutionException, StorageUnavailableException, ConcurrentOperationException;
/**
* Finds a domain router by user and data center
@ -449,7 +449,7 @@ public interface ManagementServer {
* @param cmd
* @return List of UserAccounts
*/
List<UserAccountVO> searchForUsers(ListUsersCmd cmd) throws PermissionDeniedException;
List<UserAccountVO> searchForUsers(ListUsersCmd cmd);
/**
* Searches for Service Offerings by the specified search criteria
@ -457,7 +457,7 @@ public interface ManagementServer {
* @param cmd
* @return List of ServiceOfferings
*/
List<ServiceOfferingVO> searchForServiceOfferings(ListServiceOfferingsCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
List<ServiceOfferingVO> searchForServiceOfferings(ListServiceOfferingsCmd cmd);
/**
* Searches for Clusters by the specified search criteria
@ -521,7 +521,7 @@ public interface ManagementServer {
* @return Message to display to user
* @throws InvalidParameterValueException 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);
/**
* Finds a user by their user ID.
@ -592,8 +592,8 @@ public interface ManagementServer {
* @return updated template
* @throws InvalidParameterValueException, PermissionDeniedException
*/
VMTemplateVO updateTemplate(UpdateIsoCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
VMTemplateVO updateTemplate(UpdateTemplateCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
VMTemplateVO updateTemplate(UpdateIsoCmd cmd);
VMTemplateVO updateTemplate(UpdateTemplateCmd cmd);
/**
* Copies a template from one secondary storage server to another
@ -604,7 +604,7 @@ public interface ManagementServer {
* @return true if success
* @throws InternalErrorException
*/
boolean copyTemplate(long userId, long templateId, long sourceZoneId, long destZoneId, long startEventId) throws InternalErrorException;
boolean copyTemplate(long userId, long templateId, long sourceZoneId, long destZoneId, long startEventId);
/**
* Finds a template by the specified ID.
@ -627,14 +627,14 @@ public interface ManagementServer {
* @param cmd the API command that wraps the search criteria
* @return List of UserVMs.
*/
List<UserVmVO> searchForUserVMs(ListVMsCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
List<UserVmVO> searchForUserVMs(ListVMsCmd cmd);
/**
* Update an existing port forwarding rule on the given public IP / public port for the given protocol
* @param cmd - the UpdateIPForwardingRuleCmd command that wraps publicIp, privateIp, publicPort, privatePort, protocol of the rule to update
* @return the new firewall rule if updated, null if no rule on public IP / public port of that protocol could be found
*/
FirewallRuleVO updatePortForwardingRule(UpdateIPForwardingRuleCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
FirewallRuleVO updatePortForwardingRule(UpdateIPForwardingRuleCmd cmd);
/**
* Find a firewall rule by rule id
@ -656,7 +656,7 @@ public interface ManagementServer {
* @param c
* @return List of Events.
*/
List<EventVO> searchForEvents(ListEventsCmd c) throws PermissionDeniedException, InvalidParameterValueException;
List<EventVO> searchForEvents(ListEventsCmd c);
List<EventVO> listPendingEvents(int entryTime, int duration);
@ -679,7 +679,7 @@ public interface ManagementServer {
* @param cmd
* @return List of DomainRouters.
*/
List<DomainRouterVO> searchForRouters(ListRoutersCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
List<DomainRouterVO> searchForRouters(ListRoutersCmd cmd);
List<ConsoleProxyVO> searchForConsoleProxy(Criteria c);
@ -689,7 +689,7 @@ public interface ManagementServer {
* @param cmd
* @return List of Volumes.
*/
List<VolumeVO> searchForVolumes(ListVolumesCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
List<VolumeVO> searchForVolumes(ListVolumesCmd cmd);
/**
* Finds a pod by the specified ID.
@ -711,7 +711,7 @@ public interface ManagementServer {
* @param cmd the command that wraps the search criteria
* @return List of IPAddresses
*/
List<IPAddressVO> searchForIPAddresses(ListPublicIpAddressesCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
List<IPAddressVO> searchForIPAddresses(ListPublicIpAddressesCmd cmd);
/**
* Obtains a list of billing records by the specified search criteria.
@ -752,14 +752,14 @@ public interface ManagementServer {
void logoutUser(Long userId);
ConsoleProxyInfo getConsoleProxy(long dataCenterId, long userVmId);
ConsoleProxyVO startConsoleProxy(long instanceId, long startEventId) throws InternalErrorException;
ConsoleProxyVO startConsoleProxy(long instanceId, long startEventId);
ConsoleProxyVO stopConsoleProxy(long instanceId, long startEventId);
ConsoleProxyVO rebootConsoleProxy(long instanceId, long startEventId);
String getConsoleAccessUrlRoot(long vmId);
ConsoleProxyVO findConsoleProxyById(long instanceId);
VMInstanceVO findSystemVMById(long instanceId);
VMInstanceVO stopSystemVM(StopSystemVmCmd cmd);
VMInstanceVO startSystemVM(StartSystemVMCmd cmd) throws InternalErrorException;
VMInstanceVO startSystemVM(StartSystemVMCmd cmd);
VMInstanceVO rebootSystemVM(RebootSystemVmCmd cmd);
/**
@ -782,15 +782,15 @@ public interface ManagementServer {
* in a command object.
* @return list of domains owned by the given user
*/
List<DomainVO> searchForDomains(ListDomainsCmd c) throws PermissionDeniedException;
List<DomainVO> searchForDomains(ListDomainsCmd c);
List<DomainVO> searchForDomainChildren(ListDomainChildrenCmd cmd) throws PermissionDeniedException;
List<DomainVO> searchForDomainChildren(ListDomainChildrenCmd cmd);
/**
* create a new domain
* @param command - the create command defining the name to use and the id of the parent domain under which to create the new domain.
*/
DomainVO createDomain(CreateDomainCmd command) throws InvalidParameterValueException, PermissionDeniedException;
DomainVO createDomain(CreateDomainCmd command);
/**
* delete a domain with the given domainId
@ -799,7 +799,7 @@ public interface ManagementServer {
* - ownerId
* - cleanup: whether or not to delete all accounts/VMs/sub-domains when deleting the domain
*/
boolean deleteDomain(DeleteDomainCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
boolean deleteDomain(DeleteDomainCmd cmd);
/**
* update an existing domain
@ -807,7 +807,7 @@ public interface ManagementServer {
* @return Domain object if the command succeeded
* @throws InvalidParameterValueException, PermissionDeniedException
*/
DomainVO updateDomain(UpdateDomainCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
DomainVO updateDomain(UpdateDomainCmd cmd);
/**
* find the domain Id associated with the given account
@ -927,7 +927,7 @@ public interface ManagementServer {
* @throws InvalidParameterValueException
* @throws PermissionDeniedException
*/
List<SnapshotVO> listSnapshots(ListSnapshotsCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
List<SnapshotVO> listSnapshots(ListSnapshotsCmd cmd);
/**
* Finds a diskOffering by the specified ID.
@ -947,7 +947,7 @@ public interface ManagementServer {
* @param cmd the command wrapping the search criteria (template id)
* @return list of account names that have been granted permission to launch instances from the template
*/
List<String> listTemplatePermissions(ListTemplateOrIsoPermissionsCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
List<String> listTemplatePermissions(ListTemplateOrIsoPermissionsCmd cmd);
/**
* List private templates for which the given account/domain has been granted permission to launch instances
@ -961,14 +961,14 @@ public interface ManagementServer {
* @param cmd The command that wraps the (optional) templateId, name, keyword, templateFilter, bootable, account, and zoneId parameters.
* @return list of ISOs
*/
List<VMTemplateVO> listIsos(ListIsosCmd cmd) throws IllegalArgumentException, InvalidParameterValueException;
List<VMTemplateVO> listIsos(ListIsosCmd cmd);
/**
* List templates that match the specified criteria.
* @param cmd The command that wraps the (optional) templateId, name, keyword, templateFilter, bootable, account, and zoneId parameters.
* @return list of ISOs
*/
List<VMTemplateVO> listTemplates(ListTemplatesCmd cmd) throws IllegalArgumentException, InvalidParameterValueException;
List<VMTemplateVO> listTemplates(ListTemplatesCmd cmd);
/**
* Search for disk offerings based on search criteria
@ -982,7 +982,7 @@ public interface ManagementServer {
* @param jobId async-call job id
* @return async-call result object
*/
AsyncJobResult queryAsyncJobResult(long jobId) throws PermissionDeniedException;
AsyncJobResult queryAsyncJobResult(long jobId);
/**
* Queries for the status or final result of an async job.
@ -990,7 +990,7 @@ public interface ManagementServer {
* @return an async-call result object
* @throws PermissionDeniedException
*/
AsyncJobResult queryAsyncJobResult(QueryAsyncJobResultCmd cmd) throws PermissionDeniedException;
AsyncJobResult queryAsyncJobResult(QueryAsyncJobResultCmd cmd);
AsyncJobVO findAsyncJobById(long jobId);
@ -999,7 +999,7 @@ public interface ManagementServer {
* @param cmd the command specifying the account and start date parameters
* @return the list of async jobs that match the criteria
*/
List<AsyncJobVO> searchForAsyncJobs(ListAsyncJobsCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
List<AsyncJobVO> searchForAsyncJobs(ListAsyncJobsCmd cmd);
LoadBalancerVO findLoadBalancer(Long accountId, String name);
LoadBalancerVO findLoadBalancerById(long loadBalancerId);
@ -1009,7 +1009,7 @@ public interface ManagementServer {
* @param cmd
* @return list of vm instances that have been or can be applied to a load balancer
*/
List<UserVmVO> listLoadBalancerInstances(ListLoadBalancerRuleInstancesCmd cmd) throws PermissionDeniedException;
List<UserVmVO> listLoadBalancerInstances(ListLoadBalancerRuleInstancesCmd cmd);
/**
* List load balancer rules based on the given criteria
@ -1017,7 +1017,7 @@ public interface ManagementServer {
* by id, name, public ip, and vm instance id
* @return list of load balancers that match the criteria
*/
List<LoadBalancerVO> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
List<LoadBalancerVO> searchForLoadBalancers(ListLoadBalancerRulesCmd cmd);
String[] getApiConfig();
StoragePoolVO findPoolById(Long id);
@ -1054,7 +1054,7 @@ public interface ManagementServer {
* @param userId -- id for the user
* @return -- ArrayList of <CloudId+Signature>
*/
ArrayList<String> getCloudIdentifierResponse(GetCloudIdentifierCmd cmd) throws InvalidParameterValueException;
ArrayList<String> getCloudIdentifierResponse(GetCloudIdentifierCmd cmd);
NetworkGroupVO findNetworkGroupByName(Long accountId, String groupName);
@ -1076,9 +1076,9 @@ public interface ManagementServer {
boolean checkLocalStorageConfigVal();
UserAccount updateUser(UpdateUserCmd cmd) throws InvalidParameterValueException;
boolean updateTemplatePermissions(UpdateTemplatePermissionsCmd cmd)throws InvalidParameterValueException, PermissionDeniedException,InternalErrorException;
boolean updateTemplatePermissions(UpdateIsoPermissionsCmd cmd)throws InvalidParameterValueException, PermissionDeniedException,InternalErrorException;
UserAccount updateUser(UpdateUserCmd cmd);
boolean updateTemplatePermissions(UpdateTemplatePermissionsCmd cmd);
boolean updateTemplatePermissions(UpdateIsoPermissionsCmd cmd);
String[] createApiKeyAndSecretKey(RegisterCmd cmd);
VolumeVO findVolumeByInstanceAndDeviceId(long instanceId, long deviceId);
@ -1111,7 +1111,7 @@ public interface ManagementServer {
* @throws PermissionDeniedException
*
*/
Long extractVolume(ExtractVolumeCmd cmd) throws URISyntaxException, InternalErrorException, PermissionDeniedException;
Long extractVolume(ExtractVolumeCmd cmd) throws URISyntaxException;
/**
* return an array of available hypervisors
@ -1126,7 +1126,7 @@ public interface ManagementServer {
* @return -- returns a string on success
* @throws ServerApiException -- even if one of the console proxy patching fails, we throw back this exception
*/
String uploadCertificate(UploadCustomCertificateCmd cmd) throws ServerApiException;
String uploadCertificate(UploadCustomCertificateCmd cmd);
public List<RemoteAccessVpnVO> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
public List<RemoteAccessVpnVO> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd);
}

View File

@ -186,7 +186,6 @@ import com.cloud.exception.AgentUnavailableException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientStorageCapacityException;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ManagementServerException;
import com.cloud.exception.OperationTimedoutException;
@ -933,9 +932,9 @@ public class ManagementServerImpl implements ManagementServer {
List<VMTemplateVO> userTemplates = _templateDao.listByAccountId(accountId);
boolean allTemplatesDeleted = true;
for (VMTemplateVO template : userTemplates) {
try {
allTemplatesDeleted = _tmpltMgr.delete(userId, template.getId(), null);
} catch (InternalErrorException e) {
try {
allTemplatesDeleted = _tmpltMgr.delete(userId, template.getId(), null);
} catch (Exception e) {
s_logger.warn("Failed to delete template while removing account: " + template.getName() + " due to: " + e.getMessage());
allTemplatesDeleted = false;
}
@ -1508,8 +1507,8 @@ public class ManagementServerImpl implements ManagementServer {
}
private UserVm deployVirtualMachineImpl(long userId, long accountId, long dataCenterId, long serviceOfferingId, long templateId, Long diskOfferingId,
String domain, String password, String displayName, String group, String userData, String [] networkGroups, long startEventId, long size) throws ResourceAllocationException, InvalidParameterValueException, InternalErrorException,
InsufficientStorageCapacityException, PermissionDeniedException, ExecutionException, StorageUnavailableException, ConcurrentOperationException {
String domain, String password, String displayName, String group, String userData, String [] networkGroups, long startEventId, long size) throws ResourceAllocationException,
InsufficientStorageCapacityException, ExecutionException, StorageUnavailableException, ConcurrentOperationException {
EventUtils.saveStartedEvent(userId, accountId, EventTypes.EVENT_VM_CREATE, "Deploying Vm", startEventId);
@ -1605,7 +1604,7 @@ public class ManagementServerImpl implements ManagementServer {
}
if (externalIp == null) {
throw new InternalErrorException("Unable to allocate a source nat ip address");
throw new CloudRuntimeException("Unable to allocate a source nat ip address");
}
if (s_logger.isDebugEnabled()) {
@ -1631,16 +1630,16 @@ public class ManagementServerImpl implements ManagementServer {
if (group != null) {
boolean addToGroup = _vmMgr.addInstanceToGroup(Long.valueOf(vmId), group);
if (!addToGroup) {
throw new InternalErrorException("Unable to assing Vm to the group " + group);
throw new CloudRuntimeException("Unable to assing Vm to the group " + group);
}
}
} catch (Exception ex) {
throw new InternalErrorException("Unable to assing Vm to the group " + group);
throw new CloudRuntimeException("Unable to assing Vm to the group " + group);
}
if (created == null) {
throw new InternalErrorException("Unable to create VM for account (" + accountId + "): " + account.getAccountName());
throw new CloudRuntimeException("Unable to create VM for account (" + accountId + "): " + account.getAccountName());
}
if (s_logger.isDebugEnabled()) {
@ -1726,7 +1725,7 @@ public class ManagementServerImpl implements ManagementServer {
throw new ConcurrentOperationException(concurrentOperationExceptionMsg);
}
else{
throw new InternalErrorException("Unable to start the VM " + created.getId() + "-" + created.getName());
throw new CloudRuntimeException("Unable to start the VM " + created.getId() + "-" + created.getName());
}
} else {
@ -1752,8 +1751,8 @@ public class ManagementServerImpl implements ManagementServer {
}
@Override
public UserVm deployVirtualMachine(DeployVMCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, ResourceAllocationException,
InternalErrorException, InsufficientStorageCapacityException, ExecutionException,
public UserVm deployVirtualMachine(DeployVMCmd cmd) throws ResourceAllocationException,
InsufficientStorageCapacityException, ExecutionException,
StorageUnavailableException, ConcurrentOperationException {
Account ctxAccount = UserContext.current().getAccount();
Long userId = UserContext.current().getUserId();
@ -1920,11 +1919,6 @@ public class ManagementServerImpl implements ManagementServer {
s_logger.debug("Unable to deploy VM: " + e.getMessage());
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: VM_INVALID_PARAM_ERROR", null, eventId);
throw e;
} catch (InternalErrorException e) {
if(s_logger.isDebugEnabled())
s_logger.debug("Unable to deploy VM: " + e.getMessage());
EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, EventTypes.EVENT_VM_CREATE, "Unable to deploy VM: INTERNAL_ERROR", null, eventId);
throw e;
} catch (InsufficientStorageCapacityException e) {
if(s_logger.isDebugEnabled())
s_logger.debug("Unable to deploy VM: " + e.getMessage());
@ -2925,7 +2919,7 @@ public class ManagementServerImpl implements ManagementServer {
}
@Override
public boolean copyTemplate(long userId, long templateId, long sourceZoneId, long destZoneId, long startEventId) throws InternalErrorException {
public boolean copyTemplate(long userId, long templateId, long sourceZoneId, long destZoneId, long startEventId) {
boolean success = false;
try {
success = _tmpltMgr.copy(userId, templateId, sourceZoneId, destZoneId, startEventId);
@ -3925,7 +3919,7 @@ public class ManagementServerImpl implements ManagementServer {
}
@Override
public ConsoleProxyVO startConsoleProxy(long instanceId, long startEventId) throws InternalErrorException {
public ConsoleProxyVO startConsoleProxy(long instanceId, long startEventId) {
return _consoleProxyMgr.startProxy(instanceId, startEventId);
}
@ -4463,20 +4457,17 @@ public class ManagementServerImpl implements ManagementServer {
}
@Override @DB
public boolean updateTemplatePermissions(UpdateTemplatePermissionsCmd cmd) throws InvalidParameterValueException,
PermissionDeniedException, InternalErrorException {
public boolean updateTemplatePermissions(UpdateTemplatePermissionsCmd cmd) {
return updateTemplateOrIsoPermissions(cmd);
}
@Override @DB
public boolean updateTemplatePermissions(UpdateIsoPermissionsCmd cmd) throws InvalidParameterValueException,
PermissionDeniedException, InternalErrorException {
public boolean updateTemplatePermissions(UpdateIsoPermissionsCmd cmd) {
return updateTemplateOrIsoPermissions(cmd);
}
@DB
protected boolean updateTemplateOrIsoPermissions(UpdateTemplateOrIsoPermissionsCmd cmd) throws InvalidParameterValueException,
PermissionDeniedException, InternalErrorException {
protected boolean updateTemplateOrIsoPermissions(UpdateTemplateOrIsoPermissionsCmd cmd) {
Transaction txn = Transaction.currentTxn();
//Input validation
@ -4600,18 +4591,14 @@ public class ManagementServerImpl implements ManagementServer {
}
txn.commit();
} else if ("remove".equalsIgnoreCase(operation)) {
try {
List<Long> accountIds = new ArrayList<Long>();
for (String accountName : accountNames) {
Account permittedAccount = _accountDao.findActiveAccount(accountName, domainId);
if (permittedAccount != null) {
accountIds.add(permittedAccount.getId());
}
List<Long> accountIds = new ArrayList<Long>();
for (String accountName : accountNames) {
Account permittedAccount = _accountDao.findActiveAccount(accountName, domainId);
if (permittedAccount != null) {
accountIds.add(permittedAccount.getId());
}
_launchPermissionDao.removePermissions(id, accountIds);
} catch (CloudRuntimeException ex) {
throw new InternalErrorException("Internal error removing launch permissions for template " + template.getName());
}
_launchPermissionDao.removePermissions(id, accountIds);
} else if ("reset".equalsIgnoreCase(operation)) {
// do we care whether the owning account is an admin? if the
// owner is an admin, will we still set public to false?
@ -5224,7 +5211,7 @@ public class ManagementServerImpl implements ManagementServer {
return _domainDao.isChildDomain(parentId, childId);
}
public SecondaryStorageVmVO startSecondaryStorageVm(long instanceId, long startEventId) throws InternalErrorException {
public SecondaryStorageVmVO startSecondaryStorageVm(long instanceId, long startEventId) {
return _secStorageVmMgr.startSecStorageVm(instanceId, startEventId);
}
@ -5327,9 +5314,9 @@ public class ManagementServerImpl implements ManagementServer {
}
@Override
public VMInstanceVO startSystemVM(StartSystemVMCmd cmd) throws InternalErrorException {
public VMInstanceVO startSystemVM(StartSystemVMCmd cmd) {
//verify input
//verify inputf
Long id = cmd.getId();
VMInstanceVO systemVm = _vmInstanceDao.findByIdTypes(id, VirtualMachine.Type.ConsoleProxy, VirtualMachine.Type.SecondaryStorageVm);
@ -5635,7 +5622,7 @@ public class ManagementServerImpl implements ManagementServer {
}
@Override
public Long extractVolume(ExtractVolumeCmd cmd) throws URISyntaxException, InternalErrorException, PermissionDeniedException {
public Long extractVolume(ExtractVolumeCmd cmd) throws URISyntaxException {
Long volumeId = cmd.getId();
String url = cmd.getUrl();
Long zoneId = cmd.getZoneId();
@ -5747,7 +5734,7 @@ public class ManagementServerImpl implements ManagementServer {
_uploadDao.update(uploadJob.getId(), uploadJob);
EventUtils.saveEvent(userId, accountId, EventTypes.EVENT_VOLUME_UPLOAD, errorString);
throw new InternalErrorException(errorString);
throw new CloudRuntimeException(errorString);
}
String volumeLocalPath = "volumes/"+volume.getId()+"/"+cvAnswer.getVolumePath()+".vhd";

View File

@ -24,7 +24,6 @@ import javax.servlet.http.HttpServlet;
import org.apache.log4j.Logger;
import com.cloud.api.ApiServer;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.server.ConfigurationServer;
import com.cloud.server.ManagementServer;
@ -52,9 +51,6 @@ public class CloudStartupServlet extends HttpServlet {
} catch (InvalidParameterValueException ipve) {
s_logger.error("Exception starting management server ", ipve);
throw new ServletException (ipve.getMessage());
} catch (InternalErrorException iee) {
s_logger.error("Exception starting management server ", iee);
throw new ServletException (iee.getMessage());
} catch (Exception e) {
s_logger.error("Exception starting management server ", e);
throw new ServletException (e.getMessage());

View File

@ -26,9 +26,7 @@ import com.cloud.api.commands.DeleteSnapshotCmd;
import com.cloud.api.commands.DeleteSnapshotPoliciesCmd;
import com.cloud.api.commands.ListRecurringSnapshotScheduleCmd;
import com.cloud.api.commands.ListSnapshotPoliciesCmd;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.storage.SnapshotPolicyVO;
import com.cloud.storage.SnapshotScheduleVO;
@ -52,34 +50,30 @@ public interface SnapshotManager extends Manager {
* Create a snapshot of a volume
* @param cmd the API command wrapping the parameters for creating the snapshot (mainly volumeId)
* @return the Snapshot that was created
* @throws InternalErrorException
*/
SnapshotVO createSnapshotImpl(long volumeId, long policyId) throws InvalidParameterValueException, ResourceAllocationException, InternalErrorException;
SnapshotVO createSnapshotImpl(long volumeId, long policyId) throws ResourceAllocationException;
/**
* Create a snapshot of a volume
* @param cmd the API command wrapping the parameters for creating the snapshot (mainly volumeId)
* @return the Snapshot that was created
* @throws InternalErrorException
*/
SnapshotVO createSnapshotDB(CreateSnapshotCmd cmd) throws InvalidParameterValueException, ResourceAllocationException, InternalErrorException;
SnapshotVO createSnapshotDB(CreateSnapshotCmd cmd) throws ResourceAllocationException;
/**
* Create a snapshot of a volume
* @param cmd the API command wrapping the parameters for creating the snapshot (mainly volumeId)
* @return the Snapshot that was created
* @throws InternalErrorException
*/
SnapshotVO createSnapshot(CreateSnapshotCmd cmd) throws InvalidParameterValueException, ResourceAllocationException, InternalErrorException;
SnapshotVO createSnapshot(CreateSnapshotCmd cmd) throws InvalidParameterValueException, ResourceAllocationException;
/**
* An internal method for creating recurring snapshots. The command is not exposed through the API but is used to hook into the async framework.
* @param cmd the command specifying volumeId and policyId
* @return the created snapshot
* @throws InternalErrorException
* @throws ResourceAllocationException
*/
SnapshotVO createSnapshotInternal(CreateSnapshotInternalCmd cmd) throws InternalErrorException, ResourceAllocationException;
SnapshotVO createSnapshotInternal(CreateSnapshotInternalCmd cmd) throws ResourceAllocationException;
/**
* After successfully creating a snapshot of a volume, copy the snapshot to the secondary storage for
@ -121,7 +115,7 @@ public interface SnapshotManager extends Manager {
* @param cmd the command that
* @return the newly created snapshot policy if success, null otherwise
*/
SnapshotPolicyVO createPolicy(CreateSnapshotPolicyCmd cmd) throws InvalidParameterValueException;
SnapshotPolicyVO createPolicy(CreateSnapshotPolicyCmd cmd);
/**
* Deletes snapshot scheduling policy. Delete will fail if this policy is assigned to one or more volumes
@ -144,7 +138,7 @@ public interface SnapshotManager extends Manager {
* @param cmd the command that specifies the volume criteria
* @return list of snapshot policies
*/
List<SnapshotPolicyVO> listPoliciesforVolume(ListSnapshotPoliciesCmd cmd) throws InvalidParameterValueException;
List<SnapshotPolicyVO> listPoliciesforVolume(ListSnapshotPoliciesCmd cmd);
/**
* List all policies to which a specified snapshot belongs. For ex: A snapshot
@ -164,7 +158,7 @@ public interface SnapshotManager extends Manager {
* @param cmd the command wrapping the volumeId (volume for which the snapshots are required) and policyId (to show snapshots for only this policy).
* @return The list of snapshot schedules.
*/
public List<SnapshotScheduleVO> findRecurringSnapshotSchedule(ListRecurringSnapshotScheduleCmd cmd) throws InvalidParameterValueException, PermissionDeniedException;
public List<SnapshotScheduleVO> findRecurringSnapshotSchedule(ListRecurringSnapshotScheduleCmd cmd);
SnapshotPolicyVO getPolicyForVolumeByInterval(long volumeId, short interval);
@ -181,7 +175,7 @@ public interface SnapshotManager extends Manager {
void validateSnapshot(Long userId, SnapshotVO snapshot);
boolean deleteSnapshotPolicies(DeleteSnapshotPoliciesCmd cmd) throws InvalidParameterValueException;
boolean deleteSnapshotPolicies(DeleteSnapshotPoliciesCmd cmd);
ImageFormat getImageFormat(Long volumeId);
SnapshotPolicyVO getPolicyForVolume(long volumeId);

View File

@ -57,7 +57,6 @@ import com.cloud.event.EventState;
import com.cloud.event.EventTypes;
import com.cloud.event.EventVO;
import com.cloud.event.dao.EventDao;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
@ -186,7 +185,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
}
private boolean shouldRunSnapshot(long userId, VolumeVO volume, long policyId)
throws InvalidParameterValueException, ResourceAllocationException {
throws ResourceAllocationException {
boolean runSnap = isVolumeDirty(volume.getId(), policyId);
/*
@ -207,7 +206,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
}
@Override
public SnapshotVO createSnapshotDB(CreateSnapshotCmd cmd) throws InvalidParameterValueException, ResourceAllocationException, InternalErrorException {
public SnapshotVO createSnapshotDB(CreateSnapshotCmd cmd) throws ResourceAllocationException {
// FIXME: When a valid snapshot is returned, the snapshot must have been created on the storage server side so that the caller
// knows it is safe to once again resume normal operations on the volume in question.
Long volumeId = cmd.getVolumeId();
@ -236,7 +235,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
}
@Override @DB
public SnapshotVO createSnapshotImpl(long volumeId, long policyId) throws InvalidParameterValueException, ResourceAllocationException {
public SnapshotVO createSnapshotImpl(long volumeId, long policyId) throws ResourceAllocationException {
Long userId = UserContext.current().getUserId();
SnapshotVO createdSnapshot = null;
@ -368,7 +367,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
}
@Override
public SnapshotVO createSnapshot(CreateSnapshotCmd cmd) throws InvalidParameterValueException, ResourceAllocationException, InternalErrorException {
public SnapshotVO createSnapshot(CreateSnapshotCmd cmd) throws ResourceAllocationException {
SnapshotVO snapshot = _snapshotDao.findById(cmd.getId());
Long snapshotId = null;
boolean backedUp = false;
@ -377,7 +376,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
snapshotId = snapshot.getId();
backedUp = backupSnapshotToSecondaryStorage(snapshot, cmd.getStartEventId());
if (!backedUp) {
throw new InternalErrorException("Created snapshot: " + snapshotId + " on primary but failed to backup on secondary");
throw new CloudRuntimeException("Created snapshot: " + snapshotId + " on primary but failed to backup on secondary");
}
}
@ -389,7 +388,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
}
@Override
public SnapshotVO createSnapshotInternal(CreateSnapshotInternalCmd cmd) throws InternalErrorException, ResourceAllocationException {
public SnapshotVO createSnapshotInternal(CreateSnapshotInternalCmd cmd) throws ResourceAllocationException {
Long volumeId = cmd.getVolumeId();
Long policyId = cmd.getPolicyId();
SnapshotVO snapshot = null;
@ -405,7 +404,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
snapshotId = snapshot.getId();
backedUp = backupSnapshotToSecondaryStorage(snapshot, cmd.getStartEventId());
if (!backedUp) {
throw new InternalErrorException("Created snapshot: " + snapshotId + " on primary but failed to backup on secondary");
throw new CloudRuntimeException("Created snapshot: " + snapshotId + " on primary but failed to backup on secondary");
}
} else {
// if the snapshot wasn't created properly, just return now and avoid problems in the postCreate step
@ -614,6 +613,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
}
@Override
@DB
public void postCreateSnapshot(long volumeId, long snapshotId, long policyId, boolean backedUp) {
Long userId = UserContext.current().getUserId();
@ -660,7 +660,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
private Long checkAccountPermissions(long targetAccountId, long targetDomainId, String targetDesc, long targetId) throws ServerApiException {
Long accountId = null;
Account account = (Account)UserContext.current().getAccount();
Account account = UserContext.current().getAccount();
if (account != null) {
if (!isAdmin(account.getType())) {
if (account.getId() != targetAccountId) {
@ -705,7 +705,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
}
boolean status = true;
if (SnapshotType.MANUAL.ordinal() == (int)snapshotCheck.getSnapshotType()) {
if (SnapshotType.MANUAL.ordinal() == snapshotCheck.getSnapshotType()) {
status = deleteSnapshotInternal(snapshotId, Snapshot.MANUAL_POLICY_ID, userId);
if (!status) {
@ -1089,7 +1089,7 @@ public class SnapshotManagerImpl implements SnapshotManager {
public List<SnapshotScheduleVO> findRecurringSnapshotSchedule(ListRecurringSnapshotScheduleCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
Long volumeId = cmd.getVolumeId();
Long policyId = cmd.getSnapshotPolicyId();
Account account = (Account)UserContext.current().getAccount();
Account account = UserContext.current().getAccount();
//Verify parameters
VolumeVO volume = _volsDao.findById(volumeId);

View File

@ -19,7 +19,6 @@
package com.cloud.storage.upload;
import com.cloud.async.AsyncJobManager;
import com.cloud.exception.InternalErrorException;
import com.cloud.host.HostVO;
import com.cloud.storage.Upload.Mode;
import com.cloud.storage.Upload.Status;
@ -29,7 +28,6 @@ import com.cloud.storage.VMTemplateHostVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VolumeVO;
import com.cloud.utils.component.Manager;
import com.cloud.utils.exception.CloudRuntimeException;
/**
* Monitor upload progress of all entities.
@ -58,6 +56,6 @@ public interface UploadMonitor extends Manager{
VMTemplateHostVO vmTemplateHost, Long dataCenterId, long eventId);
void createVolumeDownloadURL(Long entityId, String path, Type type,
Long dataCenterId, Long uploadId) throws InternalErrorException;
Long dataCenterId, Long uploadId);
}

View File

@ -30,7 +30,6 @@ import com.cloud.configuration.dao.ConfigurationDao;
import com.cloud.event.EventTypes;
import com.cloud.event.EventVO;
import com.cloud.event.dao.EventDao;
import com.cloud.exception.InternalErrorException;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
@ -54,7 +53,6 @@ import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.vm.SecondaryStorageVmVO;
import com.cloud.vm.State;
import com.cloud.vm.dao.SecondaryStorageVmDao;
import com.sun.corba.se.impl.logging.InterceptorsSystemException;
/**
* @author nitin
@ -234,7 +232,7 @@ public class UploadMonitorImpl implements UploadMonitor {
}
@Override
public void createVolumeDownloadURL(Long entityId, String path, Type type, Long dataCenterId, Long uploadId) throws InternalErrorException{
public void createVolumeDownloadURL(Long entityId, String path, Type type, Long dataCenterId, Long uploadId) {
String errorString = "";
boolean success = false;
@ -257,7 +255,7 @@ public class UploadMonitorImpl implements UploadMonitor {
if (result == -1){
errorString = "Unable to create a link for " +type+ " id:"+entityId;
s_logger.warn(errorString);
throw new InternalErrorException(errorString);
throw new CloudRuntimeException(errorString);
}
//Construct actual URL locally now that the symlink exists at SSVM
@ -267,7 +265,7 @@ public class UploadMonitorImpl implements UploadMonitor {
if (ssVm.getPublicIpAddress() == null) {
errorString = "A running secondary storage vm has a null public ip?";
s_logger.warn(errorString);
throw new InternalErrorException(errorString);
throw new CloudRuntimeException(errorString);
}
String extractURL = generateCopyUrl(ssVm.getPublicIpAddress(), path);
UploadVO vo = _uploadDao.createForUpdate();
@ -279,7 +277,7 @@ public class UploadMonitorImpl implements UploadMonitor {
return;
}
errorString = "Couldnt find a running SSVM in the zone" + dataCenterId+ ". Couldnt create the extraction URL.";
throw new InternalErrorException(errorString);
throw new CloudRuntimeException(errorString);
}finally{
if(!success){
UploadVO uploadJob = _uploadDao.createForUpdate(uploadId);

View File

@ -34,7 +34,6 @@ import com.cloud.api.commands.RegisterTemplateCmd;
import com.cloud.async.AsyncJobManager;
import com.cloud.exception.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.storage.Storage.ImageFormat;
@ -76,8 +75,8 @@ public interface TemplateManager extends Manager {
* @return the template created.
*/
// Long create(long userId, Long zoneId, String name, String displayText, boolean isPublic, boolean featured, ImageFormat format, FileSystem fs, URI url, String chksum, boolean requiresHvm, int bits, boolean enablePassword, long guestOSId, boolean bootable);
VMTemplateVO registerTemplate(RegisterTemplateCmd cmd) throws InvalidParameterValueException, URISyntaxException, ResourceAllocationException;
VMTemplateVO registerIso(RegisterIsoCmd cmd) throws InvalidParameterValueException, IllegalArgumentException, ResourceAllocationException;
VMTemplateVO registerTemplate(RegisterTemplateCmd cmd) throws URISyntaxException, ResourceAllocationException;
VMTemplateVO registerIso(RegisterIsoCmd cmd) throws IllegalArgumentException, ResourceAllocationException;
/**
* Creates a Template
@ -145,9 +144,9 @@ public interface TemplateManager extends Manager {
* @throws StorageUnavailableException
* @throws InvalidParameterValueException
*/
boolean copy(long userId, long templateId, long sourceZoneId, long destZoneId, long startEventId) throws InternalErrorException, StorageUnavailableException, InvalidParameterValueException;
VMTemplateVO copyIso(CopyIsoCmd cmd) throws InvalidParameterValueException, StorageUnavailableException, PermissionDeniedException;
VMTemplateVO copyTemplate(CopyTemplateCmd cmd) throws InvalidParameterValueException, StorageUnavailableException, PermissionDeniedException;
boolean copy(long userId, long templateId, long sourceZoneId, long destZoneId, long startEventId) throws StorageUnavailableException;
VMTemplateVO copyIso(CopyIsoCmd cmd) throws StorageUnavailableException;
VMTemplateVO copyTemplate(CopyTemplateCmd cmd) throws StorageUnavailableException;
/**
* Deletes a template from secondary storage servers
@ -156,11 +155,11 @@ public interface TemplateManager extends Manager {
* @param zoneId - optional. If specified, will only delete the template from the specified zone's secondary storage server.
* @return true if success
*/
boolean delete(long userId, long templateId, Long zoneId) throws InternalErrorException;
boolean delete(long userId, long templateId, Long zoneId);
boolean detachIso(DetachIsoCmd cmd) throws InternalErrorException, InvalidParameterValueException, PermissionDeniedException;
boolean detachIso(DetachIsoCmd cmd);
boolean attachIso(AttachIsoCmd cmd) throws InternalErrorException, InvalidParameterValueException, PermissionDeniedException;
boolean attachIso(AttachIsoCmd cmd);
/**
* Lists templates in the specified storage pool that are not being used by any VM.
@ -181,7 +180,7 @@ public interface TemplateManager extends Manager {
* Deletes a template
* @param cmd - the command specifying templateId
*/
boolean deleteTemplate(DeleteTemplateCmd cmd) throws InvalidParameterValueException, InternalErrorException, PermissionDeniedException;
boolean deleteTemplate(DeleteTemplateCmd cmd);
/**
* Deletes a template
@ -189,9 +188,9 @@ public interface TemplateManager extends Manager {
* @return true if deletion is successful, false otherwise
* @throws InvalidParameterValueException, InternalErrorException, PermissionDeniedException
*/
boolean deleteIso(DeleteIsoCmd cmd) throws InvalidParameterValueException, InternalErrorException, PermissionDeniedException;
boolean deleteIso(DeleteIsoCmd cmd);
void extract(VMTemplateVO template, String url, VMTemplateHostVO tmpltHostRef, Long zoneId, long eventId, long asyncJobId, AsyncJobManager asyncMgr);
Long extract(ExtractIsoCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, InternalErrorException;
Long extract(ExtractTemplateCmd cmd) throws InvalidParameterValueException, PermissionDeniedException, InternalErrorException;
Long extract(ExtractIsoCmd cmd);
Long extract(ExtractTemplateCmd cmd);
}

View File

@ -62,7 +62,6 @@ 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.InternalErrorException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
@ -159,7 +158,7 @@ public class TemplateManagerImpl implements TemplateManager {
protected SearchBuilder<VMTemplateHostVO> HostTemplateStatesSearch;
@Override
public VMTemplateVO registerIso(RegisterIsoCmd cmd) throws InvalidParameterValueException, IllegalArgumentException, ResourceAllocationException{
public VMTemplateVO registerIso(RegisterIsoCmd cmd) throws ResourceAllocationException{
Account account = UserContext.current().getAccount();
Long userId = UserContext.current().getUserId();
String name = cmd.getIsoName();
@ -229,7 +228,7 @@ public class TemplateManagerImpl implements TemplateManager {
}
@Override
public VMTemplateVO registerTemplate(RegisterTemplateCmd cmd) throws InvalidParameterValueException, URISyntaxException, ResourceAllocationException{
public VMTemplateVO registerTemplate(RegisterTemplateCmd cmd) throws URISyntaxException, ResourceAllocationException{
Account account = UserContext.current().getAccount();
Long userId = UserContext.current().getUserId();
@ -311,7 +310,7 @@ public class TemplateManagerImpl implements TemplateManager {
}
private VMTemplateVO createTemplateOrIso(long userId, Long zoneId, String name, String displayText, boolean isPublic, boolean featured, String format, String diskType, String url, String chksum, boolean requiresHvm, int bits, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hypervisorType) throws InvalidParameterValueException,IllegalArgumentException, ResourceAllocationException {
private VMTemplateVO createTemplateOrIso(long userId, Long zoneId, String name, String displayText, boolean isPublic, boolean featured, String format, String diskType, String url, String chksum, boolean requiresHvm, int bits, boolean enablePassword, long guestOSId, boolean bootable, HypervisorType hypervisorType) throws IllegalArgumentException, ResourceAllocationException {
try
{
if (name.length() > 32)
@ -411,7 +410,7 @@ public class TemplateManagerImpl implements TemplateManager {
}
@Override
public Long extract(ExtractIsoCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
public Long extract(ExtractIsoCmd cmd) {
Account account = UserContext.current().getAccount();
Long templateId = cmd.getId();
Long zoneId = cmd.getZoneId();
@ -423,7 +422,7 @@ public class TemplateManagerImpl implements TemplateManager {
}
@Override
public Long extract(ExtractTemplateCmd cmd) throws InvalidParameterValueException, PermissionDeniedException {
public Long extract(ExtractTemplateCmd cmd) {
Account account = UserContext.current().getAccount();
Long templateId = cmd.getId();
Long zoneId = cmd.getZoneId();
@ -434,7 +433,7 @@ public class TemplateManagerImpl implements TemplateManager {
return extract(account, templateId, url, zoneId, mode, eventId, false, cmd.getJob(), cmd.getAsyncJobManager());
}
private Long extract(Account account, Long templateId, String url, Long zoneId, String mode, Long eventId, boolean isISO, AsyncJobVO job, AsyncJobManager mgr) throws InvalidParameterValueException, PermissionDeniedException {
private Long extract(Account account, Long templateId, String url, Long zoneId, String mode, Long eventId, boolean isISO, AsyncJobVO job, AsyncJobManager mgr) {
String desc = "template";
if (isISO) {
desc = "ISO";
@ -668,7 +667,7 @@ public class TemplateManagerImpl implements TemplateManager {
@Override
@DB
public boolean copy(long userId, long templateId, long sourceZoneId, long destZoneId, long startEventId) throws StorageUnavailableException, InvalidParameterValueException {
public boolean copy(long userId, long templateId, long sourceZoneId, long destZoneId, long startEventId) throws StorageUnavailableException {
HostVO srcSecHost = _storageMgr.getSecondaryStorageHost(sourceZoneId);
HostVO dstSecHost = _storageMgr.getSecondaryStorageHost(destZoneId);
DataCenterVO destZone = _dcDao.findById(destZoneId);
@ -774,7 +773,7 @@ public class TemplateManagerImpl implements TemplateManager {
}
@Override
public VMTemplateVO copyIso(CopyIsoCmd cmd) throws InvalidParameterValueException, StorageUnavailableException, PermissionDeniedException {
public VMTemplateVO copyIso(CopyIsoCmd cmd) throws StorageUnavailableException {
Long isoId = cmd.getId();
Long userId = UserContext.current().getUserId();
Long sourceZoneId = cmd.getSourceZoneId();
@ -808,7 +807,7 @@ public class TemplateManagerImpl implements TemplateManager {
@Override
public VMTemplateVO copyTemplate(CopyTemplateCmd cmd) throws InvalidParameterValueException, StorageUnavailableException, PermissionDeniedException {
public VMTemplateVO copyTemplate(CopyTemplateCmd cmd) throws StorageUnavailableException {
Long templateId = cmd.getId();
Long userId = UserContext.current().getUserId();
Long sourceZoneId = cmd.getSourceZoneId();
@ -841,11 +840,11 @@ public class TemplateManagerImpl implements TemplateManager {
}
@Override @DB
public boolean delete(long userId, long templateId, Long zoneId) throws InternalErrorException {
public boolean delete(long userId, long templateId, Long zoneId) {
boolean success = true;
VMTemplateVO template = _tmpltDao.findById(templateId);
if (template == null || template.getRemoved() != null) {
throw new InternalErrorException("Please specify a valid template.");
throw new InvalidParameterValueException("Please specify a valid template.");
}
String zoneName;
@ -870,7 +869,7 @@ public class TemplateManagerImpl implements TemplateManager {
if (templateHostVO.getDownloadState() == Status.DOWNLOAD_IN_PROGRESS) {
String errorMsg = "Please specify a template that is not currently being downloaded.";
s_logger.debug("Template: " + template.getName() + " is currently being downloaded to secondary storage host: " + secondaryStorageHost.getName() + "; cant' delete it.");
throw new InternalErrorException(errorMsg);
throw new CloudRuntimeException(errorMsg);
}
}
}
@ -1131,7 +1130,7 @@ public class TemplateManagerImpl implements TemplateManager {
}
@Override
public boolean detachIso(DetachIsoCmd cmd) throws InternalErrorException, InvalidParameterValueException, PermissionDeniedException {
public boolean detachIso(DetachIsoCmd cmd) {
Account account = UserContext.current().getAccount();
Long userId = UserContext.current().getUserId();
Long vmId = cmd.getVirtualMachineId();
@ -1165,7 +1164,7 @@ public class TemplateManagerImpl implements TemplateManager {
}
@Override
public boolean attachIso(AttachIsoCmd cmd) throws InternalErrorException, InvalidParameterValueException, PermissionDeniedException {
public boolean attachIso(AttachIsoCmd cmd) {
Account account = UserContext.current().getAccount();
Long userId = UserContext.current().getUserId();
Long vmId = cmd.getVirtualMachineId();
@ -1269,7 +1268,7 @@ public class TemplateManagerImpl implements TemplateManager {
}
@Override
public boolean deleteTemplate(DeleteTemplateCmd cmd) throws InvalidParameterValueException, InternalErrorException, PermissionDeniedException {
public boolean deleteTemplate(DeleteTemplateCmd cmd) {
Long templateId = cmd.getId();
Long userId = UserContext.current().getUserId();
Account account = UserContext.current().getAccount();
@ -1302,7 +1301,7 @@ public class TemplateManagerImpl implements TemplateManager {
}
@Override
public boolean deleteIso(DeleteIsoCmd cmd) throws InvalidParameterValueException, InternalErrorException, PermissionDeniedException {
public boolean deleteIso(DeleteIsoCmd cmd) {
Long templateId = cmd.getId();
Long userId = UserContext.current().getUserId();
Account account = UserContext.current().getAccount();

View File

@ -51,9 +51,9 @@ import com.cloud.utils.db.GlobalLock;
import com.cloud.utils.db.SearchBuilder;
import com.cloud.utils.db.SearchCriteria;
@Local(value={AccountManager.class})
public class AccountManagerImpl implements AccountManager {
public static final Logger s_logger = Logger.getLogger(AccountManagerImpl.class.getName());
@Local(value={AccountManager.class, AccountService.class})
public class AccountManagerImpl implements AccountManager, AccountService {
public static final Logger s_logger = Logger.getLogger(AccountManagerImpl.class);
private String _name;
@Inject private AccountDao _accountDao;

View File

@ -0,0 +1,24 @@
/**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.user;
import com.cloud.utils.component.Manager;
public interface AccountService extends Manager {
}