Alona Kaplan has uploaded a new change for review. Change subject: engine: add getByNicId method to HostNicVfsConfigDao ......................................................................
engine: add getByNicId method to HostNicVfsConfigDao Change-Id: I349623fe0b049e931b35d08f7f360aeb2f62cb53 Signed-off-by: Alona Kaplan <[email protected]> --- M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDao.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoDbFacadeImpl.java M backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoTest.java M packaging/dbscripts/network_sp.sql 4 files changed, 48 insertions(+), 14 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/10/36610/1 diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDao.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDao.java index 1e01fac..969b8bb 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDao.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDao.java @@ -13,14 +13,22 @@ * * @param vfsConfigId * host nic vfs config id - * networkId - * network id * @return list of all the vfsConfig on this host * */ List<HostNicVfsConfig> getAllVfsConfigByHostId(Guid hostId); /** + * Retrieves the vfsConfig of the specified nic. + * + * @param nicId + * host nic vfs config id + * @return the vfsConfig of the specified nic + * + */ + HostNicVfsConfig getByNicId(Guid nicId); + + /** * Attaches a network to the allowed network list of the specified vfs config * * @param vfsConfigId diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoDbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoDbFacadeImpl.java index 022ba56..ad9ba2d 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoDbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoDbFacadeImpl.java @@ -66,18 +66,6 @@ } } - @Override - public HostNicVfsConfig get(Guid id) { - HostNicVfsConfig vfsConfig = super.get(id); - return vfsConfig; - } - - @Override - public List<HostNicVfsConfig> getAll() { - List<HostNicVfsConfig> allConfigs = super.getAll(); - return allConfigs; - } - private void fillNetworksAndLabelsDataOnConfig(HostNicVfsConfig vfsConfig) { if (vfsConfig == null) { return; @@ -129,6 +117,13 @@ } @Override + public HostNicVfsConfig getByNicId(Guid nicId) { + return getCallsHandler().executeRead("GetVfsConfigByNicId", + createEntityRowMapper(), + getCustomMapSqlParameterSource().addValue("nic_id", nicId)); + } + + @Override public void addNetwork(Guid vfsConfigId, Guid networkId) { getCallsHandler().executeModification("InsertvfsConfigNetwork", createNetworkParametersMapper(vfsConfigId, networkId)); diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoTest.java index 9be983e..a0eb20e 100644 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoTest.java +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/HostNicVfsConfigDaoTest.java @@ -95,6 +95,27 @@ } /** + * Ensures that a null hostNicVfsConfig is returned. + */ + @Test + public void testGetByNicWithInvalidNicId() { + HostNicVfsConfig result = dao.getByNicId(Guid.Empty); + + assertNull(result); + } + + /** + * Ensures that retrieving a hostNicVfsConfig by id works as expected. + */ + @Test + public void testGetByNicId() { + HostNicVfsConfig result = dao.getByNicId(FixturesTool.VDS_NETWORK_INTERFACE); + + assertNotNull(result); + assertEquals(FixturesTool.VDS_NETWORK_INTERFACE, result.getNicId()); + } + + /** * Ensures that saving a hostNicVfsConfig works as expected. No network and labels are added. */ @Test diff --git a/packaging/dbscripts/network_sp.sql b/packaging/dbscripts/network_sp.sql index b5a8964..b970230 100644 --- a/packaging/dbscripts/network_sp.sql +++ b/packaging/dbscripts/network_sp.sql @@ -1366,6 +1366,16 @@ LANGUAGE plpgsql; +Create or replace FUNCTION GetVfsConfigByNicId(v_nic_id UUID) RETURNS SETOF host_nic_vfs_config STABLE +AS $procedure$ +BEGIN + RETURN QUERY SELECT * + FROM host_nic_vfs_config + WHERE nic_id = v_nic_id; +END; $procedure$ +LANGUAGE plpgsql; + + Create or replace FUNCTION GetAllFromhostNicVfsConfigs() RETURNS SETOF host_nic_vfs_config STABLE AS $procedure$ BEGIN -- To view, visit http://gerrit.ovirt.org/36610 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I349623fe0b049e931b35d08f7f360aeb2f62cb53 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alona Kaplan <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
