Search in sources :

Example 1 with LBHealthCheckPolicyVO

use of com.cloud.network.LBHealthCheckPolicyVO in project cloudstack by apache.

the class LoadBalancingRulesManagerImpl method updateLBHealthCheckPolicy.

@Override
@ActionEvent(eventType = EventTypes.EVENT_LB_HEALTHCHECKPOLICY_UPDATE, eventDescription = "updating lb healthcheck policy", async = true)
public HealthCheckPolicy updateLBHealthCheckPolicy(long id, String customId, Boolean forDisplay) {
    LBHealthCheckPolicyVO policy = _lb2healthcheckDao.findById(id);
    if (policy == null) {
        throw new InvalidParameterValueException("Fail to find stickiness policy with " + id);
    }
    LoadBalancerVO loadBalancer = _lbDao.findById(Long.valueOf(policy.getLoadBalancerId()));
    if (loadBalancer == null) {
        throw new InvalidParameterException("Invalid Load balancer : " + policy.getLoadBalancerId() + " for Stickiness policy id: " + id);
    }
    _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, loadBalancer);
    if (customId != null) {
        policy.setUuid(customId);
    }
    if (forDisplay != null) {
        policy.setDisplay(forDisplay);
    }
    _lb2healthcheckDao.update(id, policy);
    return _lb2healthcheckDao.findById(id);
}
Also used : InvalidParameterException(java.security.InvalidParameterException) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) LoadBalancerVO(com.cloud.network.dao.LoadBalancerVO) LBHealthCheckPolicyVO(com.cloud.network.LBHealthCheckPolicyVO) ActionEvent(com.cloud.event.ActionEvent)

Example 2 with LBHealthCheckPolicyVO

use of com.cloud.network.LBHealthCheckPolicyVO in project cloudstack by apache.

the class LoadBalancingRulesManagerImpl method getHealthCheckPolicies.

@Override
public List<LbHealthCheckPolicy> getHealthCheckPolicies(long lbId) {
    List<LbHealthCheckPolicy> healthCheckPolicies = new ArrayList<LbHealthCheckPolicy>();
    List<LBHealthCheckPolicyVO> hcDbpolicies = _lb2healthcheckDao.listByLoadBalancerIdAndDisplayFlag(lbId, null);
    for (LBHealthCheckPolicyVO policy : hcDbpolicies) {
        String pingpath = policy.getpingpath();
        LbHealthCheckPolicy hDbPolicy = new LbHealthCheckPolicy(pingpath, policy.getDescription(), policy.getResponseTime(), policy.getHealthcheckInterval(), policy.getHealthcheckThresshold(), policy.getUnhealthThresshold(), policy.isRevoke());
        healthCheckPolicies.add(hDbPolicy);
    }
    return healthCheckPolicies;
}
Also used : ArrayList(java.util.ArrayList) LbHealthCheckPolicy(com.cloud.network.lb.LoadBalancingRule.LbHealthCheckPolicy) LBHealthCheckPolicyVO(com.cloud.network.LBHealthCheckPolicyVO)

Example 3 with LBHealthCheckPolicyVO

use of com.cloud.network.LBHealthCheckPolicyVO in project cloudstack by apache.

the class LoadBalancingRulesManagerImpl method searchForLBHealthCheckPolicies.

@Override
public List<LBHealthCheckPolicyVO> searchForLBHealthCheckPolicies(ListLBHealthCheckPoliciesCmd cmd) throws PermissionDeniedException {
    Account caller = CallContext.current().getCallingAccount();
    Long loadBalancerId = cmd.getLbRuleId();
    Long policyId = cmd.getId();
    boolean forDisplay = cmd.getDisplay();
    if (loadBalancerId == null) {
        loadBalancerId = findLBIdByHealtCheckPolicyId(policyId);
    }
    LoadBalancerVO loadBalancer = _lbDao.findById(loadBalancerId);
    if (loadBalancer == null) {
        return null;
    }
    _accountMgr.checkAccess(caller, null, true, loadBalancer);
    List<LBHealthCheckPolicyVO> hcDbpolicies = _lb2healthcheckDao.listByLoadBalancerIdAndDisplayFlag(loadBalancerId, forDisplay);
    return hcDbpolicies;
}
Also used : Account(com.cloud.user.Account) LoadBalancerVO(com.cloud.network.dao.LoadBalancerVO) LBHealthCheckPolicyVO(com.cloud.network.LBHealthCheckPolicyVO)

Example 4 with LBHealthCheckPolicyVO

