More api refactor - build api response is execute() method instead of getResponse method.

This commit is contained in:
alena 2010-11-09 00:20:43 -08:00
parent 3455a0f563
commit 5fafef9970
164 changed files with 1589 additions and 2617 deletions

View File

@ -107,11 +107,7 @@ public class ApiDispatcher {
setupParameters(cmd, params);
try {
Object result = cmd.execute();
if (!(result instanceof ResponseObject)) {
cmd.setResponseObject(result);
}
cmd.execute();
} catch (InvalidParameterValueException e1) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, e1.getMessage());
} catch (IllegalArgumentException e2) {

View File

@ -79,6 +79,7 @@ import org.apache.http.protocol.ResponseServer;
import org.apache.log4j.Logger;
import com.cloud.api.response.ApiResponseSerializer;
import com.cloud.api.response.ListResponse;
import com.cloud.async.AsyncJobVO;
import com.cloud.configuration.ConfigurationVO;
import com.cloud.configuration.dao.ConfigurationDao;
@ -352,7 +353,6 @@ public class ApiServer implements HttpRequestHandler {
BaseAsyncCreateCmd createCmd = (BaseAsyncCreateCmd)cmdObj;
_dispatcher.dispatchCreateCmd(createCmd, params);
objectId = createCmd.getId();
//createCmd.setId(objectId);
params.put("id", objectId.toString());
} else {
ApiDispatcher.setupParameters(cmdObj, params);
@ -398,7 +398,7 @@ public class ApiServer implements HttpRequestHandler {
return ApiResponseSerializer.toSerializedString(asyncCmd.getResponse(jobId), asyncCmd.getResponseType());
} else {
_dispatcher.dispatch(cmdObj, params);
return ApiResponseSerializer.toSerializedString(cmdObj.getResponse(), cmdObj.getResponseType());
return ApiResponseSerializer.toSerializedString((ResponseObject)cmdObj.getResponseObject(), cmdObj.getResponseType());
}
}

View File

@ -91,4 +91,5 @@ public abstract class BaseAsyncCmd extends BaseCmd {
public void setStartEventId(Long startEventId) {
this.startEventId = startEventId;
}
}

View File

@ -151,7 +151,7 @@ public abstract class BaseCmd {
return locator;
}
public abstract Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
public abstract void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
public String getResponseType() {
if (responseType == null) {
@ -165,7 +165,6 @@ public abstract class BaseCmd {
}
public abstract String getName();
public abstract <T extends ResponseObject> T getResponse();
public Object getResponseObject() {
return _responseObject;

View File

@ -22,7 +22,6 @@ import java.util.List;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.api.ApiConstants;
import com.cloud.api.ApiResponseHelper;
import com.cloud.api.BaseCmd;
@ -39,7 +38,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.host.HostVO;
@Implementation(method="discoverHosts", manager=AgentManager.class, description="Adds a new host.")
@Implementation(description="Adds a new host.")
public class AddHostCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(AddHostCmd.class.getName());
@ -111,32 +110,26 @@ public class AddHostCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<HostResponse> getResponse() {
List<HostVO> hosts = (List<HostVO>)getResponseObject();
ListResponse<HostResponse> response = new ListResponse<HostResponse>();
List<HostResponse> hostResponses = new ArrayList<HostResponse>();
if (hosts != null) {
for (HostVO host : hosts) {
HostResponse hostResponse = ApiResponseHelper.createHostResponse(host);
hostResponses.add(hostResponse);
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add host");
}
response.setResponses(hostResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
try {
List<HostVO> result = _agentMgr.discoverHosts(this);
return result;
ListResponse<HostResponse> response = new ListResponse<HostResponse>();
List<HostResponse> hostResponses = new ArrayList<HostResponse>();
if (result != null) {
for (HostVO host : result) {
HostResponse hostResponse = ApiResponseHelper.createHostResponse(host);
hostResponses.add(hostResponse);
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add host");
}
response.setResponses(hostResponses);
response.setResponseName(getName());
this.setResponseObject(response);
} catch (DiscoveryException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}

View File

@ -22,7 +22,6 @@ import java.util.List;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.api.ApiConstants;
import com.cloud.api.ApiResponseHelper;
import com.cloud.api.BaseCmd;
@ -38,7 +37,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.host.HostVO;
@Implementation(method="discoverHosts", manager=AgentManager.class, description="Adds secondary storage.")
@Implementation(description="Adds secondary storage.")
public class AddSecondaryStorageCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(AddSecondaryStorageCmd.class.getName());
private static final String s_name = "addsecondarystorageresponse";
@ -74,29 +73,22 @@ public class AddSecondaryStorageCmd extends BaseCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public HostResponse getResponse() {
List<HostVO> hosts = (List<HostVO>)getResponseObject();
HostResponse hostResponse = null;
if (hosts != null && hosts.size() > 0) {
for (HostVO host : hosts) {
// There should only be one secondary storage host per add
hostResponse = ApiResponseHelper.createHostResponse(host);
hostResponse.setResponseName(getName());
hostResponse.setObjectName("secondarystorage");
return hostResponse;
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add secondary storage");
}
return hostResponse;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
try {
List<HostVO> result = _agentMgr.discoverHosts(this);
return result;
HostResponse hostResponse = null;
if (result != null && result.size() > 0) {
for (HostVO host : result) {
// There should only be one secondary storage host per add
hostResponse = ApiResponseHelper.createHostResponse(host);
hostResponse.setResponseName(getName());
hostResponse.setObjectName("secondarystorage");
this.setResponseObject(hostResponse);
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add secondary storage");
}
} catch (DiscoveryException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}

View File

@ -32,12 +32,11 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.NetworkManager;
import com.cloud.network.VpnUserVO;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@Implementation( method="addVpnUser", manager=NetworkManager.class, description="Adds vpn users")
@Implementation(description="Adds vpn users")
public class AddVpnUserCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(AddVpnUserCmd.class.getName());
@ -95,25 +94,6 @@ public class AddVpnUserCmd extends BaseAsyncCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public VpnUsersResponse getResponse() {
VpnUserVO vpnUser = (VpnUserVO)getResponseObject();
VpnUsersResponse vpnResponse = new VpnUsersResponse();
vpnResponse.setId(vpnUser.getId());
vpnResponse.setUserName(vpnUser.getUsername());
vpnResponse.setAccountName(vpnUser.getAccountName());
Account accountTemp = ApiDBUtils.findAccountById(vpnUser.getAccountId());
if (accountTemp != null) {
vpnResponse.setDomainId(accountTemp.getDomainId());
vpnResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
vpnResponse.setResponseName(getName());
vpnResponse.setObjectName("vpnuser");
return vpnResponse;
}
@Override
public long getAccountId() {
Account account = (Account)UserContext.current().getAccount();
@ -146,9 +126,21 @@ public class AddVpnUserCmd extends BaseAsyncCmd {
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
VpnUserVO result = _networkMgr.addVpnUser(this);
return result;
}
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
VpnUserVO vpnUser = _networkMgr.addVpnUser(this);
VpnUsersResponse vpnResponse = new VpnUsersResponse();
vpnResponse.setId(vpnUser.getId());
vpnResponse.setUserName(vpnUser.getUsername());
vpnResponse.setAccountName(vpnUser.getAccountName());
Account accountTemp = ApiDBUtils.findAccountById(vpnUser.getAccountId());
if (accountTemp != null) {
vpnResponse.setDomainId(accountTemp.getDomainId());
vpnResponse.setDomainName(ApiDBUtils.findDomainById(accountTemp.getDomainId()).getName());
}
vpnResponse.setResponseName(getName());
vpnResponse.setObjectName("vpnuser");
this.setResponseObject(vpnResponse);
}
}

View File

@ -37,10 +37,9 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.LoadBalancerVO;
import com.cloud.network.NetworkManager;
import com.cloud.user.Account;
@Implementation(method="assignToLoadBalancer", manager=NetworkManager.class, description="Assigns virtual machine or a list of virtual machines to a load balancer rule.")
@Implementation(description="Assigns virtual machine or a list of virtual machines to a load balancer rule.")
public class AssignToLoadBalancerRuleCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(AssignToLoadBalancerRuleCmd.class.getName());
@ -102,21 +101,17 @@ public class AssignToLoadBalancerRuleCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "applying port forwarding service for vm with id: " + getVirtualMachineId();
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to assign to load balancer");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
try {
boolean result = _networkMgr.assignToLoadBalancer(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to assign load balancer rule");
}
} catch (NetworkRuleConflictException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}

View File

@ -33,9 +33,8 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.network.IPAddressVO;
import com.cloud.network.NetworkManager;
@Implementation(method="associateIP", manager=NetworkManager.class, description="Acquires and associates a public IP to an account.")
@Implementation(description="Acquires and associates a public IP to an account.")
public class AssociateIPAddrCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(AssociateIPAddrCmd.class.getName());
private static final String s_name = "associateipaddressresponse";
@ -84,22 +83,15 @@ public class AssociateIPAddrCmd extends BaseCmd {
return "addressinfo";
}
@SuppressWarnings("unchecked")
public IPAddressResponse getResponse() {
IPAddressVO ipAddress = (IPAddressVO)getResponseObject();
IPAddressResponse ipResponse = ApiResponseHelper.createIPAddressResponse(ipAddress);
ipResponse.setResponseName(getName());
return ipResponse;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
try {
IPAddressVO result = _networkMgr.associateIP(this);
return result;
IPAddressResponse ipResponse = ApiResponseHelper.createIPAddressResponse(result);
ipResponse.setResponseName(getName());
this.setResponseObject(ipResponse);
} catch (ResourceAllocationException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}
}

View File

@ -34,11 +34,10 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.VMTemplateVO;
import com.cloud.template.TemplateManager;
import com.cloud.user.Account;
import com.cloud.vm.VMInstanceVO;
@Implementation(method="attachIso", manager=TemplateManager.class, description="Attaches an ISO to a virtual machine.")
@Implementation(description="Attaches an ISO to a virtual machine.")
public class AttachIsoCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(AttachIsoCmd.class.getName());
@ -95,12 +94,11 @@ public class AttachIsoCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "attaching ISO: " + getId() + " to vm: " + getVirtualMachineId();
}
@Override @SuppressWarnings("unchecked")
public IsoVmResponse getResponse() {
Boolean responseObject = (Boolean)getResponseObject();
if (responseObject != null && responseObject != false) {
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _templateMgr.attachIso(this);
if (result) {
IsoVmResponse response = new IsoVmResponse();
VMTemplateVO iso = ApiDBUtils.findTemplateById(id);
VMInstanceVO vmInstance = ApiDBUtils.findVMInstanceById(virtualMachineId);
@ -115,15 +113,10 @@ public class AttachIsoCmd extends BaseAsyncCmd {
response.setVirtualMachineState(vmInstance.getState().toString());
response.setResponseName(getName());
response.setObjectName("iso");
return response;
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to attach iso");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _templateMgr.attachIso(this);
return result;
}
}

View File

@ -37,9 +37,8 @@ import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.Volume;
import com.cloud.storage.VolumeVO;
import com.cloud.user.Account;
import com.cloud.vm.UserVmManager;
@Implementation(method="attachVolumeToVM", manager=UserVmManager.class, description="Attaches a disk volume to a virtual machine.")
@Implementation(description="Attaches a disk volume to a virtual machine.")
public class AttachVolumeCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(AttachVolumeCmd.class.getName());
private static final String s_name = "attachvolumeresponse";
@ -112,18 +111,12 @@ public class AttachVolumeCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "attaching volume: " + getId() + " to vm: " + getVirtualMachineId();
}
@Override @SuppressWarnings("unchecked")
public VolumeResponse getResponse() {
VolumeVO volume = (VolumeVO)getResponseObject();
VolumeResponse response = ApiResponseHelper.createVolumeResponse(volume);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
Volume result = _userVmService.attachVolumeToVM(this);
return result;
VolumeResponse response = ApiResponseHelper.createVolumeResponse((VolumeVO)result);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -42,12 +42,12 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.security.IngressRuleVO;
import com.cloud.network.security.NetworkGroupManager;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
import com.cloud.utils.StringUtils;
@Implementation(method="authorizeNetworkGroupIngress", manager=NetworkGroupManager.class) @SuppressWarnings("rawtypes")
//FIXME - add description
@Implementation() @SuppressWarnings("rawtypes")
public class AuthorizeNetworkGroupIngressCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(AuthorizeNetworkGroupIngressCmd.class.getName());
@ -210,12 +210,11 @@ public class AuthorizeNetworkGroupIngressCmd extends BaseAsyncCmd {
return "authorizing ingress to group: " + getNetworkGroupName() + " to " + sb.toString();
}
@Override @SuppressWarnings("unchecked")
public ListResponse<IngressRuleResponse> getResponse() {
List<IngressRuleVO> ingressRules = (List<IngressRuleVO>)getResponseObject();
ListResponse<IngressRuleResponse> response = new ListResponse<IngressRuleResponse>();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<IngressRuleVO> ingressRules = _networkGroupMgr.authorizeNetworkGroupIngress(this);
ListResponse<IngressRuleResponse> response = new ListResponse<IngressRuleResponse>();
if ((ingressRules != null) && !ingressRules.isEmpty()) {
List<IngressRuleResponse> responses = new ArrayList<IngressRuleResponse>();
for (IngressRuleVO ingressRule : ingressRules) {
@ -243,16 +242,7 @@ public class AuthorizeNetworkGroupIngressCmd extends BaseAsyncCmd {
}
response.setResponses(responses);
}
response.setResponseName("securitygroupingressrule");
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<IngressRuleVO> result = _networkGroupMgr.authorizeNetworkGroupIngress(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -20,7 +20,6 @@ package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.api.ApiConstants;
import com.cloud.api.ApiResponseHelper;
import com.cloud.api.BaseAsyncCmd;
@ -38,7 +37,7 @@ import com.cloud.host.HostVO;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@Implementation(method="cancelMaintenance", manager=AgentManager.class, description="Cancels host maintenance.")
@Implementation(description="Cancels host maintenance.")
public class CancelMaintenanceCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(CancelMaintenanceCmd.class.getName());
@ -93,18 +92,12 @@ public class CancelMaintenanceCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "canceling maintenance for host: " + getId();
}
@Override @SuppressWarnings("unchecked")
public HostResponse getResponse() {
HostVO host = (HostVO)getResponseObject();
HostResponse response = ApiResponseHelper.createHostResponse(host);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
HostVO result = _agentMgr.cancelMaintenance(this);
return result;
HostResponse response = ApiResponseHelper.createHostResponse(result);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -33,12 +33,11 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePoolVO;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@Implementation(method="cancelPrimaryStorageForMaintenance", manager=StorageManager.class)
@Implementation(description="Cancels maintenance for primary storage")
public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(CancelPrimaryStorageMaintenanceCmd.class.getName());
@ -93,18 +92,12 @@ public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "canceling maintenance for primary storage pool: " + getId();
}
@Override @SuppressWarnings("unchecked")
public StoragePoolResponse getResponse() {
StoragePoolVO primaryStorage = (StoragePoolVO)getResponseObject();
StoragePoolResponse response = ApiResponseHelper.createStoragePoolResponse(primaryStorage);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
StoragePoolVO result = _storageMgr.cancelPrimaryStorageForMaintenance(this);
return result;
StoragePoolResponse response = ApiResponseHelper.createStoragePoolResponse(result);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -39,11 +39,10 @@ import com.cloud.storage.GuestOS;
import com.cloud.storage.VMTemplateHostVO;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.VMTemplateVO;
import com.cloud.template.TemplateManager;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@Implementation(method="copyIso", manager=TemplateManager.class, description="Copies an ISO file.")
@Implementation(description="Copies an ISO file.")
public class CopyIsoCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(CopyIsoCmd.class.getName());
private static final String s_name = "copyisoresponse";
@ -110,90 +109,82 @@ public class CopyIsoCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "copying ISO: " + getId() + " from zone: " + getSourceZoneId() + " to zone: " + getDestinationZoneId();
}
@Override @SuppressWarnings("unchecked")
public TemplateResponse getResponse() {
TemplateResponse isoResponse = new TemplateResponse();
VMTemplateVO iso = (VMTemplateVO)getResponseObject();
if (iso != null) {
isoResponse.setId(iso.getId());
isoResponse.setName(iso.getName());
isoResponse.setDisplayText(iso.getDisplayText());
isoResponse.setPublic(iso.isPublicTemplate());
isoResponse.setBootable(iso.isBootable());
isoResponse.setFeatured(iso.isFeatured());
isoResponse.setCrossZones(iso.isCrossZones());
isoResponse.setCreated(iso.getCreated());
isoResponse.setZoneId(destZoneId);
isoResponse.setZoneName(ApiDBUtils.findZoneById(destZoneId).getName());
GuestOS os = ApiDBUtils.findGuestOSById(iso.getGuestOSId());
if (os != null) {
isoResponse.setOsTypeId(os.getId());
isoResponse.setOsTypeName(os.getDisplayName());
} else {
isoResponse.setOsTypeId(-1L);
isoResponse.setOsTypeName("");
}
// add account ID and name
Account owner = ApiDBUtils.findAccountById(iso.getAccountId());
if (owner != null) {
isoResponse.setAccount(owner.getAccountName());
isoResponse.setDomainId(owner.getDomainId());
isoResponse.setDomainName(ApiDBUtils.findDomainById(owner.getDomainId()).getName());
}
//set status
Account account = (Account)UserContext.current().getAccount();
boolean isAdmin = false;
if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN) || (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
isAdmin = true;
}
//Return download status for admin users
VMTemplateHostVO templateHostRef = ApiDBUtils.findTemplateHostRef(iso.getId(), destZoneId);
if (isAdmin || iso.getAccountId() == account.getId()) {
if (templateHostRef.getDownloadState()!=Status.DOWNLOADED) {
String templateStatus = "Processing";
if (templateHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS) {
if (templateHostRef.getDownloadPercent() == 100) {
templateStatus = "Installing Template";
} else {
templateStatus = templateHostRef.getDownloadPercent() + "% Downloaded";
}
} else {
templateStatus = templateHostRef.getErrorString();
}
isoResponse.setStatus(templateStatus);
} else if (templateHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOADED) {
isoResponse.setStatus("Download Complete");
} else {
isoResponse.setStatus("Successfully Installed");
}
}
isoResponse.setReady(templateHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOADED);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to copy iso");
}
isoResponse.setResponseName(getName());
isoResponse.setObjectName("iso");
return isoResponse;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
try {
VMTemplateVO result = _templateMgr.copyIso(this);
return result;
VMTemplateVO iso = _templateMgr.copyIso(this);
TemplateResponse isoResponse = new TemplateResponse();
if (iso != null) {
isoResponse.setId(iso.getId());
isoResponse.setName(iso.getName());
isoResponse.setDisplayText(iso.getDisplayText());
isoResponse.setPublic(iso.isPublicTemplate());
isoResponse.setBootable(iso.isBootable());
isoResponse.setFeatured(iso.isFeatured());
isoResponse.setCrossZones(iso.isCrossZones());
isoResponse.setCreated(iso.getCreated());
isoResponse.setZoneId(destZoneId);
isoResponse.setZoneName(ApiDBUtils.findZoneById(destZoneId).getName());
GuestOS os = ApiDBUtils.findGuestOSById(iso.getGuestOSId());
if (os != null) {
isoResponse.setOsTypeId(os.getId());
isoResponse.setOsTypeName(os.getDisplayName());
} else {
isoResponse.setOsTypeId(-1L);
isoResponse.setOsTypeName("");
}
// add account ID and name
Account owner = ApiDBUtils.findAccountById(iso.getAccountId());
if (owner != null) {
isoResponse.setAccount(owner.getAccountName());
isoResponse.setDomainId(owner.getDomainId());
isoResponse.setDomainName(ApiDBUtils.findDomainById(owner.getDomainId()).getName());
}
//set status
Account account = (Account)UserContext.current().getAccount();
boolean isAdmin = false;
if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN) || (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
isAdmin = true;
}
//Return download status for admin users
VMTemplateHostVO templateHostRef = ApiDBUtils.findTemplateHostRef(iso.getId(), destZoneId);
if (isAdmin || iso.getAccountId() == account.getId()) {
if (templateHostRef.getDownloadState()!=Status.DOWNLOADED) {
String templateStatus = "Processing";
if (templateHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS) {
if (templateHostRef.getDownloadPercent() == 100) {
templateStatus = "Installing Template";
} else {
templateStatus = templateHostRef.getDownloadPercent() + "% Downloaded";
}
} else {
templateStatus = templateHostRef.getErrorString();
}
isoResponse.setStatus(templateStatus);
} else if (templateHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOADED) {
isoResponse.setStatus("Download Complete");
} else {
isoResponse.setStatus("Successfully Installed");
}
}
isoResponse.setReady(templateHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOADED);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to copy iso");
}
isoResponse.setResponseName(getName());
isoResponse.setObjectName("iso");
this.setResponseObject(isoResponse);
} catch (StorageUnavailableException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}
}

View File

@ -39,11 +39,10 @@ import com.cloud.storage.GuestOS;
import com.cloud.storage.VMTemplateHostVO;
import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.VMTemplateVO;
import com.cloud.template.TemplateManager;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@Implementation(method="copyTemplate", manager=TemplateManager.class, description="Copies a template from one zone to another.")
@Implementation(description="Copies a template from one zone to another.")
public class CopyTemplateCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(CopyTemplateCmd.class.getName());
private static final String s_name = "copytemplateresponse";
@ -112,92 +111,85 @@ public class CopyTemplateCmd extends BaseAsyncCmd {
return "copying template: " + getId() + " from zone: " + getSourceZoneId() + " to zone: " + getDestinationZoneId();
}
@Override @SuppressWarnings("unchecked")
public TemplateResponse getResponse() {
TemplateResponse templateResponse = new TemplateResponse();
VMTemplateVO template = (VMTemplateVO)getResponseObject();
if (template != null) {
templateResponse.setId(template.getId());
templateResponse.setName(template.getName());
templateResponse.setDisplayText(template.getDisplayText());
templateResponse.setPublic(template.isPublicTemplate());
templateResponse.setBootable(template.isBootable());
templateResponse.setFeatured(template.isFeatured());
templateResponse.setCrossZones(template.isCrossZones());
templateResponse.setCreated(template.getCreated());
templateResponse.setFormat(template.getFormat());
templateResponse.setPasswordEnabled(template.getEnablePassword());
templateResponse.setZoneId(destZoneId);
templateResponse.setZoneName(ApiDBUtils.findZoneById(destZoneId).getName());
GuestOS os = ApiDBUtils.findGuestOSById(template.getGuestOSId());
if (os != null) {
templateResponse.setOsTypeId(os.getId());
templateResponse.setOsTypeName(os.getDisplayName());
} else {
templateResponse.setOsTypeId(-1L);
templateResponse.setOsTypeName("");
}
// add account ID and name
Account owner = ApiDBUtils.findAccountById(template.getAccountId());
if (owner != null) {
templateResponse.setAccount(owner.getAccountName());
templateResponse.setDomainId(owner.getDomainId());
templateResponse.setDomainName(ApiDBUtils.findDomainById(owner.getDomainId()).getName());
}
//set status
Account account = (Account)UserContext.current().getAccount();
boolean isAdmin = false;
if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN) || (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
isAdmin = true;
}
//Return download status for admin users
VMTemplateHostVO templateHostRef = ApiDBUtils.findTemplateHostRef(template.getId(), destZoneId);
if (isAdmin || template.getAccountId() == account.getId()) {
if (templateHostRef.getDownloadState()!=Status.DOWNLOADED) {
String templateStatus = "Processing";
if (templateHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS) {
if (templateHostRef.getDownloadPercent() == 100) {
templateStatus = "Installing Template";
} else {
templateStatus = templateHostRef.getDownloadPercent() + "% Downloaded";
}
} else {
templateStatus = templateHostRef.getErrorString();
}
templateResponse.setStatus(templateStatus);
} else if (templateHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOADED) {
templateResponse.setStatus("Download Complete");
} else {
templateResponse.setStatus("Successfully Installed");
}
}
templateResponse.setReady(templateHostRef != null && templateHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOADED);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to copy template");
}
templateResponse.setResponseName(getName());
templateResponse.setObjectName("template");
return templateResponse;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
try {
VMTemplateVO result = _templateMgr.copyTemplate(this);
return result;
VMTemplateVO template = _templateMgr.copyTemplate(this);
TemplateResponse templateResponse = new TemplateResponse();
if (template != null) {
templateResponse.setId(template.getId());
templateResponse.setName(template.getName());
templateResponse.setDisplayText(template.getDisplayText());
templateResponse.setPublic(template.isPublicTemplate());
templateResponse.setBootable(template.isBootable());
templateResponse.setFeatured(template.isFeatured());
templateResponse.setCrossZones(template.isCrossZones());
templateResponse.setCreated(template.getCreated());
templateResponse.setFormat(template.getFormat());
templateResponse.setPasswordEnabled(template.getEnablePassword());
templateResponse.setZoneId(destZoneId);
templateResponse.setZoneName(ApiDBUtils.findZoneById(destZoneId).getName());
GuestOS os = ApiDBUtils.findGuestOSById(template.getGuestOSId());
if (os != null) {
templateResponse.setOsTypeId(os.getId());
templateResponse.setOsTypeName(os.getDisplayName());
} else {
templateResponse.setOsTypeId(-1L);
templateResponse.setOsTypeName("");
}
// add account ID and name
Account owner = ApiDBUtils.findAccountById(template.getAccountId());
if (owner != null) {
templateResponse.setAccount(owner.getAccountName());
templateResponse.setDomainId(owner.getDomainId());
templateResponse.setDomainName(ApiDBUtils.findDomainById(owner.getDomainId()).getName());
}
//set status
Account account = (Account)UserContext.current().getAccount();
boolean isAdmin = false;
if ((account == null) || (account.getType() == Account.ACCOUNT_TYPE_ADMIN) || (account.getType() == Account.ACCOUNT_TYPE_DOMAIN_ADMIN)) {
isAdmin = true;
}
//Return download status for admin users
VMTemplateHostVO templateHostRef = ApiDBUtils.findTemplateHostRef(template.getId(), destZoneId);
if (isAdmin || template.getAccountId() == account.getId()) {
if (templateHostRef.getDownloadState()!=Status.DOWNLOADED) {
String templateStatus = "Processing";
if (templateHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOAD_IN_PROGRESS) {
if (templateHostRef.getDownloadPercent() == 100) {
templateStatus = "Installing Template";
} else {
templateStatus = templateHostRef.getDownloadPercent() + "% Downloaded";
}
} else {
templateStatus = templateHostRef.getErrorString();
}
templateResponse.setStatus(templateStatus);
} else if (templateHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOADED) {
templateResponse.setStatus("Download Complete");
} else {
templateResponse.setStatus("Successfully Installed");
}
}
templateResponse.setReady(templateHostRef != null && templateHostRef.getDownloadState() == VMTemplateHostVO.Status.DOWNLOADED);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to copy template");
}
templateResponse.setResponseName(getName());
templateResponse.setObjectName("template");
this.setResponseObject(templateResponse);
} catch (StorageUnavailableException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}
}

View File

@ -27,7 +27,6 @@ import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.ConfigurationResponse;
import com.cloud.configuration.Configuration;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.configuration.ConfigurationVO;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
@ -35,7 +34,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="addConfig", manager=ConfigurationManager.class)
@Implementation(description="Adds configuration value")
public class CreateCfgCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateCfgCmd.class.getName());
private static final String s_name = "addconfigresponse";
@ -102,21 +101,15 @@ public class CreateCfgCmd extends BaseCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ConfigurationResponse getResponse() {
ConfigurationVO cfg = (ConfigurationVO)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
Configuration cfg = _configService.addConfig(this);
if (cfg != null) {
ConfigurationResponse response = ApiResponseHelper.createConfigurationResponse(cfg);
ConfigurationResponse response = ApiResponseHelper.createConfigurationResponse((ConfigurationVO)cfg);
response.setResponseName(getName());
return response;
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add config");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
Configuration result = _configService.addConfig(this);
return result;
}
}

View File

@ -26,7 +26,6 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.DiskOfferingResponse;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
@ -35,7 +34,7 @@ import com.cloud.exception.PermissionDeniedException;
import com.cloud.offering.DiskOffering;
import com.cloud.storage.DiskOfferingVO;
@Implementation(method="createDiskOffering", manager=ConfigurationManager.class, description="Creates a disk offering.")
@Implementation(description="Creates a disk offering.")
public class CreateDiskOfferingCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateDiskOfferingCmd.class.getName());
@ -90,23 +89,17 @@ public class CreateDiskOfferingCmd extends BaseCmd {
@Override
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public DiskOfferingResponse getResponse() {
DiskOfferingVO offering = (DiskOfferingVO)getResponseObject();
}
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
DiskOffering offering = _configService.createDiskOffering(this);
if (offering != null) {
DiskOfferingResponse response = ApiResponseHelper.createDiskOfferingResponse(offering);
DiskOfferingResponse response = ApiResponseHelper.createDiskOfferingResponse((DiskOfferingVO)offering);
response.setResponseName(getName());
return response;
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create disk offering");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
DiskOffering result = _configService.createDiskOffering(this);
return result;
}
}

View File

@ -33,7 +33,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="createDomain", description="Creates a domain")
@Implementation(description="Creates a domain")
public class CreateDomainCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateDomainCmd.class.getName());
@ -70,24 +70,17 @@ public class CreateDomainCmd extends BaseCmd {
@Override
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public DomainResponse getResponse() {
DomainVO domain = (DomainVO)getResponseObject();
}
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
DomainVO domain = _mgr.createDomain(this);
if (domain != null) {
DomainResponse response = ApiResponseHelper.createDomainResponse(domain);
response.setResponseName(getName());
return response;
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create domain");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
DomainVO domain = _mgr.createDomain(this);
return domain;
//set response object here; change return type to void
}
}

View File

@ -34,9 +34,8 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.NetworkRuleConflictException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.FirewallRuleVO;
import com.cloud.network.NetworkManager;
@Implementation(method="createPortForwardingRule", manager=NetworkManager.class, description="Creates a port forwarding rule")
@Implementation(description="Creates a port forwarding rule")
public class CreateIPForwardingRuleCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateIPForwardingRuleCmd.class.getName());
@ -94,25 +93,19 @@ public class CreateIPForwardingRuleCmd extends BaseCmd {
@Override
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public FirewallRuleResponse getResponse() {
FirewallRuleVO fwRule = (FirewallRuleVO)getResponseObject();
if (fwRule != null) {
FirewallRuleResponse fwResponse = ApiResponseHelper.createFirewallRuleResponse(fwRule);
fwResponse.setResponseName(getName());
return fwResponse;
}
throw new ServerApiException(NET_CREATE_IPFW_RULE_ERROR, "An existing rule for ipAddress / port / protocol of " + ipAddress + " / " + publicPort + " / " + protocol + " exits.");
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
try {
FirewallRuleVO result = _networkMgr.createPortForwardingRule(this);
return result;
if (result != null) {
FirewallRuleResponse fwResponse = ApiResponseHelper.createFirewallRuleResponse(result);
fwResponse.setResponseName(getName());
this.setResponseObject(fwResponse);
} else {
throw new ServerApiException(NET_CREATE_IPFW_RULE_ERROR, "An existing rule for ipAddress / port / protocol of " + ipAddress + " / " + publicPort + " / " + protocol + " exits.");
}
} catch (NetworkRuleConflictException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}

View File

@ -33,9 +33,8 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.LoadBalancerVO;
import com.cloud.network.NetworkManager;
@Implementation(method="createLoadBalancerRule", manager=NetworkManager.class, description="Creates a load balancer rule")
@Implementation(description="Creates a load balancer rule")
public class CreateLoadBalancerRuleCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateLoadBalancerRuleCmd.class.getName());
@ -100,18 +99,12 @@ public class CreateLoadBalancerRuleCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public LoadBalancerResponse getResponse() {
LoadBalancerVO loadBalancer = (LoadBalancerVO)getResponseObject();
LoadBalancerResponse response = ApiResponseHelper.createLoadBalancerResponse(loadBalancer);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
LoadBalancerVO result = _networkMgr.createLoadBalancerRule(this);
return result;
LoadBalancerResponse response = ApiResponseHelper.createLoadBalancerResponse(result);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -31,10 +31,10 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.security.NetworkGroupManager;
import com.cloud.network.security.NetworkGroupVO;
@Implementation(method="createNetworkGroup", manager=NetworkGroupManager.class)
//TODO - add description to implementation
@Implementation()
public class CreateNetworkGroupCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateNetworkGroupCmd.class.getName());
@ -85,11 +85,10 @@ public class CreateNetworkGroupCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public NetworkGroupResponse getResponse() {
NetworkGroupVO group = (NetworkGroupVO)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
NetworkGroupVO group = _networkGroupMgr.createNetworkGroup(this);
NetworkGroupResponse response = new NetworkGroupResponse();
response.setAccountName(group.getAccountName());
response.setDescription(group.getDescription());
@ -100,12 +99,6 @@ public class CreateNetworkGroupCmd extends BaseCmd {
response.setResponseName(getName());
response.setObjectName("securitygroup");
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
NetworkGroupVO result = _networkGroupMgr.createNetworkGroup(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -27,7 +27,6 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.PodResponse;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.dc.HostPodVO;
import com.cloud.dc.Pod;
import com.cloud.exception.ConcurrentOperationException;
@ -36,7 +35,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="createPod", manager=ConfigurationManager.class, description="Creates a new Pod.")
@Implementation(description="Creates a new Pod.")
public class CreatePodCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreatePodCmd.class.getName());
@ -102,17 +101,11 @@ public class CreatePodCmd extends BaseCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public PodResponse getResponse() {
HostPodVO pod = (HostPodVO)getResponseObject();
PodResponse response = ApiResponseHelper.createPodResponse(pod);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
Pod result = _configService.createPod(this);
return result;
PodResponse response = ApiResponseHelper.createPodResponse((HostPodVO)result);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -34,12 +34,11 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.NetworkManager;
import com.cloud.network.RemoteAccessVpnVO;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@Implementation(createMethod="createRemoteAccessVpn", method="startRemoteAccessVpn", manager=NetworkManager.class, description="Creates a l2tp/ipsec remote access vpn")
@Implementation(description="Creates a l2tp/ipsec remote access vpn")
public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
public static final Logger s_logger = Logger.getLogger(CreateRemoteAccessVpnCmd.class.getName());
@ -108,23 +107,6 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public RemoteAccessVpnResponse getResponse() {
RemoteAccessVpnVO responseObj = (RemoteAccessVpnVO)getResponseObject();
RemoteAccessVpnResponse response = new RemoteAccessVpnResponse();
response.setId(responseObj.getId());
response.setPublicIp(responseObj.getVpnServerAddress());
response.setIpRange(responseObj.getIpRange());
response.setAccountName(responseObj.getAccountName());
response.setDomainId(responseObj.getDomainId());
response.setDomainName(ApiDBUtils.findDomainById(responseObj.getDomainId()).getName());
response.setObjectName("remoteaccessvpn");
response.setResponseName(getName());
response.setPresharedKey(responseObj.getIpsecPresharedKey());
return response;
}
@Override
public long getAccountId() {
Account account = (Account)UserContext.current().getAccount();
@ -163,13 +145,22 @@ public class CreateRemoteAccessVpnCmd extends BaseAsyncCreateCmd {
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
try {
RemoteAccessVpnVO result = _networkMgr.startRemoteAccessVpn(this);
return result;
RemoteAccessVpnResponse response = new RemoteAccessVpnResponse();
response.setId(result.getId());
response.setPublicIp(result.getVpnServerAddress());
response.setIpRange(result.getIpRange());
response.setAccountName(result.getAccountName());
response.setDomainId(result.getDomainId());
response.setDomainName(ApiDBUtils.findDomainById(result.getDomainId()).getName());
response.setObjectName("remoteaccessvpn");
response.setResponseName(getName());
response.setPresharedKey(result.getIpsecPresharedKey());
this.setResponseObject(response);
} catch (ResourceUnavailableException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}
}
}
}

View File

@ -27,7 +27,6 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.ServiceOfferingResponse;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
@ -36,7 +35,7 @@ import com.cloud.exception.PermissionDeniedException;
import com.cloud.offering.ServiceOffering;
import com.cloud.service.ServiceOfferingVO;
@Implementation(method="createServiceOffering", manager=ConfigurationManager.class, description="Creates a service offering.")
@Implementation(description="Creates a service offering.")
public class CreateServiceOfferingCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateServiceOfferingCmd.class.getName());
private static final String _name = "createserviceofferingresponse";
@ -121,17 +120,11 @@ public class CreateServiceOfferingCmd extends BaseCmd {
return _name;
}
@Override @SuppressWarnings("unchecked")
public ServiceOfferingResponse getResponse() {
ServiceOfferingVO offering = (ServiceOfferingVO)getResponseObject();
ServiceOfferingResponse response = ApiResponseHelper.createServiceOfferingResponse(offering);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
ServiceOffering result = _configService.createServiceOffering(this);
return result;
ServiceOfferingResponse response = ApiResponseHelper.createServiceOfferingResponse((ServiceOfferingVO)result);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -38,10 +38,9 @@ import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.storage.SnapshotVO;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.snapshot.SnapshotManager;
import com.cloud.user.Account;
@Implementation(method="createSnapshot", manager=SnapshotManager.class, description="Creates an instant snapshot of a volume.")
@Implementation(description="Creates an instant snapshot of a volume.")
public class CreateSnapshotCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(CreateSnapshotCmd.class.getName());
private static final String s_name = "createsnapshotresponse";
@ -109,24 +108,16 @@ public class CreateSnapshotCmd extends BaseAsyncCmd {
return "creating snapshot for volume: " + getVolumeId();
}
@Override @SuppressWarnings("unchecked")
public SnapshotResponse getResponse() {
SnapshotVO snapshot = (SnapshotVO)getResponseObject();
if (snapshot != null) {
SnapshotResponse response = ApiResponseHelper.createSnapshotResponse(snapshot);
response.setResponseName(getName());
return response;
}
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create snapshot due to an internal error creating snapshot for volume " + volumeId);
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
try {
SnapshotVO snapshot = _snapshotMgr.createSnapshot(this);
return snapshot;
if (snapshot != null) {
SnapshotResponse response = ApiResponseHelper.createSnapshotResponse(snapshot);
response.setResponseName(getName());
this.setResponseObject(response);
}
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create snapshot due to an internal error creating snapshot for volume " + volumeId);
} catch (ResourceAllocationException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}

View File

@ -37,10 +37,9 @@ import com.cloud.exception.ResourceAllocationException;
import com.cloud.storage.Snapshot.SnapshotType;
import com.cloud.storage.SnapshotVO;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.snapshot.SnapshotManager;
import com.cloud.user.Account;
@Implementation(method="createSnapshotInternal", manager=SnapshotManager.class, description="Creates an instant snapshot of a volume.")
@Implementation(description="Creates an instant snapshot of a volume.")
public class CreateSnapshotInternalCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(CreateSnapshotInternalCmd.class.getName());
private static final String s_name = "createsnapshotresponse";
@ -101,38 +100,31 @@ public class CreateSnapshotInternalCmd extends BaseAsyncCmd {
return "creating snapshot for volume: " + getVolumeId();
}
@Override @SuppressWarnings("unchecked")
public SnapshotResponse getResponse() {
SnapshotVO snapshot = (SnapshotVO)getResponseObject();
SnapshotResponse response = new SnapshotResponse();
response.setId(snapshot.getId());
Account account = ApiDBUtils.findAccountById(snapshot.getAccountId());
if (account != null) {
response.setAccountName(account.getAccountName());
response.setDomainId(account.getDomainId());
response.setDomainName(ApiDBUtils.findDomainById(account.getDomainId()).getName());
}
VolumeVO volume = ApiDBUtils.findVolumeById(snapshot.getVolumeId());
String snapshotTypeStr = SnapshotType.values()[snapshot.getSnapshotType()].name();
response.setSnapshotType(snapshotTypeStr);
response.setVolumeId(snapshot.getVolumeId());
response.setVolumeName(volume.getName());
response.setVolumeType(volume.getVolumeType().toString());
response.setCreated(snapshot.getCreated());
response.setName(snapshot.getName());
response.setObjectName("snapshot");
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
try {
SnapshotVO snapshot = _snapshotMgr.createSnapshotInternal(this);
return snapshot;
SnapshotResponse response = new SnapshotResponse();
response.setId(snapshot.getId());
Account account = ApiDBUtils.findAccountById(snapshot.getAccountId());
if (account != null) {
response.setAccountName(account.getAccountName());
response.setDomainId(account.getDomainId());
response.setDomainName(ApiDBUtils.findDomainById(account.getDomainId()).getName());
}
VolumeVO volume = ApiDBUtils.findVolumeById(snapshot.getVolumeId());
String snapshotTypeStr = SnapshotType.values()[snapshot.getSnapshotType()].name();
response.setSnapshotType(snapshotTypeStr);
response.setVolumeId(snapshot.getVolumeId());
response.setVolumeName(volume.getName());
response.setVolumeType(volume.getVolumeType().toString());
response.setCreated(snapshot.getCreated());
response.setName(snapshot.getName());
response.setObjectName("snapshot");
response.setResponseName(getName());
this.setResponseObject(response);
} catch (ResourceAllocationException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}

View File

@ -33,9 +33,8 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.SnapshotPolicyVO;
import com.cloud.storage.snapshot.SnapshotManager;
@Implementation(method="createPolicy", manager=SnapshotManager.class, description="Creates a snapshot policy for the account.")
@Implementation(description="Creates a snapshot policy for the account.")
public class CreateSnapshotPolicyCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateSnapshotPolicyCmd.class.getName());
@ -112,19 +111,13 @@ public class CreateSnapshotPolicyCmd extends BaseCmd {
@Override
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SnapshotPolicyResponse getResponse() {
SnapshotPolicyVO snapshotPolicy = (SnapshotPolicyVO)getResponseObject();
SnapshotPolicyResponse response = ApiResponseHelper.createSnapshotPolicyResponse(snapshotPolicy);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
SnapshotPolicyVO result = _snapshotMgr.createPolicy(this);
return result;
SnapshotPolicyResponse response = ApiResponseHelper.createSnapshotPolicyResponse(result);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -37,11 +37,10 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceInUseException;
import com.cloud.storage.StorageManager;
import com.cloud.storage.StoragePoolVO;
@SuppressWarnings("rawtypes")
@Implementation(method="createPool", manager=StorageManager.class, description="Creates a storage pool.")
@Implementation(description="Creates a storage pool.")
public class CreateStoragePoolCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateStoragePoolCmd.class.getName());
@ -112,25 +111,18 @@ public class CreateStoragePoolCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public StoragePoolResponse getResponse() {
StoragePoolVO pool = (StoragePoolVO)getResponseObject();
if (pool != null) {
StoragePoolResponse response = ApiResponseHelper.createStoragePoolResponse(pool);
response.setResponseName(getName());
return response;
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add host");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
try {
StoragePoolVO result = _storageMgr.createPool(this);
return result;
if (result != null) {
StoragePoolResponse response = ApiResponseHelper.createStoragePoolResponse(result);
response.setResponseName(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add host");
}
} catch (ResourceAllocationException ex1) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex1.getMessage());
}catch (ResourceInUseException ex2) {

View File

@ -42,9 +42,8 @@ import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
import com.cloud.storage.VMTemplateVO;
import com.cloud.storage.VolumeVO;
import com.cloud.user.Account;
import com.cloud.vm.UserVmManager;
@Implementation(method="createPrivateTemplate", createMethod="createPrivateTemplateRecord", manager=UserVmManager.class, description="Creates a template of a virtual machine. " +
@Implementation(description="Creates a template of a virtual machine. " +
"The virtual machine must be in a STOPPED state. " +
"A template created from this command is automatically designated as a private template visible to the account that created it.")
public class CreateTemplateCmd extends BaseAsyncCreateCmd {
@ -172,9 +171,16 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd {
return "creating template: " + getTemplateName();
}
@Override @SuppressWarnings("unchecked")
public TemplateResponse getResponse() {
VMTemplateVO template = (VMTemplateVO)getResponseObject();
@Override
public void callCreate() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException{
VMTemplateVO template = _userVmService.createPrivateTemplateRecord(this);
if (template != null)
this.setId(template.getId());
}
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
VMTemplateVO template = _userVmService.createPrivateTemplate(this);
TemplateResponse response = new TemplateResponse();
response.setId(template.getId());
@ -220,19 +226,7 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd {
response.setObjectName("template");
response.setResponseName(getName());
return response;
}
@Override
public void callCreate() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException{
VMTemplateVO template = _userVmService.createPrivateTemplateRecord(this);
if (template != null)
this.setId(template.getId());
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
VMTemplateVO result = _userVmService.createPrivateTemplate(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -34,7 +34,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.user.UserAccount;
@Implementation(method="createUser", description="Creates a user account")
@Implementation(description="Creates a user account")
public class CreateUserCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateUserCmd.class.getName());
@ -126,18 +126,12 @@ public class CreateUserCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public UserResponse getResponse() {
UserAccount user = (UserAccount)getResponseObject();
UserResponse response = ApiResponseHelper.createUserResponse(user);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
UserAccount result = _accountService.createUser(this);
return result;
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
UserAccount user = _accountService.createUser(this);
UserResponse response = ApiResponseHelper.createUserResponse(user);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -32,9 +32,8 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.vm.InstanceGroupVO;
import com.cloud.vm.UserVmManager;
@Implementation(method="createVmGroup", manager=UserVmManager.class)
@Implementation(description="Creates a vm group")
public class CreateVMGroupCmd extends BaseCmd{
public static final Logger s_logger = Logger.getLogger(CreateVMGroupCmd.class.getName());
@ -77,18 +76,12 @@ public class CreateVMGroupCmd extends BaseCmd{
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public InstanceGroupResponse getResponse() {
InstanceGroupVO group = (InstanceGroupVO)getResponseObject();
InstanceGroupResponse response = ApiResponseHelper.createInstanceGroupResponse(group);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
InstanceGroupVO result = _userVmService.createVmGroup(this);
return result;
InstanceGroupResponse response = ApiResponseHelper.createInstanceGroupResponse(result);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -27,7 +27,6 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.VlanIpRangeResponse;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.dc.Vlan;
import com.cloud.dc.VlanVO;
import com.cloud.exception.ConcurrentOperationException;
@ -36,7 +35,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="createVlanAndPublicIpRange", manager=ConfigurationManager.class, description="Creates a VLAN IP range.")
@Implementation(description="Creates a VLAN IP range.")
public class CreateVlanIpRangeCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateVlanIpRangeCmd.class.getName());
@ -129,18 +128,12 @@ public class CreateVlanIpRangeCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public VlanIpRangeResponse getResponse() {
VlanVO vlan = (VlanVO)getResponseObject();
VlanIpRangeResponse response = ApiResponseHelper.createVlanIpRangeResponse(vlan);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
Vlan result = _configService.createVlanAndPublicIpRange(this);
return result;
VlanIpRangeResponse response = ApiResponseHelper.createVlanIpRangeResponse((VlanVO)result);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -145,16 +145,6 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
return "creating volume: " + getVolumeName() + ((getSnapshotId() == null) ? "" : " from snapshot: " + getSnapshotId());
}
@Override @SuppressWarnings("unchecked")
public VolumeResponse getResponse() {
VolumeVO volume = (VolumeVO)getResponseObject();
VolumeResponse response = ApiResponseHelper.createVolumeResponse(volume);
//FIXME - have to be moved to ApiResponseHelper
response.setSnapshotId(getSnapshotId()); // if the volume was created from a snapshot, snapshotId will be set so we pass it back in the response
response.setResponseName(getName());
return response;
}
@Override
public void callCreate() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException{
Volume volume = _storageMgr.allocVolume(this);
@ -164,8 +154,12 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
Volume volume = _storageMgr.createVolume(this);
return volume;
VolumeResponse response = ApiResponseHelper.createVolumeResponse((VolumeVO)volume);
//FIXME - have to be moved to ApiResponseHelper
response.setSnapshotId(getSnapshotId()); // if the volume was created from a snapshot, snapshotId will be set so we pass it back in the response
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -27,7 +27,6 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.ZoneResponse;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.dc.DataCenter;
import com.cloud.dc.DataCenterVO;
import com.cloud.exception.ConcurrentOperationException;
@ -36,7 +35,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="createZone", manager=ConfigurationManager.class, description="Creates a Zone.")
@Implementation(description="Creates a Zone.")
public class CreateZoneCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(CreateZoneCmd.class.getName());
@ -121,18 +120,12 @@ public class CreateZoneCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ZoneResponse getResponse() {
DataCenterVO zone = (DataCenterVO)getResponseObject();
ZoneResponse response = ApiResponseHelper.createZoneResponse(zone);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
DataCenter result = _configService.createZone(this);
return result;
ZoneResponse response = ApiResponseHelper.createZoneResponse((DataCenterVO)result);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -25,14 +25,13 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.SuccessResponse;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="deleteDiskOffering", manager=ConfigurationManager.class, description="Updates a disk offering.")
@Implementation(description="Updates a disk offering.")
public class DeleteDiskOfferingCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeleteDiskOfferingCmd.class.getName());
private static final String s_name = "deletediskofferingresponse";
@ -60,20 +59,16 @@ public class DeleteDiskOfferingCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete disk offering");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _configService.deleteDiskOffering(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete disk offering");
}
}
}

View File

@ -36,7 +36,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.user.Account;
@Implementation(method="deleteDomain", description="Deletes a specified domain")
@Implementation(description="Deletes a specified domain")
public class DeleteDomainCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DeleteDomainCmd.class.getName());
private static final String s_name = "deletedomainresponse";
@ -92,19 +92,15 @@ public class DeleteDomainCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "deleting domain: " + getId();
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete delete domain");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _mgr.deleteDomain(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete domain");
}
}
}

View File

@ -20,7 +20,6 @@ package com.cloud.api.commands;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.api.ApiConstants;
import com.cloud.api.BaseCmd;
import com.cloud.api.Implementation;
@ -34,7 +33,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="deleteHost", manager=AgentManager.class, description="Deletes a host.")
@Implementation(description="Deletes a host.")
public class DeleteHostCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeleteHostCmd.class.getName());
@ -66,18 +65,14 @@ public class DeleteHostCmd extends BaseCmd {
return s_name;
}
@Override@SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete host");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _agentMgr.deleteHost(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete host");
}
}
}

View File

@ -30,9 +30,8 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.NetworkManager;
@Implementation(method="deleteIpForwardingRule", manager=NetworkManager.class, description="Deletes a port forwarding rule")
@Implementation(description="Deletes a port forwarding rule")
public class DeleteIPForwardingRuleCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeleteIPForwardingRuleCmd.class.getName());
private static final String s_name = "deleteportforwardingruleresponse";
@ -61,20 +60,15 @@ public class DeleteIPForwardingRuleCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete port forwarding rule");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _networkMgr.deleteIpForwardingRule(this);
return result;
}
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete port forwarding rule");
}
}
}

