Moti Asayag has uploaded a new change for review. Change subject: engine: Add labels to host interface ......................................................................
engine: Add labels to host interface Adding the labels property to the host nic entity to manage the networks to be attach to the nic by that label. Change-Id: I6552eb2b8414c7cff77407872ae72bd0ae72f8c2 Signed-off-by: Moti Asayag <masa...@redhat.com> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VdsNetworkInterface.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/InterfaceDaoDbFacadeImpl.java M backend/manager/modules/dal/src/test/resources/fixtures.xml M packaging/dbscripts/create_views.sql M packaging/dbscripts/network_sp.sql A packaging/dbscripts/upgrade/03_04_0310_add_labels_column_to_vds_interfaces.sql 6 files changed, 41 insertions(+), 11 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/35/22635/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VdsNetworkInterface.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VdsNetworkInterface.java index f3e22d6..ce25e40 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VdsNetworkInterface.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/network/VdsNetworkInterface.java @@ -1,6 +1,7 @@ package org.ovirt.engine.core.common.businessentities.network; import java.io.Serializable; +import java.util.Set; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; @@ -39,10 +40,9 @@ private Integer bondType; private String bondOptions; private int mtu; - private boolean bridged; - private NetworkImplementationDetails networkImplementationDetails; + private Set<String> labels; public VdsNetworkInterface() { super(new VdsNetworkStatistics(), VdsInterfaceType.NONE.getValue()); @@ -323,6 +323,14 @@ this.networkImplementationDetails = networkImplementationDetails; } + public Set<String> getLabels() { + return labels; + } + + public void setLabels(Set<String> labels) { + this.labels = labels; + } + @Override public String toString() { StringBuilder builder = new StringBuilder(); @@ -361,6 +369,8 @@ .append(getType()) .append(", networkImplementationDetails=") .append(getNetworkImplementationDetails()) + .append(", labels=") + .append(labels) .append("}"); return builder.toString(); } @@ -382,6 +392,7 @@ result = prime * result + ((subnet == null) ? 0 : subnet.hashCode()); result = prime * result + ((vdsId == null) ? 0 : vdsId.hashCode()); result = prime * result + ((vlanId == null) ? 0 : vlanId.hashCode()); + result = prime * result + ((labels == null) ? 0 : labels.hashCode()); return result; } @@ -472,6 +483,10 @@ } else if (!vlanId.equals(other.vlanId)) { return false; } + if (!ObjectUtils.objectsEqual(labels, other.labels)) { + return false; + } + return true; } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/InterfaceDaoDbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/InterfaceDaoDbFacadeImpl.java index f7b92cf..d679843 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/InterfaceDaoDbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/network/InterfaceDaoDbFacadeImpl.java @@ -4,6 +4,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.Collection; +import java.util.HashSet; import java.util.List; import org.ovirt.engine.core.common.businessentities.network.Bond; @@ -16,6 +17,7 @@ import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.dal.dbbroker.MapSqlParameterMapper; import org.ovirt.engine.core.dao.BaseDAODbFacade; +import org.ovirt.engine.core.utils.SerializationFactory; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; @@ -56,7 +58,8 @@ .addValue("vds_id", entity.getVdsId()) .addValue("vlan_id", entity.getVlanId()) .addValue("mtu", entity.getMtu()) - .addValue("bridged", entity.isBridged()); + .addValue("bridged", entity.isBridged()) + .addValue("labels", SerializationFactory.getSerializer().serialize(entity.getLabels())); return paramValue; } }); @@ -89,7 +92,8 @@ .addValue("vds_id", stats.getVdsId()) .addValue("vlan_id", stats.getVlanId()) .addValue("mtu", stats.getMtu()) - .addValue("bridged", stats.isBridged()); + .addValue("bridged", stats.isBridged()) + .addValue("labels", SerializationFactory.getSerializer().serialize(stats.getLabels())); getCallsHandler().executeModification("Insertvds_interface", parameterSource); } @@ -157,7 +161,8 @@ .addValue("vds_id", stats.getVdsId()) .addValue("vlan_id", stats.getVlanId()) .addValue("mtu", stats.getMtu()) - .addValue("bridged", stats.isBridged()); + .addValue("bridged", stats.isBridged()) + .addValue("labels", SerializationFactory.getSerializer().serialize(stats.getLabels())); getCallsHandler().executeModification("Updatevds_interface", parameterSource); } @@ -229,6 +234,7 @@ private static final RowMapper<VdsNetworkInterface> vdsNetworkInterfaceRowMapper = new RowMapper<VdsNetworkInterface>() { + @SuppressWarnings("unchecked") @Override public VdsNetworkInterface mapRow(ResultSet rs, int rowNum) throws SQLException { @@ -252,6 +258,8 @@ entity.setBootProtocol(NetworkBootProtocol.forValue(rs.getInt("boot_protocol"))); entity.setMtu(rs.getInt("mtu")); entity.setBridged(rs.getBoolean("bridged")); + entity.setLabels(SerializationFactory.getDeserializer().deserialize(rs.getString("labels"), + HashSet.class)); return entity; } diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml b/backend/manager/modules/dal/src/test/resources/fixtures.xml index 78735b1..00c483a 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -4000,6 +4000,7 @@ <column>_create_date</column> <column>_update_date</column> <column>bond_opts</column> + <column>labels</column> <row> <value>ba31682e-6ae7-4f9d-8c6f-04c93acca9db</value> <value>eth0</value> @@ -4018,6 +4019,7 @@ <value>2</value> <value>2010-11-12 10:12:41</value> <value>2010-11-12 15:57:01</value> + <null /> <null /> </row> <row> @@ -4039,6 +4041,7 @@ <value>2012-11-12 10:12:41</value> <value>2012-11-12 15:57:01</value> <null /> + <null /> </row> <row> <value>ba31682e-6ae7-4f9d-8c6f-04c93acca9de</value> @@ -4059,6 +4062,7 @@ <value>2012-11-12 10:12:41</value> <value>2012-11-12 15:57:01</value> <null /> + <null /> </row> </table> diff --git a/packaging/dbscripts/create_views.sql b/packaging/dbscripts/create_views.sql index e138bfb..2d46408 100644 --- a/packaging/dbscripts/create_views.sql +++ b/packaging/dbscripts/create_views.sql @@ -870,7 +870,7 @@ vds_interface.subnet, vds_interface.addr, vds_interface.speed, vds_interface.vlan_id, vds_interface.bond_type, vds_interface.bond_name, vds_interface.is_bond, vds_interface.bond_opts, vds_interface.mac_addr, vds_interface.network_name, vds_interface.name, vds_static.vds_id, vds_static.vds_name, vds_interface.id, - vds_interface.boot_protocol, vds_interface.mtu as mtu, vds_interface.bridged, 1 AS is_vds + vds_interface.boot_protocol, vds_interface.mtu as mtu, vds_interface.bridged, 1 AS is_vds, vds_interface.labels as labels FROM vds_interface_statistics JOIN vds_interface ON vds_interface_statistics.id = vds_interface.id JOIN vds_static ON vds_interface.vds_id = vds_static.vds_id; diff --git a/packaging/dbscripts/network_sp.sql b/packaging/dbscripts/network_sp.sql index 15b4c2e..00a314d 100644 --- a/packaging/dbscripts/network_sp.sql +++ b/packaging/dbscripts/network_sp.sql @@ -294,12 +294,13 @@ v_vds_id UUID, v_vlan_id INTEGER, v_mtu INTEGER, - v_bridged BOOLEAN) + v_bridged BOOLEAN, + v_labels TEXT) RETURNS VOID AS $procedure$ BEGIN -INSERT INTO vds_interface(addr, bond_name, bond_type, gateway, id, is_bond, bond_opts, mac_addr, name, network_name, speed, subnet, boot_protocol, type, VDS_ID, vlan_id, mtu, bridged) - VALUES(v_addr, v_bond_name, v_bond_type, v_gateway, v_id, v_is_bond, v_bond_opts, v_mac_addr, v_name, v_network_name, v_speed, v_subnet, v_boot_protocol, v_type, v_vds_id, v_vlan_id, v_mtu, v_bridged); +INSERT INTO vds_interface(addr, bond_name, bond_type, gateway, id, is_bond, bond_opts, mac_addr, name, network_name, speed, subnet, boot_protocol, type, VDS_ID, vlan_id, mtu, bridged, labels) + VALUES(v_addr, v_bond_name, v_bond_type, v_gateway, v_id, v_is_bond, v_bond_opts, v_mac_addr, v_name, v_network_name, v_speed, v_subnet, v_boot_protocol, v_type, v_vds_id, v_vlan_id, v_mtu, v_bridged, v_labels); END; $procedure$ LANGUAGE plpgsql; @@ -324,7 +325,8 @@ v_vds_id UUID, v_vlan_id INTEGER, v_mtu INTEGER, - v_bridged BOOLEAN) + v_bridged BOOLEAN, + v_labels TEXT) RETURNS VOID --The [vds_interface] table doesn't have a timestamp column. Optimistic concurrency logic cannot be generated @@ -336,7 +338,7 @@ name = v_name,network_name = v_network_name,speed = v_speed, subnet = v_subnet,boot_protocol = v_boot_protocol, type = v_type,VDS_ID = v_vds_id,vlan_id = v_vlan_id,_update_date = LOCALTIMESTAMP, mtu = v_mtu, - bridged = v_bridged + bridged = v_bridged, labels = v_labels WHERE id = v_id; END; $procedure$ LANGUAGE plpgsql; diff --git a/packaging/dbscripts/upgrade/03_04_0310_add_labels_column_to_vds_interfaces.sql b/packaging/dbscripts/upgrade/03_04_0310_add_labels_column_to_vds_interfaces.sql new file mode 100644 index 0000000..9fd6a88 --- /dev/null +++ b/packaging/dbscripts/upgrade/03_04_0310_add_labels_column_to_vds_interfaces.sql @@ -0,0 +1 @@ +select fn_db_add_column('vds_interface', 'labels', 'text'); -- To view, visit http://gerrit.ovirt.org/22635 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6552eb2b8414c7cff77407872ae72bd0ae72f8c2 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Moti Asayag <masa...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches