Search in sources :

Example 51 with UserVmResponse

use of org.apache.cloudstack.api.response.UserVmResponse 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)

Example 52 with UserVmResponse

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

the class ApiResponseHelper method createNicResponse.

/**
 * The resulting Response attempts to be in line with what is returned from
 * @see com.cloud.api.query.dao.UserVmJoinDaoImpl#setUserVmResponse(ResponseView, UserVmResponse, UserVmJoinVO)
 */
@Override
public NicResponse createNicResponse(Nic result) {
    NicResponse response = new NicResponse();
    NetworkVO network = _entityMgr.findById(NetworkVO.class, result.getNetworkId());
    VMInstanceVO vm = _entityMgr.findById(VMInstanceVO.class, result.getInstanceId());
    List<NicExtraDhcpOptionVO> nicExtraDhcpOptionVOs = _nicExtraDhcpOptionDao.listByNicId(result.getId());
    // The numbered comments are to keep track of the data returned from here and UserVmJoinDaoImpl.setUserVmResponse()
    // the data can't be identical but some tidying up/unifying might be possible
    /*1: nicUuid*/
    response.setId(result.getUuid());
    /*2: networkUuid*/
    response.setNetworkid(network.getUuid());
    /*3: vmId*/
    if (vm != null) {
        response.setVmId(vm.getUuid());
    }
    if (network.getTrafficType() != null) {
        /*4: trafficType*/
        response.setTrafficType(network.getTrafficType().toString());
    }
    if (network.getGuestType() != null) {
        /*5: guestType*/
        response.setType(network.getGuestType().toString());
    }
    /*6: ipAddress*/
    response.setIpaddress(result.getIPv4Address());
    /*7: gateway*/
    response.setGateway(result.getIPv4Gateway());
    /*8: netmask*/
    response.setNetmask(result.getIPv4Netmask());
    /*9: networkName*/
    response.setNetworkName(network.getName());
    /*10: macAddress*/
    response.setMacAddress(result.getMacAddress());
    /*11: IPv6Address*/
    if (result.getIPv6Address() != null) {
        response.setIp6Address(result.getIPv6Address());
    }
    /*12: IPv6Gateway*/
    if (result.getIPv6Gateway() != null) {
        response.setIp6Gateway(result.getIPv6Gateway());
    }
    /*13: IPv6Cidr*/
    if (result.getIPv6Cidr() != null) {
        response.setIp6Cidr(result.getIPv6Cidr());
    }
    /*14: deviceId*/
    response.setDeviceId(String.valueOf(result.getDeviceId()));
    /*15: broadcastURI*/
    if (result.getBroadcastUri() != null) {
        response.setBroadcastUri(result.getBroadcastUri().toString());
    }
    /*16: isolationURI*/
    if (result.getIsolationUri() != null) {
        response.setIsolationUri(result.getIsolationUri().toString());
    }
    /*17: default*/
    response.setIsDefault(result.isDefaultNic());
    if (result.getSecondaryIp()) {
        List<NicSecondaryIpVO> secondaryIps = ApiDBUtils.findNicSecondaryIps(result.getId());
        if (secondaryIps != null) {
            List<NicSecondaryIpResponse> ipList = new ArrayList<NicSecondaryIpResponse>();
            for (NicSecondaryIpVO ip : secondaryIps) {
                NicSecondaryIpResponse ipRes = new NicSecondaryIpResponse();
                ipRes.setId(ip.getUuid());
                setResponseIpAddress(ip, ipRes);
                ipList.add(ipRes);
            }
            response.setSecondaryIps(ipList);
        }
    }
    /*18: extra dhcp options */
    List<NicExtraDhcpOptionResponse> nicExtraDhcpOptionResponses = nicExtraDhcpOptionVOs.stream().map(vo -> new NicExtraDhcpOptionResponse(Dhcp.DhcpOptionCode.valueOfInt(vo.getCode()).getName(), vo.getCode(), vo.getValue())).collect(Collectors.toList());
    response.setExtraDhcpOptions(nicExtraDhcpOptionResponses);
    if (result instanceof NicVO) {
        if (((NicVO) result).getNsxLogicalSwitchUuid() != null) {
            response.setNsxLogicalSwitch(((NicVO) result).getNsxLogicalSwitchUuid());
        }
        if (((NicVO) result).getNsxLogicalSwitchPortUuid() != null) {
            response.setNsxLogicalSwitchPort(((NicVO) result).getNsxLogicalSwitchPortUuid());
        }
    }
    return response;
}
Also used : ProviderResponse(org.apache.cloudstack.api.response.ProviderResponse) ServiceOfferingJoinVO(com.cloud.api.query.vo.ServiceOfferingJoinVO) NetworkModel(com.cloud.network.NetworkModel) PhysicalNetworkTrafficType(com.cloud.network.PhysicalNetworkTrafficType) ControlledViewEntityResponse(org.apache.cloudstack.api.response.ControlledViewEntityResponse) Pod(com.cloud.dc.Pod) EventResponse(org.apache.cloudstack.api.response.EventResponse) GlobalLoadBalancerResponse(org.apache.cloudstack.api.response.GlobalLoadBalancerResponse) StringUtils(org.apache.commons.lang3.StringUtils) StickinessPolicy(com.cloud.network.rules.StickinessPolicy) RouterHealthCheckResult(com.cloud.network.RouterHealthCheckResult) DiskOffering(com.cloud.offering.DiskOffering) PortForwardingRule(com.cloud.network.rules.PortForwardingRule) Map(java.util.Map) ControlledEntityResponse(org.apache.cloudstack.api.response.ControlledEntityResponse) TrafficType(com.cloud.network.Networks.TrafficType) OvsProvider(com.cloud.network.OvsProvider) GuestOSCategoryVO(com.cloud.storage.GuestOSCategoryVO) VirtualRouter(com.cloud.network.router.VirtualRouter) Service(com.cloud.network.Network.Service) EnumSet(java.util.EnumSet) SnapshotPolicy(com.cloud.storage.snapshot.SnapshotPolicy) ApplicationLoadBalancerInstanceResponse(org.apache.cloudstack.api.response.ApplicationLoadBalancerInstanceResponse) Site2SiteCustomerGateway(com.cloud.network.Site2SiteCustomerGateway) DiskOfferingResponse(org.apache.cloudstack.api.response.DiskOfferingResponse) NetworkACLItemResponse(org.apache.cloudstack.api.response.NetworkACLItemResponse) StoragePoolResponse(org.apache.cloudstack.api.response.StoragePoolResponse) Network(com.cloud.network.Network) ViewResponseHelper(com.cloud.api.query.ViewResponseHelper) ProjectAccountJoinVO(com.cloud.api.query.vo.ProjectAccountJoinVO) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) ConditionVO(com.cloud.network.as.ConditionVO) Detail(com.cloud.offering.NetworkOffering.Detail) NetworkACLResponse(org.apache.cloudstack.api.response.NetworkACLResponse) NicExtraDhcpOptionVO(com.cloud.vm.NicExtraDhcpOptionVO) ProjectInvitation(com.cloud.projects.ProjectInvitation) SnapshotPolicyResponse(org.apache.cloudstack.api.response.SnapshotPolicyResponse) Project(com.cloud.projects.Project) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) GuestOS(com.cloud.storage.GuestOS) ServiceOffering(com.cloud.offering.ServiceOffering) ProjectInvitationJoinVO(com.cloud.api.query.vo.ProjectInvitationJoinVO) ResourceIconResponse(org.apache.cloudstack.api.response.ResourceIconResponse) VMSnapshotVO(com.cloud.vm.snapshot.VMSnapshotVO) SummedCapacity(com.cloud.capacity.dao.CapacityDaoImpl.SummedCapacity) GuestVlanRangeResponse(org.apache.cloudstack.api.response.GuestVlanRangeResponse) VpnUsersResponse(org.apache.cloudstack.api.response.VpnUsersResponse) IsolationMethodResponse(org.apache.cloudstack.api.response.IsolationMethodResponse) StorageNetworkIpRangeResponse(org.apache.cloudstack.api.response.StorageNetworkIpRangeResponse) FirewallRule(com.cloud.network.rules.FirewallRule) DataCenterVO(com.cloud.dc.DataCenterVO) Site2SiteVpnConnectionResponse(org.apache.cloudstack.api.response.Site2SiteVpnConnectionResponse) ResourceLimitResponse(org.apache.cloudstack.api.response.ResourceLimitResponse) NicProfile(com.cloud.vm.NicProfile) DataCenterJoinVO(com.cloud.api.query.vo.DataCenterJoinVO) VpcOffering(com.cloud.network.vpc.VpcOffering) SnapshotVO(com.cloud.storage.SnapshotVO) FirewallRuleResponse(org.apache.cloudstack.api.response.FirewallRuleResponse) Calendar(java.util.Calendar) ImageStoreJoinVO(com.cloud.api.query.vo.ImageStoreJoinVO) SearchCriteria(com.cloud.utils.db.SearchCriteria) VMDetails(org.apache.cloudstack.api.ApiConstants.VMDetails) VlanVO(com.cloud.dc.VlanVO) User(com.cloud.user.User) ClusterVO(com.cloud.dc.ClusterVO) ResourceTag(com.cloud.server.ResourceTag) PrivateGateway(com.cloud.network.vpc.PrivateGateway) HostJoinVO(com.cloud.api.query.vo.HostJoinVO) UserVm(com.cloud.uservm.UserVm) ResourceTagResponse(org.apache.cloudstack.api.response.ResourceTagResponse) Vlan(com.cloud.dc.Vlan) SecurityRuleType(com.cloud.network.security.SecurityRule.SecurityRuleType) PortableIpResponse(org.apache.cloudstack.api.response.PortableIpResponse) ProjectAccountResponse(org.apache.cloudstack.api.response.ProjectAccountResponse) CounterResponse(org.apache.cloudstack.api.response.CounterResponse) PhysicalNetwork(com.cloud.network.PhysicalNetwork) CapacityResponse(org.apache.cloudstack.api.response.CapacityResponse) ResourceOwnerType(com.cloud.configuration.Resource.ResourceOwnerType) NicSecondaryIpResponse(org.apache.cloudstack.api.response.NicSecondaryIpResponse) VirtualRouterProviderResponse(org.apache.cloudstack.api.response.VirtualRouterProviderResponse) ControlledEntity(org.apache.cloudstack.acl.ControlledEntity) Counter(com.cloud.network.as.Counter) PortableIp(org.apache.cloudstack.region.PortableIp) ConditionResponse(org.apache.cloudstack.api.response.ConditionResponse) ClusterDetailsDao(com.cloud.dc.ClusterDetailsDao) SecurityGroupResponse(org.apache.cloudstack.api.response.SecurityGroupResponse) Condition(com.cloud.network.as.Condition) NetworkResponse(org.apache.cloudstack.api.response.NetworkResponse) GuestOSHypervisor(com.cloud.storage.GuestOSHypervisor) AnnotationDao(org.apache.cloudstack.annotation.dao.AnnotationDao) ServiceOfferingResponse(org.apache.cloudstack.api.response.ServiceOfferingResponse) RollingMaintenanceResponse(org.apache.cloudstack.api.response.RollingMaintenanceResponse) SnapshotSchedule(com.cloud.storage.snapshot.SnapshotSchedule) Date(java.util.Date) UsageService(org.apache.cloudstack.usage.UsageService) StoragePool(com.cloud.storage.StoragePool) UserStatisticsDao(com.cloud.user.dao.UserStatisticsDao) PrivateGatewayResponse(org.apache.cloudstack.api.response.PrivateGatewayResponse) ServiceResponse(org.apache.cloudstack.api.response.ServiceResponse) UserVmJoinVO(com.cloud.api.query.vo.UserVmJoinVO) ResourceType(com.cloud.configuration.Resource.ResourceType) Cluster(com.cloud.org.Cluster) GuestOSCategoryDao(com.cloud.storage.dao.GuestOSCategoryDao) ConsoleProxyVO(com.cloud.vm.ConsoleProxyVO) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) RollingMaintenanceHostUpdatedResponse(org.apache.cloudstack.api.response.RollingMaintenanceHostUpdatedResponse) StaticRouteResponse(org.apache.cloudstack.api.response.StaticRouteResponse) ResourceObjectType(com.cloud.server.ResourceTag.ResourceObjectType) NicSecondaryIp(com.cloud.vm.NicSecondaryIp) ConfigurationResponse(org.apache.cloudstack.api.response.ConfigurationResponse) InstanceGroupJoinVO(com.cloud.api.query.vo.InstanceGroupJoinVO) VMInstanceVO(com.cloud.vm.VMInstanceVO) Capacity(com.cloud.capacity.Capacity) StaticRoute(com.cloud.network.vpc.StaticRoute) TimeZone(java.util.TimeZone) Site2SiteVpnGateway(com.cloud.network.Site2SiteVpnGateway) IpAddress(com.cloud.network.IpAddress) Type(com.cloud.vm.VirtualMachine.Type) Pair(com.cloud.utils.Pair) NicVO(com.cloud.vm.NicVO) Collectors(java.util.stream.Collectors) BackupResponse(org.apache.cloudstack.api.response.BackupResponse) Scheme(com.cloud.network.rules.LoadBalancerContainer.Scheme) BackupOfferingDao(org.apache.cloudstack.backup.dao.BackupOfferingDao) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) NicResponse(org.apache.cloudstack.api.response.NicResponse) ProjectAccount(com.cloud.projects.ProjectAccount) AutoScaleVmProfileResponse(org.apache.cloudstack.api.response.AutoScaleVmProfileResponse) BackupSchedule(org.apache.cloudstack.backup.BackupSchedule) NetUtils(com.cloud.utils.net.NetUtils) DomainResponse(org.apache.cloudstack.api.response.DomainResponse) DomainDetails(org.apache.cloudstack.api.ApiConstants.DomainDetails) TrafficTypeResponse(org.apache.cloudstack.api.response.TrafficTypeResponse) VirtualMachine(com.cloud.vm.VirtualMachine) AsyncJobManager(org.apache.cloudstack.framework.jobs.AsyncJobManager) VpnUserVO(com.cloud.network.VpnUserVO) BroadcastDomainType(com.cloud.network.Networks.BroadcastDomainType) DataStoreManager(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager) NetworkDetailsDao(com.cloud.network.dao.NetworkDetailsDao) VMSnapshot(com.cloud.vm.snapshot.VMSnapshot) SecurityGroupJoinVO(com.cloud.api.query.vo.SecurityGroupJoinVO) Domain(com.cloud.domain.Domain) DBEncryptionUtil(com.cloud.utils.crypt.DBEncryptionUtil) GuestVlan(com.cloud.network.GuestVlan) PortForwardingRuleVO(com.cloud.network.rules.PortForwardingRuleVO) HashSet(java.util.HashSet) Inject(javax.inject.Inject) UsageTypes(org.apache.cloudstack.usage.UsageTypes) OvsProviderResponse(org.apache.cloudstack.api.response.OvsProviderResponse) SecurityRule(com.cloud.network.security.SecurityRule) VolumeJoinVO(com.cloud.api.query.vo.VolumeJoinVO) AsyncJobJoinVO(com.cloud.api.query.vo.AsyncJobJoinVO) ResourceCount(com.cloud.configuration.ResourceCount) IPAddressVO(com.cloud.network.dao.IPAddressVO) LBHealthCheckPolicyResponse(org.apache.cloudstack.api.response.LBHealthCheckPolicyResponse) CapacityVO(com.cloud.capacity.CapacityVO) VolumeDao(com.cloud.storage.dao.VolumeDao) AffinityGroup(org.apache.cloudstack.affinity.AffinityGroup) IPAddressDao(com.cloud.network.dao.IPAddressDao) SnapshotResponse(org.apache.cloudstack.api.response.SnapshotResponse) ImageStoreResponse(org.apache.cloudstack.api.response.ImageStoreResponse) VMSnapshotResponse(org.apache.cloudstack.api.response.VMSnapshotResponse) Snapshot(com.cloud.storage.Snapshot) DataCenter(com.cloud.dc.DataCenter) PermissionDeniedException(com.cloud.exception.PermissionDeniedException) ImageStore(com.cloud.storage.ImageStore) HostVO(com.cloud.host.HostVO) HostDetails(org.apache.cloudstack.api.ApiConstants.HostDetails) StorageNetworkIpRange(com.cloud.dc.StorageNetworkIpRange) VMTemplateVO(com.cloud.storage.VMTemplateVO) Site2SiteCustomerGatewayResponse(org.apache.cloudstack.api.response.Site2SiteCustomerGatewayResponse) ConfigurationManager(com.cloud.configuration.ConfigurationManager) QueryAsyncJobResultCmd(org.apache.cloudstack.api.command.user.job.QueryAsyncJobResultCmd) DomainRouterResponse(org.apache.cloudstack.api.response.DomainRouterResponse) UsageRecordResponse(org.apache.cloudstack.api.response.UsageRecordResponse) DecimalFormat(java.text.DecimalFormat) BackupScheduleResponse(org.apache.cloudstack.api.response.BackupScheduleResponse) ZoneResponse(org.apache.cloudstack.api.response.ZoneResponse) AutoScaleVmProfile(com.cloud.network.as.AutoScaleVmProfile) NumbersUtil.toHumanReadableSize(com.cloud.utils.NumbersUtil.toHumanReadableSize) BackupOfferingResponse(org.apache.cloudstack.api.response.BackupOfferingResponse) ProjectResponse(org.apache.cloudstack.api.response.ProjectResponse) DataStoreRole(com.cloud.storage.DataStoreRole) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) NetworkDetailVO(com.cloud.network.dao.NetworkDetailVO) NicSecondaryIpVO(com.cloud.vm.dao.NicSecondaryIpVO) IPAddressResponse(org.apache.cloudstack.api.response.IPAddressResponse) AutoScaleVmGroupResponse(org.apache.cloudstack.api.response.AutoScaleVmGroupResponse) ManagementServerHost(org.apache.cloudstack.management.ManagementServerHost) LBStickinessResponse(org.apache.cloudstack.api.response.LBStickinessResponse) SystemVmInstanceResponse(org.apache.cloudstack.api.response.SystemVmInstanceResponse) Arrays(java.util.Arrays) AutoScalePolicyResponse(org.apache.cloudstack.api.response.AutoScalePolicyResponse) ClusterResponse(org.apache.cloudstack.api.response.ClusterResponse) ProjectJoinVO(com.cloud.api.query.vo.ProjectJoinVO) IsolationType(com.cloud.network.Networks.IsolationType) VirtualMachineTemplate(com.cloud.template.VirtualMachineTemplate) CapabilityResponse(org.apache.cloudstack.api.response.CapabilityResponse) RegionResponse(org.apache.cloudstack.api.response.RegionResponse) SnapshotScheduleResponse(org.apache.cloudstack.api.response.SnapshotScheduleResponse) TemplateResponse(org.apache.cloudstack.api.response.TemplateResponse) StaticNatRule(com.cloud.network.rules.StaticNatRule) LBHealthCheckResponse(org.apache.cloudstack.api.response.LBHealthCheckResponse) NicExtraDhcpOptionDao(com.cloud.vm.dao.NicExtraDhcpOptionDao) ApplicationLoadBalancerRuleResponse(org.apache.cloudstack.api.response.ApplicationLoadBalancerRuleResponse) CallContext(org.apache.cloudstack.context.CallContext) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) EventJoinVO(com.cloud.api.query.vo.EventJoinVO) VpcOfferingResponse(org.apache.cloudstack.api.response.VpcOfferingResponse) CreateSSHKeyPairResponse(org.apache.cloudstack.api.response.CreateSSHKeyPairResponse) Set(java.util.Set) UploadVO(com.cloud.storage.UploadVO) StoragePoolJoinVO(com.cloud.api.query.vo.StoragePoolJoinVO) HealthCheckPolicy(com.cloud.network.rules.HealthCheckPolicy) VpcOfferingJoinVO(com.cloud.api.query.vo.VpcOfferingJoinVO) LoadBalancerVO(com.cloud.network.dao.LoadBalancerVO) GuestOSDao(com.cloud.storage.dao.GuestOSDao) NetworkACL(com.cloud.network.vpc.NetworkACL) ListResponse(org.apache.cloudstack.api.response.ListResponse) ApplicationLoadBalancerRule(org.apache.cloudstack.network.lb.ApplicationLoadBalancerRule) SnapshotDataStoreVO(org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO) Upload(com.cloud.storage.Upload) PodResponse(org.apache.cloudstack.api.response.PodResponse) VgpuTypesInfo(com.cloud.agent.api.VgpuTypesInfo) ArrayList(java.util.ArrayList) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) SSHKeyPairResponse(org.apache.cloudstack.api.response.SSHKeyPairResponse) Event(com.cloud.event.Event) CreateCmdResponse(org.apache.cloudstack.api.response.CreateCmdResponse) ControlledViewEntity(com.cloud.api.query.vo.ControlledViewEntity) HostForMigrationResponse(org.apache.cloudstack.api.response.HostForMigrationResponse) AsyncJob(org.apache.cloudstack.framework.jobs.AsyncJob) HypervisorCapabilities(com.cloud.hypervisor.HypervisorCapabilities) TemplatePermissionsResponse(org.apache.cloudstack.api.response.TemplatePermissionsResponse) Site2SiteVpnConnection(com.cloud.network.Site2SiteVpnConnection) UserAccount(com.cloud.user.UserAccount) Op(com.cloud.utils.db.SearchCriteria.Op) Dhcp(com.cloud.utils.net.Dhcp) ProjectInvitationResponse(org.apache.cloudstack.api.response.ProjectInvitationResponse) Vpc(com.cloud.network.vpc.Vpc) RemoteAccessVpn(com.cloud.network.RemoteAccessVpn) NetworkOfferingResponse(org.apache.cloudstack.api.response.NetworkOfferingResponse) DiskOfferingJoinVO(com.cloud.api.query.vo.DiskOfferingJoinVO) ResourceTagDao(com.cloud.tags.dao.ResourceTagDao) IpForwardingRuleResponse(org.apache.cloudstack.api.response.IpForwardingRuleResponse) VirtualRouterProvider(com.cloud.network.VirtualRouterProvider) SnapshotInfo(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo) Host(com.cloud.host.Host) PhysicalNetworkResponse(org.apache.cloudstack.api.response.PhysicalNetworkResponse) HypervisorCapabilitiesResponse(org.apache.cloudstack.api.response.HypervisorCapabilitiesResponse) GlobalLoadBalancerRule(com.cloud.region.ha.GlobalLoadBalancerRule) AccountManager(com.cloud.user.AccountManager) GuestOSResponse(org.apache.cloudstack.api.response.GuestOSResponse) RouterHealthCheckResultResponse(org.apache.cloudstack.api.response.RouterHealthCheckResultResponse) ManagementServerResponse(org.apache.cloudstack.api.response.ManagementServerResponse) UpgradeRouterTemplateResponse(org.apache.cloudstack.api.response.UpgradeRouterTemplateResponse) SnapshotDataFactory(org.apache.cloudstack.engine.subsystem.api.storage.SnapshotDataFactory) LoadBalancer(com.cloud.network.rules.LoadBalancer) GuestOsCategory(com.cloud.storage.GuestOsCategory) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) Logger(org.apache.log4j.Logger) IpRangeResponse(org.apache.cloudstack.api.response.IpRangeResponse) SnapshotDataStoreDao(org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao) ResourceCountResponse(org.apache.cloudstack.api.response.ResourceCountResponse) PortableIpRange(org.apache.cloudstack.region.PortableIpRange) ResponseGenerator(org.apache.cloudstack.api.ResponseGenerator) LBStickinessPolicyResponse(org.apache.cloudstack.api.response.LBStickinessPolicyResponse) SystemVmResponse(org.apache.cloudstack.api.response.SystemVmResponse) SecurityGroupVO(com.cloud.network.security.SecurityGroupVO) NetworkACLItem(com.cloud.network.vpc.NetworkACLItem) SecurityGroup(com.cloud.network.security.SecurityGroup) Ip(com.cloud.utils.net.Ip) NetworkProfile(com.cloud.network.NetworkProfile) PrimaryDataStoreDao(org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao) HostResponse(org.apache.cloudstack.api.response.HostResponse) RollingMaintenanceHostSkippedResponse(org.apache.cloudstack.api.response.RollingMaintenanceHostSkippedResponse) RollingMaintenanceManager(com.cloud.resource.RollingMaintenanceManager) SSHKeyPair(com.cloud.user.SSHKeyPair) Account(com.cloud.user.Account) ExtractResponse(org.apache.cloudstack.api.response.ExtractResponse) AsyncJobResponse(org.apache.cloudstack.api.response.AsyncJobResponse) TrafficMonitorResponse(org.apache.cloudstack.api.response.TrafficMonitorResponse) VMSnapshotDao(com.cloud.vm.snapshot.dao.VMSnapshotDao) List(java.util.List) NicExtraDhcpOptionResponse(org.apache.cloudstack.api.response.NicExtraDhcpOptionResponse) ACLType(org.apache.cloudstack.acl.ControlledEntity.ACLType) ResourceIcon(com.cloud.server.ResourceIcon) ResponseView(org.apache.cloudstack.api.ResponseObject.ResponseView) InternalLoadBalancerElementResponse(org.apache.cloudstack.api.response.InternalLoadBalancerElementResponse) VpcResponse(org.apache.cloudstack.api.response.VpcResponse) InstanceGroup(com.cloud.vm.InstanceGroup) InstanceGroupResponse(org.apache.cloudstack.api.response.InstanceGroupResponse) ApiResponseSerializer(com.cloud.api.response.ApiResponseSerializer) RemoteAccessVpnResponse(org.apache.cloudstack.api.response.RemoteAccessVpnResponse) Backup(org.apache.cloudstack.backup.Backup) ResourceLimit(com.cloud.configuration.ResourceLimit) Capability(com.cloud.network.Network.Capability) Site2SiteVpnGatewayResponse(org.apache.cloudstack.api.response.Site2SiteVpnGatewayResponse) PortableIpRangeResponse(org.apache.cloudstack.api.response.PortableIpRangeResponse) EntityManager(com.cloud.utils.db.EntityManager) VolumeResponse(org.apache.cloudstack.api.response.VolumeResponse) SearchBuilder(com.cloud.utils.db.SearchBuilder) UserAccountJoinVO(com.cloud.api.query.vo.UserAccountJoinVO) HashMap(java.util.HashMap) UserResponse(org.apache.cloudstack.api.response.UserResponse) Nic(com.cloud.vm.Nic) TemplateJoinVO(com.cloud.api.query.vo.TemplateJoinVO) DataStoreCapabilities(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities) Usage(org.apache.cloudstack.usage.Usage) AutoScaleVmProfileVO(com.cloud.network.as.AutoScaleVmProfileVO) AutoScalePolicy(com.cloud.network.as.AutoScalePolicy) CollectionUtils(org.apache.commons.collections.CollectionUtils) NetworkVO(com.cloud.network.dao.NetworkVO) VlanType(com.cloud.dc.Vlan.VlanType) GuestOsMappingResponse(org.apache.cloudstack.api.response.GuestOsMappingResponse) Region(org.apache.cloudstack.region.Region) NetworkOfferingJoinVO(com.cloud.api.query.vo.NetworkOfferingJoinVO) AffinityGroupResponse(org.apache.cloudstack.affinity.AffinityGroupResponse) AutoScaleVmGroup(com.cloud.network.as.AutoScaleVmGroup) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse) GPU(com.cloud.gpu.GPU) AnnotationService(org.apache.cloudstack.annotation.AnnotationService) PhysicalNetworkServiceProvider(com.cloud.network.PhysicalNetworkServiceProvider) FirewallResponse(org.apache.cloudstack.api.response.FirewallResponse) ResourceTagJoinVO(com.cloud.api.query.vo.ResourceTagJoinVO) DomainRouterJoinVO(com.cloud.api.query.vo.DomainRouterJoinVO) BackupOffering(org.apache.cloudstack.backup.BackupOffering) NetworkOffering(com.cloud.offering.NetworkOffering) HostPodVO(com.cloud.dc.HostPodVO) Configuration(org.apache.cloudstack.config.Configuration) ApplicationLoadBalancerResponse(org.apache.cloudstack.api.response.ApplicationLoadBalancerResponse) VpnUser(com.cloud.network.VpnUser) Volume(com.cloud.storage.Volume) AccountResponse(org.apache.cloudstack.api.response.AccountResponse) AccountJoinVO(com.cloud.api.query.vo.AccountJoinVO) DomainVO(com.cloud.domain.DomainVO) FirewallRuleVO(com.cloud.network.rules.FirewallRuleVO) Provider(com.cloud.network.Network.Provider) SecurityGroupRuleResponse(org.apache.cloudstack.api.response.SecurityGroupRuleResponse) VlanIpRangeResponse(org.apache.cloudstack.api.response.VlanIpRangeResponse) UserStatisticsVO(com.cloud.user.UserStatisticsVO) LoadBalancerResponse(org.apache.cloudstack.api.response.LoadBalancerResponse) VolumeVO(com.cloud.storage.VolumeVO) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) NetworkVO(com.cloud.network.dao.NetworkVO) NicExtraDhcpOptionResponse(org.apache.cloudstack.api.response.NicExtraDhcpOptionResponse) ArrayList(java.util.ArrayList) VMInstanceVO(com.cloud.vm.VMInstanceVO) NicExtraDhcpOptionVO(com.cloud.vm.NicExtraDhcpOptionVO) NicSecondaryIpResponse(org.apache.cloudstack.api.response.NicSecondaryIpResponse) NicSecondaryIpVO(com.cloud.vm.dao.NicSecondaryIpVO) NicVO(com.cloud.vm.NicVO) NicResponse(org.apache.cloudstack.api.response.NicResponse)

Example 53 with UserVmResponse

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

the class KeystoreTest method testUuid.

/*
        public void testKeystoreSave() throws Exception {
            KeystoreVO ksVo;

            ComponentLocator locator = ComponentLocator.getCurrentLocator();

            KeystoreDao ksDao = locator.getDao(KeystoreDao.class);
            ksDao.save("CPVMCertificate", "CPVMCertificate", "KeyForCertificate", "realhostip.com");
            ksVo = ksDao.findByName("CPVMCertificate");
            assertTrue(ksVo != null);
            assertTrue(ksVo.getCertificate().equals("CPVMCertificate"));
            assertTrue(ksVo.getKey().equals("KeyForCertificate"));
            assertTrue(ksVo.getDomainSuffix().equals("realhostip.com"));

            ksDao.save("CPVMCertificate", "CPVMCertificate Again", "KeyForCertificate Again", "again.realhostip.com");

            ksVo = ksDao.findByName("CPVMCertificate");
            assertTrue(ksVo != null);
            assertTrue(ksVo.getCertificate().equals("CPVMCertificate Again"));
            assertTrue(ksVo.getKey().equals("KeyForCertificate Again"));
            assertTrue(ksVo.getDomainSuffix().equals("again.realhostip.com"));

            ksDao.expunge(ksVo.getId());
        }

        public void testStripeKey() throws Exception {
            Pattern regex = Pattern.compile("(^[\\-]+[^\\-]+[\\-]+[\\n]?)([^\\-]+)([\\-]+[^\\-]+[\\-]+$)");
            Matcher m = regex.matcher("-----BEGIN RSA PRIVATE KEY-----\nMIIEpAIBAAKCAQEAm4bLUORp9oM65GV9XrPrbs+K563DjUR1M8mP1HaE+Y4lX5pk\nvQjC/xoEqSs5pxDDWXAkoexvxij8A4AWcsKU1Q+ep2E+GcytBoz8XINGvgb8cQNn\n/4PlVWKp7j5SDDNCfleYvmiRn8k6P4mxVJOHKzwb/IwQcKghyqAF1w==\n-----END RSA PRIVATE KEY-----");
            if(m.find()) {
                String content = m.group(2);
                assertTrue(content.startsWith("MIIEpAIBAAKCAQE"));
                assertTrue(content.endsWith("KghyqAF1w==\n"));
            } else {
                assertTrue(false);
            }
        }

        public void testKeystoreManager() throws Exception {
            ComponentLocator locator = ComponentLocator.getCurrentLocator();

            KeystoreManagerImpl ksMgr = ComponentLocator.inject(KeystoreManagerImpl.class);
            assertTrue(ksMgr.configure("TaskManager", new HashMap<String, Object>()));
            assertTrue(ksMgr.start());

            ksMgr.saveCertificate("CPVMCertificate", certContent, keyContent, "realhostip.com");

            byte[] ksBits = ksMgr.getKeystoreBits("CPVMCertificate", "realhostip", "vmops.com");
            assertTrue(ksBits != null);

            try {
                KeyStore ks = CertificateHelper.loadKeystore(ksBits, "vmops.com");
                assertTrue(ks != null);
            } catch(Exception e) {
                assertTrue(false);
            }

            KeystoreDao ksDao = locator.getDao(KeystoreDao.class);
            KeystoreVO ksVo = ksDao.findByName("CPVMCertificate");
            ksDao.expunge(ksVo.getId());
        }
    */
public void testUuid() {
    UserVmResponse vm = new UserVmResponse();
    vm.setId(Long.toString(3L));
    /*
                vm.setAccountName("admin");
                vm.setName("i-2-3-KY");
                vm.setDisplayName("i-2-3-KY");
                vm.setDomainId(1L);
                vm.setDomainName("ROOT");
                vm.setCreated(new Date());
                vm.setState("Running");
                vm.setZoneId(1L);
                vm.setZoneName("KY");
                vm.setHostId(1L);

                vm.setObjectName("virtualmachine");
        */
    String result = ApiSerializerHelper.toSerializedString(vm);
    System.out.println(result);
    // Object obj = ApiSerializerHelper.fromSerializedString(result);
    AlertResponse alert = new AlertResponse();
    alert.setId("100");
    alert.setDescription("Hello");
    result = ApiSerializerHelper.toSerializedString(alert);
    System.out.println(result);
    ApiSerializerHelper.fromSerializedString(result);
}
Also used : AlertResponse(org.apache.cloudstack.api.response.AlertResponse) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse)

Example 54 with UserVmResponse

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

the class QueryManagerImpl method searchForUserVMs.

@Override
public ListResponse<UserVmResponse> searchForUserVMs(ListVMsCmd cmd) {
    Pair<List<UserVmJoinVO>, Integer> result = searchForUserVMsInternal(cmd);
    ListResponse<UserVmResponse> response = new ListResponse<UserVmResponse>();
    ResponseView respView = ResponseView.Restricted;
    Account caller = CallContext.current().getCallingAccount();
    if (_accountMgr.isRootAdmin(caller.getId())) {
        respView = ResponseView.Full;
    }
    List<UserVmResponse> vmResponses = ViewResponseHelper.createUserVmResponse(respView, "virtualmachine", cmd.getDetails(), result.first().toArray(new UserVmJoinVO[result.first().size()]));
    response.setResponses(vmResponses, result.second());
    return response;
}
Also used : Account(com.cloud.user.Account) ResponseView(org.apache.cloudstack.api.ResponseObject.ResponseView) ListResponse(org.apache.cloudstack.api.response.ListResponse) ArrayList(java.util.ArrayList) List(java.util.List) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse) UserVmJoinVO(com.cloud.api.query.vo.UserVmJoinVO)