View File

@ -34,10 +34,9 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.VMTemplateVO;
import com.cloud.template.TemplateManager;
import com.cloud.user.Account;
@Implementation(method="deleteIso", manager=TemplateManager.class, description="Deletes an ISO file.")
@Implementation(description="Deletes an ISO file.")
public class DeleteIsoCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DeleteIsoCmd.class.getName());
private static final String s_name = "deleteisosresponse";
@ -78,15 +77,6 @@ public class DeleteIsoCmd extends BaseAsyncCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete iso");
}
}
@Override
public long getAccountId() {
VMTemplateVO iso = ApiDBUtils.findTemplateById(getId());
@ -108,8 +98,13 @@ public class DeleteIsoCmd extends BaseAsyncCmd {
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _templateMgr.deleteIso(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete iso");
}
}
}

View File

@ -34,10 +34,9 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.LoadBalancerVO;
import com.cloud.network.NetworkManager;
import com.cloud.user.Account;
@Implementation(method="deleteLoadBalancerRule", manager=NetworkManager.class, description="Deletes a load balancer rule.")
@Implementation(description="Deletes a load balancer rule.")
public class DeleteLoadBalancerRuleCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DeleteLoadBalancerRuleCmd.class.getName());
private static final String s_name = "deleteloadbalancerruleresponse";
@ -85,19 +84,15 @@ public class DeleteLoadBalancerRuleCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "deleting load balancer: " + getId();
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete load balancer rule");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _networkMgr.deleteLoadBalancerRule(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete load balancer");
}
}
}

