Search in sources :

Example 1 with AffinityGroupResponse

use of com.cloud.affinity.AffinityGroupResponse in project cosmic by MissionCriticalCloud.

the class CreateAffinityGroupCmd method execute.

// ///////////////////////////////////////////////////
// ///////////// API Implementation///////////////////
// ///////////////////////////////////////////////////
@Override
public void execute() {
    final AffinityGroup group = _affinityGroupService.getAffinityGroup(getEntityId());
    if (group != null) {
        final AffinityGroupResponse response = _responseGenerator.createAffinityGroupResponse(group);
        response.setResponseName(getCommandName());
        setResponseObject(response);
    } else {
        throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "Failed to create affinity group:" + affinityGroupName);
    }
}
Also used : AffinityGroupResponse(com.cloud.affinity.AffinityGroupResponse) ServerApiException(com.cloud.api.ServerApiException) AffinityGroup(com.cloud.affinity.AffinityGroup)

Example 2 with AffinityGroupResponse

use of com.cloud.affinity.AffinityGroupResponse in project cosmic by MissionCriticalCloud.

the class ApiResponseHelper method createAffinityGroupResponse.

@Override
public AffinityGroupResponse createAffinityGroupResponse(final AffinityGroup group) {
    final AffinityGroupResponse response = new AffinityGroupResponse();
    final Account account = ApiDBUtils.findAccountById(group.getAccountId());
    response.setId(group.getUuid());
    response.setAccountName(account.getAccountName());
    response.setName(group.getName());
    response.setType(group.getType());
    response.setDescription(group.getDescription());
    final Domain domain = ApiDBUtils.findDomainById(account.getDomainId());
    if (domain != null) {
        response.setDomainId(domain.getUuid());
        response.setDomainName(domain.getName());
    }
    response.setObjectName("affinitygroup");
    return response;
}
Also used : UserAccount(com.cloud.user.UserAccount) Account(com.cloud.user.Account) AffinityGroupResponse(com.cloud.affinity.AffinityGroupResponse) Domain(com.cloud.domain.Domain)

Example 3 with AffinityGroupResponse

use of com.cloud.affinity.AffinityGroupResponse in project cosmic by MissionCriticalCloud.

the class AffinityGroupJoinDaoImpl method newAffinityGroupResponse.

@Override
public AffinityGroupResponse newAffinityGroupResponse(final AffinityGroupJoinVO vag) {
    final AffinityGroupResponse agResponse = new AffinityGroupResponse();
    agResponse.setId(vag.getUuid());
    agResponse.setName(vag.getName());
    agResponse.setDescription(vag.getDescription());
    agResponse.setType(vag.getType());
    ApiResponseHelper.populateOwner(agResponse, vag);
    // update vm information
    final long instanceId = vag.getVmId();
    if (instanceId > 0) {
        final List<String> vmIdList = new ArrayList<>();
        vmIdList.add(vag.getVmUuid());
        agResponse.setVMIdList(vmIdList);
    }
    agResponse.setObjectName("affinitygroup");
    return agResponse;
}
Also used : AffinityGroupResponse(com.cloud.affinity.AffinityGroupResponse) ArrayList(java.util.ArrayList)

Example 4 with AffinityGroupResponse

use of com.cloud.affinity.AffinityGroupResponse in project cosmic by MissionCriticalCloud.

the class ViewResponseHelper method createAffinityGroupResponses.

public static List<AffinityGroupResponse> createAffinityGroupResponses(final List<AffinityGroupJoinVO> groups) {
    final Hashtable<Long, AffinityGroupResponse> vrDataList = new Hashtable<>();
    for (final AffinityGroupJoinVO vr : groups) {
        AffinityGroupResponse vrData = vrDataList.get(vr.getId());
        if (vrData == null) {
            // first time encountering this AffinityGroup
            vrData = ApiDBUtils.newAffinityGroupResponse(vr);
        } else {
            // update vms
            vrData = ApiDBUtils.fillAffinityGroupDetails(vrData, vr);
        }
        vrDataList.put(vr.getId(), vrData);
    }
    return new ArrayList<>(vrDataList.values());
}
Also used : AffinityGroupResponse(com.cloud.affinity.AffinityGroupResponse) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) AffinityGroupJoinVO(com.cloud.api.query.vo.AffinityGroupJoinVO)

Example 5 with AffinityGroupResponse

use of com.cloud.affinity.AffinityGroupResponse in project cosmic by MissionCriticalCloud.

the class UserVmJoinDaoImpl method setUserVmResponse.