use of com.cloud.network.LBHealthCheckPolicyVO in project cosmic by MissionCriticalCloud.

the class LoadBalancingRulesManagerImpl method updateLBHealthCheckPolicy.

@Override
@ActionEvent(eventType = EventTypes.EVENT_LB_HEALTHCHECKPOLICY_UPDATE, eventDescription = "updating lb healthcheck policy", async = true)
public HealthCheckPolicy updateLBHealthCheckPolicy(final long id, final String customId, final Boolean forDisplay) {
    final LBHealthCheckPolicyVO policy = _lb2healthcheckDao.findById(id);
    if (policy == null) {
        throw new InvalidParameterValueException("Fail to find stickiness policy with " + id);
    }
    final LoadBalancerVO loadBalancer = _lbDao.findById(Long.valueOf(policy.getLoadBalancerId()));
    if (loadBalancer == null) {
        throw new InvalidParameterException("Invalid Load balancer : " + policy.getLoadBalancerId() + " for Stickiness policy id: " + id);
    }
    _accountMgr.checkAccess(CallContext.current().getCallingAccount(), null, true, loadBalancer);
    if (customId != null) {
        policy.setUuid(customId);
    }
    if (forDisplay != null) {
        policy.setDisplay(forDisplay);
    }
    _lb2healthcheckDao.update(id, policy);
    return _lb2healthcheckDao.findById(id);
}
Also used : InvalidParameterException(java.security.InvalidParameterException) InvalidParameterValueException(com.cloud.utils.exception.InvalidParameterValueException) LoadBalancerVO(com.cloud.network.dao.LoadBalancerVO) LBHealthCheckPolicyVO(com.cloud.network.LBHealthCheckPolicyVO) ActionEvent(com.cloud.event.ActionEvent)

Example 5 with LBHealthCheckPolicyVO

use of com.cloud.network.LBHealthCheckPolicyVO in project cosmic by MissionCriticalCloud.

the class LoadBalancingRulesManagerImpl method searchForLBHealthCheckPolicies.

@Override
public List<LBHealthCheckPolicyVO> searchForLBHealthCheckPolicies(final ListLBHealthCheckPoliciesCmd cmd) throws PermissionDeniedException {
    final Account caller = CallContext.current().getCallingAccount();
    Long loadBalancerId = cmd.getLbRuleId();
    final Long policyId = cmd.getId();
    final boolean forDisplay = cmd.getDisplay();
    if (loadBalancerId == null) {
        loadBalancerId = findLBIdByHealtCheckPolicyId(policyId);
    }
    final LoadBalancerVO loadBalancer = _lbDao.findById(loadBalancerId);
    if (loadBalancer == null) {
        return null;
    }
    _accountMgr.checkAccess(caller, null, true, loadBalancer);
    final List<LBHealthCheckPolicyVO> hcDbpolicies = _lb2healthcheckDao.listByLoadBalancerIdAndDisplayFlag(loadBalancerId, forDisplay);
    return hcDbpolicies;
}
Also used : Account(com.cloud.user.Account) LoadBalancerVO(com.cloud.network.dao.LoadBalancerVO) LBHealthCheckPolicyVO(com.cloud.network.LBHealthCheckPolicyVO)

Aggregations

LBHealthCheckPolicyVO (com.cloud.network.LBHealthCheckPolicyVO)12 LoadBalancerVO (com.cloud.network.dao.LoadBalancerVO)10 ActionEvent (com.cloud.event.ActionEvent)6 DB (com.cloud.utils.db.DB)6 ArrayList (java.util.ArrayList)6 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)4 LoadBalancerVMMapVO (com.cloud.network.dao.LoadBalancerVMMapVO)4 LbHealthCheckPolicy (com.cloud.network.lb.LoadBalancingRule.LbHealthCheckPolicy)4 FirewallRule (com.cloud.network.rules.FirewallRule)4 TransactionStatus (com.cloud.utils.db.TransactionStatus)4 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)4 InvalidParameterException (java.security.InvalidParameterException)4 CallContext (com.cloud.context.CallContext)2 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)2 LoadBalancerCertMapVO (com.cloud.network.dao.LoadBalancerCertMapVO)2 NetworkVO (com.cloud.network.dao.NetworkVO)2 FirewallRuleVO (com.cloud.network.rules.FirewallRuleVO)2 Account (com.cloud.user.Account)2 TransactionCallbackNoReturn (com.cloud.utils.db.TransactionCallbackNoReturn)2 InvalidParameterValueException (com.cloud.utils.exception.InvalidParameterValueException)2