Search in sources :

Example 1 with LBStickinessPolicyResponse

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

the class ApiResponseHelper method createLBStickinessPolicyResponse.

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

Example 2 with LBStickinessPolicyResponse

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

the class ApiResponseHelper method createLBStickinessPolicyResponse.

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

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 LBStickinessPolicyResponse (org.apache.cloudstack.api.response.LBStickinessPolicyResponse)2 LBStickinessResponse (org.apache.cloudstack.api.response.LBStickinessResponse)2 StickinessPolicy (com.cloud.network.rules.StickinessPolicy)1