Search in sources :

Example 1 with AffinityGroupResponse

use of org.apache.cloudstack.affinity.AffinityGroupResponse in project cloudstack by apache.

the class AffinityGroupJoinDaoImpl method newAffinityGroupResponse.

@Override
public AffinityGroupResponse newAffinityGroupResponse(AffinityGroupJoinVO vag) {
    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
    long instanceId = vag.getVmId();
    if (instanceId > 0) {
        List<String> vmIdList = new ArrayList<String>();
        vmIdList.add(vag.getVmUuid());
        agResponse.setVMIdList(vmIdList);
    }
    agResponse.setObjectName("affinitygroup");
    return agResponse;
}
Also used : AffinityGroupResponse(org.apache.cloudstack.affinity.AffinityGroupResponse) ArrayList(java.util.ArrayList)

Example 2 with AffinityGroupResponse

use of org.apache.cloudstack.affinity.AffinityGroupResponse in project cloudstack by apache.

the class UserVmJoinDaoImpl method setUserVmResponse.

/**
 * The resulting Response attempts to be in line with what is returned from
 * @see com.cloud.api.ApiResponseHelper#createNicResponse(Nic)
 */
@Override
public UserVmResponse setUserVmResponse(ResponseView view, UserVmResponse userVmData, UserVmJoinVO uvo) {
    Long securityGroupId = uvo.getSecurityGroupId();
    if (securityGroupId != null && securityGroupId.longValue() != 0) {
        SecurityGroupResponse resp = new SecurityGroupResponse();
        resp.setId(uvo.getSecurityGroupUuid());
        resp.setName(uvo.getSecurityGroupName());
        resp.setDescription(uvo.getSecurityGroupDescription());
        resp.setObjectName("securitygroup");
        if (uvo.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
            resp.setProjectId(uvo.getProjectUuid());
            resp.setProjectName(uvo.getProjectName());
        } else {
            resp.setAccountName(uvo.getAccountName());
        }
        userVmData.addSecurityGroup(resp);
    }
    long nic_id = uvo.getNicId();
    if (nic_id > 0) {
        NicResponse nicResponse = new NicResponse();
        // The numbered comments are to keep track of the data returned from here and ApiResponseHelper.createNicResponse()
        // the data can't be identical but some tidying up/unifying might be possible
        /*1: nicUuid*/
        nicResponse.setId(uvo.getNicUuid());
        /*2: networkUuid*/
        nicResponse.setNetworkid(uvo.getNetworkUuid());
        if (uvo.getTrafficType() != null) {
            /*4: trafficType*/
            nicResponse.setTrafficType(uvo.getTrafficType().toString());
        }
        if (uvo.getGuestType() != null) {
            /*5: guestType*/
            nicResponse.setType(uvo.getGuestType().toString());
        }
        /*6: ipAddress*/
        nicResponse.setIpaddress(uvo.getIpAddress());
        /*7: gateway*/
        nicResponse.setGateway(uvo.getGateway());
        /*8: netmask*/
        nicResponse.setNetmask(uvo.getNetmask());
        /*9: networkName*/
        nicResponse.setNetworkName(uvo.getNetworkName());
        /*10: macAddress*/
        nicResponse.setMacAddress(uvo.getMacAddress());
        /*11: IPv6Address*/
        nicResponse.setIp6Address(uvo.getIp6Address());
        /*12: IPv6Gateway*/
        nicResponse.setIp6Gateway(uvo.getIp6Gateway());
        /*13: IPv6Cidr*/
        nicResponse.setIp6Cidr(uvo.getIp6Cidr());
        /*15: broadcastURI*/
        if (uvo.getBroadcastUri() != null) {
            nicResponse.setBroadcastUri(uvo.getBroadcastUri().toString());
        }
        /*16: isolationURI*/
        if (uvo.getIsolationUri() != null) {
            nicResponse.setIsolationUri(uvo.getIsolationUri().toString());
        }
        /*17: default*/
        nicResponse.setIsDefault(uvo.isDefaultNic());
        nicResponse.setDeviceId(String.valueOf(uvo.getNicDeviceId()));
        List<NicSecondaryIpVO> secondaryIps = ApiDBUtils.findNicSecondaryIps(uvo.getNicId());
        if (secondaryIps != null) {
            List<NicSecondaryIpResponse> ipList = new ArrayList<NicSecondaryIpResponse>();
            for (NicSecondaryIpVO ip : secondaryIps) {
                NicSecondaryIpResponse ipRes = new NicSecondaryIpResponse();
                ipRes.setId(ip.getUuid());
                ApiResponseHelper.setResponseIpAddress(ip, ipRes);
                ipList.add(ipRes);
            }
            nicResponse.setSecondaryIps(ipList);
        }
        /* 18: extra dhcp options */
        nicResponse.setObjectName("nic");
        List<NicExtraDhcpOptionResponse> nicExtraDhcpOptionResponses = _nicExtraDhcpOptionDao.listByNicId(nic_id).stream().map(vo -> new NicExtraDhcpOptionResponse(Dhcp.DhcpOptionCode.valueOfInt(vo.getCode()).getName(), vo.getCode(), vo.getValue())).collect(Collectors.toList());
        nicResponse.setExtraDhcpOptions(nicExtraDhcpOptionResponses);
        userVmData.addNic(nicResponse);
    }
    long tag_id = uvo.getTagId();
    if (tag_id > 0 && !userVmData.containTag(tag_id)) {
        addTagInformation(uvo, userVmData);
    }
    if (userVmData.hasAnnotation() == null) {
        userVmData.setHasAnnotation(annotationDao.hasAnnotations(uvo.getUuid(), AnnotationService.EntityType.VM.name(), _accountMgr.isRootAdmin(CallContext.current().getCallingAccount().getId())));
    }
    Long affinityGroupId = uvo.getAffinityGroupId();
    if (affinityGroupId != null && affinityGroupId.longValue() != 0) {
        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 : UserVmManager(com.cloud.vm.UserVmManager) AnnotationDao(org.apache.cloudstack.annotation.dao.AnnotationDao) UserStatisticsDao(com.cloud.user.dao.UserStatisticsDao) UserVmJoinVO(com.cloud.api.query.vo.UserVmJoinVO) Logger(org.apache.log4j.Logger) Map(java.util.Map) NicExtraDhcpOptionDao(com.cloud.vm.dao.NicExtraDhcpOptionDao) EnumSet(java.util.EnumSet) CallContext(org.apache.cloudstack.context.CallContext) State(com.cloud.vm.VirtualMachine.State) Set(java.util.Set) ApiDBUtils(com.cloud.api.ApiDBUtils) Account(com.cloud.user.Account) QueryService(org.apache.cloudstack.query.QueryService) Collectors(java.util.stream.Collectors) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) List(java.util.List) NicExtraDhcpOptionResponse(org.apache.cloudstack.api.response.NicExtraDhcpOptionResponse) NicResponse(org.apache.cloudstack.api.response.NicResponse) GuestOS(com.cloud.storage.GuestOS) ResponseView(org.apache.cloudstack.api.ResponseObject.ResponseView) SearchBuilder(com.cloud.utils.db.SearchBuilder) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ServiceOfferingDetailsVO(com.cloud.service.ServiceOfferingDetailsVO) UserDao(com.cloud.user.dao.UserDao) SearchCriteria(com.cloud.utils.db.SearchCriteria) VMDetails(org.apache.cloudstack.api.ApiConstants.VMDetails) User(com.cloud.user.User) UserVmDetailsDao(com.cloud.vm.dao.UserVmDetailsDao) UserVmDetailVO(com.cloud.vm.UserVmDetailVO) VmStats(com.cloud.vm.VmStats) AffinityGroupResponse(org.apache.cloudstack.affinity.AffinityGroupResponse) Hashtable(java.util.Hashtable) Op(com.cloud.utils.db.SearchCriteria.Op) Dhcp(com.cloud.utils.net.Dhcp) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse) UserVm(com.cloud.uservm.UserVm) ApiResponseHelper(com.cloud.api.ApiResponseHelper) GPU(com.cloud.gpu.GPU) AnnotationService(org.apache.cloudstack.annotation.AnnotationService) DecimalFormat(java.text.DecimalFormat) ApiConstants(org.apache.cloudstack.api.ApiConstants) NicSecondaryIpResponse(org.apache.cloudstack.api.response.NicSecondaryIpResponse) Component(org.springframework.stereotype.Component) AccountManager(com.cloud.user.AccountManager) SecurityGroupResponse(org.apache.cloudstack.api.response.SecurityGroupResponse) ConfigurationDao(org.apache.cloudstack.framework.config.dao.ConfigurationDao) UserStatisticsVO(com.cloud.user.UserStatisticsVO) NicSecondaryIpVO(com.cloud.vm.dao.NicSecondaryIpVO) NicExtraDhcpOptionResponse(org.apache.cloudstack.api.response.NicExtraDhcpOptionResponse) ArrayList(java.util.ArrayList) SecurityGroupResponse(org.apache.cloudstack.api.response.SecurityGroupResponse) NicSecondaryIpResponse(org.apache.cloudstack.api.response.NicSecondaryIpResponse) NicSecondaryIpVO(com.cloud.vm.dao.NicSecondaryIpVO) AffinityGroupResponse(org.apache.cloudstack.affinity.AffinityGroupResponse) NicResponse(org.apache.cloudstack.api.response.NicResponse)