@Override
public UserVmResponse setUserVmResponse(final ResponseView view, final UserVmResponse userVmData, final UserVmJoinVO uvo) {
    final long nic_id = uvo.getNicId();
    if (nic_id > 0) {
        final NicResponse nicResponse = new NicResponse();
        nicResponse.setId(uvo.getNicUuid());
        nicResponse.setIpaddress(uvo.getIpAddress());
        nicResponse.setGateway(uvo.getGateway());
        nicResponse.setNetmask(uvo.getNetmask());
        nicResponse.setNetworkid(uvo.getNetworkUuid());
        nicResponse.setNetworkName(uvo.getNetworkName());
        nicResponse.setMacAddress(uvo.getMacAddress());
        nicResponse.setIp6Address(uvo.getIp6Address());
        nicResponse.setIp6Gateway(uvo.getIp6Gateway());
        nicResponse.setIp6Cidr(uvo.getIp6Cidr());
        if (uvo.getBroadcastUri() != null) {
            nicResponse.setBroadcastUri(uvo.getBroadcastUri().toString());
        }
        if (uvo.getIsolationUri() != null) {
            nicResponse.setIsolationUri(uvo.getIsolationUri().toString());
        }
        if (uvo.getTrafficType() != null) {
            nicResponse.setTrafficType(uvo.getTrafficType().toString());
        }
        if (uvo.getGuestType() != null) {
            nicResponse.setType(uvo.getGuestType().toString());
        }
        nicResponse.setIsDefault(uvo.isDefaultNic());
        final List<NicSecondaryIpVO> secondaryIps = ApiDBUtils.findNicSecondaryIps(uvo.getNicId());
        if (secondaryIps != null) {
            final List<NicSecondaryIpResponse> ipList = new ArrayList<>();
            for (final NicSecondaryIpVO ip : secondaryIps) {
                final NicSecondaryIpResponse ipRes = new NicSecondaryIpResponse();
                ipRes.setId(ip.getUuid());
                ipRes.setIpAddr(ip.getIp4Address());
                ipList.add(ipRes);
            }
            nicResponse.setSecondaryIps(ipList);
        }
        nicResponse.setObjectName("nic");
        userVmData.addNic(nicResponse);
    }
    final long tag_id = uvo.getTagId();
    if (tag_id > 0 && !userVmData.containTag(tag_id)) {
        final ResourceTagJoinVO vtag = ApiDBUtils.findResourceTagViewById(tag_id);
        if (vtag != null) {
            userVmData.addTag(ApiDBUtils.newResourceTagResponse(vtag, false));
        }
    }
    final Long affinityGroupId = uvo.getAffinityGroupId();
    if (affinityGroupId != null && affinityGroupId.longValue() != 0) {
        final AffinityGroupResponse resp = new AffinityGroupResponse();
        resp.setId(uvo.getAffinityGroupUuid());
        resp.setName(uvo.getAffinityGroupName());
        resp.setDescription(uvo.getAffinityGroupDescription());
        resp.setObjectName("affinitygroup");
        resp.setAccountName(uvo.getAccountName());
        userVmData.addAffinityGroup(resp);
    }
    return userVmData;
}
Also used : NicSecondaryIpResponse(com.cloud.api.response.NicSecondaryIpResponse) NicSecondaryIpVO(com.cloud.vm.dao.NicSecondaryIpVO) AffinityGroupResponse(com.cloud.affinity.AffinityGroupResponse) ArrayList(java.util.ArrayList) ResourceTagJoinVO(com.cloud.api.query.vo.ResourceTagJoinVO) NicResponse(com.cloud.api.response.NicResponse)

Aggregations

AffinityGroupResponse (com.cloud.affinity.AffinityGroupResponse)6 ArrayList (java.util.ArrayList)4 ResourceTagJoinVO (com.cloud.api.query.vo.ResourceTagJoinVO)2 NicResponse (com.cloud.api.response.NicResponse)2 NicSecondaryIpResponse (com.cloud.api.response.NicSecondaryIpResponse)2 NicSecondaryIpVO (com.cloud.vm.dao.NicSecondaryIpVO)2 AffinityGroup (com.cloud.affinity.AffinityGroup)1 ServerApiException (com.cloud.api.ServerApiException)1 AffinityGroupJoinVO (com.cloud.api.query.vo.AffinityGroupJoinVO)1 UserVmResponse (com.cloud.api.response.UserVmResponse)1 Domain (com.cloud.domain.Domain)1 ServiceOfferingDetailsVO (com.cloud.service.ServiceOfferingDetailsVO)1 Account (com.cloud.user.Account)1 User (com.cloud.user.User)1 UserAccount (com.cloud.user.UserAccount)1 UserVmDetailVO (com.cloud.vm.UserVmDetailVO)1 VmStats (com.cloud.vm.VmStats)1 DecimalFormat (java.text.DecimalFormat)1 HashMap (java.util.HashMap)1 Hashtable (java.util.Hashtable)1