Idan Shaby has uploaded a new change for review. Change subject: core: Empty Change CD List when ISO is Inactive ......................................................................
core: Empty Change CD List when ISO is Inactive The VM's Change CD list should be empty when the ISO domain in the DC is inactive. Change-Id: I784be2510e2f51be277f7ee06a5bd5573ab23d66 Bug-Url: https://bugzilla.redhat.com/1085398 Signed-off-by: Idan Shaby <ish...@redhat.com> --- M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageDomainDAO.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageDomainDAODbFacadeImpl.java M packaging/dbscripts/storages_sp.sql 3 files changed, 33 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/31/34031/1 diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageDomainDAO.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageDomainDAO.java index b2657a9..5d53a94 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageDomainDAO.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageDomainDAO.java @@ -4,6 +4,7 @@ import org.ovirt.engine.core.common.businessentities.ActionGroup; import org.ovirt.engine.core.common.businessentities.StorageDomain; +import org.ovirt.engine.core.common.businessentities.StorageDomainStatus; import org.ovirt.engine.core.common.businessentities.StorageDomainType; import org.ovirt.engine.core.compat.Guid; @@ -34,6 +35,15 @@ StorageDomain getStorageDomain(Guid pool, StorageDomainType type); /** + * Retrieves the storage domain for the specified pool, type and status. + * @param pool The storage pool. + * @param type The storage domain type. + * @param status The storage domain status. + * @return the storage domain for the specified pool, type and status. + */ + StorageDomain getStorageDomain(Guid pool, StorageDomainType type, StorageDomainStatus status); + + /** * Retrieves the master storage domain for the specified pool. * * @param pool diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageDomainDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageDomainDAODbFacadeImpl.java index cab1c91..b3d2b76 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageDomainDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/StorageDomainDAODbFacadeImpl.java @@ -28,16 +28,22 @@ @Override public StorageDomain getStorageDomain(Guid pool, StorageDomainType type) { - return getCallsHandler().executeRead("Getstorage_domain_by_type_and_storagePoolId", + return getStorageDomain(pool, type, null); + } + + public StorageDomain getStorageDomain(Guid pool, StorageDomainType type, StorageDomainStatus status) { + Integer statusNum = status == null ? null : status.getValue(); + return getCallsHandler().executeRead("Getstorage_domain_by_type_storagePoolId_and_status", StorageDomainRowMapper.instance, getCustomMapSqlParameterSource() .addValue("storage_pool_id", pool) - .addValue("storage_domain_type", type.getValue())); + .addValue("storage_domain_type", type.getValue()) + .addValue("status", statusNum)); } @Override public Guid getIsoStorageDomainIdForPool(Guid pool) { - return getStorageDomainId(pool, StorageDomainType.ISO); + return getStorageDomainId(pool, StorageDomainType.ISO, StorageDomainStatus.Active); } @Override @@ -219,8 +225,18 @@ * @return the storage domain id of the given type for the given storage pool id. */ private Guid getStorageDomainId(Guid poolId, StorageDomainType type) { + return getStorageDomainId(poolId, type, null); + } + + /** + * Gets the storage domain id of the given type for the given storage pool id. + * @param poolId The storage pool id, + * @param type The Storage domain type. + * @return the storage domain id of the given type for the given storage pool id. + */ + private Guid getStorageDomainId(Guid poolId, StorageDomainType type, StorageDomainStatus status) { Guid returnValue = Guid.Empty; - StorageDomain domain = getStorageDomain(poolId, type); + StorageDomain domain = getStorageDomain(poolId, type, status); if (domain != null) { returnValue = domain.getId(); } diff --git a/packaging/dbscripts/storages_sp.sql b/packaging/dbscripts/storages_sp.sql index 8ce7d4d..f81921a 100644 --- a/packaging/dbscripts/storages_sp.sql +++ b/packaging/dbscripts/storages_sp.sql @@ -628,14 +628,15 @@ LANGUAGE plpgsql; -Create or replace FUNCTION Getstorage_domain_by_type_and_storagePoolId(v_storage_domain_type INTEGER, v_storage_pool_id UUID) +Create or replace FUNCTION Getstorage_domain_by_type_storagePoolId_and_status(v_storage_domain_type INTEGER, v_storage_pool_id UUID, v_status INTEGER) RETURNS SETOF storage_domains STABLE AS $procedure$ BEGIN RETURN QUERY SELECT * FROM storage_domains WHERE storage_pool_id = v_storage_pool_id - AND storage_domain_type = v_storage_domain_type; + AND storage_domain_type = v_storage_domain_type + AND (v_status IS NULL OR status = v_status); END; $procedure$ LANGUAGE plpgsql; -- To view, visit http://gerrit.ovirt.org/34031 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I784be2510e2f51be277f7ee06a5bd5573ab23d66 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Idan Shaby <ish...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches