Merge branch 'master' into cloud-agent-with-openvswitch

Conflicts:
	plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
This commit is contained in:
Hugo Trippaers 2013-01-21 12:18:21 +01:00
commit 04f82623f6
455 changed files with 15382 additions and 8721 deletions

View File

@ -0,0 +1,40 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.api.storage;
import com.cloud.agent.api.Answer;
public class ResizeVolumeAnswer extends Answer {
private long newSize;
protected ResizeVolumeAnswer() {
}
public ResizeVolumeAnswer(ResizeVolumeCommand cmd, boolean result, String details, long newSize) {
super(cmd, result, details);
this.newSize = newSize;
}
public ResizeVolumeAnswer(ResizeVolumeCommand cmd, boolean result, String details) {
super(cmd, result, details);
}
public long getNewSize() {
return newSize;
}
}

View File

@ -0,0 +1,86 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.agent.api.storage;
import com.cloud.agent.api.Command;
import com.cloud.agent.api.to.StorageFilerTO;
import com.cloud.storage.StoragePool;
public class ResizeVolumeCommand extends Command {
private String path;
private StorageFilerTO pool;
private String vmInstance;
private Long newSize;
private Long currentSize;
private boolean shrinkOk;
protected ResizeVolumeCommand() {
}
public ResizeVolumeCommand(String path,
StorageFilerTO pool,
Long currentSize,
Long newSize,
boolean shrinkOk,
String vmInstance)
{
this.path = path;
this.pool = pool;
this.vmInstance = vmInstance;
this.currentSize = currentSize;
this.newSize = newSize;
this.shrinkOk = shrinkOk;
}
public String getPath() {
return path;
}
public String getPoolUuid() {
return pool.getUuid();
}
public StorageFilerTO getPool() {
return pool;
}
public long getNewSize() {
return newSize;
}
public long getCurrentSize() {
return currentSize;
}
public boolean getShrinkOk() {
return shrinkOk;
}
public String getInstanceName() {
return vmInstance;
}
/**
* {@inheritDoc}
*/
@Override
public boolean executeInSequence() {
return false;
}
}

View File

@ -145,17 +145,17 @@ public class CreatePrivateNetworkCmd extends BaseAsyncCreateCmd {
} catch (InsufficientCapacityException ex){
s_logger.info(ex);
s_logger.trace(ex);
throw new ServerApiException(BaseCmd.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, ex.getMessage());
} catch (ConcurrentOperationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
if (result != null) {
this.setEntityId(result.getId());
this.setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a Private network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a Private network");
}
}
@ -167,7 +167,7 @@ public class CreatePrivateNetworkCmd extends BaseAsyncCreateCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create private network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create private network");
}
}

View File

@ -84,7 +84,7 @@ public class DestroyConsoleProxyCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to destroy console proxy");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to destroy console proxy");
}
}
}

View File

@ -108,6 +108,7 @@ public class EventTypes {
public static final String EVENT_VOLUME_EXTRACT = "VOLUME.EXTRACT";
public static final String EVENT_VOLUME_UPLOAD = "VOLUME.UPLOAD";
public static final String EVENT_VOLUME_MIGRATE = "VOLUME.MIGRATE";
public static final String EVENT_VOLUME_RESIZE = "VOLUME.RESIZE";
// Domains
public static final String EVENT_DOMAIN_CREATE = "DOMAIN.CREATE";

View File

@ -17,9 +17,9 @@
package com.cloud.exception;
import com.cloud.utils.SerialVersionUID;
import com.cloud.utils.exception.RuntimeCloudException;
import com.cloud.utils.exception.CloudRuntimeException;
public class CloudAuthenticationException extends RuntimeCloudException {
public class CloudAuthenticationException extends CloudRuntimeException {
private static final long serialVersionUID = SerialVersionUID.CloudAuthenticationException;
public CloudAuthenticationException(String message) {

View File

@ -54,7 +54,6 @@ public class CloudException extends Exception {
return;
}
public ArrayList<String> getIdProxyList() {
return idList;
}

View File

@ -1,57 +0,0 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.exception;
import java.util.HashMap;
import com.cloud.utils.exception.RuntimeCloudException;
import com.cloud.utils.SerialVersionUID;
/**
*
*/
public class CloudExecutionException extends RuntimeCloudException {
private final static long serialVersionUID = SerialVersionUID.CloudExecutionException;
private final ErrorCode code;
private final HashMap<String, Object> details;
public CloudExecutionException(ErrorCode code, String message, Throwable cause) {
super(message, cause);
this.code = code;
details = new HashMap<String, Object>();
}
public ErrorCode getErrorCode() {
return code;
}
public String getErrorMessage() {
return new StringBuilder("Error Code=").append(code).append("; Error Message=").append(super.toString()).toString();
}
@Override
public String toString() {
StringBuilder buff = new StringBuilder();
buff.append("Error Code=").append(code);
buff.append("; Error Message=").append(super.toString());
if (details.size() > 0) {
buff.append("; Error Details=").append(details.toString());
}
return buff.toString();
}
}

View File

@ -16,37 +16,28 @@
// under the License.
package com.cloud.exception;
import java.util.HashSet;
import com.cloud.utils.SerialVersionUID;
import com.cloud.utils.exception.CloudRuntimeException;
/**
* Exception thrown if number of requests is over api rate limit set.
* @author minc
*
*/
public class ErrorCode {
String code;
private static HashSet<ErrorCode> s_codes = new HashSet<ErrorCode>();
public class RequestLimitException extends CloudRuntimeException {
public ErrorCode(String code) {
this.code = code;
assert !s_codes.contains(this) : "There is already an error code registered for this code: " + code;
s_codes.add(this);
private static final long serialVersionUID = SerialVersionUID.AccountLimitException;
protected RequestLimitException() {
super();
}
public String getCode() {
return code;
public RequestLimitException(String msg) {
super(msg);
}
@Override
public int hashCode() {
return code.hashCode();
public RequestLimitException(String msg, Throwable cause) {
super(msg, cause);
}
@Override
public boolean equals(Object that) {
if (!(that instanceof ErrorCode)) {
return false;
}
return this.code.equals(((ErrorCode)that).code);
}
public final static ErrorCode UnableToReachResource = new ErrorCode("resource.unavailable");
}

View File

@ -170,7 +170,6 @@ public interface Network extends ControlledEntity, InternalIdentity, Identity {
public static final Capability AllowDnsSuffixModification = new Capability("AllowDnsSuffixModification");
public static final Capability RedundantRouter = new Capability("RedundantRouter");
public static final Capability ElasticIp = new Capability("ElasticIp");
public static final Capability AssociatePublicIP = new Capability("AssociatePublicIP");
public static final Capability ElasticLb = new Capability("ElasticLb");
public static final Capability AutoScaleCounters = new Capability("AutoScaleCounters");
public static final Capability InlineMode = new Capability("InlineMode");

View File

@ -0,0 +1,252 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package com.cloud.network;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.cloud.dc.Vlan;
import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.network.Network.Capability;
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.element.NetworkElement;
import com.cloud.network.element.UserDataServiceProvider;
import com.cloud.offering.NetworkOffering;
import com.cloud.user.Account;
import com.cloud.vm.Nic;
import com.cloud.vm.NicProfile;
import com.cloud.vm.VirtualMachine;
/**
* The NetworkModel presents a read-only view into the Network data such as L2 networks,
* Nics, PublicIps, NetworkOfferings, traffic labels, physical networks and the like
* The idea is that only the orchestration core should be able to modify the data, while other
* participants in the orchestration can use this interface to query the data.
*/
public interface NetworkModel {
/**
* Lists IP addresses that belong to VirtualNetwork VLANs
*
* @param accountId
* - account that the IP address should belong to
* @param associatedNetworkId
* TODO
* @param sourceNat
* - (optional) true if the IP address should be a source NAT address
* @return - list of IP addresses
*/
List<? extends IpAddress> listPublicIpsAssignedToGuestNtwk(long accountId, long associatedNetworkId, Boolean sourceNat);
List<? extends NetworkOffering> getSystemAccountNetworkOfferings(String... offeringNames);
List<? extends Nic> getNics(long vmId);
String getNextAvailableMacAddressInNetwork(long networkConfigurationId) throws InsufficientAddressCapacityException;
PublicIpAddress getPublicIpAddress(long ipAddressId);
List<? extends Vlan> listPodVlans(long podId);
List<? extends Network> listNetworksUsedByVm(long vmId, boolean isSystem);
Nic getNicInNetwork(long vmId, long networkId);
List<? extends Nic> getNicsForTraffic(long vmId, TrafficType type);
Network getDefaultNetworkForVm(long vmId);
Nic getDefaultNic(long vmId);
UserDataServiceProvider getUserDataUpdateProvider(Network network);
boolean networkIsConfiguredForExternalNetworking(long zoneId, long networkId);
Map<Capability, String> getNetworkServiceCapabilities(long networkId, Service service);
boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services);
Network getNetworkWithSecurityGroupEnabled(Long zoneId);
String getIpOfNetworkElementInVirtualNetwork(long accountId, long dataCenterId);
List<? extends Network> listNetworksForAccount(long accountId, long zoneId, Network.GuestType type);
List<? extends Network> listAllNetworksInAllZonesByType(Network.GuestType type);
String getGlobalGuestDomainSuffix();
String getStartIpAddress(long networkId);
String getIpInNetwork(long vmId, long networkId);
String getIpInNetworkIncludingRemoved(long vmId, long networkId);
Long getPodIdForVlan(long vlanDbId);
List<Long> listNetworkOfferingsForUpgrade(long networkId);
boolean isSecurityGroupSupportedInNetwork(Network network);
boolean isProviderSupportServiceInNetwork(long networkId, Service service, Provider provider);
boolean isProviderEnabledInPhysicalNetwork(long physicalNetowrkId, String providerName);
String getNetworkTag(HypervisorType hType, Network network);
List<Service> getElementServices(Provider provider);
boolean canElementEnableIndividualServices(Provider provider);
boolean areServicesSupportedInNetwork(long networkId, Service... services);
boolean isNetworkSystem(Network network);
Map<Capability, String> getNetworkOfferingServiceCapabilities(NetworkOffering offering, Service service);
Long getPhysicalNetworkId(Network network);
boolean getAllowSubdomainAccessGlobal();
boolean isProviderForNetwork(Provider provider, long networkId);
boolean isProviderForNetworkOffering(Provider provider, long networkOfferingId);
void canProviderSupportServices(Map<Provider, Set<Service>> providersMap);
List<PhysicalNetworkSetupInfo> getPhysicalNetworkInfo(long dcId, HypervisorType hypervisorType);
boolean canAddDefaultSecurityGroup();
List<Service> listNetworkOfferingServices(long networkOfferingId);
boolean areServicesEnabledInZone(long zoneId, NetworkOffering offering, List<Service> services);
Map<PublicIpAddress, Set<Service>> getIpToServices(List<? extends PublicIpAddress> publicIps, boolean rulesRevoked,
boolean includingFirewall);
Map<Provider, ArrayList<PublicIpAddress>> getProviderToIpList(Network network, Map<PublicIpAddress, Set<Service>> ipToServices);
boolean checkIpForService(IpAddress ip, Service service, Long networkId);
void checkCapabilityForProvider(Set<Provider> providers, Service service, Capability cap, String capValue);
Provider getDefaultUniqueProviderForService(String serviceName);
void checkNetworkPermissions(Account owner, Network network);
String getDefaultManagementTrafficLabel(long zoneId, HypervisorType hypervisorType);
String getDefaultStorageTrafficLabel(long zoneId, HypervisorType hypervisorType);
String getDefaultPublicTrafficLabel(long dcId, HypervisorType vmware);
String getDefaultGuestTrafficLabel(long dcId, HypervisorType vmware);
/**
* @param providerName
* @return
*/
NetworkElement getElementImplementingProvider(String providerName);
/**
* @param accountId
* @param zoneId
* @return
*/
String getAccountNetworkDomain(long accountId, long zoneId);
/**
* @return
*/
String getDefaultNetworkDomain();
/**
* @param ntwkOffId
* @return
*/
List<Provider> getNtwkOffDistinctProviders(long ntwkOffId);
/**
* @param accountId
* @param dcId
* @param sourceNat
* @return
*/
List<? extends IpAddress> listPublicIpsAssignedToAccount(long accountId, long dcId, Boolean sourceNat);
/**
* @param zoneId
* @param trafficType
* @return
*/
List<? extends PhysicalNetwork> getPhysicalNtwksSupportingTrafficType(long zoneId, TrafficType trafficType);
/**
* @param guestNic
* @return
*/
boolean isPrivateGateway(Nic guestNic);
Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId);
Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
Long getDedicatedNetworkDomain(long networkId);
Map<Service, Set<Provider>> getNetworkOfferingServiceProvidersMap(long networkOfferingId);
List<? extends Provider> listSupportedNetworkServiceProviders(String serviceName);
List<? extends Network> listNetworksByVpc(long vpcId);
boolean canUseForDeploy(Network network);
Network getExclusiveGuestNetwork(long zoneId);
long findPhysicalNetworkId(long zoneId, String tag, TrafficType trafficType);
Integer getNetworkRate(long networkId, Long vmId);
boolean isVmPartOfNetwork(long vmId, long ntwkId);
PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
Network getNetwork(long networkId);
IpAddress getIp(long sourceIpAddressId);
boolean isNetworkAvailableInDomain(long networkId, long domainId);
NicProfile getNicProfile(VirtualMachine vm, long networkId, String broadcastUri);
Set<Long> getAvailableIps(Network network, String requestedIp);
String getDomainNetworkDomain(long domainId, long zoneId);
PublicIpAddress getSourceNatIpAddressForGuestNetwork(Account owner, Network guestNetwork);
boolean isNetworkInlineMode(Network network);
}

View File

@ -17,8 +17,6 @@
package com.cloud.network;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
@ -29,19 +27,22 @@ import com.cloud.exception.InsufficientAddressCapacityException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network.Capability;
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
import com.cloud.network.Networks.TrafficType;
import com.cloud.user.Account;
import com.cloud.user.User;
import com.cloud.utils.Pair;
/**
* The NetworkService interface is the "public" api to entities that make requests to the orchestration engine
* Such entities are usually the admin and end-user API.
*
*/
public interface NetworkService {
List<? extends Network> getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner);
IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) throws ResourceAllocationException,
IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId) throws ResourceAllocationException,
InsufficientAddressCapacityException, ConcurrentOperationException;
boolean releaseIpAddress(long ipAddressId) throws InsufficientAddressCapacityException;
@ -64,24 +65,12 @@ public interface NetworkService {
IpAddress getIp(long id);
NetworkProfile convertNetworkToNetworkProfile(long networkId);
Map<Service, Map<Capability, String>> getNetworkCapabilities(long networkId);
boolean isNetworkAvailableInDomain(long networkId, long domainId);
Long getDedicatedNetworkDomain(long networkId);
Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount, User callerUser,
String domainSuffix, Long networkOfferingId, Boolean changeCidr);
Integer getNetworkRate(long networkId, Long vmId);
Network getSystemNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
Map<Service, Set<Provider>> getNetworkOfferingServiceProvidersMap(long networkOfferingId);
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed,
PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed,
List<String> isolationMethods, String broadcastDomainRange, Long domainId, List<String> tags, String name);
Pair<List<? extends PhysicalNetwork>, Integer> searchPhysicalNetworks(Long id, Long zoneId, String keyword,
@ -94,8 +83,6 @@ public interface NetworkService {
List<? extends Service> listNetworkServices(String providerName);
List<? extends Provider> listSupportedNetworkServiceProviders(String serviceName);
PhysicalNetworkServiceProvider addProviderToPhysicalNetwork(Long physicalNetworkId, String providerName,
Long destinationPhysicalNetworkId, List<String> enabledServices);
@ -127,17 +114,14 @@ public interface NetworkService {
Pair<List<? extends PhysicalNetworkTrafficType>, Integer> listTrafficTypes(Long physicalNetworkId);
PhysicalNetwork getDefaultPhysicalNetworkByZoneAndTrafficType(long zoneId, TrafficType trafficType);
Network getExclusiveGuestNetwork(long zoneId);
List<Pair<TrafficType, String>> listTrafficTypeImplementor(ListTrafficTypeImplementorsCmd cmd);
List<? extends Network> getIsolatedNetworksWithSourceNATOwnedByAccountInZone(long zoneId, Account owner);
List<? extends Network> listNetworksByVpc(long vpcId);
boolean isVmPartOfNetwork(long vmId, long ntwkId);
/**
* @param networkId
@ -170,9 +154,5 @@ public interface NetworkService {
Network createPrivateNetwork(String networkName, String displayText, long physicalNetworkId, String vlan,
String startIp, String endIP, String gateway, String netmask, long networkOwnerId, Long vpcId)
throws ResourceAllocationException, ConcurrentOperationException, InsufficientCapacityException;
/**
* @param network
* @return
*/
boolean canUseForDeploy(Network network);
}

View File

@ -24,8 +24,9 @@ import com.cloud.network.Network;
import com.cloud.network.Network.Provider;
import com.cloud.network.Network.Service;
import com.cloud.network.PublicIpAddress;
import com.cloud.utils.component.Adapter;
public interface IpDeployer {
public interface IpDeployer extends Adapter{
/**
* Apply ip addresses to this network
* @param network

View File

@ -22,8 +22,9 @@ import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.network.RemoteAccessVpn;
import com.cloud.network.VpnUser;
import com.cloud.utils.component.Adapter;
public interface RemoteAccessVPNServiceProvider extends NetworkElement, IpDeployingRequester {
public interface RemoteAccessVPNServiceProvider extends Adapter {
String[] applyVpnUsers(RemoteAccessVpn vpn, List<? extends VpnUser> users) throws ResourceUnavailableException;
boolean startVpn(Network network, RemoteAccessVpn vpn) throws ResourceUnavailableException;

View File

@ -17,10 +17,10 @@
package com.cloud.network.element;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.network.Network;
import com.cloud.network.Site2SiteVpnConnection;
import com.cloud.utils.component.Adapter;
public interface Site2SiteVpnServiceProvider extends NetworkElement {
public interface Site2SiteVpnServiceProvider extends Adapter {
boolean startSite2SiteVpn(Site2SiteVpnConnection conn) throws ResourceUnavailableException;
boolean stopSite2SiteVpn(Site2SiteVpnConnection conn) throws ResourceUnavailableException;

View File

@ -105,8 +105,6 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
boolean getElasticIp();
boolean getAssociatePublicIP();
boolean getElasticLb();
boolean getSpecifyIpRanges();

View File

@ -25,6 +25,7 @@ import java.util.Set;
import com.cloud.alert.Alert;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd;
import org.apache.cloudstack.api.command.admin.host.ListHostsCmd;
import org.apache.cloudstack.api.command.admin.host.UpdateHostPasswordCmd;
import org.apache.cloudstack.api.command.admin.pod.ListPodsByCmd;
import org.apache.cloudstack.api.command.admin.resource.ListAlertsCmd;
@ -140,6 +141,14 @@ public interface ManagementService {
*/
Pair<List<? extends Pod>, Integer> searchForPods(ListPodsByCmd cmd);
/**
* Searches for servers by the specified search criteria Can search by: "name", "type", "state", "dataCenterId",
* "podId"
*
* @param cmd
* @return List of Hosts
*/
Pair<List<? extends Host>, Integer> searchForServers(ListHostsCmd cmd);
/**
* Creates a new template
@ -384,7 +393,7 @@ public interface ManagementService {
* @return Pair<List<? extends Host>, List<? extends Host>> List of all Hosts in VM's cluster and list of Hosts with
* enough capacity
*/
Pair<List<? extends Host>, List<? extends Host>> listHostsForMigrationOfVM(Long vmId, Long startIndex, Long pageSize);
Pair<Pair<List<? extends Host>, Integer>, List<? extends Host>> listHostsForMigrationOfVM(Long vmId, Long startIndex, Long pageSize);
String[] listEventTypes();

View File

@ -23,6 +23,7 @@ import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaint
import org.apache.cloudstack.api.command.admin.storage.UpdateStoragePoolCmd;
import org.apache.cloudstack.api.command.user.volume.CreateVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.UploadVolumeCmd;
import org.apache.cloudstack.api.command.user.volume.ResizeVolumeCmd;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.PermissionDeniedException;
@ -70,6 +71,15 @@ public interface StorageService{
Volume createVolume(CreateVolumeCmd cmd);
/**
* Resizes the volume based on the given criteria
*
* @param cmd
* the API command wrapping the criteria
* @return the volume object
*/
Volume resizeVolume(ResizeVolumeCmd cmd);
/**
* Delete the storage pool
*

View File

@ -36,6 +36,7 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
Ready("The volume is ready to be used."),
Migrating("The volume is migrating to other storage pool"),
Snapshotting("There is a snapshot created on this volume, not backed up to secondary storage yet"),
Resizing("The volume is being resized"),
Expunging("The volume is being expunging"),
Destroy("The volume is destroyed, and can't be recovered."),
UploadOp ("The volume upload operation is in progress or in short the volume is on secondary storage");
@ -62,7 +63,10 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
s_fsm.addTransition(Creating, Event.OperationFailed, Allocated);
s_fsm.addTransition(Creating, Event.OperationSucceeded, Ready);
s_fsm.addTransition(Creating, Event.DestroyRequested, Destroy);
s_fsm.addTransition(Creating, Event.CreateRequested, Creating);
s_fsm.addTransition(Creating, Event.CreateRequested, Creating);
s_fsm.addTransition(Ready, Event.ResizeRequested, Resizing);
s_fsm.addTransition(Resizing, Event.OperationSucceeded, Ready);
s_fsm.addTransition(Resizing, Event.OperationFailed, Ready);
s_fsm.addTransition(Allocated, Event.UploadRequested, UploadOp);
s_fsm.addTransition(UploadOp, Event.CopyRequested, Creating);// CopyRequested for volume from sec to primary storage
s_fsm.addTransition(Creating, Event.CopySucceeded, Ready);
@ -92,7 +96,8 @@ public interface Volume extends ControlledEntity, Identity, InternalIdentity, Ba
MigrationRequested,
SnapshotRequested,
DestroyRequested,
ExpungingRequested;
ExpungingRequested,
ResizeRequested;
}
/**

View File

@ -82,7 +82,7 @@ public interface SnapshotService {
* the command that specifies the volume criteria
* @return list of snapshot policies
*/
List<? extends SnapshotPolicy> listPoliciesforVolume(ListSnapshotPoliciesCmd cmd);
Pair<List<? extends SnapshotPolicy>, Integer> listPoliciesforVolume(ListSnapshotPoliciesCmd cmd);
boolean deleteSnapshotPolicies(DeleteSnapshotPoliciesCmd cmd);

View File

@ -50,6 +50,10 @@ public class UserContext {
return userId;
}
public User getCallerUser() {
return _accountMgr.getActiveUser(userId);
}
public void setCallerUserId(long userId) {
this.userId = userId;
}

View File

@ -17,6 +17,7 @@
package org.apache.cloudstack.acl;
import com.cloud.exception.PermissionDeniedException;
import com.cloud.exception.RequestLimitException;
import com.cloud.user.User;
import com.cloud.utils.component.Adapter;
@ -26,5 +27,5 @@ public interface APIChecker extends Adapter {
// If true, apiChecker has checked the operation
// If false, apiChecker is unable to handle the operation or not implemented
// On exception, checkAccess failed don't allow
boolean checkAccess(User user, String apiCommandName) throws PermissionDeniedException;
boolean checkAccess(User user, String apiCommandName) throws PermissionDeniedException, RequestLimitException;
}

View File

@ -0,0 +1,30 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.acl;
import org.apache.cloudstack.api.ServerApiException;
import com.cloud.user.Account;
import com.cloud.utils.component.Adapter;
/**
* APILimitChecker checks if we should block an API request based on pre-set account based api limit.
*/
public interface APILimitChecker extends Adapter {
// Interface for checking if the account is over its api limit
void checkLimit(Account account) throws ServerApiException;
}

View File

@ -387,6 +387,7 @@ public class ApiConstants {
public static final String ESP_LIFETIME = "esplifetime";
public static final String DPD = "dpd";
public static final String FOR_VPC = "forvpc";
public static final String SHRINK_OK = "shrinkok";
public static final String NICIRA_NVP_DEVICE_ID = "nvpdeviceid";
public static final String NICIRA_NVP_TRANSPORT_ZONE_UUID = "transportzoneuuid";
public static final String NICIRA_NVP_DEVICE_NAME = "niciradevicename";

View File

@ -0,0 +1,59 @@
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api;
/**
* Enum class for various API error code used in CloudStack
* @author minc
*
*/
public enum ApiErrorCode {
MALFORMED_PARAMETER_ERROR(430),
PARAM_ERROR(431),
UNSUPPORTED_ACTION_ERROR(432),
API_LIMIT_EXCEED(429),
INTERNAL_ERROR(530),
ACCOUNT_ERROR(531),
ACCOUNT_RESOURCE_LIMIT_ERROR(532),
INSUFFICIENT_CAPACITY_ERROR(533),
RESOURCE_UNAVAILABLE_ERROR(534),
RESOURCE_ALLOCATION_ERROR(534),
RESOURCE_IN_USE_ERROR(536),
NETWORK_RULE_CONFLICT_ERROR(537);
private int httpCode;
private ApiErrorCode(int httpStatusCode){
httpCode = httpStatusCode;
}
public int getHttpCode() {
return httpCode;
}
public void setHttpCode(int httpCode) {
this.httpCode = httpCode;
}
public String toString(){
return String.valueOf(this.httpCode);
}
}

View File

@ -81,23 +81,6 @@ public abstract class BaseCmd {
BOOLEAN, DATE, FLOAT, INTEGER, SHORT, LIST, LONG, OBJECT, MAP, STRING, TZDATE, UUID
}
// FIXME: Extract these out into a separate file
// Client error codes
public static final int MALFORMED_PARAMETER_ERROR = 430;
public static final int PARAM_ERROR = 431;
public static final int UNSUPPORTED_ACTION_ERROR = 432;
public static final int PAGE_LIMIT_EXCEED = 433;
// Server error codes
public static final int INTERNAL_ERROR = 530;
public static final int ACCOUNT_ERROR = 531;
public static final int ACCOUNT_RESOURCE_LIMIT_ERROR = 532;
public static final int INSUFFICIENT_CAPACITY_ERROR = 533;
public static final int RESOURCE_UNAVAILABLE_ERROR = 534;
public static final int RESOURCE_ALLOCATION_ERROR = 534;
public static final int RESOURCE_IN_USE_ERROR = 536;
public static final int NETWORK_RULE_CONFLICT_ERROR = 537;
public static final DateFormat INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd");
public static final DateFormat NEW_INPUT_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public static Pattern newInputDateFormat = Pattern.compile("[\\d]+-[\\d]+-[\\d]+ [\\d]+:[\\d]+:[\\d]+");
@ -230,7 +213,7 @@ public abstract class BaseCmd {
int arrayStartIndex = key.indexOf('[');
int arrayStartLastIndex = key.lastIndexOf('[');
if (arrayStartIndex != arrayStartLastIndex) {
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
+ "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
}
@ -239,7 +222,7 @@ public abstract class BaseCmd {
int arrayEndLastIndex = key.lastIndexOf(']');
if ((arrayEndIndex < arrayStartIndex) || (arrayEndIndex != arrayEndLastIndex)) {
// malformed parameter
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
+ "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
}
@ -247,7 +230,7 @@ public abstract class BaseCmd {
int fieldIndex = key.indexOf('.');
String fieldName = null;
if (fieldIndex < arrayEndIndex) {
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
+ "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
} else {
fieldName = key.substring(fieldIndex + 1);
@ -272,7 +255,7 @@ public abstract class BaseCmd {
}
if (!parsedIndex) {
throw new ServerApiException(MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
throw new ServerApiException(ApiErrorCode.MALFORMED_PARAMETER_ERROR, "Unable to decode parameter " + key
+ "; if specifying an object array, please use parameter[index].field=XXX, e.g. userGroupList[0].group=httpGroup");
}

View File

View File

@ -119,7 +119,7 @@ public abstract class BaseUpdateTemplateOrIsoPermissionsCmd extends BaseCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update template/iso permissions");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update template/iso permissions");
}
}
}

View File

@ -15,28 +15,51 @@
// specific language governing permissions and limitations
// under the License.
package org.apache.cloudstack.api;
import com.cloud.utils.exception.RuntimeCloudException;
import java.util.ArrayList;
import com.cloud.exception.CloudException;
import com.cloud.utils.exception.CSExceptionErrorCode;
import com.cloud.utils.exception.CloudRuntimeException;
@SuppressWarnings("serial")
public class ServerApiException extends RuntimeCloudException {
private int _errorCode;
public class ServerApiException extends CloudRuntimeException {
private ApiErrorCode _errorCode;
private String _description;
public ServerApiException() {
_errorCode = 0;
_errorCode = ApiErrorCode.INTERNAL_ERROR;
_description = null;
setCSErrorCode(CSExceptionErrorCode.getCSErrCode(ServerApiException.class.getName()));
}
public ServerApiException(int errorCode, String description) {
public ServerApiException(ApiErrorCode errorCode, String description) {
_errorCode = errorCode;
_description = description;
setCSErrorCode(CSExceptionErrorCode.getCSErrCode(ServerApiException.class.getName()));
}
public int getErrorCode() {
// wrap a specific CloudRuntimeException to a ServerApiException
public ServerApiException(ApiErrorCode errorCode, String description, Throwable cause){
super(description, cause);
_errorCode = errorCode;
_description = description;
if (cause instanceof CloudRuntimeException || cause instanceof CloudException ) {
CloudRuntimeException rt = (CloudRuntimeException) cause;
ArrayList<String> idList = rt.getIdProxyList();
if (idList != null) {
for (int i = 0; i < idList.size(); i++) {
addProxyObject(idList.get(i));
}
}
setCSErrorCode(rt.getCSErrorCode());
}
}
public ApiErrorCode getErrorCode() {
return _errorCode;
}
public void setErrorCode(int errorCode) {
public void setErrorCode(ApiErrorCode errorCode) {
_errorCode = errorCode;
}

View File

@ -151,7 +151,7 @@ public class CreateAccountCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create a user account");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create a user account");
}
}
}

View File

@ -91,7 +91,7 @@ public class DeleteAccountCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete user account and all corresponding users");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete user account and all corresponding users");
}
}

View File

@ -115,7 +115,7 @@ public class DisableAccountCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, lockRequested == true ? "Failed to lock account" : "Failed to disable account" );
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, lockRequested == true ? "Failed to lock account" : "Failed to disable account" );
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.account;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -95,7 +96,7 @@ public class EnableAccountCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to enable account");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to enable account");
}
}
}

View File

@ -84,7 +84,7 @@ public class LockAccountCmd extends BaseCmd {
// response.setResponseName(getCommandName());
// this.setResponseObject(response);
// } else {
// throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to lock account");
// throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to lock account");
// }
}
}

View File

@ -22,6 +22,7 @@ import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -125,7 +126,7 @@ public class UpdateAccountCmd extends BaseCmd{
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update account");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update account");
}
}
}

View File

@ -20,6 +20,7 @@ package org.apache.cloudstack.api.command.admin.autoscale;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -86,7 +87,7 @@ public class CreateCounterCmd extends BaseAsyncCreateCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create Counter with name " + getName());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create Counter with name " + getName());
}
}

View File

@ -20,6 +20,7 @@ package org.apache.cloudstack.api.command.admin.autoscale;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -56,7 +57,7 @@ public class DeleteCounterCmd extends BaseAsyncCmd {
result = _autoScaleService.deleteCounter(getId());
} catch (ResourceInUseException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_IN_USE_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.RESOURCE_IN_USE_ERROR, ex.getMessage());
}
if (result) {
@ -64,7 +65,7 @@ public class DeleteCounterCmd extends BaseAsyncCmd {
this.setResponseObject(response);
} else {
s_logger.warn("Failed to delete counter with Id: " + getId());
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete counter.");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete counter.");
}
}

View File

@ -156,7 +156,7 @@ public class AddClusterCmd extends BaseCmd {
clusterResponses.add(clusterResponse);
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add cluster");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add cluster");
}
response.setResponses(clusterResponses);
@ -165,10 +165,10 @@ public class AddClusterCmd extends BaseCmd {
this.setResponseObject(response);
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
} catch (ResourceInUseException ex) {
s_logger.warn("Exception: ", ex);
ServerApiException e = new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
ServerApiException e = new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
for (String proxyObj : ex.getIdProxyList()) {
e.addProxyObject(proxyObj);
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.cluster;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -70,7 +71,7 @@ public class DeleteClusterCmd extends BaseCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete cluster");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete cluster");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.cluster;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -112,7 +113,7 @@ public class UpdateClusterCmd extends BaseCmd {
clusterResponse.setResponseName(getCommandName());
this.setResponseObject(clusterResponse);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update cluster");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update cluster");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.config;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -76,7 +77,7 @@ public class UpdateCfgCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update config");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update config");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.config;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -86,7 +87,7 @@ public class UpdateHypervisorCapabilitiesCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update hypervisor capabilities");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update hypervisor capabilities");
}
}
}

