// Licensed to the Apache Software Foundation (ASF) under one // or more contributor license agreements. See the NOTICE file // distributed with this work for additional information // regarding copyright ownership. The ASF licenses this file // to you under the Apache License, Version 2.0 (the // "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, // software distributed under the License is distributed on an // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. package com.cloud.storage.dao; import java.util.List; import com.cloud.hypervisor.Hypervisor.HypervisorType; import com.cloud.storage.ScopeType; import com.cloud.storage.Storage.ImageFormat; import com.cloud.storage.Volume; import com.cloud.storage.VolumeVO; import com.cloud.utils.Pair; import com.cloud.utils.db.GenericDao; import com.cloud.utils.fsm.StateDao; public interface VolumeDao extends GenericDao, StateDao { List findDetachedByAccount(long accountId); List findByAccount(long accountId); Pair getCountAndTotalByPool(long poolId); Pair getNonDestroyedCountAndTotalByPool(long poolId); List findByInstance(long id); List findByInstanceAndType(long id, Volume.Type vType); List findByInstanceIdDestroyed(long vmId); List findByAccountAndPod(long accountId, long podId); List findByTemplateAndZone(long templateId, long zoneId); void deleteVolumesByInstance(long instanceId); void attachVolume(long volumeId, long vmId, long deviceId); void detachVolume(long volumeId); boolean isAnyVolumeActivelyUsingTemplateOnPool(long templateId, long poolId); List findCreatedByInstance(long id); List findByPoolId(long poolId); List findByPoolId(long poolId, Volume.Type volumeType); List findByInstanceAndDeviceId(long instanceId, long deviceId); List findUsableVolumesForInstance(long instanceId); Long countAllocatedVolumesForAccount(long accountId); HypervisorType getHypervisorType(long volumeId); List listVolumesToBeDestroyed(); ImageFormat getImageFormat(Long volumeId); List findReadyRootVolumesByInstance(long instanceId); List listPoolIdsByVolumeCount(long dcId, Long podId, Long clusterId, long accountId); List listZoneWidePoolIdsByVolumeCount(long dcId, long accountId); /** * Gets the Total Primary Storage space allocated for an account * * @param account * @param list of ids of virtual router VMs under this account * @return total Primary Storage space (in bytes) used */ long primaryStorageUsedForAccount(long accountId, List virtualRouters); /** * Gets the Total Secondary Storage space used by volumes allocated for an * account * * @param account * @return total Secondary Storage space (in bytes) used */ long secondaryStorageUsedForAccount(long accountId); /*** * * @param volumeId * @return the scope of the storage pool where the volume is present (ZONE/CLUSTER) */ ScopeType getVolumeStoragePoolScope(long volumeId); }