Example 3 with AffinityGroupResponse

use of org.apache.cloudstack.affinity.AffinityGroupResponse in project cloudstack by apache.

the class ViewResponseHelper method createAffinityGroupResponses.

public static List<AffinityGroupResponse> createAffinityGroupResponses(List<AffinityGroupJoinVO> groups) {
    Hashtable<Long, AffinityGroupResponse> vrDataList = new Hashtable<Long, AffinityGroupResponse>();
    for (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<AffinityGroupResponse>(vrDataList.values());
}
Also used : AffinityGroupResponse(org.apache.cloudstack.affinity.AffinityGroupResponse) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) AffinityGroupJoinVO(com.cloud.api.query.vo.AffinityGroupJoinVO)

Example 4 with AffinityGroupResponse

use of org.apache.cloudstack.affinity.AffinityGroupResponse in project cloudstack by apache.

the class CreateAffinityGroupCmd method execute.

@Override
public void execute() {
    AffinityGroup group = _affinityGroupService.getAffinityGroup(getEntityId());
    if (group != null) {
        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(org.apache.cloudstack.affinity.AffinityGroupResponse) ServerApiException(org.apache.cloudstack.api.ServerApiException) AffinityGroup(org.apache.cloudstack.affinity.AffinityGroup)

Example 5 with AffinityGroupResponse

use of org.apache.cloudstack.affinity.AffinityGroupResponse in project cloudstack by apache.

the class UserVmJoinDaoImpl method newUserVmResponse.

@Override
public UserVmResponse newUserVmResponse(ResponseView view, String objectName, UserVmJoinVO userVm, EnumSet<VMDetails> details, Account caller) {
    UserVmResponse userVmResponse = new UserVmResponse();
    if (userVm.getHypervisorType() != null) {
        userVmResponse.setHypervisor(userVm.getHypervisorType().toString());
    }
    userVmResponse.setId(userVm.getUuid());
    userVmResponse.setName(userVm.getName());
    if (userVm.getDisplayName() != null) {
        userVmResponse.setDisplayName(userVm.getDisplayName());
    } else {
        userVmResponse.setDisplayName(userVm.getName());
    }
    if (userVm.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
        userVmResponse.setProjectId(userVm.getProjectUuid());
        userVmResponse.setProjectName(userVm.getProjectName());
    } else {
        userVmResponse.setAccountName(userVm.getAccountName());
    }
    User user = _userDao.getUser(userVm.getUserId());
    if (user != null) {
        userVmResponse.setUserId(user.getUuid());
        userVmResponse.setUserName(user.getUsername());
    }
    userVmResponse.setDomainId(userVm.getDomainUuid());
    userVmResponse.setDomainName(userVm.getDomainName());
    userVmResponse.setCreated(userVm.getCreated());
    userVmResponse.setLastUpdated(userVm.getLastUpdated());
    userVmResponse.setDisplayVm(userVm.isDisplayVm());
    if (userVm.getState() != null) {
        userVmResponse.setState(userVm.getState().toString());
    }
    userVmResponse.setHaEnable(userVm.isHaEnabled());
    if (details.contains(VMDetails.all) || details.contains(VMDetails.group)) {
        userVmResponse.setGroupId(userVm.getInstanceGroupUuid());
        userVmResponse.setGroup(userVm.getInstanceGroupName());
    }
    userVmResponse.setZoneId(userVm.getDataCenterUuid());
    userVmResponse.setZoneName(userVm.getDataCenterName());
    if (view == ResponseView.Full) {
        userVmResponse.setInstanceName(userVm.getInstanceName());
        userVmResponse.setHostId(userVm.getHostUuid());
        userVmResponse.setHostName(userVm.getHostName());
    }
    if (details.contains(VMDetails.all) || details.contains(VMDetails.tmpl)) {
        userVmResponse.setTemplateId(userVm.getTemplateUuid());
        userVmResponse.setTemplateName(userVm.getTemplateName());
        userVmResponse.setTemplateDisplayText(userVm.getTemplateDisplayText());
        userVmResponse.setPasswordEnabled(userVm.isPasswordEnabled());
    }
    if (details.contains(VMDetails.all) || details.contains(VMDetails.iso)) {
        userVmResponse.setIsoId(userVm.getIsoUuid());
        userVmResponse.setIsoName(userVm.getIsoName());
        userVmResponse.setIsoDisplayText(userVm.getIsoDisplayText());
    }
    if (details.contains(VMDetails.all) || details.contains(VMDetails.servoff)) {
        userVmResponse.setServiceOfferingId(userVm.getServiceOfferingUuid());
        userVmResponse.setServiceOfferingName(userVm.getServiceOfferingName());
    }
    if (details.contains(VMDetails.all) || details.contains(VMDetails.diskoff)) {
        DiskOfferingVO diskOfferingVO = ApiDBUtils.findDiskOfferingById(userVm.getDiskOfferingId());
        if (diskOfferingVO != null) {
            userVmResponse.setDiskOfferingId(userVm.getDiskOfferingUuid());
            userVmResponse.setDiskOfferingName(userVm.getDiskOfferingName());
        }
    }
    if (details.contains(VMDetails.all) || details.contains(VMDetails.backoff)) {
        userVmResponse.setBackupOfferingId(userVm.getBackupOfferingUuid());
        userVmResponse.setBackupOfferingName(userVm.getBackupOfferingName());
    }
    if (details.contains(VMDetails.all) || details.contains(VMDetails.servoff) || details.contains(VMDetails.stats)) {
        userVmResponse.setCpuNumber(userVm.getCpu());
        userVmResponse.setCpuSpeed(userVm.getSpeed());
        userVmResponse.setMemory(userVm.getRamSize());
        ServiceOfferingDetailsVO serviceOfferingDetail = ApiDBUtils.findServiceOfferingDetail(userVm.getServiceOfferingId(), GPU.Keys.vgpuType.toString());
        if (serviceOfferingDetail != null) {
            userVmResponse.setVgpu(serviceOfferingDetail.getValue());
        }
    }
    userVmResponse.setGuestOsId(userVm.getGuestOsUuid());
    if (details.contains(VMDetails.all) || details.contains(VMDetails.volume)) {
        userVmResponse.setRootDeviceId(userVm.getVolumeDeviceId());
        if (userVm.getVolumeType() != null) {
            userVmResponse.setRootDeviceType(userVm.getVolumeType().toString());
        }
    }
    userVmResponse.setPassword(userVm.getPassword());
    if (userVm.getJobId() != null) {
        userVmResponse.setJobId(userVm.getJobUuid());
        userVmResponse.setJobStatus(userVm.getJobStatus());
    }
    // userVmResponse.setForVirtualNetwork(userVm.getForVirtualNetwork());
    userVmResponse.setPublicIpId(userVm.getPublicIpUuid());
    userVmResponse.setPublicIp(userVm.getPublicIpAddress());
    userVmResponse.setKeyPairName(userVm.getKeypairName());
    userVmResponse.setOsTypeId(userVm.getGuestOsUuid());
    GuestOS guestOS = ApiDBUtils.findGuestOSById(userVm.getGuestOsId());
    if (guestOS != null) {
        userVmResponse.setOsDisplayName(guestOS.getDisplayName());
    }
    if (details.contains(VMDetails.all) || details.contains(VMDetails.stats)) {
        // stats calculation
        VmStats vmStats = ApiDBUtils.getVmStatistics(userVm.getId());
        if (vmStats != null) {
            userVmResponse.setCpuUsed(new DecimalFormat("#.##").format(vmStats.getCPUUtilization()) + "%");
            userVmResponse.setNetworkKbsRead((long) vmStats.getNetworkReadKBs());
            userVmResponse.setNetworkKbsWrite((long) vmStats.getNetworkWriteKBs());
            userVmResponse.setDiskKbsRead((long) vmStats.getDiskReadKBs());
            userVmResponse.setDiskKbsWrite((long) vmStats.getDiskWriteKBs());
            userVmResponse.setDiskIORead((long) vmStats.getDiskReadIOs());
            userVmResponse.setDiskIOWrite((long) vmStats.getDiskWriteIOs());
            long totalMemory = (long) vmStats.getMemoryKBs();
            long freeMemory = (long) vmStats.getIntFreeMemoryKBs();
            long correctedFreeMemory = freeMemory >= totalMemory ? 0 : freeMemory;
            userVmResponse.setMemoryKBs(totalMemory);
            userVmResponse.setMemoryIntFreeKBs(correctedFreeMemory);
            userVmResponse.setMemoryTargetKBs((long) vmStats.getTargetMemoryKBs());
        }
    }
    if (details.contains(VMDetails.all) || details.contains(VMDetails.secgrp)) {
        Long securityGroupId = userVm.getSecurityGroupId();
        if (securityGroupId != null && securityGroupId.longValue() != 0) {
            SecurityGroupResponse resp = new SecurityGroupResponse();
            resp.setId(userVm.getSecurityGroupUuid());
            resp.setName(userVm.getSecurityGroupName());
            resp.setDescription(userVm.getSecurityGroupDescription());
            resp.setObjectName("securitygroup");
            if (userVm.getAccountType() == Account.ACCOUNT_TYPE_PROJECT) {
                resp.setProjectId(userVm.getProjectUuid());
                resp.setProjectName(userVm.getProjectName());
            } else {
                resp.setAccountName(userVm.getAccountName());
            }
            userVmResponse.addSecurityGroup(resp);
        }
    }
    if (details.contains(VMDetails.all) || details.contains(VMDetails.nics)) {
        long nic_id = userVm.getNicId();
        if (nic_id > 0) {
            NicResponse nicResponse = new NicResponse();
            nicResponse.setId(userVm.getNicUuid());
            nicResponse.setIpaddress(userVm.getIpAddress());
            nicResponse.setGateway(userVm.getGateway());
            nicResponse.setNetmask(userVm.getNetmask());
            nicResponse.setNetworkid(userVm.getNetworkUuid());
            nicResponse.setNetworkName(userVm.getNetworkName());
            nicResponse.setMacAddress(userVm.getMacAddress());
            nicResponse.setIp6Address(userVm.getIp6Address());
            nicResponse.setIp6Gateway(userVm.getIp6Gateway());
            nicResponse.setIp6Cidr(userVm.getIp6Cidr());
            if (userVm.getBroadcastUri() != null) {
                nicResponse.setBroadcastUri(userVm.getBroadcastUri().toString());
            }
            if (userVm.getIsolationUri() != null) {
                nicResponse.setIsolationUri(userVm.getIsolationUri().toString());
            }
            if (userVm.getTrafficType() != null) {
                nicResponse.setTrafficType(userVm.getTrafficType().toString());
            }
            if (userVm.getGuestType() != null) {
                nicResponse.setType(userVm.getGuestType().toString());
            }
            nicResponse.setIsDefault(userVm.isDefaultNic());
            nicResponse.setDeviceId(String.valueOf(userVm.getNicDeviceId()));
            List<NicSecondaryIpVO> secondaryIps = ApiDBUtils.findNicSecondaryIps(userVm.getNicId());
            if (secondaryIps != null) {
                List<NicSecondaryIpResponse> ipList = new ArrayList<NicSecondaryIpResponse>();
                for (NicSecondaryIpVO ip : secondaryIps) {
                    NicSecondaryIpResponse ipRes = new NicSecondaryIpResponse();
                    ipRes.setId(ip.getUuid());
                    ApiResponseHelper.setResponseIpAddress(ip, ipRes);
                    ipList.add(ipRes);
                }
                nicResponse.setSecondaryIps(ipList);
            }
            nicResponse.setObjectName("nic");
            List<NicExtraDhcpOptionResponse> nicExtraDhcpOptionResponses = _nicExtraDhcpOptionDao.listByNicId(nic_id).stream().map(vo -> new NicExtraDhcpOptionResponse(Dhcp.DhcpOptionCode.valueOfInt(vo.getCode()).getName(), vo.getCode(), vo.getValue())).collect(Collectors.toList());
            nicResponse.setExtraDhcpOptions(nicExtraDhcpOptionResponses);
            userVmResponse.addNic(nicResponse);
        }
    }
    // update tag information
    long tag_id = userVm.getTagId();
    if (tag_id > 0 && !userVmResponse.containTag(tag_id)) {
        addTagInformation(userVm, userVmResponse);
    }
    userVmResponse.setHasAnnotation(annotationDao.hasAnnotations(userVm.getUuid(), AnnotationService.EntityType.VM.name(), _accountMgr.isRootAdmin(caller.getId())));
    if (details.contains(VMDetails.all) || details.contains(VMDetails.affgrp)) {
        Long affinityGroupId = userVm.getAffinityGroupId();
        if (affinityGroupId != null && affinityGroupId.longValue() != 0) {
            AffinityGroupResponse resp = new AffinityGroupResponse();
            resp.setId(userVm.getAffinityGroupUuid());
            resp.setName(userVm.getAffinityGroupName());
            resp.setDescription(userVm.getAffinityGroupDescription());
            resp.setObjectName("affinitygroup");
            resp.setAccountName(userVm.getAccountName());
            userVmResponse.addAffinityGroup(resp);
        }
    }
    // set resource details map
    // Allow passing details to end user
    // Honour the display field and only return if display is set to true
    List<UserVmDetailVO> vmDetails = _userVmDetailsDao.listDetails(userVm.getId(), true);
    if (vmDetails != null) {
        Map<String, String> resourceDetails = new HashMap<String, String>();
        for (UserVmDetailVO userVmDetailVO : vmDetails) {
            if (!userVmDetailVO.getName().startsWith(ApiConstants.PROPERTIES) || (UserVmManager.DisplayVMOVFProperties.value() && userVmDetailVO.getName().startsWith(ApiConstants.PROPERTIES))) {
                resourceDetails.put(userVmDetailVO.getName(), userVmDetailVO.getValue());
            }
            if ((ApiConstants.BootType.UEFI.toString()).equalsIgnoreCase(userVmDetailVO.getName())) {
                userVmResponse.setBootType("Uefi");
                userVmResponse.setBootMode(userVmDetailVO.getValue().toLowerCase());
            }
        }
        if (vmDetails.size() == 0) {
            userVmResponse.setBootType("Bios");
            userVmResponse.setBootMode("legacy");
        }
        if (userVm.getPoolType() != null) {
            userVmResponse.setPoolType(userVm.getPoolType().toString());
        }
        // Remove deny listed settings if user is not admin
        if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
            String[] userVmSettingsToHide = QueryService.UserVMDeniedDetails.value().split(",");
            for (String key : userVmSettingsToHide) {
                resourceDetails.remove(key.trim());
            }
        }
        userVmResponse.setDetails(resourceDetails);
        if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN) {
            userVmResponse.setReadOnlyDetails(QueryService.UserVMReadOnlyDetails.value());
        }
    }
    userVmResponse.setObjectName(objectName);
    if (userVm.isDynamicallyScalable() == null) {
        userVmResponse.setDynamicallyScalable(false);
    } else {
        userVmResponse.setDynamicallyScalable(userVm.isDynamicallyScalable());
    }
    addVmRxTxDataToResponse(userVm, userVmResponse);
    return userVmResponse;
}
Also used : UserVmManager(com.cloud.vm.UserVmManager) AnnotationDao(org.apache.cloudstack.annotation.dao.AnnotationDao) UserStatisticsDao(com.cloud.user.dao.UserStatisticsDao) UserVmJoinVO(com.cloud.api.query.vo.UserVmJoinVO) Logger(org.apache.log4j.Logger) Map(java.util.Map) NicExtraDhcpOptionDao(com.cloud.vm.dao.NicExtraDhcpOptionDao) EnumSet(java.util.EnumSet) CallContext(org.apache.cloudstack.context.CallContext) State(com.cloud.vm.VirtualMachine.State) Set(java.util.Set) ApiDBUtils(com.cloud.api.ApiDBUtils) Account(com.cloud.user.Account) QueryService(org.apache.cloudstack.query.QueryService) Collectors(java.util.stream.Collectors) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) List(java.util.List) NicExtraDhcpOptionResponse(org.apache.cloudstack.api.response.NicExtraDhcpOptionResponse) NicResponse(org.apache.cloudstack.api.response.NicResponse) GuestOS(com.cloud.storage.GuestOS) ResponseView(org.apache.cloudstack.api.ResponseObject.ResponseView) SearchBuilder(com.cloud.utils.db.SearchBuilder) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Inject(javax.inject.Inject) ServiceOfferingDetailsVO(com.cloud.service.ServiceOfferingDetailsVO) UserDao(com.cloud.user.dao.UserDao) SearchCriteria(com.cloud.utils.db.SearchCriteria) VMDetails(org.apache.cloudstack.api.ApiConstants.VMDetails) User(com.cloud.user.User) UserVmDetailsDao(com.cloud.vm.dao.UserVmDetailsDao) UserVmDetailVO(com.cloud.vm.UserVmDetailVO) VmStats(com.cloud.vm.VmStats) AffinityGroupResponse(org.apache.cloudstack.affinity.AffinityGroupResponse) Hashtable(java.util.Hashtable) Op(com.cloud.utils.db.SearchCriteria.Op) Dhcp(com.cloud.utils.net.Dhcp) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse) UserVm(com.cloud.uservm.UserVm) ApiResponseHelper(com.cloud.api.ApiResponseHelper) GPU(com.cloud.gpu.GPU) AnnotationService(org.apache.cloudstack.annotation.AnnotationService) DecimalFormat(java.text.DecimalFormat) ApiConstants(org.apache.cloudstack.api.ApiConstants) NicSecondaryIpResponse(org.apache.cloudstack.api.response.NicSecondaryIpResponse) Component(org.springframework.stereotype.Component) AccountManager(com.cloud.user.AccountManager) SecurityGroupResponse(org.apache.cloudstack.api.response.SecurityGroupResponse) ConfigurationDao(org.apache.cloudstack.framework.config.dao.ConfigurationDao) UserStatisticsVO(com.cloud.user.UserStatisticsVO) NicSecondaryIpVO(com.cloud.vm.dao.NicSecondaryIpVO) User(com.cloud.user.User) HashMap(java.util.HashMap) DecimalFormat(java.text.DecimalFormat) ArrayList(java.util.ArrayList) ServiceOfferingDetailsVO(com.cloud.service.ServiceOfferingDetailsVO) SecurityGroupResponse(org.apache.cloudstack.api.response.SecurityGroupResponse) NicSecondaryIpResponse(org.apache.cloudstack.api.response.NicSecondaryIpResponse) NicSecondaryIpVO(com.cloud.vm.dao.NicSecondaryIpVO) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) VmStats(com.cloud.vm.VmStats) GuestOS(com.cloud.storage.GuestOS) NicResponse(org.apache.cloudstack.api.response.NicResponse) NicExtraDhcpOptionResponse(org.apache.cloudstack.api.response.NicExtraDhcpOptionResponse) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse) UserVmDetailVO(com.cloud.vm.UserVmDetailVO) AffinityGroupResponse(org.apache.cloudstack.affinity.AffinityGroupResponse)