View File

@ -84,7 +84,7 @@ public class CreateDomainCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create domain");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create domain");
}
}
}

View File

@ -93,7 +93,7 @@ public class DeleteDomainCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete domain");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete domain");
}
}
}

View File

@ -83,7 +83,7 @@ public class UpdateDomainCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update domain");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update domain");
}
}
}

View File

@ -22,6 +22,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -148,7 +149,7 @@ public class AddHostCmd extends BaseCmd {
hostResponses.add(hostResponse);
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add host");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add host");
}
response.setResponses(hostResponses);
@ -157,7 +158,7 @@ public class AddHostCmd extends BaseCmd {
this.setResponseObject(response);
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
}

View File

@ -84,11 +84,11 @@ public class AddSecondaryStorageCmd extends BaseCmd {
this.setResponseObject(hostResponse);
}
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add secondary storage");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add secondary storage");
}
} catch (DiscoveryException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.host;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -104,7 +105,7 @@ public class CancelMaintenanceCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to cancel host maintenance");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to cancel host maintenance");
}
}
}

View File

@ -20,6 +20,7 @@ import org.apache.cloudstack.api.response.HostResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -84,7 +85,7 @@ public class DeleteHostCmd extends BaseCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete host");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete host");
}
}
}

View File

@ -168,17 +168,16 @@ public class ListHostsCmd extends BaseListCmd {
if (getVirtualMachineId() == null) {
response = _queryService.searchForServers(this);
} else {
List<? extends Host> result = new ArrayList<Host>();
Pair<List<? extends Host>,Integer> result;
List<? extends Host> hostsWithCapacity = new ArrayList<Host>();
Pair<List<? extends Host>, List<? extends Host>> hostsForMigration = _mgr.listHostsForMigrationOfVM(getVirtualMachineId(),
this.getStartIndex(), this.getPageSizeVal());
Pair<Pair<List<? extends Host>,Integer>, List<? extends Host>> hostsForMigration = _mgr.listHostsForMigrationOfVM(getVirtualMachineId(), this.getStartIndex(), this.getPageSizeVal());
result = hostsForMigration.first();
hostsWithCapacity = hostsForMigration.second();
response = new ListResponse<HostResponse>();
List<HostResponse> hostResponses = new ArrayList<HostResponse>();
for (Host host : result) {
for (Host host : result.first()) {
HostResponse hostResponse = _responseGenerator.createHostResponse(host, getDetails());
Boolean suitableForMigration = false;
if (hostsWithCapacity.contains(host)) {
@ -189,7 +188,7 @@ public class ListHostsCmd extends BaseListCmd {
hostResponses.add(hostResponse);
}
response.setResponses(hostResponses);
response.setResponses(hostResponses, result.second());
}
response.setResponseName(getCommandName());
this.setResponseObject(response);

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.host;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -104,7 +105,7 @@ public class PrepareForMaintenanceCmd extends BaseAsyncCmd {
response.setResponseName("host");
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to prepare host for maintenance");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to prepare host for maintenance");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.host;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -103,11 +104,11 @@ public class ReconnectHostCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reconnect host");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reconnect host");
}
} catch (Exception ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
}
}
}

