Search in sources :

Example 76 with StoragePoolVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.

the class ElastistorPrimaryDataStoreLifeCycle method initialize.

@Override
public DataStore initialize(Map<String, Object> dsInfos) {
    String url = (String) dsInfos.get("url");
    Long zoneId = (Long) dsInfos.get("zoneId");
    Long podId = (Long) dsInfos.get("podId");
    Long clusterId = (Long) dsInfos.get("clusterId");
    String storagePoolName = (String) dsInfos.get("name");
    String providerName = (String) dsInfos.get("providerName");
    Long capacityBytes = (Long) dsInfos.get("capacityBytes");
    Long capacityIops = (Long) dsInfos.get("capacityIops");
    String tags = (String) dsInfos.get("tags");
    boolean managed = (Boolean) dsInfos.get("managed");
    Map<String, String> details = (Map<String, String>) dsInfos.get("details");
    String domainName = details.get("domainname");
    String storageIp;
    int storagePort = 0;
    StoragePoolType storagetype = null;
    String accesspath = null;
    String protocoltype = null;
    String mountpoint = null;
    if (!managed) {
        storageIp = getStorageIp(url);
        storagePort = getDefaultStoragePort(url);
        storagetype = getStorageType(url);
        accesspath = getAccessPath(url);
        protocoltype = getProtocolType(url);
        String[] mp = accesspath.split("/");
        mountpoint = mp[1];
    } else if (details.get("hypervisortype") == "KVM") {
        storageIp = url;
        storagePort = 3260;
        storagetype = StoragePoolType.Iscsi;
        accesspath = storageIp + ":/" + storagePoolName;
    } else {
        storageIp = url;
        storagePort = 2049;
        storagetype = StoragePoolType.NetworkFilesystem;
        accesspath = storageIp + ":/" + storagePoolName;
    }
    /**
     * if the elastistor params which are required for plugin configuration
     * are not injected through spring-storage-volume-cloudbyte-context.xml,
     * it can be set from details map.
     */
    if (details.get("esaccountid") != null)
        ElastistorUtil.setElastistorAccountId(details.get("esaccountid"));
    if (details.get("esdefaultgateway") != null)
        ElastistorUtil.setElastistorGateway(details.get("esdefaultgateway"));
    if (details.get("estntinterface") != null)
        ElastistorUtil.setElastistorInterface(details.get("estntinterface"));
    if (details.get("espoolid") != null)
        ElastistorUtil.setElastistorPoolId(details.get("espoolid"));
    if (details.get("essubnet") != null)
        ElastistorUtil.setElastistorSubnet(details.get("essubnet"));
    s_logger.info("Elastistor details was set successfully.");
    if (capacityBytes == null || capacityBytes <= 0) {
        throw new IllegalArgumentException("'capacityBytes' must be present and greater than 0.");
    }
    if (capacityIops == null || capacityIops <= 0) {
        throw new IllegalArgumentException("'capacityIops' must be present and greater than 0.");
    }
    if (domainName == null) {
        domainName = "ROOT";
        s_logger.debug("setting the domain to ROOT");
    }
    // elastistor does not allow same name and ip pools.
    List<StoragePoolVO> storagePoolVO = _storagePoolDao.listAll();
    for (StoragePoolVO poolVO : storagePoolVO) {
        if (storagePoolName.equals(poolVO.getName())) {
            throw new IllegalArgumentException("Storage pool with this name already exists in elastistor, please specify a unique name. [name:" + storagePoolName + "]");
        }
        if (storageIp.equals(poolVO.getHostAddress())) {
            throw new IllegalArgumentException("Storage pool with this ip already exists in elastistor, please specify a unique ip. [ip:" + storageIp + "]");
        }
    }
    PrimaryDataStoreParameters parameters = new PrimaryDataStoreParameters();
    parameters.setHost(storageIp);
    parameters.setPort(storagePort);
    parameters.setPath(accesspath);
    parameters.setType(storagetype);
    parameters.setZoneId(zoneId);
    parameters.setPodId(podId);
    parameters.setName(storagePoolName);
    parameters.setProviderName(providerName);
    parameters.setManaged(managed);
    parameters.setCapacityBytes(capacityBytes);
    parameters.setUsedBytes(0);
    parameters.setCapacityIops(capacityIops);
    parameters.setHypervisorType(HypervisorType.Any);
    parameters.setTags(tags);
    parameters.setDetails(details);
    parameters.setClusterId(clusterId);
    Tsm tsm = null;
    if (managed) {
        // creates the TSM in elastistor
        tsm = createElastistorTSM(storagePoolName, storageIp, capacityBytes, capacityIops, domainName);
    } else {
        // creates the TSM & Volume in elastistor
        tsm = createElastistorTSM(storagePoolName, storageIp, capacityBytes, capacityIops, domainName);
        parameters = createElastistorVolume(parameters, tsm, storagePoolName, capacityBytes, capacityIops, protocoltype, mountpoint);
    }
    // setting tsm's uuid as storagepool's uuid
    parameters.setUuid(tsm.getUuid());
    return _dataStoreHelper.createPrimaryDataStore(parameters);
}
Also used : StoragePoolType(com.cloud.storage.Storage.StoragePoolType) Tsm(org.apache.cloudstack.storage.datastore.util.ElastistorUtil.Tsm) PrimaryDataStoreParameters(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStoreParameters) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) Map(java.util.Map)

Example 77 with StoragePoolVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.