Aggregations

AffinityGroupResponse (org.apache.cloudstack.affinity.AffinityGroupResponse)6 ArrayList (java.util.ArrayList)4 Account (com.cloud.user.Account)3 Hashtable (java.util.Hashtable)3 ApiDBUtils (com.cloud.api.ApiDBUtils)2 ApiResponseHelper (com.cloud.api.ApiResponseHelper)2 UserVmJoinVO (com.cloud.api.query.vo.UserVmJoinVO)2 GPU (com.cloud.gpu.GPU)2 ServiceOfferingDetailsVO (com.cloud.service.ServiceOfferingDetailsVO)2 DiskOfferingVO (com.cloud.storage.DiskOfferingVO)2 GuestOS (com.cloud.storage.GuestOS)2 AccountManager (com.cloud.user.AccountManager)2 User (com.cloud.user.User)2 UserStatisticsVO (com.cloud.user.UserStatisticsVO)2 UserDao (com.cloud.user.dao.UserDao)2 UserStatisticsDao (com.cloud.user.dao.UserStatisticsDao)2 UserVm (com.cloud.uservm.UserVm)2 SearchBuilder (com.cloud.utils.db.SearchBuilder)2 SearchCriteria (com.cloud.utils.db.SearchCriteria)2 Op (com.cloud.utils.db.SearchCriteria.Op)2