View File

@ -14,9 +14,8 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceInUseException;
import com.cloud.network.security.NetworkGroupManager;
@Implementation(method="deleteNetworkGroup", manager=NetworkGroupManager.class)
@Implementation(description="Deletes network group")
public class DeleteNetworkGroupCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeleteNetworkGroupCmd.class.getName());
private static final String s_name = "deletenetworkgroupresponse";
@ -60,21 +59,17 @@ public class DeleteNetworkGroupCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete security group");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
try{
boolean result = _networkGroupMgr.deleteNetworkGroup(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network group");
}
} catch (ResourceInUseException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}

View File

@ -26,14 +26,13 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.SuccessResponse;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="deletePod", manager=ConfigurationManager.class, description="Deletes a Pod.")
@Implementation(description="Deletes a Pod.")
public class DeletePodCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeletePodCmd.class.getName());
@ -62,19 +61,15 @@ public class DeletePodCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete pod");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _configService.deletePod(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete pod");
}
}
}

View File

@ -13,9 +13,8 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.StorageManager;
@Implementation(method="deletePool", manager=StorageManager.class, description="Deletes a storage pool.")
@Implementation(description="Deletes a storage pool.")
public class DeletePoolCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeletePoolCmd.class.getName());
private static final String s_name = "deletestoragepoolresponse";
@ -46,18 +45,14 @@ public class DeletePoolCmd extends BaseCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if ((Boolean)getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete storage pool");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _storageMgr.deletePool(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete storage pool");
}
}
}

View File

@ -29,7 +29,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="unregisterPreallocatedLun")
@Implementation(description="Unregisters PreallocatedLun")
public class DeletePreallocatedLunCmd extends BaseCmd {
private static final String s_name = "deletePreallocatedLunsResponse";
@ -57,18 +57,14 @@ public class DeletePreallocatedLunCmd extends BaseCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete preallocated lun");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _mgr.unregisterPreallocatedLun(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete preallocated lun");
}
}
}

View File

@ -33,11 +33,10 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.NetworkManager;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@Implementation(method="destroyRemoteAccessVpn", manager=NetworkManager.class, description="Destroys a l2tp/ipsec remote access vpn")
@Implementation(description="Destroys a l2tp/ipsec remote access vpn")
public class DeleteRemoteAccessVpnCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DeleteRemoteAccessVpnCmd.class.getName());
@ -83,15 +82,6 @@ public class DeleteRemoteAccessVpnCmd extends BaseAsyncCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if ((Boolean)getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete remote access vpn");
}
}
@Override
public long getAccountId() {
Account account = (Account)UserContext.current().getAccount();
@ -122,9 +112,14 @@ public class DeleteRemoteAccessVpnCmd extends BaseAsyncCmd {
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _networkMgr.destroyRemoteAccessVpn(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete remote access vpn");
}
}
}

View File

@ -26,14 +26,13 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.SuccessResponse;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="deleteServiceOffering", manager=ConfigurationManager.class, description="Deletes a service offering.")
@Implementation(description="Deletes a service offering.")
public class DeleteServiceOfferingCmd extends BaseCmd{
public static final Logger s_logger = Logger.getLogger(DeleteServiceOfferingCmd.class.getName());
private static final String s_name = "deleteserviceofferingresponse";
@ -62,21 +61,16 @@ public class DeleteServiceOfferingCmd extends BaseCmd{
@Override
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete service offering");
}
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _configService.deleteServiceOffering(this);
return result;
}
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete service offering");
}
}
}

View File

@ -35,10 +35,9 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.Snapshot;
import com.cloud.storage.snapshot.SnapshotManager;
import com.cloud.user.Account;
@Implementation(method="deleteSnapshot", manager=SnapshotManager.class, description="Deletes a snapshot of a disk volume.")
@Implementation(description="Deletes a snapshot of a disk volume.")
public class DeleteSnapshotCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DeleteSnapshotCmd.class.getName());
private static final String s_name = "deletesnapshotresponse";
@ -102,18 +101,14 @@ public class DeleteSnapshotCmd extends BaseAsyncCmd {
return "deleting snapshot: " + getId();
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete snapshot");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _snapshotMgr.deleteSnapshot(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete snapshot");
}
}
}

View File

@ -33,9 +33,8 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.snapshot.SnapshotManager;
@Implementation(method="deleteSnapshotPolicies", manager=SnapshotManager.class, description="Deletes snapshot policies for the account.")
@Implementation(description="Deletes snapshot policies for the account.")
public class DeleteSnapshotPoliciesCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeleteSnapshotPoliciesCmd.class.getName());
@ -88,18 +87,14 @@ public class DeleteSnapshotPoliciesCmd extends BaseCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete snapshot policy");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _snapshotMgr.deleteSnapshotPolicies(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete snapshot policy");
}
}
}

View File

@ -35,10 +35,9 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.VMTemplateVO;
import com.cloud.template.TemplateManager;
import com.cloud.user.Account;
@Implementation(method="deleteTemplate", manager=TemplateManager.class, description="Deletes a template from the system. All virtual machines using the deleted template will not be affected.")
@Implementation(description="Deletes a template from the system. All virtual machines using the deleted template will not be affected.")
public class DeleteTemplateCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DeleteTemplateCmd.class.getName());
private static final String s_name = "deletetemplateresponse";
@ -80,15 +79,6 @@ public class DeleteTemplateCmd extends BaseAsyncCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete template");
}
}
@Override
public long getAccountId() {
VMTemplateVO template = ApiDBUtils.findTemplateById(getId());
@ -110,8 +100,13 @@ public class DeleteTemplateCmd extends BaseAsyncCmd {
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _templateMgr.deleteTemplate(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete template");
}
}
}

View File

@ -34,12 +34,11 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.server.ManagementServer;
import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.user.UserContext;
@Implementation(method="deleteUser", manager=ManagementServer.class, description="Deletes a user account")
@Implementation(description="Deletes a user account")
public class DeleteUserCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DeleteUserCmd.class.getName());
private static final String s_name = "deleteuserresponse";
@ -94,19 +93,15 @@ public class DeleteUserCmd extends BaseAsyncCmd {
User user = ApiDBUtils.findUserById(getId());
return (user != null ? ("User " + user.getUsername() + " (id: " + user.getId() + ") and accountId = " + user.getAccountId()) : "user delete, but this user does not exist in the system");
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete user");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _accountService.deleteUser(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete user");
}
}
}

View File

@ -30,9 +30,8 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.vm.UserVmManager;
@Implementation(method="deleteVmGroup", manager=UserVmManager.class)
@Implementation(description="Deletes a vm group")
public class DeleteVMGroupCmd extends BaseCmd{
public static final Logger s_logger = Logger.getLogger(DeleteVMGroupCmd.class.getName());
private static final String s_name = "deleteinstancegroupresponse";
@ -60,19 +59,15 @@ public class DeleteVMGroupCmd extends BaseCmd{
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete virtual machine group");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _userVmService.deleteVmGroup(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete vm group");
}
}
}

View File

@ -26,14 +26,13 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.SuccessResponse;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="deleteVlanIpRange", manager=ConfigurationManager.class, description="Creates a VLAN IP range.")
@Implementation(description="Creates a VLAN IP range.")
public class DeleteVlanIpRangeCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeleteVlanIpRangeCmd.class.getName());
@ -62,19 +61,15 @@ public class DeleteVlanIpRangeCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete vlan ip range");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _configService.deleteVlanIpRange(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete vlan ip range");
}
}
}