the class ElastistorPrimaryDataStoreLifeCycle method updateStoragePool.

@Override
public void updateStoragePool(StoragePool storagePool, Map<String, String> details) {
    String capacityBytes = details.get(PrimaryDataStoreLifeCycle.CAPACITY_BYTES);
    String capacityIops = details.get(PrimaryDataStoreLifeCycle.CAPACITY_IOPS);
    StoragePoolVO storagePoolVO = _storagePoolDao.findById(storagePool.getId());
    try {
        if (capacityBytes != null) {
            long usedBytes = _capacityMgr.getUsedBytes(storagePoolVO);
            if (Long.parseLong(capacityBytes) < usedBytes) {
                throw new CloudRuntimeException("Cannot reduce the number of bytes for this storage pool as it would lead to an insufficient number of bytes");
            }
            UpdateTsmStorageCmdResponse updateTsmStorageCmdResponse = ElastistorUtil.updateElastistorTsmStorage(capacityBytes, storagePool.getUuid());
            if (updateTsmStorageCmdResponse.getStorage().getId() != null) {
                // update the cloudstack db
                _storagePoolDao.updateCapacityBytes(storagePool.getId(), Long.parseLong(capacityBytes));
                s_logger.info("elastistor TSM storage successfully updated");
            } else {
                throw new CloudRuntimeException("Failed to update the storage of Elastistor TSM" + updateTsmStorageCmdResponse.toString());
            }
        }
        if (capacityIops != null) {
            long usedIops = _capacityMgr.getUsedIops(storagePoolVO);
            long capacity = Long.parseLong(capacityIops);
            if (capacity < usedIops) {
                throw new CloudRuntimeException("Cannot reduce the number of IOPS for this storage pool as it would lead to an insufficient number of IOPS");
            }
            UpdateTsmCmdResponse updateTsmCmdResponse = ElastistorUtil.updateElastistorTsmIOPS(capacityIops, storagePool.getUuid());
            if (updateTsmCmdResponse.getTsm(0).getUuid() != null) {
                // update the cloudstack db
                _storagePoolDao.updateCapacityIops(storagePool.getId(), capacity);
                s_logger.info("elastistor TSM IOPS successfully updated");
            } else {
                throw new CloudRuntimeException("Failed to update the IOPS of Elastistor TSM" + updateTsmCmdResponse.toString());
            }
        }
    } catch (Throwable e) {
        throw new CloudRuntimeException("Failed to update the storage pool" + e);
    }
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) UpdateTsmStorageCmdResponse(org.apache.cloudstack.storage.datastore.util.ElastistorUtil.UpdateTsmStorageCmdResponse) UpdateTsmCmdResponse(org.apache.cloudstack.storage.datastore.util.ElastistorUtil.UpdateTsmCmdResponse)

Example 78 with StoragePoolVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.

the class QueryManagerImpl method searchForUserVMsInternal.

