use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.
the class ListLBHealthCheckPoliciesCmd method execute.
@Override
public void execute() {
List<LBHealthCheckResponse> hcpResponses = new ArrayList<LBHealthCheckResponse>();
ListResponse<LBHealthCheckResponse> response = new ListResponse<LBHealthCheckResponse>();
Long lbRuleId = getLbRuleId();
Long hId = getId();
if (lbRuleId == null) {
if (hId != null) {
lbRuleId = _lbService.findLBIdByHealtCheckPolicyId(hId);
} else {
throw new InvalidParameterValueException("Either load balancer rule ID or health check policy ID should be specified");
}
}
LoadBalancer lb = _lbService.findById(lbRuleId);
if (lb != null) {
List<? extends HealthCheckPolicy> healthCheckPolicies = _lbService.searchForLBHealthCheckPolicies(this);
LBHealthCheckResponse spResponse = _responseGenerator.createLBHealthCheckPolicyResponse(healthCheckPolicies, lb);
hcpResponses.add(spResponse);
response.setResponses(hcpResponses);
}
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.
the class ListLBStickinessPoliciesCmd method execute.
@Override
public void execute() {
LoadBalancer lb = null;
if (lbRuleId == null && id == null) {
throw new InvalidParameterValueException("load balancer rule ID and stickiness policy ID can't be null");
}
if (id != null) {
lb = _lbService.findLbByStickinessId(id);
if (lb == null) {
throw new InvalidParameterValueException("stickiness policy ID doesn't exist");
}
if ((lbRuleId != null) && (lbRuleId != lb.getId())) {
throw new InvalidParameterValueException("stickiness policy ID doesn't belong to lbId" + lbRuleId);
}
}
if (lbRuleId != null && lb == null) {
lb = _lbService.findById(getLbRuleId());
}
List<LBStickinessResponse> spResponses = new ArrayList<LBStickinessResponse>();
ListResponse<LBStickinessResponse> response = new ListResponse<LBStickinessResponse>();
if (lb != null) {
//check permissions
Account caller = CallContext.current().getCallingAccount();
_accountService.checkAccess(caller, null, true, lb);
List<? extends StickinessPolicy> stickinessPolicies = _lbService.searchForLBStickinessPolicies(this);
LBStickinessResponse spResponse = _responseGenerator.createLBStickinessPolicyResponse(stickinessPolicies, lb);
spResponses.add(spResponse);
response.setResponses(spResponses);
}
response.setResponseName(getCommandName());
this.setResponseObject(response);
}
use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.
the class AssignToLoadBalancerRuleCmd method getVmIdIpListMap.
public Map<Long, List<String>> getVmIdIpListMap() {
Map<Long, List<String>> vmIdIpsMap = new HashMap<Long, List<String>>();
if (vmIdIpMap != null && !vmIdIpMap.isEmpty()) {
Collection idIpsCollection = vmIdIpMap.values();
Iterator iter = idIpsCollection.iterator();
while (iter.hasNext()) {
HashMap<String, String> idIpsMap = (HashMap<String, String>) iter.next();
String vmId = idIpsMap.get("vmid");
String vmIp = idIpsMap.get("vmip");
VirtualMachine lbvm = _entityMgr.findByUuid(VirtualMachine.class, vmId);
if (lbvm == null) {
throw new InvalidParameterValueException("Unable to find virtual machine ID: " + vmId);
}
//check wether the given ip is valid ip or not
if (vmIp == null || !NetUtils.isValidIp(vmIp)) {
throw new InvalidParameterValueException("Invalid ip address " + vmIp + " passed in vmidipmap for " + "vmid " + vmId);
}
Long longVmId = lbvm.getId();
List<String> ipsList = null;
if (vmIdIpsMap.containsKey(longVmId)) {
ipsList = vmIdIpsMap.get(longVmId);
} else {
ipsList = new ArrayList<String>();
}
ipsList.add(vmIp);
vmIdIpsMap.put(longVmId, ipsList);
}
}
return vmIdIpsMap;
}
use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.
the class CreateIpForwardingRuleCmd method create.
@Override
public void create() {
//cidr list parameter is deprecated
if (cidrlist != null) {
throw new InvalidParameterValueException("Parameter cidrList is deprecated; if you need to open firewall rule for the specific CIDR, please refer to createFirewallRule command");
}
try {
StaticNatRule rule = _rulesService.createStaticNatRule(this, getOpenFirewall());
setEntityId(rule.getId());
setEntityUuid(rule.getUuid());
} catch (NetworkRuleConflictException e) {
s_logger.info("Unable to create static NAT rule due to ", e);
throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage());
}
}
use of com.cloud.exception.InvalidParameterValueException in project cloudstack by apache.
the class DeleteLBHealthCheckPolicyCmd method getSyncObjId.
@Override
public Long getSyncObjId() {
HealthCheckPolicy policy = _entityMgr.findById(HealthCheckPolicy.class, getId());
if (policy == null) {
throw new InvalidParameterValueException("Unable to find load balancer health check rule: " + id);
}
LoadBalancer lb = _lbService.findById(policy.getLoadBalancerId());
if (lb == null) {
throw new InvalidParameterValueException("Unable to find load balancer rule for health check rule: " + id);
}
return lb.getNetworkId();
}
Aggregations