View File

@ -21,6 +21,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -108,7 +109,7 @@ public class UpdateHostCmd extends BaseCmd {
this.setResponseObject(hostResponse);
} catch (Exception e) {
s_logger.debug("Failed to update host:" + getId(), e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update host:" + getId() + "," + e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update host:" + getId() + "," + e.getMessage());
}
}
}

View File

@ -21,6 +21,7 @@ import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -74,9 +75,9 @@ public class AddNetworkDeviceCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} catch (InvalidParameterValueException ipve) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
} catch (CloudRuntimeException cre) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
}
}

View File

@ -21,6 +21,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -103,7 +104,7 @@ public class AddNetworkServiceProviderCmd extends BaseAsyncCreateCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider to physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add service provider to physical network");
}
}
@ -114,7 +115,7 @@ public class AddNetworkServiceProviderCmd extends BaseAsyncCreateCmd {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add service provider entity to physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add service provider entity to physical network");
}
}

View File

@ -225,7 +225,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create network offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create network offering");
}
}
}

View File

@ -21,6 +21,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -151,7 +152,7 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create physical network");
}
}
@ -162,7 +163,7 @@ public class CreatePhysicalNetworkCmd extends BaseAsyncCreateCmd {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create physical network entity");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create physical network entity");
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.network;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -110,7 +111,7 @@ public class CreateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
this.setResponseObject(response);
} catch (Exception e) {
s_logger.warn("Create storage network IP range failed", e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.network;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -65,12 +66,12 @@ public class DeleteNetworkDeviceCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network device:" + getId());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network device:" + getId());
}
} catch (InvalidParameterValueException ipve) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
} catch (CloudRuntimeException cre) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.network;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -70,7 +71,7 @@ public class DeleteNetworkOfferingCmd extends BaseCmd{
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete service offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete service offering");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.network;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -76,14 +77,14 @@ public class DeleteNetworkServiceProviderCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete network service provider");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete network service provider");
}
} catch (ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
} catch (ConcurrentOperationException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex.getMessage());
}
}