private Pair<List<UserVmJoinVO>, Integer> searchForUserVMsInternal(ListVMsCmd cmd) {
    Account caller = CallContext.current().getCallingAccount();
    List<Long> permittedAccounts = new ArrayList<Long>();
    boolean listAll = cmd.listAll();
    Long id = cmd.getId();
    Long userId = cmd.getUserId();
    Map<String, String> tags = cmd.getTags();
    Boolean display = cmd.getDisplay();
    Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
    _accountMgr.buildACLSearchParameters(caller, id, cmd.getAccountName(), cmd.getProjectId(), permittedAccounts, domainIdRecursiveListProject, listAll, false);
    Long domainId = domainIdRecursiveListProject.first();
    Boolean isRecursive = domainIdRecursiveListProject.second();
    ListProjectResourcesCriteria listProjectResourcesCriteria = domainIdRecursiveListProject.third();
    Filter searchFilter = new Filter(UserVmJoinVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal());
    List<Long> ids = null;
    if (cmd.getId() != null) {
        if (cmd.getIds() != null && !cmd.getIds().isEmpty()) {
            throw new InvalidParameterValueException("Specify either id or ids but not both parameters");
        }
        ids = new ArrayList<Long>();
        ids.add(cmd.getId());
    } else {
        ids = cmd.getIds();
    }
    // first search distinct vm id by using query criteria and pagination
    SearchBuilder<UserVmJoinVO> sb = _userVmJoinDao.createSearchBuilder();
    // select distinct ids
    sb.select(null, Func.DISTINCT, sb.entity().getId());
    _accountMgr.buildACLViewSearchBuilder(sb, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    String hypervisor = cmd.getHypervisor();
    Object name = cmd.getName();
    String state = cmd.getState();
    Object zoneId = cmd.getZoneId();
    Object keyword = cmd.getKeyword();
    boolean isAdmin = false;
    boolean isRootAdmin = false;
    if (_accountMgr.isAdmin(caller.getId())) {
        isAdmin = true;
    }
    if (_accountMgr.isRootAdmin(caller.getId())) {
        isRootAdmin = true;
    }
    Object groupId = cmd.getGroupId();
    Object networkId = cmd.getNetworkId();
    if (HypervisorType.getType(hypervisor) == HypervisorType.None && hypervisor != null) {
        // invalid hypervisor type input
        throw new InvalidParameterValueException("Invalid HypervisorType " + hypervisor);
    }
    Object templateId = cmd.getTemplateId();
    Object isoId = cmd.getIsoId();
    Object vpcId = cmd.getVpcId();
    Object affinityGroupId = cmd.getAffinityGroupId();
    Object keyPairName = cmd.getKeyPairName();
    Object serviceOffId = cmd.getServiceOfferingId();
    Object securityGroupId = cmd.getSecurityGroupId();
    Object backupOfferingId = cmd.getBackupOfferingId();
    Object isHaEnabled = cmd.getHaEnabled();
    Object pod = null;
    Long clusterId = null;
    Object hostId = null;
    Object storageId = null;
    if (_accountMgr.isRootAdmin(caller.getId())) {
        pod = cmd.getPodId();
        if (cmd instanceof ListVMsCmdByAdmin) {
            clusterId = ((ListVMsCmdByAdmin) cmd).getClusterId();
        }
        hostId = cmd.getHostId();
        storageId = cmd.getStorageId();
    }
    sb.and("displayName", sb.entity().getDisplayName(), SearchCriteria.Op.LIKE);
    sb.and("idIN", sb.entity().getId(), SearchCriteria.Op.IN);
    sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE);
    sb.and("stateEQ", sb.entity().getState(), SearchCriteria.Op.EQ);
    sb.and("stateNEQ", sb.entity().getState(), SearchCriteria.Op.NEQ);
    sb.and("stateNIN", sb.entity().getState(), SearchCriteria.Op.NIN);
    sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ);
    sb.and("podId", sb.entity().getPodId(), SearchCriteria.Op.EQ);
    sb.and("clusterId", sb.entity().getClusterId(), SearchCriteria.Op.EQ);
    sb.and("hypervisorType", sb.entity().getHypervisorType(), SearchCriteria.Op.EQ);
    sb.and("hostIdEQ", sb.entity().getHostId(), SearchCriteria.Op.EQ);
    sb.and("templateId", sb.entity().getTemplateId(), SearchCriteria.Op.EQ);
    sb.and("isoId", sb.entity().getIsoId(), SearchCriteria.Op.EQ);
    sb.and("instanceGroupId", sb.entity().getInstanceGroupId(), SearchCriteria.Op.EQ);
    if (serviceOffId != null) {
        sb.and("serviceOfferingId", sb.entity().getServiceOfferingId(), SearchCriteria.Op.EQ);
    }
    if (backupOfferingId != null) {
        sb.and("backupOfferingId", sb.entity().getBackupOfferingId(), SearchCriteria.Op.EQ);
    }
    if (display != null) {
        sb.and("display", sb.entity().isDisplayVm(), SearchCriteria.Op.EQ);
    }
    if (isHaEnabled != null) {
        sb.and("haEnabled", sb.entity().isHaEnabled(), SearchCriteria.Op.EQ);
    }
    if (groupId != null && (Long) groupId != -1) {
        sb.and("instanceGroupId", sb.entity().getInstanceGroupId(), SearchCriteria.Op.EQ);
    }
    if (userId != null) {
        sb.and("userId", sb.entity().getUserId(), SearchCriteria.Op.EQ);
    }
    if (networkId != null) {
        sb.and("networkId", sb.entity().getNetworkId(), SearchCriteria.Op.EQ);
    }
    if (vpcId != null && networkId == null) {
        sb.and("vpcId", sb.entity().getVpcId(), SearchCriteria.Op.EQ);
    }
    if (storageId != null) {
        StoragePoolVO poolVO = _storagePoolDao.findById((Long) storageId);
        if (poolVO.getPoolType() == Storage.StoragePoolType.DatastoreCluster) {
            sb.and("poolId", sb.entity().getPoolId(), SearchCriteria.Op.IN);
        } else {
            sb.and("poolId", sb.entity().getPoolId(), SearchCriteria.Op.EQ);
        }
    }
    if (affinityGroupId != null) {
        sb.and("affinityGroupId", sb.entity().getAffinityGroupId(), SearchCriteria.Op.EQ);
    }
    if (keyPairName != null) {
        sb.and("keyPairName", sb.entity().getKeypairName(), SearchCriteria.Op.EQ);
    }
    if (!isRootAdmin) {
        sb.and("displayVm", sb.entity().isDisplayVm(), SearchCriteria.Op.EQ);
    }
    if (securityGroupId != null) {
        sb.and("securityGroupId", sb.entity().getSecurityGroupId(), SearchCriteria.Op.EQ);
    }
    // populate the search criteria with the values passed in
    SearchCriteria<UserVmJoinVO> sc = sb.create();
    // building ACL condition
    _accountMgr.buildACLViewSearchCriteria(sc, domainId, isRecursive, permittedAccounts, listProjectResourcesCriteria);
    if (tags != null && !tags.isEmpty()) {
        SearchCriteria<UserVmJoinVO> tagSc = _userVmJoinDao.createSearchCriteria();
        for (Map.Entry<String, String> entry : tags.entrySet()) {
            SearchCriteria<UserVmJoinVO> tsc = _userVmJoinDao.createSearchCriteria();
            tsc.addAnd("tagKey", SearchCriteria.Op.EQ, entry.getKey());
            tsc.addAnd("tagValue", SearchCriteria.Op.EQ, entry.getValue());
            tagSc.addOr("tagKey", SearchCriteria.Op.SC, tsc);
        }
        sc.addAnd("tagKey", SearchCriteria.Op.SC, tagSc);
    }
    if (groupId != null && (Long) groupId != -1) {
        sc.setParameters("instanceGroupId", groupId);
    }
    if (keyword != null) {
        SearchCriteria<UserVmJoinVO> ssc = _userVmJoinDao.createSearchCriteria();
        ssc.addOr("displayName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        ssc.addOr("name", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        if (isRootAdmin) {
            ssc.addOr("instanceName", SearchCriteria.Op.LIKE, "%" + keyword + "%");
        }
        ssc.addOr("state", SearchCriteria.Op.EQ, keyword);
        sc.addAnd("displayName", SearchCriteria.Op.SC, ssc);
    }
    if (serviceOffId != null) {
        sc.setParameters("serviceOfferingId", serviceOffId);
    }
    if (backupOfferingId != null) {
        sc.setParameters("backupOfferingId", backupOfferingId);
    }
    if (securityGroupId != null) {
        sc.setParameters("securityGroupId", securityGroupId);
    }
    if (display != null) {
        sc.setParameters("display", display);
    }
    if (isHaEnabled != null) {
        sc.setParameters("haEnabled", isHaEnabled);
    }
    if (ids != null && !ids.isEmpty()) {
        sc.setParameters("idIN", ids.toArray());
    }
    if (templateId != null) {
        sc.setParameters("templateId", templateId);
    }
    if (isoId != null) {
        sc.setParameters("isoId", isoId);
    }
    if (userId != null) {
        sc.setParameters("userId", userId);
    }
    if (networkId != null) {
        sc.setParameters("networkId", networkId);
    }
    if (vpcId != null && networkId == null) {
        sc.setParameters("vpcId", vpcId);
    }
    if (name != null) {
        sc.setParameters("name", "%" + name + "%");
    }
    if (state != null) {
        if (state.equalsIgnoreCase("present")) {
            sc.setParameters("stateNIN", "Destroyed", "Expunging");
        } else {
            sc.setParameters("stateEQ", state);
        }
    }
    if (hypervisor != null) {
        sc.setParameters("hypervisorType", hypervisor);
    }
    // Don't show Destroyed and Expunging vms to the end user if the AllowUserViewDestroyedVM flag is not set.
    if (!isAdmin && !AllowUserViewDestroyedVM.valueIn(caller.getAccountId())) {
        sc.setParameters("stateNIN", "Destroyed", "Expunging");
    }
    if (zoneId != null) {
        sc.setParameters("dataCenterId", zoneId);
    }
    if (affinityGroupId != null) {
        sc.setParameters("affinityGroupId", affinityGroupId);
    }
    if (keyPairName != null) {
        sc.setParameters("keyPairName", keyPairName);
    }
    if (_accountMgr.isRootAdmin(caller.getId())) {
        if (cmd.getPodId() != null) {
            sc.setParameters("podId", pod);
            if (state == null) {
                sc.setParameters("stateNEQ", "Destroyed");
            }
        }
        if (clusterId != null) {
            sc.setParameters("clusterId", clusterId);
        }
        if (hostId != null) {
            sc.setParameters("hostIdEQ", hostId);
        }
        if (storageId != null) {
            StoragePoolVO poolVO = _storagePoolDao.findById((Long) storageId);
            if (poolVO.getPoolType() == Storage.StoragePoolType.DatastoreCluster) {
                List<StoragePoolVO> childDatastores = _storagePoolDao.listChildStoragePoolsInDatastoreCluster((Long) storageId);
                List<Long> childDatastoreIds = childDatastores.stream().map(mo -> mo.getId()).collect(Collectors.toList());
                sc.setParameters("poolId", childDatastoreIds.toArray());
            } else {
                sc.setParameters("poolId", storageId);
            }
        }
    }
    if (!isRootAdmin) {
        sc.setParameters("displayVm", 1);
    }
    // search vm details by ids
    Pair<List<UserVmJoinVO>, Integer> uniqueVmPair = _userVmJoinDao.searchAndDistinctCount(sc, searchFilter);
    Integer count = uniqueVmPair.second();
    if (count.intValue() == 0) {
        // handle empty result cases
        return uniqueVmPair;
    }
    List<UserVmJoinVO> uniqueVms = uniqueVmPair.first();
    Long[] vmIds = new Long[uniqueVms.size()];
    int i = 0;
    for (UserVmJoinVO v : uniqueVms) {
        vmIds[i++] = v.getId();
    }
    List<UserVmJoinVO> vms = _userVmJoinDao.searchByIds(vmIds);
    return new Pair<List<UserVmJoinVO>, Integer>(vms, count);
}
Also used : ServiceOfferingJoinVO(com.cloud.api.query.vo.ServiceOfferingJoinVO) ListTemplatesCmd(org.apache.cloudstack.api.command.user.template.ListTemplatesCmd) HostTagVO(com.cloud.api.query.vo.HostTagVO) ListProjectAccountsCmd(org.apache.cloudstack.api.command.user.account.ListProjectAccountsCmd) ListProjectResourcesCriteria(com.cloud.projects.Project.ListProjectResourcesCriteria) DomainManager(com.cloud.user.DomainManager) EventResponse(org.apache.cloudstack.api.response.EventResponse) TemplateDataStoreDao(org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao) StringUtils(org.apache.commons.lang3.StringUtils) ListIsosCmd(org.apache.cloudstack.api.command.user.iso.ListIsosCmd) RouterHealthCheckResult(com.cloud.network.RouterHealthCheckResult) DiskOffering(com.cloud.offering.DiskOffering) StoragePoolTagVO(com.cloud.storage.StoragePoolTagVO) Map(java.util.Map) StorageTagResponse(org.apache.cloudstack.api.response.StorageTagResponse) ListStorageTagsCmd(org.apache.cloudstack.api.command.admin.storage.ListStorageTagsCmd) ListZonesCmdByAdmin(org.apache.cloudstack.api.command.admin.zone.ListZonesCmdByAdmin) ListProjectInvitationsCmd(org.apache.cloudstack.api.command.user.project.ListProjectInvitationsCmd) DiskOfferingResponse(org.apache.cloudstack.api.response.DiskOfferingResponse) StoragePoolResponse(org.apache.cloudstack.api.response.StoragePoolResponse) QueryService(org.apache.cloudstack.query.QueryService) ProjectAccountJoinVO(com.cloud.api.query.vo.ProjectAccountJoinVO) ListInternalLBVMsCmd(org.apache.cloudstack.api.command.admin.internallb.ListInternalLBVMsCmd) ProjectInvitation(com.cloud.projects.ProjectInvitation) ProjectManager(com.cloud.projects.ProjectManager) ResourceTagVO(com.cloud.tags.ResourceTagVO) Stream(java.util.stream.Stream) Project(com.cloud.projects.Project) ServiceOfferingVO(com.cloud.service.ServiceOfferingVO) VolumeApiServiceImpl(com.cloud.storage.VolumeApiServiceImpl) ProjectInvitationJoinVO(com.cloud.api.query.vo.ProjectInvitationJoinVO) ResourceIconResponse(org.apache.cloudstack.api.response.ResourceIconResponse) AffinityGroupDomainMapDao(org.apache.cloudstack.affinity.dao.AffinityGroupDomainMapDao) VMTemplateDao(com.cloud.storage.dao.VMTemplateDao) ProjectInvitationDao(com.cloud.projects.dao.ProjectInvitationDao) DataCenterJoinVO(com.cloud.api.query.vo.DataCenterJoinVO) ResourceMetaDataService(com.cloud.server.ResourceMetaDataService) ImageStoreJoinVO(com.cloud.api.query.vo.ImageStoreJoinVO) UserDao(com.cloud.user.dao.UserDao) SearchCriteria(com.cloud.utils.db.SearchCriteria) DomainRouterVO(com.cloud.vm.DomainRouterVO) DomainRouterJoinDao(com.cloud.api.query.dao.DomainRouterJoinDao) User(com.cloud.user.User) DiskOfferingDetailsDao(org.apache.cloudstack.resourcedetail.dao.DiskOfferingDetailsDao) AffinityGroupVMMapDao(org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao) ListAccountsCmdByAdmin(org.apache.cloudstack.api.command.admin.account.ListAccountsCmdByAdmin) ListZonesCmd(org.apache.cloudstack.api.command.user.zone.ListZonesCmd) ResourceTag(com.cloud.server.ResourceTag) HostJoinVO(com.cloud.api.query.vo.HostJoinVO) ListUsersCmd(org.apache.cloudstack.api.command.admin.user.ListUsersCmd) ResourceTagResponse(org.apache.cloudstack.api.response.ResourceTagResponse) HighAvailabilityManager(com.cloud.ha.HighAvailabilityManager) CloudAuthenticationException(com.cloud.exception.CloudAuthenticationException) ProjectAccountResponse(org.apache.cloudstack.api.response.ProjectAccountResponse) DomainJoinDao(com.cloud.api.query.dao.DomainJoinDao) UserVmDao(com.cloud.vm.dao.UserVmDao) ListSecurityGroupsCmd(org.apache.cloudstack.api.command.user.securitygroup.ListSecurityGroupsCmd) ListDiskOfferingsCmd(org.apache.cloudstack.api.command.user.offering.ListDiskOfferingsCmd) ListDetailOptionsCmd(org.apache.cloudstack.api.command.user.resource.ListDetailOptionsCmd) ResourceDetail(org.apache.cloudstack.api.ResourceDetail) SecurityGroupResponse(org.apache.cloudstack.api.response.SecurityGroupResponse) ListVMsCmdByAdmin(org.apache.cloudstack.api.command.admin.vm.ListVMsCmdByAdmin) ConfigurationDao(org.apache.cloudstack.framework.config.dao.ConfigurationDao) ServiceOfferingResponse(org.apache.cloudstack.api.response.ServiceOfferingResponse) ListMgmtsCmd(org.apache.cloudstack.api.command.admin.management.ListMgmtsCmd) ListIterator(java.util.ListIterator) Date(java.util.Date) ListResourceIconCmd(org.apache.cloudstack.api.command.admin.resource.icon.ListResourceIconCmd) UserVmJoinVO(com.cloud.api.query.vo.UserVmJoinVO) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) StoragePoolDetailVO(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO) ResourceObjectType(com.cloud.server.ResourceTag.ResourceObjectType) InstanceGroupJoinVO(com.cloud.api.query.vo.InstanceGroupJoinVO) ResourceIconDao(com.cloud.resource.icon.dao.ResourceIconDao) VMInstanceVO(com.cloud.vm.VMInstanceVO) RouterHealthCheckResultDao(com.cloud.network.dao.RouterHealthCheckResultDao) ListIsosCmdByAdmin(org.apache.cloudstack.api.command.admin.iso.ListIsosCmdByAdmin) Pair(com.cloud.utils.Pair) Collectors(java.util.stream.Collectors) DiskOfferingVO(com.cloud.storage.DiskOfferingVO) VirtualMachineManager(com.cloud.vm.VirtualMachineManager) DedicatedResourceVO(com.cloud.dc.DedicatedResourceVO) DomainResponse(org.apache.cloudstack.api.response.DomainResponse) HostTagDao(com.cloud.api.query.dao.HostTagDao) VirtualMachine(com.cloud.vm.VirtualMachine) TemplateFilter(com.cloud.template.VirtualMachineTemplate.TemplateFilter) ProjectAccountJoinDao(com.cloud.api.query.dao.ProjectAccountJoinDao) ListDomainsCmdByAdmin(org.apache.cloudstack.api.command.admin.domain.ListDomainsCmdByAdmin) EventJoinDao(com.cloud.event.dao.EventJoinDao) DataStoreManager(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager) StoragePoolJoinDao(com.cloud.api.query.dao.StoragePoolJoinDao) DiskOfferingDao(com.cloud.storage.dao.DiskOfferingDao) SecurityGroupJoinVO(com.cloud.api.query.vo.SecurityGroupJoinVO) Domain(com.cloud.domain.Domain) GetRouterHealthCheckResultsCmd(org.apache.cloudstack.api.command.admin.router.GetRouterHealthCheckResultsCmd) HashSet(java.util.HashSet) Inject(javax.inject.Inject) ConfigKey(org.apache.cloudstack.framework.config.ConfigKey) VolumeJoinVO(com.cloud.api.query.vo.VolumeJoinVO) ManagementServerHostDao(com.cloud.cluster.dao.ManagementServerHostDao) AsyncJobJoinVO(com.cloud.api.query.vo.AsyncJobJoinVO) AsyncJobJoinDao(com.cloud.api.query.dao.AsyncJobJoinDao) ListImageStoresCmd(org.apache.cloudstack.api.command.admin.storage.ListImageStoresCmd) VolumeDao(com.cloud.storage.dao.VolumeDao) ImageStoreResponse(org.apache.cloudstack.api.response.ImageStoreResponse) PermissionDeniedException(com.cloud.exception.PermissionDeniedException) VMTemplateVO(com.cloud.storage.VMTemplateVO) DomainRouterResponse(org.apache.cloudstack.api.response.DomainRouterResponse) ListAffinityGroupsCmd(org.apache.cloudstack.api.command.user.affinitygroup.ListAffinityGroupsCmd) ZoneResponse(org.apache.cloudstack.api.response.ZoneResponse) ApiConstants(org.apache.cloudstack.api.ApiConstants) ProjectResponse(org.apache.cloudstack.api.response.ProjectResponse) TemplateState(org.apache.cloudstack.engine.subsystem.api.storage.TemplateState) DataStoreRole(com.cloud.storage.DataStoreRole) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) VMTemplateDetailsDao(com.cloud.storage.dao.VMTemplateDetailsDao) SecurityGroupJoinDao(com.cloud.api.query.dao.SecurityGroupJoinDao) ListHostsCmd(org.apache.cloudstack.api.command.admin.host.ListHostsCmd) HostTagResponse(org.apache.cloudstack.api.response.HostTagResponse) VirtualNetworkApplianceManager(com.cloud.network.router.VirtualNetworkApplianceManager) Arrays(java.util.Arrays) UserVmJoinDao(com.cloud.api.query.dao.UserVmJoinDao) ProjectJoinVO(com.cloud.api.query.vo.ProjectJoinVO) RouterHealthCheckResultVO(com.cloud.network.dao.RouterHealthCheckResultVO) ServiceOfferingDetailsDao(com.cloud.service.dao.ServiceOfferingDetailsDao) TemplateType(com.cloud.storage.Storage.TemplateType) ServiceOfferingDao(com.cloud.service.dao.ServiceOfferingDao) TemplateResponse(org.apache.cloudstack.api.response.TemplateResponse) SecurityGroupVMMapVO(com.cloud.network.security.SecurityGroupVMMapVO) Storage(com.cloud.storage.Storage) CallContext(org.apache.cloudstack.context.CallContext) EventJoinVO(com.cloud.api.query.vo.EventJoinVO) ResourceManager(com.cloud.resource.ResourceManager) HostJoinDao(com.cloud.api.query.dao.HostJoinDao) Set(java.util.Set) ProjectJoinDao(com.cloud.api.query.dao.ProjectJoinDao) ScopeType(com.cloud.storage.ScopeType) ListAccountsCmd(org.apache.cloudstack.api.command.user.account.ListAccountsCmd) StoragePoolJoinVO(com.cloud.api.query.vo.StoragePoolJoinVO) DomainJoinVO(com.cloud.api.query.vo.DomainJoinVO) ResourceDetailResponse(org.apache.cloudstack.api.response.ResourceDetailResponse) ImageStoreJoinDao(com.cloud.api.query.dao.ImageStoreJoinDao) ServiceOfferingJoinDao(com.cloud.api.query.dao.ServiceOfferingJoinDao) AccountDao(com.cloud.user.dao.AccountDao) ListResponse(org.apache.cloudstack.api.response.ListResponse) BaseListProjectAndAccountResourcesCmd(org.apache.cloudstack.api.BaseListProjectAndAccountResourcesCmd) NumbersUtil(com.cloud.utils.NumbersUtil) ListTagsCmd(org.apache.cloudstack.api.command.user.tag.ListTagsCmd) AffinityGroupDomainMapVO(org.apache.cloudstack.affinity.AffinityGroupDomainMapVO) ArrayList(java.util.ArrayList) DiskOfferingJoinDao(com.cloud.api.query.dao.DiskOfferingJoinDao) AffinityGroupJoinDao(com.cloud.api.query.dao.AffinityGroupJoinDao) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) AccountJoinDao(com.cloud.api.query.dao.AccountJoinDao) VolumeJoinDao(com.cloud.api.query.dao.VolumeJoinDao) SecurityGroupVMMapDao(com.cloud.network.security.dao.SecurityGroupVMMapDao) VMInstanceDao(com.cloud.vm.dao.VMInstanceDao) DomainRouterDao(com.cloud.vm.dao.DomainRouterDao) HypervisorType(com.cloud.hypervisor.Hypervisor.HypervisorType) Op(com.cloud.utils.db.SearchCriteria.Op) ProjectInvitationResponse(org.apache.cloudstack.api.response.ProjectInvitationResponse) ProjectDao(com.cloud.projects.dao.ProjectDao) InstanceGroupJoinDao(com.cloud.api.query.dao.InstanceGroupJoinDao) DiskOfferingJoinVO(com.cloud.api.query.vo.DiskOfferingJoinVO) ResourceTagDao(com.cloud.tags.dao.ResourceTagDao) AffinityGroupJoinVO(com.cloud.api.query.vo.AffinityGroupJoinVO) ProjectAccountDao(com.cloud.projects.dao.ProjectAccountDao) State(com.cloud.template.VirtualMachineTemplate.State) AccountManager(com.cloud.user.AccountManager) ListResourceDetailsCmd(org.apache.cloudstack.api.command.user.volume.ListResourceDetailsCmd) ImageFormat(com.cloud.storage.Storage.ImageFormat) ListServiceOfferingsCmd(org.apache.cloudstack.api.command.user.offering.ListServiceOfferingsCmd) StoragePoolTagsDao(com.cloud.storage.dao.StoragePoolTagsDao) RouterHealthCheckResultResponse(org.apache.cloudstack.api.response.RouterHealthCheckResultResponse) ListDomainsCmd(org.apache.cloudstack.api.command.admin.domain.ListDomainsCmd) DataStoreDriver(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreDriver) ManagementServerResponse(org.apache.cloudstack.api.response.ManagementServerResponse) Grouping(com.cloud.org.Grouping) Func(com.cloud.utils.db.SearchCriteria.Func) Filter(com.cloud.utils.db.Filter) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) UserAccountJoinDao(com.cloud.api.query.dao.UserAccountJoinDao) Logger(org.apache.log4j.Logger) JoinBuilder(com.cloud.utils.db.JoinBuilder) ResponseGenerator(org.apache.cloudstack.api.ResponseGenerator) ListStoragePoolsCmd(org.apache.cloudstack.api.command.admin.storage.ListStoragePoolsCmd) DomainDao(com.cloud.domain.dao.DomainDao) ResourceTagJoinDao(com.cloud.api.query.dao.ResourceTagJoinDao) ProjectVO(com.cloud.projects.ProjectVO) PrimaryDataStoreDao(org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao) ResourceManagerUtil(com.cloud.server.ResourceManagerUtil) HostResponse(org.apache.cloudstack.api.response.HostResponse) ListVolumesCmd(org.apache.cloudstack.api.command.user.volume.ListVolumesCmd) VpcVirtualNetworkApplianceService(com.cloud.network.VpcVirtualNetworkApplianceService) ListVMsCmd(org.apache.cloudstack.api.command.user.vm.ListVMsCmd) Account(com.cloud.user.Account) DedicatedResourceDao(com.cloud.dc.dao.DedicatedResourceDao) AsyncJobResponse(org.apache.cloudstack.api.response.AsyncJobResponse) ListRoutersCmd(org.apache.cloudstack.api.command.admin.router.ListRoutersCmd) List(java.util.List) DataCenterJoinDao(com.cloud.api.query.dao.DataCenterJoinDao) ListHostTagsCmd(org.apache.cloudstack.api.command.admin.host.ListHostTagsCmd) ACLType(org.apache.cloudstack.acl.ControlledEntity.ACLType) ListProjectsCmd(org.apache.cloudstack.api.command.user.project.ListProjectsCmd) ResponseView(org.apache.cloudstack.api.ResponseObject.ResponseView) InstanceGroupResponse(org.apache.cloudstack.api.response.InstanceGroupResponse) ListEventsCmd(org.apache.cloudstack.api.command.user.event.ListEventsCmd) TaggedResourceService(com.cloud.server.TaggedResourceService) DetailOptionsResponse(org.apache.cloudstack.api.response.DetailOptionsResponse) 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) TemplateJoinVO(com.cloud.api.query.vo.TemplateJoinVO) VmDetailConstants(com.cloud.vm.VmDetailConstants) DataStoreCapabilities(org.apache.cloudstack.engine.subsystem.api.storage.DataStoreCapabilities) StoragePoolDetailsDao(org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao) CollectionUtils(org.apache.commons.collections.CollectionUtils) Configurable(org.apache.cloudstack.framework.config.Configurable) ListSecondaryStagingStoresCmd(org.apache.cloudstack.api.command.admin.storage.ListSecondaryStagingStoresCmd) ListAsyncJobsCmd(org.apache.cloudstack.api.command.user.job.ListAsyncJobsCmd) AffinityGroupResponse(org.apache.cloudstack.affinity.AffinityGroupResponse) UserVmResponse(org.apache.cloudstack.api.response.UserVmResponse) ResourceTagJoinVO(com.cloud.api.query.vo.ResourceTagJoinVO) DomainRouterJoinVO(com.cloud.api.query.vo.DomainRouterJoinVO) AffinityGroupVMMapVO(org.apache.cloudstack.affinity.AffinityGroupVMMapVO) ManagementServerHostVO(com.cloud.cluster.ManagementServerHostVO) Hypervisor(com.cloud.hypervisor.Hypervisor) DateUtil(com.cloud.utils.DateUtil) TemplateJoinDao(com.cloud.api.query.dao.TemplateJoinDao) Component(org.springframework.stereotype.Component) UserVmVO(com.cloud.vm.UserVmVO) ProjectInvitationJoinDao(com.cloud.api.query.dao.ProjectInvitationJoinDao) Ternary(com.cloud.utils.Ternary) GenericSearchBuilder(com.cloud.utils.db.GenericSearchBuilder) Volume(com.cloud.storage.Volume) ListVMGroupsCmd(org.apache.cloudstack.api.command.user.vmgroup.ListVMGroupsCmd) AccountResponse(org.apache.cloudstack.api.response.AccountResponse) AccountJoinVO(com.cloud.api.query.vo.AccountJoinVO) DomainVO(com.cloud.domain.DomainVO) ListTemplatesCmdByAdmin(org.apache.cloudstack.api.command.admin.template.ListTemplatesCmdByAdmin) Collections(java.util.Collections) Account(com.cloud.user.Account) ArrayList(java.util.ArrayList) InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) ArrayList(java.util.ArrayList) List(java.util.List) Pair(com.cloud.utils.Pair) Ternary(com.cloud.utils.Ternary) UserVmJoinVO(com.cloud.api.query.vo.UserVmJoinVO) ListProjectResourcesCriteria(com.cloud.projects.Project.ListProjectResourcesCriteria) TemplateFilter(com.cloud.template.VirtualMachineTemplate.TemplateFilter) Filter(com.cloud.utils.db.Filter) ListVMsCmdByAdmin(org.apache.cloudstack.api.command.admin.vm.ListVMsCmdByAdmin) Map(java.util.Map) HashMap(java.util.HashMap)

