Search in sources :

Example 1 with LBHealthCheckPolicyResponse

use of org.apache.cloudstack.api.response.LBHealthCheckPolicyResponse in project cloudstack by apache.

the class ApiResponseHelper method createLBHealthCheckPolicyResponse.

@Override
public LBHealthCheckResponse createLBHealthCheckPolicyResponse(HealthCheckPolicy healthcheckPolicy, LoadBalancer lb) {
    LBHealthCheckResponse hcResponse = new LBHealthCheckResponse();
    hcResponse.setlbRuleId(lb.getUuid());
    Account accountTemp = ApiDBUtils.findAccountById(lb.getAccountId());
    if (accountTemp != null) {
        hcResponse.setAccountName(accountTemp.getAccountName());
        Domain domain = ApiDBUtils.findDomainById(accountTemp.getDomainId());
        if (domain != null) {
            hcResponse.setDomainId(domain.getUuid());
            hcResponse.setDomainName(domain.getName());
        }
    }
    List<LBHealthCheckPolicyResponse> responses = new ArrayList<LBHealthCheckPolicyResponse>();
    LBHealthCheckPolicyResponse ruleResponse = new LBHealthCheckPolicyResponse(healthcheckPolicy);
    responses.add(ruleResponse);
    hcResponse.setRules(responses);
    hcResponse.setObjectName("healthcheckpolicies");
    return hcResponse;
}
Also used : ProjectAccount(com.cloud.projects.ProjectAccount) UserAccount(com.cloud.user.UserAccount) Account(com.cloud.user.Account) LBHealthCheckPolicyResponse(org.apache.cloudstack.api.response.LBHealthCheckPolicyResponse) ArrayList(java.util.ArrayList) LBHealthCheckResponse(org.apache.cloudstack.api.response.LBHealthCheckResponse) Domain(com.cloud.domain.Domain)

Example 2 with LBHealthCheckPolicyResponse

use of org.apache.cloudstack.api.response.LBHealthCheckPolicyResponse in project cloudstack by apache.

the class ApiResponseHelper method createLBHealthCheckPolicyResponse.

@Override
public LBHealthCheckResponse createLBHealthCheckPolicyResponse(List<? extends HealthCheckPolicy> healthcheckPolicies, LoadBalancer lb) {
    LBHealthCheckResponse hcResponse = new LBHealthCheckResponse();
    if (lb == null) {
        return hcResponse;
    }
    hcResponse.setlbRuleId(lb.getUuid());
    Account account = ApiDBUtils.findAccountById(lb.getAccountId());
    if (account != null) {
        hcResponse.setAccountName(account.getAccountName());
        Domain domain = ApiDBUtils.findDomainById(account.getDomainId());
        if (domain != null) {
            hcResponse.setDomainId(domain.getUuid());
            hcResponse.setDomainName(domain.getName());
        }
    }
    List<LBHealthCheckPolicyResponse> responses = new ArrayList<LBHealthCheckPolicyResponse>();
    for (HealthCheckPolicy healthcheckPolicy : healthcheckPolicies) {
        LBHealthCheckPolicyResponse ruleResponse = new LBHealthCheckPolicyResponse(healthcheckPolicy);
        responses.add(ruleResponse);
    }
    hcResponse.setRules(responses);
    hcResponse.setObjectName("healthcheckpolicies");
    return hcResponse;
}
Also used : ProjectAccount(com.cloud.projects.ProjectAccount) UserAccount(com.cloud.user.UserAccount) Account(com.cloud.user.Account) LBHealthCheckPolicyResponse(org.apache.cloudstack.api.response.LBHealthCheckPolicyResponse) ArrayList(java.util.ArrayList) LBHealthCheckResponse(org.apache.cloudstack.api.response.LBHealthCheckResponse) Domain(com.cloud.domain.Domain) HealthCheckPolicy(com.cloud.network.rules.HealthCheckPolicy)

Aggregations

Domain (com.cloud.domain.Domain)2 ProjectAccount (com.cloud.projects.ProjectAccount)2 Account (com.cloud.user.Account)2 UserAccount (com.cloud.user.UserAccount)2 ArrayList (java.util.ArrayList)2 LBHealthCheckPolicyResponse (org.apache.cloudstack.api.response.LBHealthCheckPolicyResponse)2 LBHealthCheckResponse (org.apache.cloudstack.api.response.LBHealthCheckResponse)2 HealthCheckPolicy (com.cloud.network.rules.HealthCheckPolicy)1