View File

@ -70,7 +70,7 @@ public class DeletePhysicalNetworkCmd extends BaseAsyncCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete physical network");
}
}

View File

@ -70,7 +70,7 @@ public class DeleteStorageNetworkIpRangeCmd extends BaseAsyncCmd {
this.setResponseObject(response);
} catch (Exception e) {
s_logger.warn("Failed to delete storage network ip range " + getId(), e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}

View File

@ -23,6 +23,7 @@ import java.util.Map;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.APICommand;
@ -85,9 +86,9 @@ public class ListNetworkDeviceCmd extends BaseListCmd {
listResponse.setResponseName(getCommandName());
this.setResponseObject(listResponse);
} catch (InvalidParameterValueException ipve) {
throw new ServerApiException(BaseCmd.PARAM_ERROR, ipve.getMessage());
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, ipve.getMessage());
} catch (CloudRuntimeException cre) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, cre.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, cre.getMessage());
}
}

View File

@ -23,6 +23,7 @@ import org.apache.cloudstack.api.response.ZoneResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.APICommand;
@ -100,7 +101,7 @@ public class ListPhysicalNetworksCmd extends BaseListCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to search for physical networks");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to search for physical networks");
}
}
}

View File

@ -88,7 +88,7 @@ public class ListStorageNetworkIpRangeCmd extends BaseListCmd {
this.setResponseObject(response);
} catch (Exception e) {
s_logger.warn("Failed to list storage network ip range for rangeId=" + getRangeId() + " podId=" + getPodId() + " zoneId=" + getZoneId());
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}