Example 79 with StoragePoolVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.

the class StorageSystemDataMotionStrategyTest method cantHandleSecondary.

@Test
public void cantHandleSecondary() {
    lenient().doReturn(sourceStore).when(volumeObjectSource).getDataStore();
    doReturn(DataStoreRole.Primary).when(sourceStore).getRole();
    lenient().doReturn(destinationStore).when(dataObjectDestination).getDataStore();
    doReturn(DataStoreRole.Image).when((DataStore) destinationStore).getRole();
    doReturn(sourceStore).when(volumeObjectSource).getDataStore();
    doReturn(destinationStore).when(dataObjectDestination).getDataStore();
    StoragePoolVO storeVO = new StoragePoolVO();
    doReturn(storeVO).when(primaryDataStoreDao).findById(0l);
    assertTrue(strategy.canHandle(volumeObjectSource, dataObjectDestination) == StrategyPriority.CANT_HANDLE);
}
Also used : PrimaryDataStore(org.apache.cloudstack.engine.subsystem.api.storage.PrimaryDataStore) DataStore(org.apache.cloudstack.engine.subsystem.api.storage.DataStore) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) Test(org.junit.Test)

Example 80 with StoragePoolVO

use of org.apache.cloudstack.storage.datastore.db.StoragePoolVO in project cloudstack by apache.

the class StorageSystemDataMotionStrategyTest method shouldMigrateVolumeTest.

@Test
public void shouldMigrateVolumeTest() {
    StoragePoolVO sourceStoragePool = Mockito.spy(new StoragePoolVO());
    HostVO destHost = new HostVO("guid");
    StoragePoolVO destStoragePool = new StoragePoolVO();
    StoragePoolType[] storagePoolTypes = StoragePoolType.values();
    for (int i = 0; i < storagePoolTypes.length; i++) {
        Mockito.lenient().doReturn(storagePoolTypes[i]).when(sourceStoragePool).getPoolType();
        boolean result = strategy.shouldMigrateVolume(sourceStoragePool, destHost, destStoragePool);
        Assert.assertTrue(result);
    }
}
Also used : StoragePoolType(com.cloud.storage.Storage.StoragePoolType) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) HostVO(com.cloud.host.HostVO) Test(org.junit.Test)

Aggregations

StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)276 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)106 VMTemplateStoragePoolVO (com.cloud.storage.VMTemplateStoragePoolVO)75 ArrayList (java.util.ArrayList)54 VolumeVO (com.cloud.storage.VolumeVO)53 HostVO (com.cloud.host.HostVO)46 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)45 DataStore (org.apache.cloudstack.engine.subsystem.api.storage.DataStore)45 HashMap (java.util.HashMap)44 Answer (com.cloud.agent.api.Answer)38 VolumeInfo (org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo)35 StoragePool (com.cloud.storage.StoragePool)33 Test (org.junit.Test)33 VMInstanceVO (com.cloud.vm.VMInstanceVO)25 Map (java.util.Map)25 Account (com.cloud.user.Account)24 HypervisorType (com.cloud.hypervisor.Hypervisor.HypervisorType)20 ExecutionException (java.util.concurrent.ExecutionException)20 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)19 ClusterVO (com.cloud.dc.ClusterVO)18