Search in sources :

Example 1 with LBHealthCheckPolicyResponse

use of com.cloud.api.response.LBHealthCheckPolicyResponse in project cosmic by MissionCriticalCloud.

the class ApiResponseHelper method createLBHealthCheckPolicyResponse.

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

Example 2 with LBHealthCheckPolicyResponse

use of com.cloud.api.response.LBHealthCheckPolicyResponse in project cosmic by MissionCriticalCloud.

the class ApiResponseHelper method createLBHealthCheckPolicyResponse.

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

Aggregations

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