Updated invalid parameter/value to com.cloud.exception.InvalidParameterValueException (#9455)

This commit is contained in:
Suresh Kumar Anaparti 2024-08-28 12:24:43 +05:30 committed by GitHub
parent 70131be8c2
commit c05edc40f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 72 additions and 85 deletions

View File

@ -16,9 +16,6 @@
// under the License.
package org.apache.cloudstack.api.command.user.vm;
import java.security.InvalidParameterException;
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
import org.apache.cloudstack.api.ACL;
import org.apache.cloudstack.api.APICommand;
@ -28,6 +25,7 @@ import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.response.GetVMPasswordResponse;
import org.apache.cloudstack.api.response.UserVmResponse;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.user.Account;
import com.cloud.uservm.UserVm;
import com.cloud.vm.VirtualMachine;
@ -61,7 +59,7 @@ public class GetVMPasswordCmd extends BaseCmd {
public void execute() {
String passwd = _mgr.getVMPassword(this);
if (passwd == null || passwd.equals(""))
throw new InvalidParameterException("No password for VM with id '" + getId() + "' found.");
throw new InvalidParameterValueException("No password for VM with id '" + getId() + "' found.");
setResponseObject(new GetVMPasswordResponse(getCommandName(), passwd));
}

View File

@ -32,8 +32,6 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import java.security.InvalidParameterException;
public class CreateVMScheduleCmdTest {
@Mock
public VMScheduleManager vmScheduleManager;
@ -70,11 +68,11 @@ public class CreateVMScheduleCmdTest {
/**
* given: "We have a VMScheduleManager and CreateVMScheduleCmd"
* when: "CreateVMScheduleCmd is executed with an invalid parameter"
* then: "an InvalidParameterException is thrown"
* then: "an InvalidParameterValueException is thrown"
*/
@Test(expected = InvalidParameterException.class)
public void testInvalidParameterException() {
Mockito.when(vmScheduleManager.createSchedule(createVMScheduleCmd)).thenThrow(InvalidParameterException.class);
@Test(expected = InvalidParameterValueException.class)
public void testInvalidParameterValueException() {
Mockito.when(vmScheduleManager.createSchedule(createVMScheduleCmd)).thenThrow(InvalidParameterValueException.class);
createVMScheduleCmd.execute();
}
@ -94,7 +92,7 @@ public class CreateVMScheduleCmdTest {
/**
* given: "We have an EntityManager and CreateVMScheduleCmd"
* when: "CreateVMScheduleCmd.getEntityOwnerId is executed for a VM which doesn't exist"
* then: "an InvalidParameterException is thrown"
* then: "an InvalidParameterValueException is thrown"
*/
@Test(expected = InvalidParameterValueException.class)
public void testFailureGetEntityOwnerId() {

View File

@ -34,8 +34,6 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import java.security.InvalidParameterException;
public class DeleteVMScheduleCmdTest {
@Mock
public VMScheduleManager vmScheduleManager;
@ -89,11 +87,11 @@ public class DeleteVMScheduleCmdTest {
/**
* given: "We have a VMScheduleManager and DeleteVMScheduleCmd"
* when: "DeleteVMScheduleCmd is executed with an invalid parameter"
* then: "an InvalidParameterException is thrown"
* then: "an InvalidParameterValueException is thrown"
*/
@Test(expected = InvalidParameterException.class)
public void testInvalidParameterException() {
Mockito.when(vmScheduleManager.removeSchedule(deleteVMScheduleCmd)).thenThrow(InvalidParameterException.class);
@Test(expected = InvalidParameterValueException.class)
public void testInvalidParameterValueException() {
Mockito.when(vmScheduleManager.removeSchedule(deleteVMScheduleCmd)).thenThrow(InvalidParameterValueException.class);
deleteVMScheduleCmd.execute();
}
@ -113,7 +111,7 @@ public class DeleteVMScheduleCmdTest {
/**
* given: "We have an EntityManager and DeleteVMScheduleCmd"
* when: "DeleteVMScheduleCmd.getEntityOwnerId is executed for a VM which doesn't exist"
* then: "an InvalidParameterException is thrown"
* then: "an InvalidParameterValueException is thrown"
*/
@Test(expected = InvalidParameterValueException.class)
public void testFailureGetEntityOwnerId() {

View File

@ -18,6 +18,7 @@
*/
package org.apache.cloudstack.api.command.user.vm;
import com.cloud.exception.InvalidParameterValueException;
import org.apache.cloudstack.api.response.ListResponse;
import org.apache.cloudstack.api.response.VMScheduleResponse;
import org.apache.cloudstack.vm.schedule.VMScheduleManager;
@ -30,7 +31,6 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Collections;
@ -88,11 +88,11 @@ public class ListVMScheduleCmdTest {
/**
* given: "We have a VMScheduleManager and ListVMScheduleCmd"
* when: "ListVMScheduleCmd is executed with an invalid parameter"
* then: "an InvalidParameterException is thrown"
* then: "an InvalidParameterValueException is thrown"
*/
@Test(expected = InvalidParameterException.class)
public void testInvalidParameterException() {
Mockito.when(vmScheduleManager.listSchedule(listVMScheduleCmd)).thenThrow(InvalidParameterException.class);
@Test(expected = InvalidParameterValueException.class)
public void testInvalidParameterValueException() {
Mockito.when(vmScheduleManager.listSchedule(listVMScheduleCmd)).thenThrow(InvalidParameterValueException.class);
listVMScheduleCmd.execute();
ListResponse<VMScheduleResponse> actualResponseObject = (ListResponse<VMScheduleResponse>) listVMScheduleCmd.getResponseObject();
}

View File

@ -33,8 +33,6 @@ import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
import java.security.InvalidParameterException;
public class UpdateVMScheduleCmdTest {
@Mock
public VMScheduleManager vmScheduleManager;
@ -71,11 +69,11 @@ public class UpdateVMScheduleCmdTest {
/**
* given: "We have a VMScheduleManager and UpdateVMScheduleCmd"
* when: "UpdateVMScheduleCmd is executed with an invalid parameter"
* then: "an InvalidParameterException is thrown"
* then: "an InvalidParameterValueException is thrown"
*/
@Test(expected = InvalidParameterException.class)
public void testInvalidParameterException() {
Mockito.when(vmScheduleManager.updateSchedule(updateVMScheduleCmd)).thenThrow(InvalidParameterException.class);
@Test(expected = InvalidParameterValueException.class)
public void testInvalidParameterValueException() {
Mockito.when(vmScheduleManager.updateSchedule(updateVMScheduleCmd)).thenThrow(InvalidParameterValueException.class);
updateVMScheduleCmd.execute();
}
@ -99,7 +97,7 @@ public class UpdateVMScheduleCmdTest {
/**
* given: "We have an EntityManager and UpdateVMScheduleCmd"
* when: "UpdateVMScheduleCmd.getEntityOwnerId is executed for a VM Schedule which doesn't exist"
* then: "an InvalidParameterException is thrown"
* then: "an InvalidParameterValueException is thrown"
*/
@Test(expected = InvalidParameterValueException.class)
public void testFailureGetEntityOwnerId() {

View File

@ -19,6 +19,7 @@
package org.apache.cloudstack.kvm.ha;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.host.Host;
import com.cloud.hypervisor.Hypervisor;
@ -36,7 +37,6 @@ import org.apache.cloudstack.outofbandmanagement.OutOfBandManagementService;
import org.joda.time.DateTime;
import javax.inject.Inject;
import java.security.InvalidParameterException;
public final class KVMHAProvider extends HAAbstractHostProvider implements HAProvider<Host>, Configurable {
@ -129,7 +129,7 @@ public final class KVMHAProvider extends HAAbstractHostProvider implements HAPro
case MaxDegradedWaitTimeout:
return KVMHAConfig.KvmHADegradedMaxPeriod.valueIn(clusterId);
default:
throw new InvalidParameterException("Unknown HAProviderConfig " + name.toString());
throw new InvalidParameterValueException("Unknown HAProviderConfig " + name.toString());
}
}

View File

@ -18,6 +18,7 @@
package org.apache.cloudstack.ha;
import com.cloud.api.response.SimulatorHAStateResponse;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.host.Host;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.utils.fsm.StateListener;
@ -30,7 +31,6 @@ import org.apache.cloudstack.ha.provider.host.HAAbstractHostProvider;
import org.joda.time.DateTime;
import javax.inject.Inject;
import java.security.InvalidParameterException;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -129,7 +129,7 @@ public class SimulatorHAProvider extends HAAbstractHostProvider implements HAPro
case RecoveryWaitTimeout:
return 1L;
default:
throw new InvalidParameterException("Unknown HAProviderConfig " + name.toString());
throw new InvalidParameterValueException("Unknown HAProviderConfig " + name.toString());
}
}

View File

@ -16,8 +16,6 @@
// under the License.
package org.apache.cloudstack.api.command.user.kubernetes.cluster;
import java.security.InvalidParameterException;
import javax.inject.Inject;
import com.cloud.exception.InvalidParameterValueException;
@ -227,7 +225,7 @@ public class CreateKubernetesClusterCmd extends BaseAsyncCreateCmd {
public Long getNodeRootDiskSize() {
if (nodeRootDiskSize != null) {
if (nodeRootDiskSize < DEFAULT_NODE_ROOT_DISK_SIZE) {
throw new InvalidParameterException("Provided node root disk size is lesser than default size of " + DEFAULT_NODE_ROOT_DISK_SIZE +"GB");
throw new InvalidParameterValueException("Provided node root disk size is lesser than default size of " + DEFAULT_NODE_ROOT_DISK_SIZE +"GB");
}
return nodeRootDiskSize;
} else {

View File

@ -21,7 +21,6 @@ package org.apache.cloudstack.network.opendaylight.agent;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.InvalidParameterException;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
@ -69,6 +68,7 @@ import com.cloud.agent.api.ReadyCommand;
import com.cloud.agent.api.StartupCommand;
import com.cloud.host.Host;
import com.cloud.host.Host.Type;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.resource.ServerResource;
public class OpenDaylightControllerResource implements ServerResource {
@ -332,11 +332,11 @@ public class OpenDaylightControllerResource implements ServerResource {
private void updateConfiguration() {
if (!configuration.containsKey("url") || !configuration.containsKey("username") || !configuration.containsKey("password"))
throw new InvalidParameterException("OpenDaylightControllerResource needs a url, username and password.");
throw new InvalidParameterValueException("OpenDaylightControllerResource needs a url, username and password.");
try {
controllerUrl = new URL((String)configuration.get("url"));
} catch (MalformedURLException e) {
throw new InvalidParameterException("OpenDaylightControllerResource found an invalid controller url");
throw new InvalidParameterValueException("OpenDaylightControllerResource found an invalid controller url");
}
controllerUsername = (String)configuration.get("username");
controllerPassword = (String)configuration.get("password");

View File

@ -32,6 +32,7 @@ import com.cloud.dc.dao.DataCenterIpAddressDao;
import com.cloud.domain.Domain;
import com.cloud.domain.DomainVO;
import com.cloud.domain.dao.DomainDao;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.exception.ResourceUnavailableException;
import com.cloud.host.Host;
import com.cloud.host.HostVO;
@ -219,7 +220,6 @@ import org.apache.commons.lang3.StringUtils;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -2466,7 +2466,7 @@ public class TungstenServiceImpl extends ManagerBase implements TungstenService
boolean success = true;
LoadBalancerVO loadBalancer = loadBalancerDao.findById(lbId);
if (loadBalancer == null) {
throw new InvalidParameterException("Invalid Load balancer Id:" + lbId);
throw new InvalidParameterValueException("Invalid Load balancer Id:" + lbId);
}
if (loadBalancer.getState() == FirewallRule.State.Active) {

View File

@ -20,6 +20,7 @@
package org.apache.cloudstack.storage.datastore.util;
import com.cloud.agent.api.Answer;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.utils.Pair;
import com.cloud.utils.exception.CloudRuntimeException;
import com.google.gson.Gson;
@ -47,7 +48,6 @@ import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.UriBuilder;
import java.net.ConnectException;
import java.security.InvalidParameterException;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
@ -196,8 +196,8 @@ public class ElastistorUtil {
} catch (InvalidCredentialsException e) {
throw new CloudRuntimeException("InvalidCredentialsException:" + e.getMessage(), e);
} catch (InvalidParameterException e) {
throw new CloudRuntimeException("InvalidParameterException:" + e.getMessage(), e);
} catch (InvalidParameterValueException e) {
throw new CloudRuntimeException("InvalidParameterValueException:" + e.getMessage(), e);
} catch (SSLHandshakeException e) {
throw new CloudRuntimeException("SSLHandshakeException:" + e.getMessage(), e);
} catch (ServiceUnavailableException e) {
@ -1050,22 +1050,22 @@ public class ElastistorUtil {
private String queryparamapikey = "apikey";
private String queryparamresponse = "response";
public ElastiCenterClient(String address, String key) throws InvalidCredentialsException, InvalidParameterException, SSLHandshakeException, ServiceUnavailableException {
public ElastiCenterClient(String address, String key) throws InvalidCredentialsException, InvalidParameterValueException, SSLHandshakeException, ServiceUnavailableException {
elastiCenterAddress = address;
apiKey = key;
initialize();
}
public void initialize() throws InvalidParameterException, SSLHandshakeException, InvalidCredentialsException, ServiceUnavailableException {
public void initialize() throws InvalidParameterValueException, SSLHandshakeException, InvalidCredentialsException, ServiceUnavailableException {
if (apiKey == null || apiKey.trim().isEmpty()) {
throw new InvalidParameterException("Unable to initialize. Please specify a valid API Key.");
throw new InvalidParameterValueException("Unable to initialize. Please specify a valid API Key.");
}
if (elastiCenterAddress == null || elastiCenterAddress.trim().isEmpty()) {
// TODO : Validate the format, like valid IP address or
// hostname.
throw new InvalidParameterException("Unable to initialize. Please specify a valid ElastiCenter IP Address or Hostname.");
throw new InvalidParameterValueException("Unable to initialize. Please specify a valid ElastiCenter IP Address or Hostname.");
}
if (ignoreSSLCertificate) {
@ -1143,7 +1143,7 @@ public class ElastistorUtil {
}
if (command == null || command.trim().isEmpty()) {
throw new InvalidParameterException("No command to execute.");
throw new InvalidParameterValueException("No command to execute.");
}
try {
@ -1175,9 +1175,9 @@ public class ElastistorUtil {
if (401 == response.getStatus()) {
throw new InvalidCredentialsException("Please specify a valid API Key.");
} else if (431 == response.getStatus()) {
throw new InvalidParameterException(response.getHeaders().getFirst("X-Description"));
throw new InvalidParameterValueException(response.getHeaders().getFirst("X-Description"));
} else if (432 == response.getStatus()) {
throw new InvalidParameterException(command + " does not exist on the ElastiCenter server. Please specify a valid command or contact your ElastiCenter Administrator.");
throw new InvalidParameterValueException(command + " does not exist on the ElastiCenter server. Please specify a valid command or contact your ElastiCenter Administrator.");
} else {
throw new ServiceUnavailableException("Internal Error. Please contact your ElastiCenter Administrator.");
}

View File

@ -18,7 +18,6 @@
package com.cloud.network;
import java.math.BigInteger;
import java.security.InvalidParameterException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.ArrayList;
@ -417,10 +416,10 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel, Confi
}
// Since it's non-conserve mode, only one service should used for IP
if (services.size() != 1) {
throw new InvalidParameterException("There are multiple services used ip " + ip.getAddress() + ".");
throw new InvalidParameterValueException("There are multiple services used ip " + ip.getAddress() + ".");
}
if (service != null && !((Service)services.toArray()[0] == service || service.equals(Service.Firewall))) {
throw new InvalidParameterException("The IP " + ip.getAddress() + " is already used as " + ((Service)services.toArray()[0]).getName() + " rather than " +
throw new InvalidParameterValueException("The IP " + ip.getAddress() + " is already used as " + ((Service)services.toArray()[0]).getName() + " rather than " +
service.getName());
}
return true;
@ -458,7 +457,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel, Confi
// Since IP already has service to bind with, the oldProvider can't be null
Set<Provider> newProviders = serviceToProviders.get(service);
if (newProviders == null || newProviders.isEmpty()) {
throw new InvalidParameterException("There is no new provider for IP " + publicIp.getAddress() + " of service " + service.getName() + "!");
throw new InvalidParameterValueException("There is no new provider for IP " + publicIp.getAddress() + " of service " + service.getName() + "!");
}
Provider newProvider = (Provider)newProviders.toArray()[0];
Set<Provider> oldProviders = serviceToProviders.get(services.toArray()[0]);
@ -471,7 +470,7 @@ public class NetworkModelImpl extends ManagerBase implements NetworkModel, Confi
IpDeployer newIpDeployer = ((IpDeployingRequester)newElement).getIpDeployer(network);
// FIXME: I ignored this check
} else {
throw new InvalidParameterException("Ip cannot be applied for new provider!");
throw new InvalidParameterValueException("Ip cannot be applied for new provider!");
}
return true;
}

View File

@ -20,7 +20,6 @@ import java.net.Inet6Address;
import java.net.InetAddress;
import java.net.URI;
import java.net.UnknownHostException;
import java.security.InvalidParameterException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@ -551,10 +550,10 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
}
// Since it's non-conserve mode, only one service should be used for IP
if (services.size() != 1) {
throw new InvalidParameterException("There are multiple services used ip " + ip.getAddress() + ".");
throw new InvalidParameterValueException("There are multiple services used ip " + ip.getAddress() + ".");
}
if (service != null && !((Service)services.toArray()[0] == service || service.equals(Service.Firewall))) {
throw new InvalidParameterException("The IP " + ip.getAddress() + " is already used as " + ((Service)services.toArray()[0]).getName() + " rather than " + service.getName());
throw new InvalidParameterValueException("The IP " + ip.getAddress() + " is already used as " + ((Service)services.toArray()[0]).getName() + " rather than " + service.getName());
}
return true;
}
@ -600,7 +599,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
}
// We don't support multiple providers for one service now
if (!provider.equals(curProvider)) {
throw new InvalidParameterException("There would be multiple providers for IP " + ip.getAddress() + " with the new network offering!");
throw new InvalidParameterValueException("There would be multiple providers for IP " + ip.getAddress() + " with the new network offering!");
}
}
}
@ -2810,7 +2809,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
* TODO Restarting a SDN based network requires updating the nics and the configuration
* in the controller. This requires a non-trivial rewrite of the restart procedure.
*/
throw new InvalidParameterException("Unable to restart a running SDN network.");
throw new InvalidParameterValueException("Unable to restart a running SDN network.");
}
Account callerAccount = _accountMgr.getActiveAccountById(user.getAccountId());
@ -4055,11 +4054,11 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
}
}
if (tags != null && tags.size() > 1) {
throw new InvalidParameterException("Only one tag can be specified for a physical network at this time");
throw new InvalidParameterValueException("Only one tag can be specified for a physical network at this time");
}
if (isolationMethods != null && isolationMethods.size() > 1) {
throw new InvalidParameterException("Only one isolationMethod can be specified for a physical network at this time");
throw new InvalidParameterValueException("Only one isolationMethod can be specified for a physical network at this time");
}
if (vnetRange != null && zoneType == NetworkType.Basic) {
@ -4198,7 +4197,7 @@ public class NetworkServiceImpl extends ManagerBase implements NetworkService, C
}
if (tags != null && tags.size() > 1) {
throw new InvalidParameterException("Unable to support more than one tag on network yet");
throw new InvalidParameterValueException("Unable to support more than one tag on network yet");
}
// If tags are null, then check if there are any other networks with null tags

View File

@ -16,7 +16,6 @@
// under the License.
package com.cloud.network.lb;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -733,7 +732,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
LoadBalancerVO loadBalancer = _lbDao.findById(cmd.getLbRuleId());
if (loadBalancer == null) {
throw new InvalidParameterException("Invalid Load balancer Id:" + cmd.getLbRuleId());
throw new InvalidParameterValueException("Invalid Load balancer Id:" + cmd.getLbRuleId());
}
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, loadBalancer);
@ -790,7 +789,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
LoadBalancerVO loadBalancer = _lbDao.findById(cmd.getLbRuleId());
if (loadBalancer == null) {
throw new InvalidParameterException("Invalid Load balancer Id:" + cmd.getLbRuleId());
throw new InvalidParameterValueException("Invalid Load balancer Id:" + cmd.getLbRuleId());
}
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, loadBalancer);
FirewallRule.State backupState = loadBalancer.getState();
@ -820,11 +819,11 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
LBStickinessPolicyVO stickinessPolicy = _lb2stickinesspoliciesDao.findById(stickinessPolicyId);
if (stickinessPolicy == null) {
throw new InvalidParameterException("Invalid Stickiness policy id value: " + stickinessPolicyId);
throw new InvalidParameterValueException("Invalid Stickiness policy id value: " + stickinessPolicyId);
}
LoadBalancerVO loadBalancer = _lbDao.findById(Long.valueOf(stickinessPolicy.getLoadBalancerId()));
if (loadBalancer == null) {
throw new InvalidParameterException("Invalid Load balancer : " + stickinessPolicy.getLoadBalancerId() + " for Stickiness policy id: " + stickinessPolicyId);
throw new InvalidParameterValueException("Invalid Load balancer : " + stickinessPolicy.getLoadBalancerId() + " for Stickiness policy id: " + stickinessPolicyId);
}
long loadBalancerId = loadBalancer.getId();
FirewallRule.State backupState = loadBalancer.getState();
@ -873,11 +872,11 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
LBHealthCheckPolicyVO healthCheckPolicy = _lb2healthcheckDao.findById(healthCheckPolicyId);
if (healthCheckPolicy == null) {
throw new InvalidParameterException("Invalid HealthCheck policy id value: " + healthCheckPolicyId);
throw new InvalidParameterValueException("Invalid HealthCheck policy id value: " + healthCheckPolicyId);
}
LoadBalancerVO loadBalancer = _lbDao.findById(Long.valueOf(healthCheckPolicy.getLoadBalancerId()));
if (loadBalancer == null) {
throw new InvalidParameterException("Invalid Load balancer : " + healthCheckPolicy.getLoadBalancerId() + " for HealthCheck policy id: " + healthCheckPolicyId);
throw new InvalidParameterValueException("Invalid Load balancer : " + healthCheckPolicy.getLoadBalancerId() + " for HealthCheck policy id: " + healthCheckPolicyId);
}
final long loadBalancerId = loadBalancer.getId();
FirewallRule.State backupState = loadBalancer.getState();
@ -1268,12 +1267,12 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
LoadBalancerVO loadBalancer = _lbDao.findById(Long.valueOf(lbRuleId));
if (loadBalancer == null) {
throw new InvalidParameterException("Invalid load balancer id: " + lbRuleId);
throw new InvalidParameterValueException("Invalid load balancer id: " + lbRuleId);
}
SslCertVO certVO = _entityMgr.findById(SslCertVO.class, certId);
if (certVO == null) {
throw new InvalidParameterException("Invalid certificate id: " + certId);
throw new InvalidParameterValueException("Invalid certificate id: " + certId);
}
_accountMgr.checkAccess(caller.getCallingAccount(), null, true, loadBalancer);
@ -1332,11 +1331,11 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
LoadBalancerCertMapVO lbCertMap = _lbCertMapDao.findByLbRuleId(lbRuleId);
if (loadBalancer == null) {
throw new InvalidParameterException("Invalid load balancer value: " + lbRuleId);
throw new InvalidParameterValueException("Invalid load balancer value: " + lbRuleId);
}
if (lbCertMap == null) {
throw new InvalidParameterException("No certificate is bound to lb with id: " + lbRuleId);
throw new InvalidParameterValueException("No certificate is bound to lb with id: " + lbRuleId);
}
_accountMgr.checkAccess(caller.getCallingAccount(), null, true, loadBalancer);
@ -1380,7 +1379,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
LoadBalancerVO loadBalancer = _lbDao.findById(Long.valueOf(loadBalancerId));
if (loadBalancer == null) {
throw new InvalidParameterException("Invalid load balancer value: " + loadBalancerId);
throw new InvalidParameterValueException("Invalid load balancer value: " + loadBalancerId);
}
_accountMgr.checkAccess(caller.getCallingAccount(), null, true, loadBalancer);
@ -2692,7 +2691,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
LoadBalancerVO loadBalancer = _lbDao.findById(Long.valueOf(policy.getLoadBalancerId()));
if (loadBalancer == null) {
throw new InvalidParameterException("Invalid Load balancer : " + policy.getLoadBalancerId() + " for Stickiness policy id: " + id);
throw new InvalidParameterValueException("Invalid Load balancer : " + policy.getLoadBalancerId() + " for Stickiness policy id: " + id);
}
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, loadBalancer);
@ -2719,7 +2718,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
LoadBalancerVO loadBalancer = _lbDao.findById(Long.valueOf(policy.getLoadBalancerId()));
if (loadBalancer == null) {
throw new InvalidParameterException("Invalid Load balancer : " + policy.getLoadBalancerId() + " for Stickiness policy id: " + id);
throw new InvalidParameterValueException("Invalid Load balancer : " + policy.getLoadBalancerId() + " for Stickiness policy id: " + id);
}
_accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, loadBalancer);

View File

@ -23,7 +23,6 @@ import java.io.IOException;
import java.io.StringWriter;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@ -56,6 +55,7 @@ import org.w3c.dom.traversal.NodeIterator;
import org.xml.sax.SAXException;
import com.cloud.exception.CloudException;
import com.cloud.exception.InvalidParameterValueException;
import com.cloud.hypervisor.vmware.util.VmwareContext;
import com.cloud.hypervisor.vmware.util.VmwareHelper;
import com.cloud.network.Networks.BroadcastDomainType;
@ -579,12 +579,12 @@ public class HypervisorHostHelper {
BroadcastDomainType.Storage, BroadcastDomainType.UnDecided, BroadcastDomainType.Vlan, BroadcastDomainType.NSX};
if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType + " it not supported on a VMWare hypervisor at this time.");
throw new InvalidParameterValueException("BroadcastDomainType " + broadcastDomainType + " it not supported on a VMWare hypervisor at this time.");
}
if (broadcastDomainType == BroadcastDomainType.Lswitch) {
if (vSwitchType == VirtualSwitchType.NexusDistributedVirtualSwitch) {
throw new InvalidParameterException("Nexus Distributed Virtualswitch is not supported with BroadcastDomainType " + broadcastDomainType);
throw new InvalidParameterValueException("Nexus Distributed Virtualswitch is not supported with BroadcastDomainType " + broadcastDomainType);
}
/**
* Nicira NVP requires all vms to be connected to a single port-group.
@ -636,7 +636,7 @@ public class HypervisorHostHelper {
if (broadcastDomainType == BroadcastDomainType.Lswitch) {
if (!dataCenterMo.hasDvPortGroup(networkName)) {
throw new InvalidParameterException("NVP integration port-group " + networkName + " does not exist on the DVS " + dvSwitchName);
throw new InvalidParameterValueException("NVP integration port-group " + networkName + " does not exist on the DVS " + dvSwitchName);
}
bWaitPortGroupReady = false;
} else if (BroadcastDomainType.NSX == broadcastDomainType && Objects.nonNull(netName)){
@ -1315,7 +1315,7 @@ public class HypervisorHostHelper {
BroadcastDomainType.Storage, BroadcastDomainType.UnDecided, BroadcastDomainType.Vlan, BroadcastDomainType.NSX};
if (!Arrays.asList(supportedBroadcastTypes).contains(broadcastDomainType)) {
throw new InvalidParameterException("BroadcastDomainType " + broadcastDomainType + " it not supported on a VMWare hypervisor at this time.");
throw new InvalidParameterValueException("BroadcastDomainType " + broadcastDomainType + " it not supported on a VMWare hypervisor at this time.");
}
if (broadcastDomainType == BroadcastDomainType.Lswitch) {
@ -1525,7 +1525,7 @@ public class HypervisorHostHelper {
}
}
if (nvpVlanId == 4095) {
throw new InvalidParameterException("No free vlan numbers on " + vSwitchName + " to create a portgroup for nic " + networkName);
throw new InvalidParameterValueException("No free vlan numbers on " + vSwitchName + " to create a portgroup for nic " + networkName);
}
// Strict security policy