public long getId() { return lb.getId(); }
@Override public void removeLBRule(LoadBalancer rule) { // remove the rule _lbDao.remove(rule.getId()); }
public Map<Long, Long> getLoadBalancerRuleWeightMap() { Map<Long, Long> lbRuleWeightMap = new HashMap<Long, Long>(); if (gslbLbRuleWieghtMap == null || gslbLbRuleWieghtMap.isEmpty()) { return null; } Collection lbruleWeightsCollection = gslbLbRuleWieghtMap.values(); Iterator iter = lbruleWeightsCollection.iterator(); while (iter.hasNext()) { HashMap<String, String> map = (HashMap<String, String>)iter.next(); Long weight; LoadBalancer lbrule = _entityMgr.findByUuid(LoadBalancer.class, map.get("loadbalancerid")); if (lbrule == null) { throw new InvalidParameterValueException("Unable to find load balancer rule with ID: " + map.get("loadbalancerid")); } try { weight = Long.parseLong(map.get("weight")); if (weight < 1 || weight > 100) { throw new InvalidParameterValueException("Invalid weight " + weight + " given for the LB rule id: " + map.get("loadbalancerid")); } } catch (NumberFormatException nfe) { throw new InvalidParameterValueException("Unable to translate weight given for the LB rule id: " + map.get("loadbalancerid")); } lbRuleWeightMap.put(lbrule.getId(), weight); } return lbRuleWeightMap; }
private Ip getSourceIp(LoadBalancer lb) { Ip sourceIp = null; if (lb.getScheme() == Scheme.Public) { sourceIp = _networkModel.getPublicIpAddress(lb.getSourceIpAddressId()).getAddress(); } else if (lb.getScheme() == Scheme.Internal) { ApplicationLoadBalancerRuleVO appLbRule = _appLbRuleDao.findById(lb.getId()); sourceIp = appLbRule.getSourceIp(); } return sourceIp; }
if ((lbRuleId != null) && (lbRuleId != lb.getId())) { throw new InvalidParameterValueException("stickiness policy ID doesn't belong to lbId" + lbRuleId);
@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 { LoadBalancer result = _lbService.createPublicLoadBalancerRule(getXid(), getName(), getDescription(), getSourcePortStart(), getSourcePortEnd(), getDefaultPortStart(), getDefaultPortEnd(), getSourceIpAddressId(), getProtocol(), getAlgorithm(), getNetworkId(), getEntityOwnerId(), getOpenFirewall(), getLbProtocol(), isDisplay()); this.setEntityId(result.getId()); this.setEntityUuid(result.getUuid()); } catch (NetworkRuleConflictException e) { s_logger.warn("Exception: ", e); throw new ServerApiException(ApiErrorCode.NETWORK_RULE_CONFLICT_ERROR, e.getMessage()); } catch (InsufficientAddressCapacityException e) { s_logger.warn("Exception: ", e); throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, e.getMessage()); } catch (InvalidParameterValueException e) { throw new ServerApiException(ApiErrorCode.PARAM_ERROR, e.getMessage()); } }
lbResponse.setName(loadBalancer.getName()); lbResponse.setDescription(loadBalancer.getDescription()); List<String> cidrs = ApiDBUtils.findFirewallSourceCidrs(loadBalancer.getId()); lbResponse.setCidrList(StringUtils.join(cidrs, ",")); List<? extends ResourceTag> tags = ApiDBUtils.listByResourceTypeAndId(ResourceObjectType.LoadBalancer, loadBalancer.getId()); List<ResourceTagResponse> tagResponses = new ArrayList<ResourceTagResponse>(); for (ResourceTag tag : tags) {