Alona Kaplan has uploaded a new change for review. Change subject: engine: add network_qos_id to vnic_profile table ......................................................................
engine: add network_qos_id to vnic_profile table In this patch- - Adding network_qos_id to profiles table. - Making network_qos_id FK (points to network_qos.id). - Adding network_qos_id to profiles_view. - Updating the relevant dao's. Change-Id: I26327fe3dd6d0af3bf7050e04e780f27e9a4bfe9 Signed-off-by: Alona Kaplan <alkap...@redhat.com> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfile.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfileView.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileViewDaoDbFacadeImpl.java M backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/VnicProfileDaoTest.java M packaging/dbscripts/create_views.sql M packaging/dbscripts/network_sp.sql A packaging/dbscripts/upgrade/03_03_0750_add_network_qos_id_to_vnic_profiles.sql 8 files changed, 50 insertions(+), 5 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/25/17925/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfile.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfile.java index 61329bd..58cac18 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfile.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfile.java @@ -27,6 +27,8 @@ private String name; @NotNull(groups = { CreateEntity.class, UpdateEntity.class }) private Guid networkId; + private Guid networkQoSId; + private boolean portMirroring; private String description; private Map<String, String> customProperties; @@ -74,6 +76,14 @@ this.networkId = networkId; } + public Guid getNetworkQoSId() { + return networkQoSId; + } + + public void setNetworkQoSId(Guid networkQoSId) { + this.networkQoSId = networkQoSId; + } + public String getDescription() { return description; } @@ -94,6 +104,7 @@ result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getName() == null) ? 0 : getName().hashCode()); result = prime * result + ((getNetworkId() == null) ? 0 : getNetworkId().hashCode()); + result = prime * result + ((getNetworkQoSId() == null) ? 0 : getNetworkQoSId().hashCode()); result = prime * result + (isPortMirroring() ? 1231 : 1237); result = prime * result + ((getDescription() == null) ? 0 : getDescription().hashCode()); return result; @@ -123,6 +134,9 @@ if (!ObjectUtils.objectsEqual(getNetworkId(), other.getNetworkId())) { return false; } + if (!ObjectUtils.objectsEqual(getNetworkQoSId(), other.getNetworkQoSId())) { + return false; + } if (isPortMirroring() != other.isPortMirroring()) { return false; } @@ -140,6 +154,8 @@ .append(getId()) .append(", networkId=") .append(getNetworkId()) + .append(", networkQoSId=") + .append(getNetworkQoSId()) .append(", portMirroring=") .append(isPortMirroring()) .append(", customProperties=") diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfileView.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfileView.java index 3992266..3bd4df8 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfileView.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VnicProfileView.java @@ -2,11 +2,11 @@ import org.ovirt.engine.core.compat.Version; - public class VnicProfileView extends VnicProfile { private static final long serialVersionUID = -7873671947250939737L; private String networkName; + private String networkQoSName; private String dataCenterName; private Version compatibilityVersion; @@ -16,6 +16,14 @@ public void setNetworkName(String networkName) { this.networkName = networkName; + } + + public String getNetworkQoSName() { + return networkQoSName; + } + + public void setNetworkQoSName(String networkQoSName) { + this.networkQoSName = networkQoSName; } public String getDataCenterName() { @@ -41,6 +49,7 @@ result = prime * result + ((getCompatibilityVersion() == null) ? 0 : getCompatibilityVersion().hashCode()); result = prime * result + ((getDataCenterName() == null) ? 0 : getDataCenterName().hashCode()); result = prime * result + ((getNetworkName() == null) ? 0 : getNetworkName().hashCode()); + result = prime * result + ((getNetworkQoSName() == null) ? 0 : getNetworkQoSName().hashCode()); return result; } @@ -77,7 +86,13 @@ } else if (!getNetworkName().equals(other.getNetworkName())) { return false; } + if (getNetworkQoSName() == null) { + if (other.getNetworkQoSName() != null) { + return false; + } + } else if (!getNetworkQoSName().equals(other.getNetworkQoSName())) { + return false; + } return true; } } - diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java index d860602..0320f71 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileDaoDbFacadeImpl.java @@ -30,6 +30,7 @@ return createIdParameterMapper(profile.getId()) .addValue("name", profile.getName()) .addValue("network_id", profile.getNetworkId()) + .addValue("network_qos_id", profile.getNetworkQoSId()) .addValue("port_mirroring", profile.isPortMirroring()) .addValue("description", profile.getDescription()) .addValue("custom_properties", @@ -55,6 +56,7 @@ entity.setId(getGuid(rs, "id")); entity.setName(rs.getString("name")); entity.setNetworkId(getGuid(rs, "network_id")); + entity.setNetworkQoSId(getGuid(rs, "network_qos_id")); entity.setCustomProperties(SerializationFactory.getDeserializer() .deserializeOrCreateNew(rs.getString("custom_properties"), LinkedHashMap.class)); entity.setPortMirroring(rs.getBoolean("port_mirroring")); diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileViewDaoDbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileViewDaoDbFacadeImpl.java index cd8d0d9..15fba98 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileViewDaoDbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/VnicProfileViewDaoDbFacadeImpl.java @@ -88,6 +88,7 @@ public VnicProfileView mapRow(ResultSet rs, int rowNum) throws SQLException { VnicProfileView entity = super.mapRow(rs, rowNum); entity.setNetworkName(rs.getString("network_name")); + entity.setNetworkQoSName(rs.getString("network_qos_name")); entity.setDataCenterName(rs.getString("data_center_name")); entity.setCompatibilityVersion(new Version(rs.getString("compatibility_version"))); return entity; diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/VnicProfileDaoTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/VnicProfileDaoTest.java index 3113172..1536598 100644 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/VnicProfileDaoTest.java +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/VnicProfileDaoTest.java @@ -28,6 +28,7 @@ vnicProfile.setId(Guid.newGuid()); vnicProfile.setName("new_profile"); vnicProfile.setNetworkId(FixturesTool.NETWORK_ENGINE); + vnicProfile.setNetworkQoSId(Guid.newGuid()); vnicProfile.setPortMirroring(false); } diff --git a/packaging/dbscripts/create_views.sql b/packaging/dbscripts/create_views.sql index b54a803..e6c71ea 100644 --- a/packaging/dbscripts/create_views.sql +++ b/packaging/dbscripts/create_views.sql @@ -1140,15 +1140,19 @@ SELECT vnic_profiles.id AS id, vnic_profiles.name AS name, vnic_profiles.network_id as network_id, + vnic_profiles.network_qos_id as network_qos_id, vnic_profiles.port_mirroring as port_mirroring, vnic_profiles.custom_properties as custom_properties, vnic_profiles.description as description, network.name as network_name, + network_qos.name as network_qos_name, storage_pool.name as data_center_name, storage_pool.compatibility_version as compatibility_version, storage_pool.id as data_center_id FROM vnic_profiles + INNER JOIN network ON vnic_profiles.network_id = network.id +INNER JOIN network_qos ON vnic_profiles.network_qos_id = network_qos.id INNER JOIN storage_pool ON network.storage_pool_id = storage_pool.id; diff --git a/packaging/dbscripts/network_sp.sql b/packaging/dbscripts/network_sp.sql index bdf6945..395fdec 100644 --- a/packaging/dbscripts/network_sp.sql +++ b/packaging/dbscripts/network_sp.sql @@ -1040,6 +1040,7 @@ Create or replace FUNCTION InsertVnicProfile(v_id UUID, v_name VARCHAR(50), v_network_id UUID, + v_network_qos_id UUID, v_port_mirroring BOOLEAN, v_custom_properties TEXT, v_description TEXT) @@ -1047,8 +1048,8 @@ AS $procedure$ BEGIN - INSERT INTO vnic_profiles(id, name, network_id, port_mirroring, custom_properties, description) - VALUES(v_id, v_name, v_network_id, v_port_mirroring, v_custom_properties, v_description); + INSERT INTO vnic_profiles(id, name, network_id, network_qos_id, port_mirroring, custom_properties, description) + VALUES(v_id, v_name, v_network_id, v_network_qos_id, v_port_mirroring, v_custom_properties, v_description); END; $procedure$ LANGUAGE plpgsql; @@ -1057,6 +1058,7 @@ Create or replace FUNCTION UpdateVnicProfile(v_id UUID, v_name VARCHAR(50), v_network_id UUID, + v_network_qos_id UUID, v_port_mirroring BOOLEAN, v_custom_properties TEXT, v_description TEXT) @@ -1065,7 +1067,7 @@ BEGIN UPDATE vnic_profiles - SET id = v_id, name = v_name, network_id = v_network_id, + SET id = v_id, name = v_name, network_id = v_network_id, network_qos_id = v_network_qos_id, port_mirroring = v_port_mirroring, custom_properties = v_custom_properties, description = v_description,_update_date = LOCALTIMESTAMP WHERE id = v_id; diff --git a/packaging/dbscripts/upgrade/03_03_0750_add_network_qos_id_to_vnic_profiles.sql b/packaging/dbscripts/upgrade/03_03_0750_add_network_qos_id_to_vnic_profiles.sql new file mode 100644 index 0000000..685a79a --- /dev/null +++ b/packaging/dbscripts/upgrade/03_03_0750_add_network_qos_id_to_vnic_profiles.sql @@ -0,0 +1,4 @@ +select fn_db_add_column('vnic_profiles', 'network_qos_id', 'UUID'); +DROP INDEX IF EXISTS IDX_vnic_profiles_network_qos_id; +CREATE INDEX IDX_vnic_profiles_network_qos_id ON vnic_profiles(network_qos_id); +select fn_db_create_constraint('vnic_profiles', 'FK_vnic_profiles_network_qos_id', 'FOREIGN KEY (network_qos_id) REFERENCES network_qos(id)'); -- To view, visit http://gerrit.ovirt.org/17925 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I26327fe3dd6d0af3bf7050e04e780f27e9a4bfe9 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alona Kaplan <alkap...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches