Search in sources :

Example 1 with LBStickinessPolicyResponse

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

the class ApiResponseHelper method createLBStickinessPolicyResponse.

@Override
public LBStickinessResponse createLBStickinessPolicyResponse(final List<? extends StickinessPolicy> stickinessPolicies, final LoadBalancer lb) {
    final LBStickinessResponse spResponse = new LBStickinessResponse();
    if (lb == null) {
        return spResponse;
    }
    spResponse.setlbRuleId(lb.getUuid());
    final Account account = ApiDBUtils.findAccountById(lb.getAccountId());
    if (account != null) {
        spResponse.setAccountName(account.getAccountName());
        final Domain domain = ApiDBUtils.findDomainById(account.getDomainId());
        if (domain != null) {
            spResponse.setDomainId(domain.getUuid());
            spResponse.setDomainName(domain.getName());
        }
    }
    final List<LBStickinessPolicyResponse> responses = new ArrayList<>();
    for (final StickinessPolicy stickinessPolicy : stickinessPolicies) {
        final LBStickinessPolicyResponse ruleResponse = new LBStickinessPolicyResponse(stickinessPolicy);
        responses.add(ruleResponse);
    }
    spResponse.setRules(responses);
    spResponse.setObjectName("stickinesspolicies");
    return spResponse;
}
Also used : UserAccount(com.cloud.user.UserAccount) Account(com.cloud.user.Account) ArrayList(java.util.ArrayList) Domain(com.cloud.domain.Domain) LBStickinessPolicyResponse(com.cloud.api.response.LBStickinessPolicyResponse) LBStickinessResponse(com.cloud.api.response.LBStickinessResponse) StickinessPolicy(com.cloud.network.rules.StickinessPolicy)

Example 2 with LBStickinessPolicyResponse

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

the class ApiResponseHelper method createLBStickinessPolicyResponse.

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

Aggregations

LBStickinessPolicyResponse (com.cloud.api.response.LBStickinessPolicyResponse)2 LBStickinessResponse (com.cloud.api.response.LBStickinessResponse)2 Domain (com.cloud.domain.Domain)2 Account (com.cloud.user.Account)2 UserAccount (com.cloud.user.UserAccount)2 ArrayList (java.util.ArrayList)2 StickinessPolicy (com.cloud.network.rules.StickinessPolicy)1