View File

@ -31,9 +31,8 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.StorageManager;
@Implementation(method="deleteVolume", manager=StorageManager.class, description="Deletes a detached disk volume.")
@Implementation(description="Deletes a detached disk volume.")
public class DeleteVolumeCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeleteVolumeCmd.class.getName());
private static final String s_name = "deletevolumeresponse";
@ -67,19 +66,15 @@ public class DeleteVolumeCmd extends BaseCmd {
public static String getResultObjectName() {
return "volume";
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete volume");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _storageMgr.deleteVolume(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete volume");
}
}
}

View File

@ -26,14 +26,13 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.SuccessResponse;
import com.cloud.configuration.ConfigurationManager;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="deleteZone", manager=ConfigurationManager.class, description="Deletes a Zone.")
@Implementation(description="Deletes a Zone.")
public class DeleteZoneCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DeleteZoneCmd.class.getName());
@ -65,18 +64,14 @@ public class DeleteZoneCmd extends BaseCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete zone");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _configService.deleteZone(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete zone");
}
}
}

View File

@ -44,7 +44,7 @@ import com.cloud.user.UserContext;
import com.cloud.uservm.UserVm;
import com.cloud.utils.exception.ExecutionException;
@Implementation(method="deployVirtualMachine", description="Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.")
@Implementation(description="Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.")
public class DeployVMCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DeployVMCmd.class.getName());
@ -196,25 +196,19 @@ public class DeployVMCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "deploying Vm";
}
@Override @SuppressWarnings("unchecked")
public UserVmResponse getResponse() {
UserVm userVm = (UserVm)getResponseObject();
UserVmResponse response = ApiResponseHelper.createUserVmResponse(userVm);
// FIXME: where will the password come from in this case?
// if (templatePasswordEnabled) {
// response.setPassword(getPassword());
// }
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, StorageUnavailableException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, StorageUnavailableException{
try {
UserVm result = _mgr.deployVirtualMachine(this);
return result;
UserVmResponse response = ApiResponseHelper.createUserVmResponse(result);
// FIXME: where will the password come from in this case?
// if (templatePasswordEnabled) {
// response.setPassword(getPassword());
// }
response.setResponseName(getName());
this.setResponseObject(response);
} catch (ResourceAllocationException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
} catch (ExecutionException ex1) {

View File

@ -37,6 +37,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.offering.ServiceOffering;
import com.cloud.storage.VMTemplateVO;
import com.cloud.user.Account;
@ -44,9 +45,8 @@ import com.cloud.user.User;
import com.cloud.user.UserContext;
import com.cloud.uservm.UserVm;
import com.cloud.vm.InstanceGroupVO;
import com.cloud.vm.UserVmService;
@Implementation(createMethod="createVirtualMachine", method="startVirtualMachine", manager=UserVmService.class, description="Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.")
@Implementation(description="Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.")
public class DeployVm2Cmd extends BaseAsyncCreateCmd {
public static final Logger s_logger = Logger.getLogger(DeployVMCmd.class.getName());
@ -161,57 +161,9 @@ public class DeployVm2Cmd extends BaseAsyncCreateCmd {
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
@Override
public Object execute() {
//TODO - method stub should be here
return null;
}
@Override
public void callCreate() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException{
}
@Override
public String getName() {
return s_name;
}
public static String getResultObjectName() {
return "virtualmachine";
}
@Override
public long getAccountId() {
Account account = UserContext.current().getAccount();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = ApiDBUtils.findAccountByNameDomain(accountName, domainId);
if (userAccount != null) {
return userAccount.getId();
}
}
}
if (account != null) {
return account.getId();
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
@Override
public String getEventType() {
return EventTypes.EVENT_VM_CREATE;
}
@Override
public String getEventDescription() {
return "deploying Vm";
}
@Override @SuppressWarnings("unchecked")
public UserVmResponse getResponse() {
UserVm userVm = (UserVm)getResponseObject();
public void execute() {
try {
UserVm userVm = _userVmService.startVirtualMachine(this);
UserVmResponse response = new UserVmResponse();
response.setId(userVm.getId());
@ -313,6 +265,61 @@ public class DeployVm2Cmd extends BaseAsyncCreateCmd {
response.setResponseName(getName());
response.setObjectName("virtualmachine");
return response;
this.setResponseObject(response);
} catch (Exception ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to deploy virtual machine");
}
}
@Override
public void callCreate() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException{
try {
UserVm vm = _userVmService.createVirtualMachine(this);
if (vm != null) {
this.setId(vm.getId());
}
} catch (ResourceUnavailableException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a vm");
}
}
@Override
public String getName() {
return s_name;
}
public static String getResultObjectName() {
return "virtualmachine";
}
@Override
public long getAccountId() {
Account account = UserContext.current().getAccount();
if ((account == null) || isAdmin(account.getType())) {
if ((domainId != null) && (accountName != null)) {
Account userAccount = ApiDBUtils.findAccountByNameDomain(accountName, domainId);
if (userAccount != null) {
return userAccount.getId();
}
}
}
if (account != null) {
return account.getId();
}
return Account.ACCOUNT_ID_SYSTEM; // no account info given, parent this command to SYSTEM so ERROR events are tracked
}
@Override
public String getEventType() {
return EventTypes.EVENT_VM_CREATE;
}
@Override
public String getEventDescription() {
return "deploying Vm";
}
}

View File

@ -27,7 +27,6 @@ import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.SuccessResponse;
import com.cloud.consoleproxy.ConsoleProxyManager;
import com.cloud.event.EventTypes;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientAddressCapacityException;
@ -37,7 +36,7 @@ import com.cloud.exception.PermissionDeniedException;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@Implementation(method="destroyConsoleProxy", manager=ConsoleProxyManager.class)
@Implementation(description="Destroys console proxy")
public class DestroyConsoleProxyCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DestroyConsoleProxyCmd.class.getName());
@ -88,19 +87,15 @@ public class DestroyConsoleProxyCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "destroying console proxy: " + getId();
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete console proxy");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _consoleProxyMgr.destroyConsoleProxy(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to destroy console proxy");
}
}
}

View File

@ -36,9 +36,8 @@ import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.user.Account;
import com.cloud.uservm.UserVm;
import com.cloud.vm.UserVmManager;
@Implementation(method="destroyVm", manager=UserVmManager.class, description="Destroys a virtual machine. Once destroyed, only the administrator can recover it.")
@Implementation(description="Destroys a virtual machine. Once destroyed, only the administrator can recover it.")
public class DestroyVMCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DestroyVMCmd.class.getName());
@ -88,17 +87,11 @@ public class DestroyVMCmd extends BaseAsyncCmd {
return "destroying vm: " + getId();
}
@Override @SuppressWarnings("unchecked")
public UserVmResponse getResponse() {
UserVm userVm = (UserVm)getResponseObject();
UserVmResponse recoverVmResponse = ApiResponseHelper.createUserVmResponse(userVm);
recoverVmResponse.setResponseName("virtualmachine");
return recoverVmResponse;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, StorageUnavailableException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, StorageUnavailableException{
UserVm result = _userVmService.destroyVm(this);
return result;
UserVmResponse response = ApiResponseHelper.createUserVmResponse(result);
response.setResponseName("virtualmachine");
this.setResponseObject(response);
}
}

View File

@ -33,11 +33,10 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.template.TemplateManager;
import com.cloud.user.Account;
import com.cloud.uservm.UserVm;
@Implementation(method="detachIso", manager=TemplateManager.class, description="Detaches any ISO file (if any) currently attached to a virtual machine.")
@Implementation(description="Detaches any ISO file (if any) currently attached to a virtual machine.")
public class DetachIsoCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DetachIsoCmd.class.getName());
@ -86,19 +85,15 @@ public class DetachIsoCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "detaching ISO from vm: " + getVirtualMachineId();
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to detach iso");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _templateMgr.detachIso(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to detach iso");
}
}
}

View File

@ -37,9 +37,8 @@ import com.cloud.storage.Volume;
import com.cloud.storage.VolumeVO;
import com.cloud.user.Account;
import com.cloud.uservm.UserVm;
import com.cloud.vm.UserVmManager;
@Implementation(method="detachVolumeFromVM", manager=UserVmManager.class, description="Detaches a disk volume from a virtual machine.")
@Implementation(description="Detaches a disk volume from a virtual machine.")
public class DetachVolumeCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DetachVolumeCmd.class.getName());
private static final String s_name = "detachvolumeresponse";
@ -123,17 +122,11 @@ public class DetachVolumeCmd extends BaseAsyncCmd {
return "detaching volume" + sb.toString();
}
@Override @SuppressWarnings("unchecked")
public VolumeResponse getResponse() {
VolumeVO volume = (VolumeVO)getResponseObject();
VolumeResponse response = ApiResponseHelper.createVolumeResponse(volume);
response.setResponseName("volume");
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
Volume result = _userVmService.detachVolumeFromVM(this);
return result;
VolumeResponse response = ApiResponseHelper.createVolumeResponse((VolumeVO)result);
response.setResponseName("volume");
this.setResponseObject(response);
}
}

View File