Example 55 with UserVmResponse

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

the class ViewResponseHelper method createUserVmResponse.

public static List<UserVmResponse> createUserVmResponse(ResponseView view, String objectName, EnumSet<VMDetails> details, UserVmJoinVO... userVms) {
    Account caller = CallContext.current().getCallingAccount();
    Hashtable<Long, UserVmResponse> vmDataList = new Hashtable<Long, UserVmResponse>();
    for (UserVmJoinVO userVm : userVms) {
        UserVmResponse userVmData = vmDataList.get(userVm.getId());
        if (userVmData == null) {
            // first time encountering this vm
            userVmData = ApiDBUtils.newUserVmResponse(view, objectName, userVm, details, caller);
        } else {
            // update nics, securitygroups, tags, affinitygroups for 1 to many mapping fields
            userVmData = ApiDBUtils.fillVmDetails(view, userVmData, userVm);
        }
        vmDataList.put(userVm.getId(), userVmData);
    }
    return new ArrayList<UserVmResponse>(vmDataList.values());
}
Also used : Account(com.cloud.user.Account) Hashtable(java.util.Hashtable) ArrayList(java.util.ArrayList) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse) UserVmJoinVO(com.cloud.api.query.vo.UserVmJoinVO)

Aggregations

UserVmResponse (org.apache.cloudstack.api.response.UserVmResponse)56 UserVm (com.cloud.uservm.UserVm)49 ServerApiException (org.apache.cloudstack.api.ServerApiException)43 ArrayList (java.util.ArrayList)19 VMDetails (org.apache.cloudstack.api.ApiConstants.VMDetails)12 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)8 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)7 ResourceUnavailableException (com.cloud.exception.ResourceUnavailableException)7 Account (com.cloud.user.Account)7 UserVmJoinVO (com.cloud.api.query.vo.UserVmJoinVO)6 VirtualMachine (com.cloud.vm.VirtualMachine)6 List (java.util.List)5 InsufficientCapacityException (com.cloud.exception.InsufficientCapacityException)4 InsufficientServerCapacityException (com.cloud.exception.InsufficientServerCapacityException)4 ManagementServerException (com.cloud.exception.ManagementServerException)4 VirtualMachineMigrationException (com.cloud.exception.VirtualMachineMigrationException)4 Host (com.cloud.host.Host)4 ServiceOffering (com.cloud.offering.ServiceOffering)4 DiskOfferingVO (com.cloud.storage.DiskOfferingVO)4 ResponseView (org.apache.cloudstack.api.ResponseObject.ResponseView)4