View File

@ -102,7 +102,7 @@ public class UpdateNetworkOfferingCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update network offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update network offering");
}
}
}

View File

@ -21,6 +21,7 @@ import java.util.List;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -88,7 +89,7 @@ public class UpdateNetworkServiceProviderCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update service provider");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update service provider");
}
}

View File

@ -96,7 +96,7 @@ public class UpdateStorageNetworkIpRangeCmd extends BaseAsyncCmd {
this.setResponseObject(response);
} catch (Exception e) {
s_logger.warn("Update storage network IP range failed", e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}

View File

@ -20,6 +20,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -115,7 +116,7 @@ public class CreateDiskOfferingCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create disk offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create disk offering");
}
}
}

View File

@ -20,6 +20,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -162,7 +163,7 @@ public class CreateServiceOfferingCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create service offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create service offering");
}
}
}

View File

@ -20,6 +20,7 @@ import org.apache.cloudstack.api.response.DiskOfferingResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -70,7 +71,7 @@ public class DeleteDiskOfferingCmd extends BaseCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete disk offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete disk offering");
}
}
}

View File

@ -68,7 +68,7 @@ public class DeleteServiceOfferingCmd extends BaseCmd{
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete service offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete service offering");
}
}
}

View File

@ -18,6 +18,7 @@ package org.apache.cloudstack.api.command.admin.offering;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -91,7 +92,7 @@ public class UpdateDiskOfferingCmd extends BaseCmd{
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update disk offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update disk offering");
}
}
}

View File

@ -89,7 +89,7 @@ public class UpdateServiceOfferingCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update service offering");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update service offering");
}
}
}

View File

@ -111,7 +111,7 @@ public class CreatePodCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to create pod");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create pod");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.pod;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -70,7 +71,7 @@ public class DeletePodCmd extends BaseCmd {
SuccessResponse response = new SuccessResponse(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete pod");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete pod");
}
}
}

View File

@ -110,7 +110,7 @@ public class UpdatePodCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update pod");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update pod");
}
}
}

View File

@ -99,7 +99,7 @@ public class UploadCustomCertificateCmd extends BaseAsyncCmd {
response.setObjectName("customcertificate");
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to upload custom certificate");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upload custom certificate");
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.router;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -120,7 +121,7 @@ public class ConfigureVirtualRouterElementCmd extends BaseAsyncCmd {
routerResponse.setResponseName(getCommandName());
this.setResponseObject(routerResponse);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to configure the virtual router provider");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to configure the virtual router provider");
}
}
}

View File

@ -82,7 +82,7 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
}
}
@ -93,7 +93,7 @@ public class CreateVirtualRouterElementCmd extends BaseAsyncCreateCmd {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Virtual Router entity to physical network");
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.router;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -104,7 +105,7 @@ public class DestroyRouterCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to destroy router");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to destroy router");
}
}
}

View File

@ -98,7 +98,7 @@ public class RebootRouterCmd extends BaseAsyncCmd {
response.setResponseName("router");
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to reboot router");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to reboot router");
}
}
}

View File

@ -102,7 +102,7 @@ public class StartRouterCmd extends BaseAsyncCmd {
routerResponse.setResponseName(getCommandName());
this.setResponseObject(routerResponse);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to start router");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to start router");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.router;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -109,7 +110,7 @@ public class StopRouterCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to stop router");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to stop router");
}
}
}

View File

@ -81,7 +81,7 @@ public class UpgradeRouterCmd extends BaseCmd {
routerResponse.setResponseName(getCommandName());
this.setResponseObject(routerResponse);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to upgrade router");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to upgrade router");
}
}
}

View File

@ -31,6 +31,7 @@ import static org.apache.cloudstack.api.BaseCmd.CommandType.STRING;
import static org.apache.cloudstack.api.BaseCmd.CommandType.BOOLEAN;
import static com.cloud.user.Account.ACCOUNT_ID_SYSTEM;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.Parameter;
@ -93,12 +94,12 @@ public final class AddS3Cmd extends BaseCmd {
result = _resourceService.discoverS3(this);
if (result == null) {
throw new ServerApiException(INTERNAL_ERROR, "Failed to add S3.");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add S3.");
}
} catch (DiscoveryException e) {
throw new ServerApiException(INTERNAL_ERROR, "Failed to add S3 due to " + e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add S3 due to " + e.getMessage());
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.storage;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -107,7 +108,7 @@ public class CancelPrimaryStorageMaintenanceCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to cancel primary storage maintenance");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to cancel primary storage maintenance");
}
}
}

View File

@ -122,17 +122,17 @@ public class CreateStoragePoolCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add storage pool");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add storage pool");
}
} catch (ResourceUnavailableException ex1) {
s_logger.warn("Exception: ", ex1);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex1.getMessage());
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex1.getMessage());
}catch (ResourceInUseException ex2) {
s_logger.warn("Exception: ", ex2);
throw new ServerApiException(BaseCmd.RESOURCE_IN_USE_ERROR, ex2.getMessage());
throw new ServerApiException(ApiErrorCode.RESOURCE_IN_USE_ERROR, ex2.getMessage());
} catch (UnknownHostException ex3) {
s_logger.warn("Exception: ", ex3);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, ex3.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, ex3.getMessage());
}
}
}

View File

@ -78,9 +78,9 @@ public class DeletePoolCmd extends BaseCmd {
} else {
StoragePool pool = _storageService.getStoragePool(id);
if (pool != null && pool.getStatus() == StoragePoolStatus.Removed) {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to finish storage pool removal. The storage pool will not be used but cleanup is needed");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to finish storage pool removal. The storage pool will not be used but cleanup is needed");
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to delete storage pool");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to delete storage pool");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.storage;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -105,7 +106,7 @@ public class PreparePrimaryStorageForMaintenanceCmd extends BaseAsyncCmd {
response.setResponseName("storagepool");
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to prepare primary storage for maintenance");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to prepare primary storage for maintenance");
}
}
}

View File

@ -78,7 +78,7 @@ public class UpdateStoragePoolCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to update storage pool");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to update storage pool");
}
}
}

View File

@ -92,12 +92,12 @@ public class AddSwiftCmd extends BaseCmd {
swiftResponse.setObjectName("swift");
this.setResponseObject(swiftResponse);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add Swift");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add Swift");
}
} catch (DiscoveryException ex) {
String errMsg = "Failed to add Swift due to " + ex.toString();
s_logger.warn(errMsg, ex);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, errMsg);
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, errMsg);
}
}
}

View File

@ -95,7 +95,7 @@ public class DestroySystemVmCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to destroy system vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to destroy system vm");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.systemvm;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -116,20 +117,20 @@ public class MigrateSystemVMCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to migrate the system vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to migrate the system vm");
}
} catch (ResourceUnavailableException ex) {
s_logger.warn("Exception: ", ex);
throw new ServerApiException(BaseCmd.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
throw new ServerApiException(ApiErrorCode.RESOURCE_UNAVAILABLE_ERROR, ex.getMessage());
} catch (ConcurrentOperationException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
} catch (ManagementServerException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
} catch (VirtualMachineMigrationException e) {
s_logger.warn("Exception: ", e);
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, e.getMessage());
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, e.getMessage());
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.systemvm;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -105,7 +106,7 @@ public class RebootSystemVmCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to reboot system vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to reboot system vm");
}
}
}

View File

@ -19,6 +19,7 @@ package org.apache.cloudstack.api.command.admin.systemvm;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -109,7 +110,7 @@ public class StartSystemVMCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to start system vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to start system vm");
}
}
}

View File

@ -112,7 +112,7 @@ public class StopSystemVmCmd extends BaseAsyncCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to stop system vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to stop system vm");
}
}
}

View File

@ -94,7 +94,7 @@ public class UpgradeSystemVMCmd extends BaseCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Fail to reboot system vm");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Fail to reboot system vm");
}
}
}

View File

@ -20,6 +20,7 @@ import org.apache.cloudstack.api.response.PhysicalNetworkResponse;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseAsyncCreateCmd;
import org.apache.cloudstack.api.BaseCmd;
import org.apache.cloudstack.api.APICommand;
@ -123,7 +124,7 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
response.setResponseName(getCommandName());
this.setResponseObject(response);
}else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add traffic type to physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add traffic type to physical network");
}
}
@ -134,7 +135,7 @@ public class AddTrafficTypeCmd extends BaseAsyncCreateCmd {
setEntityId(result.getId());
setEntityUuid(result.getUuid());
} else {
throw new ServerApiException(BaseCmd.INTERNAL_ERROR, "Failed to add traffic type to physical network");
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to add traffic type to physical network");
}
}

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