@ -32,12 +32,10 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.server.ManagementServer;
import com.cloud.user.Account;
import com.cloud.user.AccountVO;
import com.cloud.user.UserContext;
@Implementation(method="disableAccount", manager=ManagementServer.class, description="Disables an account")
@Implementation(description="Disables an account")
public class DisableAccountCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DisableAccountCmd.class.getName());
private static final String s_name = "disableaccountresponse";
@ -93,17 +91,11 @@ public class DisableAccountCmd extends BaseAsyncCmd {
return "disabling account: " + getAccountName() + " in domain: " + getDomainId();
}
@Override @SuppressWarnings("unchecked")
public AccountResponse getResponse() {
AccountVO account = (AccountVO)getResponseObject();
AccountResponse response = ApiResponseHelper.createAccountResponse(account);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
Account result = _accountService.disableAccount(this);
return result;
AccountResponse response = ApiResponseHelper.createAccountResponse(result);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -36,7 +36,7 @@ import com.cloud.user.Account;
import com.cloud.user.UserAccount;
import com.cloud.user.UserContext;
@Implementation(method="disableUser", description="Disables a user account")
@Implementation(description="Disables a user account")
public class DisableUserCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(DisableUserCmd.class.getName());
private static final String s_name = "disableuserresponse";
@ -85,17 +85,12 @@ public class DisableUserCmd extends BaseAsyncCmd {
return "disabling user: " + getId();
}
@Override @SuppressWarnings("unchecked")
public UserResponse getResponse() {
UserAccount user = (UserAccount)getResponseObject();
UserResponse response = ApiResponseHelper.createUserResponse(user);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
UserAccount result = _accountService.disableUser(this);
return result;
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
UserAccount user = _accountService.disableUser(this);
UserResponse response = ApiResponseHelper.createUserResponse(user);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -30,9 +30,8 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.NetworkManager;
@Implementation(method="disassociateIpAddress", manager=NetworkManager.class, description="Disassociates an ip address from the account.")
@Implementation(description="Disassociates an ip address from the account.")
public class DisassociateIPAddrCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(DisassociateIPAddrCmd.class.getName());
@ -62,18 +61,14 @@ public class DisassociateIPAddrCmd extends BaseCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public SuccessResponse getResponse() {
if (getResponseObject() == null || (Boolean)getResponseObject()) {
return new SuccessResponse(getName());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to disassociate ip address");
}
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
boolean result = _networkMgr.disassociateIpAddress(this);
return result;
if (result) {
SuccessResponse response = new SuccessResponse(getName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to disassociate ip address");
}
}
}

View File

@ -31,11 +31,9 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.server.ManagementServer;
import com.cloud.user.Account;
import com.cloud.user.AccountVO;
@Implementation(method="enableAccount", manager=ManagementServer.class, description="Enables an account")
@Implementation(description="Enables an account")
public class EnableAccountCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(EnableAccountCmd.class.getName());
private static final String s_name = "enableaccountresponse";
@ -70,18 +68,12 @@ public class EnableAccountCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public AccountResponse getResponse() {
AccountVO account = (AccountVO)getResponseObject();
AccountResponse response = ApiResponseHelper.createAccountResponse(account);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
Account result = _accountService.enableAccount(this);
return result;
AccountResponse response = ApiResponseHelper.createAccountResponse(result);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -32,10 +32,9 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.server.ManagementServer;
import com.cloud.user.UserAccount;
@Implementation(method="enableUser", manager=ManagementServer.class, description="Enables a user account")
@Implementation(description="Enables a user account")
public class EnableUserCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(EnableUserCmd.class.getName());
private static final String s_name = "enableuserresponse";
@ -65,17 +64,11 @@ public class EnableUserCmd extends BaseCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public UserResponse getResponse() {
UserAccount user = (UserAccount)getResponseObject();
UserResponse response = ApiResponseHelper.createUserResponse(user);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
UserAccount result = _accountService.enableUser(this);
return result;
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
UserAccount user = _accountService.enableUser(this);
UserResponse response = ApiResponseHelper.createUserResponse(user);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -37,10 +37,9 @@ import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.storage.UploadVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.template.TemplateManager;
import com.cloud.user.Account;
@Implementation(method="extract", manager=TemplateManager.class)
@Implementation(description="Extracts an ISO")
public class ExtractIsoCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(ExtractIsoCmd.class.getName());
@ -111,37 +110,30 @@ public class ExtractIsoCmd extends BaseAsyncCmd {
return "Extraction job";
}
@Override @SuppressWarnings("unchecked")
public ExtractResponse getResponse() {
Long uploadId = (Long)getResponseObject();
UploadVO uploadInfo = ApiDBUtils.findUploadById(uploadId);
ExtractResponse response = new ExtractResponse();
response.setId(id);
response.setName(ApiDBUtils.findTemplateById(id).getName());
response.setZoneId(zoneId);
response.setZoneName(ApiDBUtils.findZoneById(zoneId).getName());
response.setMode(mode);
response.setUploadId(uploadId);
response.setState(uploadInfo.getUploadState().toString());
response.setAccountId(getAccountId());
//FIX ME - Need to set the url once the gson jar is upgraded since it is throwing an error right now due to a bug.
//response.setUrl(uploadInfo.getUploadUrl());
response.setUrl(uploadInfo.getUploadUrl().replaceAll("/", "%2F"));
response.setResponseName(getName());
response.setObjectName("iso");
return response;
}
public static String getStaticName() {
return s_name;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException{
try {
Long result = _templateMgr.extract(this);
return result;
Long uploadId = _templateMgr.extract(this);
UploadVO uploadInfo = ApiDBUtils.findUploadById(uploadId);
ExtractResponse response = new ExtractResponse();
response.setId(id);
response.setName(ApiDBUtils.findTemplateById(id).getName());
response.setZoneId(zoneId);
response.setZoneName(ApiDBUtils.findZoneById(zoneId).getName());
response.setMode(mode);
response.setUploadId(uploadId);
response.setState(uploadInfo.getUploadState().toString());
response.setAccountId(getAccountId());
//FIX ME - Need to set the url once the gson jar is upgraded since it is throwing an error right now due to a bug.
//response.setUrl(uploadInfo.getUploadUrl());
response.setUrl(uploadInfo.getUploadUrl().replaceAll("/", "%2F"));
response.setResponseName(getName());
response.setObjectName("iso");
this.setResponseObject(response);
} catch (InternalErrorException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}

View File

@ -37,10 +37,9 @@ import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.storage.UploadVO;
import com.cloud.storage.VMTemplateVO;
import com.cloud.template.TemplateManager;
import com.cloud.user.Account;
@Implementation(method="extract", manager=TemplateManager.class)
@Implementation(description="Extracts a template")
public class ExtractTemplateCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(ExtractTemplateCmd.class.getName());
@ -115,34 +114,28 @@ public class ExtractTemplateCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "Extraction job";
}
@Override @SuppressWarnings("unchecked")
public ExtractResponse getResponse() {
Long uploadId = (Long)getResponseObject();
UploadVO uploadInfo = ApiDBUtils.findUploadById(uploadId);
ExtractResponse response = new ExtractResponse();
response.setResponseName(getName());
response.setObjectName("template");
response.setId(id);
response.setName(ApiDBUtils.findTemplateById(id).getName());
response.setZoneId(zoneId);
response.setZoneName(ApiDBUtils.findZoneById(zoneId).getName());
response.setMode(mode);
response.setUploadId(uploadId);
response.setState(uploadInfo.getUploadState().toString());
response.setAccountId(getAccountId());
//FIX ME - Need to set the url once the gson jar is upgraded since it is throwing an error right now.
//response.setUrl(uploadInfo.getUploadUrl());
response.setUrl(uploadInfo.getUploadUrl().replaceAll("/", "%2F"));
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException{
try {
Long result = _templateMgr.extract(this);
return result;
Long uploadId = _templateMgr.extract(this);
UploadVO uploadInfo = ApiDBUtils.findUploadById(uploadId);
ExtractResponse response = new ExtractResponse();
response.setResponseName(getName());
response.setObjectName("template");
response.setId(id);
response.setName(ApiDBUtils.findTemplateById(id).getName());
response.setZoneId(zoneId);
response.setZoneName(ApiDBUtils.findZoneById(zoneId).getName());
response.setMode(mode);
response.setUploadId(uploadId);
response.setState(uploadInfo.getUploadState().toString());
response.setAccountId(getAccountId());
//FIX ME - Need to set the url once the gson jar is upgraded since it is throwing an error right now.
//response.setUrl(uploadInfo.getUploadUrl());
response.setUrl(uploadInfo.getUploadUrl().replaceAll("/", "%2F"));
this.setResponseObject(response);
} catch (InternalErrorException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}

View File

@ -40,7 +40,7 @@ import com.cloud.storage.UploadVO;
import com.cloud.storage.VolumeVO;
import com.cloud.user.Account;
@Implementation(method="extractVolume")
@Implementation(description="Extracts volume")
public class ExtractVolumeCmd extends BaseAsyncCmd {
public static final Logger s_logger = Logger.getLogger(ExtractVolumeCmd.class.getName());
@ -93,6 +93,10 @@ public class ExtractVolumeCmd extends BaseAsyncCmd {
public String getName() {
return s_name;
}
public static String getStaticName() {
return s_name;
}
@Override
public long getAccountId() {
@ -114,37 +118,27 @@ public class ExtractVolumeCmd extends BaseAsyncCmd {
public String getEventDescription() {
return "Extraction job";
}
@Override @SuppressWarnings("unchecked")
public ExtractResponse getResponse() {
Long uploadId = (Long)getResponseObject();
UploadVO uploadInfo = ApiDBUtils.findUploadById(uploadId);
ExtractResponse response = new ExtractResponse();
response.setResponseName(getName());
response.setObjectName("volume");
response.setId(id);
response.setName(ApiDBUtils.findVolumeById(id).getName());
response.setZoneId(zoneId);
response.setZoneName(ApiDBUtils.findZoneById(zoneId).getName());
response.setMode(mode);
response.setUploadId(uploadId);
response.setState(uploadInfo.getUploadState().toString());
response.setAccountId(getAccountId());
//FIX ME - Need to set the url once the gson jar is upgraded since it is throwing an error right now.
response.setUrl(uploadInfo.getUploadUrl().replaceAll("/", "%2F"));
return response;
}
public static String getStaticName() {
return s_name;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException{
try {
Long result = _mgr.extractVolume(this);
return result;
Long uploadId = _mgr.extractVolume(this);
UploadVO uploadInfo = ApiDBUtils.findUploadById(uploadId);
ExtractResponse response = new ExtractResponse();
response.setResponseName(getName());
response.setObjectName("volume");
response.setId(id);
response.setName(ApiDBUtils.findVolumeById(id).getName());
response.setZoneId(zoneId);
response.setZoneName(ApiDBUtils.findZoneById(zoneId).getName());
response.setMode(mode);
response.setUploadId(uploadId);
response.setState(uploadInfo.getUploadState().toString());
response.setAccountId(getAccountId());
//FIX ME - Need to set the url once the gson jar is upgraded since it is throwing an error right now.
response.setUrl(uploadInfo.getUploadUrl().replaceAll("/", "%2F"));
this.setResponseObject(response);
} catch (URISyntaxException ex) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
}

View File

@ -33,9 +33,8 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.server.ManagementServer;
@Implementation(method="getCloudIdentifierResponse", manager=ManagementServer.class, description="Retrieves a cloud identifier.")
@Implementation(description="Retrieves a cloud identifier.")
public class GetCloudIdentifierCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(GetCloudIdentifierCmd.class.getName());
private static final String s_name = "getcloudidentifierresponse";
@ -65,25 +64,19 @@ public class GetCloudIdentifierCmd extends BaseCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public CloudIdentifierResponse getResponse() {
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
ArrayList<String> result = _mgr.getCloudIdentifierResponse(this);
CloudIdentifierResponse response = new CloudIdentifierResponse();
ArrayList<String> responseObject = (ArrayList<String>)getResponseObject();
if (responseObject != null) {
response.setCloudIdentifier(responseObject.get(0));
response.setSignature(responseObject.get(1));
if (result != null) {
response.setCloudIdentifier(result.get(0));
response.setSignature(result.get(1));
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add config");
}
response.setObjectName("cloudidentifier");
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
ArrayList<String> result = _mgr.getCloudIdentifierResponse(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -35,10 +35,9 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.server.ManagementServer;
import com.cloud.user.AccountVO;
@Implementation(method="searchForAccounts",manager=ManagementServer.class,description="Lists accounts and provides detailed account information for listed accounts")
@Implementation(description="Lists accounts and provides detailed account information for listed accounts")
public class ListAccountsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListAccountsCmd.class.getName());
private static final String s_name = "listaccountsresponse";
@ -110,12 +109,10 @@ public class ListAccountsCmd extends BaseListCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<AccountResponse> getResponse() {
List<AccountVO> accounts = (List<AccountVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<AccountVO> accounts = _mgr.searchForAccounts(this);
ListResponse<AccountResponse> response = new ListResponse<AccountResponse>();
List<AccountResponse> accountResponses = new ArrayList<AccountResponse>();
for (AccountVO account : accounts) {
AccountResponse acctResponse = ApiResponseHelper.createAccountResponse(account);
@ -125,12 +122,7 @@ public class ListAccountsCmd extends BaseListCmd {
response.setResponses(accountResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<AccountVO> result = _mgr.searchForAccounts(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -36,7 +36,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="searchForAlerts", description="Lists all alerts.")
@Implementation(description="Lists all alerts.")
public class ListAlertsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListAlertsCmd.class.getName());
@ -66,14 +66,13 @@ public class ListAlertsCmd extends BaseListCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<AlertResponse> getResponse() {
List<AlertVO> alertList = (List<AlertVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<AlertVO> result = _mgr.searchForAlerts(this);
ListResponse<AlertResponse> response = new ListResponse<AlertResponse>();
List<AlertResponse> alertResponseList = new ArrayList<AlertResponse>();
for (AlertVO alert : alertList) {
for (AlertVO alert : result) {
AlertResponse alertResponse = new AlertResponse();
alertResponse.setId(alert.getId());
alertResponse.setAlertType(alert.getType());
@ -86,12 +85,6 @@ public class ListAlertsCmd extends BaseListCmd {
response.setResponses(alertResponseList);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<AlertVO> result = _mgr.searchForAlerts(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -37,7 +37,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="searchForAsyncJobs", description="Lists all pending asynchronous jobs for the account.")
@Implementation(description="Lists all pending asynchronous jobs for the account.")
public class ListAsyncJobsCmd extends BaseListCmd {
private static final String s_name = "listasyncjobsresponse";
@ -79,13 +79,12 @@ public class ListAsyncJobsCmd extends BaseListCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<AsyncJobResponse> getResponse() {
List<AsyncJobVO> jobs = (List<AsyncJobVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<AsyncJobVO> result = _mgr.searchForAsyncJobs(this);
ListResponse<AsyncJobResponse> response = new ListResponse<AsyncJobResponse>();
List<AsyncJobResponse> jobResponses = new ArrayList<AsyncJobResponse>();
for (AsyncJobVO job : jobs) {
for (AsyncJobVO job : result) {
AsyncJobResponse jobResponse = new AsyncJobResponse();
jobResponse.setAccountId(job.getAccountId());
jobResponse.setCmd(job.getCmd());
@ -105,12 +104,6 @@ public class ListAsyncJobsCmd extends BaseListCmd {
response.setResponses(jobResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<AsyncJobVO> result = _mgr.searchForAsyncJobs(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -31,7 +31,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="listCapabilities")
@Implementation(description="Lists capabilities")
public class ListCapabilitiesCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(ListCapabilitiesCmd.class.getName());
@ -41,23 +41,15 @@ public class ListCapabilitiesCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public CapabilitiesResponse getResponse() {
Map<String, String> capabilities = (Map<String, String>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
Map<String, String> capabilities = _mgr.listCapabilities(this);
CapabilitiesResponse response = new CapabilitiesResponse();
response.setNetworkGroupsEnabled(capabilities.get("networkGroupsEnabled"));
response.setCloudStackVersion(capabilities.get("cloudStackVersion"));
response.setObjectName("capability");
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
Map<String, String> result = _mgr.listCapabilities(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -47,7 +47,7 @@ import com.cloud.server.Criteria;
import com.cloud.storage.Storage.StoragePoolType;
import com.cloud.storage.StoragePoolVO;
@Implementation(method="listCapacities", description="Lists capacity.")
@Implementation(description="Lists capacity.")
public class ListCapacityCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListCapacityCmd.class.getName());
@ -109,44 +109,6 @@ public class ListCapacityCmd extends BaseListCmd {
pageSizeVal = pageSize.longValue();
}
return pageSizeVal;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<CapacityResponse> getResponse() {
List<CapacityVO> capacities = (List<CapacityVO>)getResponseObject();
ListResponse<CapacityResponse> response = new ListResponse<CapacityResponse>();
List<CapacityResponse> capacityResponses = new ArrayList<CapacityResponse>();
List<CapacityVO> summedCapacities = sumCapacities(capacities);
for (CapacityVO summedCapacity : summedCapacities) {
CapacityResponse capacityResponse = new CapacityResponse();
capacityResponse.setCapacityTotal(summedCapacity.getTotalCapacity());
capacityResponse.setCapacityType(summedCapacity.getCapacityType());
capacityResponse.setCapacityUsed(summedCapacity.getUsedCapacity());
if (summedCapacity.getPodId() != null) {
capacityResponse.setPodId(summedCapacity.getPodId());
if (summedCapacity.getPodId() > 0) {
capacityResponse.setPodName(ApiDBUtils.findPodById(summedCapacity.getPodId()).getName());
} else {
capacityResponse.setPodName("All");
}
}
capacityResponse.setZoneId(summedCapacity.getDataCenterId());
capacityResponse.setZoneName(ApiDBUtils.findZoneById(summedCapacity.getDataCenterId()).getName());
if (summedCapacity.getTotalCapacity() != 0) {
float computed = ((float)summedCapacity.getUsedCapacity() / (float)summedCapacity.getTotalCapacity() * 100f);
capacityResponse.setPercentUsed(s_percentFormat.format((float)summedCapacity.getUsedCapacity() / (float)summedCapacity.getTotalCapacity() * 100f));
} else {
capacityResponse.setPercentUsed(s_percentFormat.format(0L));
}
capacityResponse.setObjectName("capacity");
capacityResponses.add(capacityResponse);
}
response.setResponses(capacityResponses);
response.setResponseName(getName());
return response;
}
private List<CapacityVO> sumCapacities(List<CapacityVO> hostCapacities) {
@ -238,8 +200,39 @@ public class ListCapacityCmd extends BaseListCmd {
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<CapacityVO> result = _mgr.listCapacities(this);
return result;
ListResponse<CapacityResponse> response = new ListResponse<CapacityResponse>();
List<CapacityResponse> capacityResponses = new ArrayList<CapacityResponse>();
List<CapacityVO> summedCapacities = sumCapacities(result);
for (CapacityVO summedCapacity : summedCapacities) {
CapacityResponse capacityResponse = new CapacityResponse();
capacityResponse.setCapacityTotal(summedCapacity.getTotalCapacity());
capacityResponse.setCapacityType(summedCapacity.getCapacityType());
capacityResponse.setCapacityUsed(summedCapacity.getUsedCapacity());
if (summedCapacity.getPodId() != null) {
capacityResponse.setPodId(summedCapacity.getPodId());
if (summedCapacity.getPodId() > 0) {
capacityResponse.setPodName(ApiDBUtils.findPodById(summedCapacity.getPodId()).getName());
} else {
capacityResponse.setPodName("All");
}
}
capacityResponse.setZoneId(summedCapacity.getDataCenterId());
capacityResponse.setZoneName(ApiDBUtils.findZoneById(summedCapacity.getDataCenterId()).getName());
if (summedCapacity.getTotalCapacity() != 0) {
float computed = ((float)summedCapacity.getUsedCapacity() / (float)summedCapacity.getTotalCapacity() * 100f);
capacityResponse.setPercentUsed(s_percentFormat.format((float)summedCapacity.getUsedCapacity() / (float)summedCapacity.getTotalCapacity() * 100f));
} else {
capacityResponse.setPercentUsed(s_percentFormat.format(0L));
}
capacityResponse.setObjectName("capacity");
capacityResponses.add(capacityResponse);
}
response.setResponses(capacityResponses);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -38,7 +38,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="searchForConfigurations", description="Lists all configurations.")
@Implementation(description="Lists all configurations.")
public class ListCfgsByCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListCfgsByCmd.class.getName());
@ -76,14 +76,13 @@ public class ListCfgsByCmd extends BaseListCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<ConfigurationResponse> getResponse() {
List<ConfigurationVO> configurations = (List<ConfigurationVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<ConfigurationVO> result = _mgr.searchForConfigurations(this);
ListResponse<ConfigurationResponse> response = new ListResponse<ConfigurationResponse>();
List<ConfigurationResponse> configResponses = new ArrayList<ConfigurationResponse>();
for (ConfigurationVO cfg : configurations) {
for (ConfigurationVO cfg : result) {
ConfigurationResponse cfgResponse = ApiResponseHelper.createConfigurationResponse(cfg);
cfgResponse.setObjectName("configuration");
configResponses.add(cfgResponse);
@ -91,12 +90,6 @@ public class ListCfgsByCmd extends BaseListCmd {
response.setResponses(configResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<ConfigurationVO> result = _mgr.searchForConfigurations(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -38,7 +38,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="searchForClusters", description="Lists clusters.")
@Implementation(description="Lists clusters.")
public class ListClustersCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListServiceOfferingsCmd.class.getName());
@ -89,14 +89,13 @@ public class ListClustersCmd extends BaseListCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<ClusterResponse> getResponse() {
List<ClusterVO> clusters = (List<ClusterVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<ClusterVO> result = _mgr.searchForClusters(this);
ListResponse<ClusterResponse> response = new ListResponse<ClusterResponse>();
List<ClusterResponse> clusterResponses = new ArrayList<ClusterResponse>();
for (ClusterVO cluster : clusters) {
for (ClusterVO cluster : result) {
ClusterResponse clusterResponse = ApiResponseHelper.createClusterResponse(cluster);
clusterResponse.setObjectName("cluster");
clusterResponses.add(clusterResponse);
@ -104,12 +103,6 @@ public class ListClustersCmd extends BaseListCmd {
response.setResponses(clusterResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<ClusterVO> result = _mgr.searchForClusters(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -37,7 +37,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.DiskOfferingVO;
@Implementation(method="searchForDiskOfferings", description="Lists all available disk offerings.")
@Implementation(description="Lists all available disk offerings.")
public class ListDiskOfferingsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListDiskOfferingsCmd.class.getName());
@ -81,13 +81,12 @@ public class ListDiskOfferingsCmd extends BaseListCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<DiskOfferingResponse> getResponse() {
List<DiskOfferingVO> offerings = (List<DiskOfferingVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<DiskOfferingVO> result = _mgr.searchForDiskOfferings(this);
ListResponse<DiskOfferingResponse> response = new ListResponse<DiskOfferingResponse>();
List<DiskOfferingResponse> diskOfferingResponses = new ArrayList<DiskOfferingResponse>();
for (DiskOfferingVO offering : offerings) {
for (DiskOfferingVO offering : result) {
DiskOfferingResponse diskOffResp = ApiResponseHelper.createDiskOfferingResponse(offering);
diskOffResp.setObjectName("diskoffering");
diskOfferingResponses.add(diskOffResp);
@ -95,12 +94,6 @@ public class ListDiskOfferingsCmd extends BaseListCmd {
response.setResponses(diskOfferingResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<DiskOfferingVO> result = _mgr.searchForDiskOfferings(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -37,7 +37,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="searchForDomainChildren", description="Lists all children domains belonging to a specified domain")
@Implementation(description="Lists all children domains belonging to a specified domain")
public class ListDomainChildrenCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListDomainChildrenCmd.class.getName());
@ -79,15 +79,14 @@ public class ListDomainChildrenCmd extends BaseListCmd {
@Override
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<DomainResponse> getResponse() {
List<DomainVO> domains = (List<DomainVO>)getResponseObject();
}
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<DomainVO> result = _mgr.searchForDomainChildren(this);
ListResponse<DomainResponse> response = new ListResponse<DomainResponse>();
List<DomainResponse> domainResponses = new ArrayList<DomainResponse>();
for (DomainVO domain : domains) {
for (DomainVO domain : result) {
DomainResponse domainResponse = ApiResponseHelper.createDomainResponse(domain);
domainResponse.setObjectName("domain");
domainResponses.add(domainResponse);
@ -95,12 +94,6 @@ public class ListDomainChildrenCmd extends BaseListCmd {
response.setResponses(domainResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<DomainVO> result = _mgr.searchForDomainChildren(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -37,7 +37,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="searchForDomains", description="Lists domains and provides detailed information for listed domains")
@Implementation(description="Lists domains and provides detailed information for listed domains")
public class ListDomainsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListDomainsCmd.class.getName());
@ -81,13 +81,12 @@ public class ListDomainsCmd extends BaseListCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<DomainResponse> getResponse() {
List<DomainVO> domains = (List<DomainVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<DomainVO> result = _mgr.searchForDomains(this);
ListResponse<DomainResponse> response = new ListResponse<DomainResponse>();
List<DomainResponse> domainResponses = new ArrayList<DomainResponse>();
for (DomainVO domain : domains) {
for (DomainVO domain : result) {
DomainResponse domainResponse = ApiResponseHelper.createDomainResponse(domain);
domainResponse.setObjectName("domain");
domainResponses.add(domainResponse);
@ -95,12 +94,6 @@ public class ListDomainsCmd extends BaseListCmd {
response.setResponses(domainResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<DomainVO> result = _mgr.searchForDomains(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -39,7 +39,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.user.User;
@Implementation(method="searchForEvents", description="A command to list events.")
@Implementation(description="A command to list events.")
public class ListEventsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListEventsCmd.class.getName());
@ -118,13 +118,12 @@ public class ListEventsCmd extends BaseListCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<EventResponse> getResponse() {
List<EventVO> events = (List<EventVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<EventVO> result = _mgr.searchForEvents(this);
ListResponse<EventResponse> response = new ListResponse<EventResponse>();
List<EventResponse> eventResponses = new ArrayList<EventResponse>();
for (EventVO event : events) {
for (EventVO event : result) {
EventResponse responseEvent = new EventResponse();
responseEvent.setAccountName(event.getAccountName());
responseEvent.setCreated(event.getCreateDate());
@ -147,12 +146,6 @@ public class ListEventsCmd extends BaseListCmd {
response.setResponses(eventResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<EventVO> result = _mgr.searchForEvents(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -37,7 +37,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.GuestOSCategoryVO;
@Implementation(method="listGuestOSCategoriesByCriteria", description="Lists all supported OS categories for this cloud.")
@Implementation(description="Lists all supported OS categories for this cloud.")
public class ListGuestOsCategoriesCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListIsosCmd.class.getName());
@ -68,14 +68,13 @@ public class ListGuestOsCategoriesCmd extends BaseListCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<GuestOSCategoryResponse> getResponse() {
List<GuestOSCategoryVO> osCategories = (List<GuestOSCategoryVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<GuestOSCategoryVO> result = _mgr.listGuestOSCategoriesByCriteria(this);
ListResponse<GuestOSCategoryResponse> response = new ListResponse<GuestOSCategoryResponse>();
List<GuestOSCategoryResponse> osCatResponses = new ArrayList<GuestOSCategoryResponse>();
for (GuestOSCategoryVO osCategory : osCategories) {
for (GuestOSCategoryVO osCategory : result) {
GuestOSCategoryResponse categoryResponse = new GuestOSCategoryResponse();
categoryResponse.setId(osCategory.getId());
categoryResponse.setName(osCategory.getName());
@ -86,12 +85,6 @@ public class ListGuestOsCategoriesCmd extends BaseListCmd {
response.setResponses(osCatResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<GuestOSCategoryVO> result = _mgr.listGuestOSCategoriesByCriteria(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -37,7 +37,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.GuestOSVO;
@Implementation(method="listGuestOSByCriteria", description="Lists all supported OS types for this cloud.")
@Implementation(description="Lists all supported OS types for this cloud.")
public class ListGuestOsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListIsosCmd.class.getName());
@ -85,14 +85,13 @@ public class ListGuestOsCmd extends BaseListCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<GuestOSResponse> getResponse() {
List<GuestOSVO> guestOSList = (List<GuestOSVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<GuestOSVO> result = _mgr.listGuestOSByCriteria(this);
ListResponse<GuestOSResponse> response = new ListResponse<GuestOSResponse>();
List<GuestOSResponse> osResponses = new ArrayList<GuestOSResponse>();
for (GuestOSVO guestOS : guestOSList) {
for (GuestOSVO guestOS : result) {
GuestOSResponse guestOSResponse = new GuestOSResponse();
guestOSResponse.setDescription(guestOS.getDisplayName());
guestOSResponse.setId(guestOS.getId());
@ -104,12 +103,6 @@ public class ListGuestOsCmd extends BaseListCmd {
response.setResponses(osResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<GuestOSVO> result = _mgr.listGuestOSByCriteria(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -38,7 +38,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.host.HostVO;
@Implementation(method="searchForServers", description="Lists hosts.")
@Implementation(description="Lists hosts.")
public class ListHostsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListHostsCmd.class.getName());
@ -112,13 +112,13 @@ public class ListHostsCmd extends BaseListCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<HostResponse> getResponse() {
List<HostVO> hosts = (List<HostVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<HostVO> result = _mgr.searchForServers(this);
ListResponse<HostResponse> response = new ListResponse<HostResponse>();
List<HostResponse> hostResponses = new ArrayList<HostResponse>();
for (HostVO host : hosts) {
for (HostVO host : result) {
HostResponse hostResponse = ApiResponseHelper.createHostResponse(host);
hostResponse.setObjectName("host");
hostResponses.add(hostResponse);
@ -126,12 +126,6 @@ public class ListHostsCmd extends BaseListCmd {
response.setResponses(hostResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<HostVO> result = _mgr.searchForServers(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -32,7 +32,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="getHypervisors")
@Implementation(description="List hypervisors")
public class ListHypervisorsCmd extends BaseCmd {
public static final Logger s_logger = Logger.getLogger(UpgradeRouterCmd.class.getName());
private static final String s_name = "listhypervisorsresponse";
@ -41,28 +41,21 @@ public class ListHypervisorsCmd extends BaseCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<HypervisorResponse> getResponse() {
String[] hypervisorList = (String[])getResponseObject();
ListResponse<HypervisorResponse> response = new ListResponse<HypervisorResponse>();
ArrayList<HypervisorResponse> responses = new ArrayList<HypervisorResponse>();
for (String hypervisor : hypervisorList) {
HypervisorResponse hypervisorResponse = new HypervisorResponse();
hypervisorResponse.setName(hypervisor);
hypervisorResponse.setObjectName("hypervisor");
responses.add(hypervisorResponse);
}
response.setResponses(responses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
String[] result = _mgr.getHypervisors(this);
return result;
ListResponse<HypervisorResponse> response = new ListResponse<HypervisorResponse>();
ArrayList<HypervisorResponse> responses = new ArrayList<HypervisorResponse>();
for (String hypervisor : result) {
HypervisorResponse hypervisorResponse = new HypervisorResponse();
hypervisorResponse.setName(hypervisor);
hypervisorResponse.setObjectName("hypervisor");
responses.add(hypervisorResponse);
}
response.setResponses(responses);
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -49,7 +49,7 @@ import com.cloud.storage.dao.VMTemplateDao.TemplateFilter;
import com.cloud.user.Account;
import com.cloud.user.UserContext;
@Implementation(method="listIsos", description="Lists all available ISO files.")
@Implementation(description="Lists all available ISO files.")
public class ListIsosCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListIsosCmd.class.getName());
@ -145,9 +145,10 @@ public class ListIsosCmd extends BaseListCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<TemplateResponse> getResponse() {
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<VMTemplateVO> isos = _mgr.listIsos(this);
TemplateFilter isoFilterObj = null;
try {
@ -177,7 +178,6 @@ public class ListIsosCmd extends BaseListCmd {
(isoFilterObj == TemplateFilter.executable && isAccountSpecific) ||
(isoFilterObj == TemplateFilter.community);
List<VMTemplateVO> isos = (List<VMTemplateVO>)getResponseObject();
Map<Long, List<VMTemplateHostVO>> isoHostsMap = new HashMap<Long, List<VMTemplateHostVO>>();
for (VMTemplateVO iso : isos) {
@ -288,12 +288,6 @@ public class ListIsosCmd extends BaseListCmd {
response.setResponses(isoResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<VMTemplateVO> result = _mgr.listIsos(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -37,7 +37,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.vm.UserVmVO;
@Implementation(method="listLoadBalancerInstances", description="List all virtual machine instances that are assigned to a load balancer rule.")
@Implementation(description="List all virtual machine instances that are assigned to a load balancer rule.")
public class ListLoadBalancerRuleInstancesCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger (ListLoadBalancerRuleInstancesCmd.class.getName());
@ -73,14 +73,13 @@ public class ListLoadBalancerRuleInstancesCmd extends BaseListCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<UserVmResponse> getResponse() {
List<UserVmVO> instances = (List<UserVmVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<UserVmVO> result = _mgr.listLoadBalancerInstances(this);
ListResponse<UserVmResponse> response = new ListResponse<UserVmResponse>();
List<UserVmResponse> vmResponses = new ArrayList<UserVmResponse>();
for (UserVmVO instance : instances) {
for (UserVmVO instance : result) {
UserVmResponse userVmResponse = ApiResponseHelper.createUserVmResponse(instance);
userVmResponse.setObjectName("loadbalancerruleinstance");
vmResponses.add(userVmResponse);
@ -88,12 +87,6 @@ public class ListLoadBalancerRuleInstancesCmd extends BaseListCmd {
response.setResponses(vmResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<UserVmVO> result = _mgr.listLoadBalancerInstances(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -38,7 +38,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.LoadBalancerVO;
@Implementation(method="searchForLoadBalancers", description="Lists load balancer rules.")
@Implementation(description="Lists load balancer rules.")
public class ListLoadBalancerRulesCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger (ListLoadBalancerRulesCmd.class.getName());
@ -103,10 +103,9 @@ public class ListLoadBalancerRulesCmd extends BaseListCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<LoadBalancerResponse> getResponse() {
List<LoadBalancerVO> loadBalancers = (List<LoadBalancerVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<LoadBalancerVO> loadBalancers = _mgr.searchForLoadBalancers(this);
ListResponse<LoadBalancerResponse> response = new ListResponse<LoadBalancerResponse>();
List<LoadBalancerResponse> lbResponses = new ArrayList<LoadBalancerResponse>();
for (LoadBalancerVO loadBalancer : loadBalancers) {
@ -117,12 +116,6 @@ public class ListLoadBalancerRulesCmd extends BaseListCmd {
response.setResponses(lbResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<LoadBalancerVO> result = _mgr.searchForLoadBalancers(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -38,10 +38,9 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.security.NetworkGroupManager;
import com.cloud.network.security.NetworkGroupRulesVO;
@Implementation(method="searchForNetworkGroupRules", manager=NetworkGroupManager.class)
@Implementation(description="Lists network groups")
public class ListNetworkGroupsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListNetworkGroupsCmd.class.getName());
@ -92,9 +91,9 @@ public class ListNetworkGroupsCmd extends BaseListCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<NetworkGroupResponse> getResponse() {
List<NetworkGroupRulesVO> networkGroups = (List<NetworkGroupRulesVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<NetworkGroupRulesVO> networkGroups = _networkGroupMgr.searchForNetworkGroupRules(this);
List<NetworkGroupResultObject> groupResultObjs = NetworkGroupResultObject.transposeNetworkGroups(networkGroups);
ListResponse<NetworkGroupResponse> response = new ListResponse<NetworkGroupResponse>();
@ -124,7 +123,7 @@ public class ListNetworkGroupsCmd extends BaseListCmd {
ingressData.setStartPort(ingressRule.getStartPort());
ingressData.setEndPort(ingressRule.getEndPort());
}
if (ingressRule.getAllowedNetworkGroup() != null) {
ingressData.setNetworkGroupName(ingressRule.getAllowedNetworkGroup());
ingressData.setAccountName(ingressRule.getAllowedNetGroupAcct());
@ -143,12 +142,6 @@ public class ListNetworkGroupsCmd extends BaseListCmd {
response.setResponses(netGrpResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<NetworkGroupRulesVO> result = _networkGroupMgr.searchForNetworkGroupRules(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -38,7 +38,7 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
@Implementation(method="searchForPods", description="Lists all Pods.")
@Implementation(description="Lists all Pods.")
public class ListPodsByCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListPodsByCmd.class.getName());
@ -83,13 +83,12 @@ public class ListPodsByCmd extends BaseListCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<PodResponse> getResponse() {
List<HostPodVO> pods = (List<HostPodVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<HostPodVO> result = _mgr.searchForPods(this);
ListResponse<PodResponse> response = new ListResponse<PodResponse>();
List<PodResponse> podResponses = new ArrayList<PodResponse>();
for (HostPodVO pod : pods) {
for (HostPodVO pod : result) {
PodResponse podResponse = ApiResponseHelper.createPodResponse(pod);
podResponse.setObjectName("pod");
podResponses.add(podResponse);
@ -97,12 +96,6 @@ public class ListPodsByCmd extends BaseListCmd {
response.setResponses(podResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<HostPodVO> result = _mgr.searchForPods(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -36,9 +36,8 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.FirewallRuleVO;
import com.cloud.network.NetworkManager;
@Implementation(method="listPortForwardingRules", manager=NetworkManager.class, description="Lists all port forwarding rules for an IP address.")
@Implementation(description="Lists all port forwarding rules for an IP address.")
public class ListPortForwardingRulesCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListPortForwardingRulesCmd.class.getName());
@ -67,27 +66,20 @@ public class ListPortForwardingRulesCmd extends BaseListCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<FirewallRuleResponse> getResponse() {
List<FirewallRuleVO> firewallRules = (List<FirewallRuleVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<FirewallRuleVO> result = _networkMgr.listPortForwardingRules(this);
ListResponse<FirewallRuleResponse> response = new ListResponse<FirewallRuleResponse>();
List<FirewallRuleResponse> fwResponses = new ArrayList<FirewallRuleResponse>();
for (FirewallRuleVO fwRule : firewallRules) {
for (FirewallRuleVO fwRule : result) {
FirewallRuleResponse ruleData = ApiResponseHelper.createFirewallRuleResponse(fwRule);
ruleData.setObjectName("portforwardingrule");
fwResponses.add(ruleData);
}
response.setResponses(fwResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<FirewallRuleVO> result = _networkMgr.listPortForwardingRules(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -38,7 +38,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.preallocatedlun.PreallocatedLunVO;
@Implementation(method="getPreAllocatedLuns")
@Implementation()
public class ListPreallocatedLunsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListPreallocatedLunsCmd.class.getName());
@ -77,10 +77,9 @@ public class ListPreallocatedLunsCmd extends BaseListCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<PreallocatedLunResponse> getResponse() {
List<PreallocatedLunVO> preallocatedLuns = (List<PreallocatedLunVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<PreallocatedLunVO> preallocatedLuns = _mgr.getPreAllocatedLuns(this);
ListResponse<PreallocatedLunResponse> response = new ListResponse<PreallocatedLunResponse>();
List<PreallocatedLunResponse> lunResponses = new ArrayList<PreallocatedLunResponse>();
for (PreallocatedLunVO preallocatedLun : preallocatedLuns) {
@ -92,12 +91,6 @@ public class ListPreallocatedLunsCmd extends BaseListCmd {
response.setResponses(lunResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<PreallocatedLunVO> result = _mgr.getPreAllocatedLuns(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -38,7 +38,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.IPAddressVO;
@Implementation(method="searchForIPAddresses", description="Lists all public ip addresses")
@Implementation(description="Lists all public ip addresses")
public class ListPublicIpAddressesCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListPublicIpAddressesCmd.class.getName());
@ -108,15 +108,14 @@ public class ListPublicIpAddressesCmd extends BaseListCmd {
@Override
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<IPAddressResponse> getResponse() {
List<IPAddressVO> ipAddresses = (List<IPAddressVO>)getResponseObject();
}
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<IPAddressVO> result = _mgr.searchForIPAddresses(this);
ListResponse<IPAddressResponse> response = new ListResponse<IPAddressResponse>();
List<IPAddressResponse> ipAddrResponses = new ArrayList<IPAddressResponse>();
for (IPAddressVO ipAddress : ipAddresses) {
for (IPAddressVO ipAddress : result) {
IPAddressResponse ipResponse = ApiResponseHelper.createIPAddressResponse(ipAddress);
ipResponse.setObjectName("publicipaddress");
ipAddrResponses.add(ipResponse);
@ -124,12 +123,6 @@ public class ListPublicIpAddressesCmd extends BaseListCmd {
response.setResponses(ipAddrResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<IPAddressVO> result = _mgr.searchForIPAddresses(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -24,7 +24,6 @@ import com.cloud.api.ApiConstants;
import com.cloud.api.BaseListCmd;
import com.cloud.api.Implementation;
import com.cloud.api.Parameter;
import com.cloud.api.ResponseObject;
import com.cloud.api.ServerApiException;
import com.cloud.api.response.ListResponse;
import com.cloud.api.response.SnapshotScheduleResponse;
@ -34,9 +33,8 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.SnapshotScheduleVO;
import com.cloud.storage.snapshot.SnapshotManager;
@Implementation(method="findRecurringSnapshotSchedule", manager=SnapshotManager.class)
@Implementation(description="Lists recurring snapshot schedule")
public class ListRecurringSnapshotScheduleCmd extends BaseListCmd {
private static final String s_name = "listrecurringsnapshotscheduleresponse";
@ -70,11 +68,10 @@ public class ListRecurringSnapshotScheduleCmd extends BaseListCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ResponseObject getResponse() {
List<SnapshotScheduleVO> snapshotSchedules = (List<SnapshotScheduleVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<SnapshotScheduleVO> snapshotSchedules = _snapshotMgr.findRecurringSnapshotSchedule(this);
ListResponse response = new ListResponse();
List<SnapshotScheduleResponse> snapshotScheduleResponses = new ArrayList<SnapshotScheduleResponse>();
for (SnapshotScheduleVO snapshotSchedule : snapshotSchedules) {
@ -90,12 +87,6 @@ public class ListRecurringSnapshotScheduleCmd extends BaseListCmd {
response.setResponses(snapshotScheduleResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<SnapshotScheduleVO> result = _snapshotMgr.findRecurringSnapshotSchedule(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -38,7 +38,7 @@ import com.cloud.exception.PermissionDeniedException;
import com.cloud.network.RemoteAccessVpnVO;
import com.cloud.user.Account;
@Implementation(method="searchForRemoteAccessVpns", description="Lists remote access vpns")
@Implementation(description="Lists remote access vpns")
public class ListRemoteAccessVpnsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger (ListRemoteAccessVpnsCmd.class.getName());
@ -102,14 +102,13 @@ public class ListRemoteAccessVpnsCmd extends BaseListCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<RemoteAccessVpnResponse> getResponse() {
List<RemoteAccessVpnVO> vpns = (List<RemoteAccessVpnVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<RemoteAccessVpnVO> vpns = _mgr.searchForRemoteAccessVpns(this);
ListResponse<RemoteAccessVpnResponse> response = new ListResponse<RemoteAccessVpnResponse>();
List<RemoteAccessVpnResponse> vpnResponses = new ArrayList<RemoteAccessVpnResponse>();
for (RemoteAccessVpnVO vpn : vpns) {
RemoteAccessVpnResponse vpnResponse = new RemoteAccessVpnResponse();
RemoteAccessVpnResponse vpnResponse = new RemoteAccessVpnResponse();
vpnResponse.setId(vpn.getId());
vpnResponse.setPublicIp(vpn.getVpnServerAddress());
vpnResponse.setIpRange(vpn.getIpRange());
@ -128,12 +127,6 @@ public class ListRemoteAccessVpnsCmd extends BaseListCmd {
response.setResponses(vpnResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<RemoteAccessVpnVO> result = _mgr.searchForRemoteAccessVpns(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -38,9 +38,8 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.user.AccountManager;
@Implementation(method="searchForLimits", manager=AccountManager.class, description="Lists resource limits.")
@Implementation(description="Lists resource limits.")
public class ListResourceLimitsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListResourceLimitsCmd.class.getName());
@ -94,14 +93,13 @@ public class ListResourceLimitsCmd extends BaseListCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<ResourceLimitResponse> getResponse() {
List<ResourceLimit> limits = (List<ResourceLimit>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<ResourceLimitVO> result = _accountService.searchForLimits(this);
ListResponse<ResourceLimitResponse> response = new ListResponse<ResourceLimitResponse>();
List<ResourceLimitResponse> limitResponses = new ArrayList<ResourceLimitResponse>();
for (ResourceLimit limit : limits) {
for (ResourceLimit limit : result) {
ResourceLimitResponse resourceLimitResponse = ApiResponseHelper.createResourceLimitResponse(limit);
resourceLimitResponse.setObjectName("resourcelimit");
limitResponses.add(resourceLimitResponse);
@ -109,12 +107,6 @@ public class ListResourceLimitsCmd extends BaseListCmd {
response.setResponses(limitResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<ResourceLimitVO> result = _accountService.searchForLimits(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -39,7 +39,7 @@ import com.cloud.exception.PermissionDeniedException;
import com.cloud.vm.DomainRouter;
import com.cloud.vm.DomainRouterVO;
@Implementation(method="searchForRouters", description="List routers.")
@Implementation(description="List routers.")
public class ListRoutersCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListRoutersCmd.class.getName());
@ -110,13 +110,13 @@ public class ListRoutersCmd extends BaseListCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<DomainRouterResponse> getResponse() {
List<DomainRouter> routers = (List<DomainRouter>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<DomainRouterVO> result = _mgr.searchForRouters(this);
ListResponse<DomainRouterResponse> response = new ListResponse<DomainRouterResponse>();
List<DomainRouterResponse> routerResponses = new ArrayList<DomainRouterResponse>();
for (DomainRouter router : routers) {
for (DomainRouter router : result) {
DomainRouterResponse routerResponse = ApiResponseHelper.createDomainRouterResponse(router);
routerResponse.setObjectName("router");
routerResponses.add(routerResponse);
@ -124,12 +124,6 @@ public class ListRoutersCmd extends BaseListCmd {
response.setResponses(routerResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<DomainRouterVO> result = _mgr.searchForRouters(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -37,7 +37,7 @@ import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.service.ServiceOfferingVO;
@Implementation(method="searchForServiceOfferings", description="Lists all available service offerings.")
@Implementation(description="Lists all available service offerings.")
public class ListServiceOfferingsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListServiceOfferingsCmd.class.getName());
@ -80,11 +80,10 @@ public class ListServiceOfferingsCmd extends BaseListCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<ServiceOfferingResponse> getResponse() {
List<ServiceOfferingVO> offerings = (List<ServiceOfferingVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<ServiceOfferingVO> offerings = _mgr.searchForServiceOfferings(this);
ListResponse<ServiceOfferingResponse> response = new ListResponse<ServiceOfferingResponse>();
List<ServiceOfferingResponse> offeringResponses = new ArrayList<ServiceOfferingResponse>();
for (ServiceOfferingVO offering : offerings) {
@ -95,12 +94,6 @@ public class ListServiceOfferingsCmd extends BaseListCmd {
response.setResponses(offeringResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<ServiceOfferingVO> result = _mgr.searchForServiceOfferings(this);
return result;
this.setResponseObject(response);
}
}

View File

@ -37,9 +37,8 @@ import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.SnapshotPolicyVO;
import com.cloud.storage.snapshot.SnapshotManager;
@Implementation(method="listPoliciesforVolume", manager=SnapshotManager.class, description="Lists snapshot policies.")
@Implementation(description="Lists snapshot policies.")
public class ListSnapshotPoliciesCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListSnapshotPoliciesCmd.class.getName());
@ -82,27 +81,19 @@ public class ListSnapshotPoliciesCmd extends BaseListCmd {
public String getName() {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<SnapshotPolicyResponse> getResponse() {
List<SnapshotPolicyVO> policies = (List<SnapshotPolicyVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<SnapshotPolicyVO> result = _snapshotMgr.listPoliciesforVolume(this);
ListResponse<SnapshotPolicyResponse> response = new ListResponse<SnapshotPolicyResponse>();
List<SnapshotPolicyResponse> policyResponses = new ArrayList<SnapshotPolicyResponse>();
for (SnapshotPolicyVO policy : policies) {
for (SnapshotPolicyVO policy : result) {
SnapshotPolicyResponse policyResponse = ApiResponseHelper.createSnapshotPolicyResponse(policy);
policyResponse.setObjectName("snapshotpolicy");
policyResponses.add(policyResponse);
}
response.setResponses(policyResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<SnapshotPolicyVO> result = _snapshotMgr.listPoliciesforVolume(this);
return result;
response.setResponseName(getName());
this.setResponseObject(response);
}
}

View File

@ -38,7 +38,7 @@ import com.cloud.exception.PermissionDeniedException;
import com.cloud.storage.Snapshot;
import com.cloud.storage.SnapshotVO;
@Implementation(method="listSnapshots", description="Lists all available snapshots for the account.")
@Implementation(description="Lists all available snapshots for the account.")
public class ListSnapshotsCmd extends BaseListCmd {
public static final Logger s_logger = Logger.getLogger(ListSnapshotsCmd.class.getName());
@ -110,26 +110,19 @@ public class ListSnapshotsCmd extends BaseListCmd {
return s_name;
}
@Override @SuppressWarnings("unchecked")
public ListResponse<SnapshotResponse> getResponse() {
List<SnapshotVO> snapshots = (List<SnapshotVO>)getResponseObject();
@Override
public void execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<SnapshotVO> result = _mgr.listSnapshots(this);
ListResponse<SnapshotResponse> response = new ListResponse<SnapshotResponse>();
List<SnapshotResponse> snapshotResponses = new ArrayList<SnapshotResponse>();
for (Snapshot snapshot : snapshots) {
for (Snapshot snapshot : result) {
SnapshotResponse snapshotResponse = ApiResponseHelper.createSnapshotResponse(snapshot);
snapshotResponse.setObjectName("snapshot");
snapshotResponses.add(snapshotResponse);
}
response.setResponses(snapshotResponses);
response.setResponseName(getName());
return response;
}
@Override
public Object execute() throws ServerApiException, InvalidParameterValueException, PermissionDeniedException, InsufficientAddressCapacityException, InsufficientCapacityException, ConcurrentOperationException{
List<SnapshotVO> result = _mgr.listSnapshots(this);
return result;
response.setResponseName(getName());
this.setResponseObject(response);
}
}

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