Liron Aravot has uploaded a new change for review. Change subject: db: add logical_name to vm_device ......................................................................
db: add logical_name to vm_device This patch adds the logical_name column to the vm_device table, the intention is to store in it the device logical name as retrieved from the guest. Change-Id: If9b5a8e771a05c1fe44834adfe998cf921f6ae52 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1063597 Signed-off-by: Liron Aravot <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AttachDiskToVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllDisksByVmIdQueryTest.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetWatchdogQueryTest.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/VmHandlerTest.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDevice.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDeviceDAODbFacadeImpl.java M backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDeviceDAOTest.java M backend/manager/modules/dal/src/test/resources/fixtures.xml M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java M packaging/dbscripts/create_views.sql A packaging/dbscripts/upgrade/03_06_0390_add_logical_name_to_vm_device.sql M packaging/dbscripts/vm_device_sp.sql 16 files changed, 72 insertions(+), 20 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/80/34480/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AttachDiskToVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AttachDiskToVmCommand.java index 05ef134..1821dd3 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AttachDiskToVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AttachDiskToVmCommand.java @@ -203,7 +203,7 @@ getParameters().isReadOnly(), "", null, - getParameters().getSnapshotId()); + getParameters().getSnapshotId(), null); } protected boolean isOperationPerformedOnDiskSnapshot() { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java index 6e2c1ab..1970954 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java @@ -575,6 +575,7 @@ isReadOnly, "", customProp, + null, null); dao.save(managedDevice); // If we add Disk/Interface/CD/Floppy, we have to recalculate boot order @@ -1135,6 +1136,7 @@ field.isReadOnly(), "", null, + null, null); vmManagedDeviceMap.put(device.getDeviceId(), device); diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllDisksByVmIdQueryTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllDisksByVmIdQueryTest.java index 5247343..1f0f17f 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllDisksByVmIdQueryTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetAllDisksByVmIdQueryTest.java @@ -127,7 +127,8 @@ true, "", null, - disk.getVmSnapshotId()); + disk.getVmSnapshotId(), + null); } private DiskImage createDiskImage(boolean active) { diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetWatchdogQueryTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetWatchdogQueryTest.java index b073500..5ab19ca 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetWatchdogQueryTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/GetWatchdogQueryTest.java @@ -48,7 +48,7 @@ watchdogSpecParams.put("action", "reset"); VmDevice vmDevice = new VmDevice(new VmDeviceId(new Guid("6f86b8a4-e721-4149-b2df-056eb621b16a"), TEST_VM_ID), VmDeviceGeneralType.WATCHDOG, VmDeviceType.WATCHDOG.getName(), "", 1, watchdogSpecParams, - true, true, true, "", null, null); + true, true, true, "", null, null, null); Mockito.when(vmDeviceDAO.getVmDeviceByVmIdAndType(TEST_VM_ID, VmDeviceGeneralType.WATCHDOG)) .thenReturn(Collections.singletonList(vmDevice)); diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java index 2c591b4..dc27391 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java @@ -772,6 +772,7 @@ false, "", null, + null, null); } } diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/VmHandlerTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/VmHandlerTest.java index 340ee81..53d8164 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/VmHandlerTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/VmHandlerTest.java @@ -206,7 +206,8 @@ false, "", null, - disk.getDiskStorageType() == Disk.DiskStorageType.IMAGE ? ((DiskImage)disk).getSnapshotId() : null); + disk.getDiskStorageType() == Disk.DiskStorageType.IMAGE ? ((DiskImage)disk).getSnapshotId() : null, + null); vm.getManagedVmDeviceMap().put(disk.getId(), device); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDevice.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDevice.java index 00968e4..8ac4514 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDevice.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDevice.java @@ -77,6 +77,11 @@ private String alias; /** + * The device logical name. + */ + private String logicalName; + + /** * Map of custom properties */ private Map<String, String> customProperties; @@ -87,14 +92,15 @@ } public VmDevice(VmDeviceId id, VmDeviceGeneralType type, String device, String address, - int bootOrder, - Map<String, Object> specParams, - boolean isManaged, - Boolean isPlugged, - Boolean isReadOnly, - String alias, - Map<String, String> customProperties, - Guid snapshotId) { + int bootOrder, + Map<String, Object> specParams, + boolean isManaged, + Boolean isPlugged, + Boolean isReadOnly, + String alias, + Map<String, String> customProperties, + Guid snapshotId, + String logicalName) { this.id = id; this.type = type; this.device = device; @@ -107,6 +113,7 @@ this.alias = alias; this.customProperties = customProperties; this.snapshotId = snapshotId; + this.logicalName = logicalName; } @Override @@ -220,6 +227,14 @@ this.alias = alias; } + public String getLogicalName() { + return logicalName; + } + + public void setLogicalName(String logicalName) { + this.logicalName = logicalName; + } + public Map<String, String> getCustomProperties() { return customProperties; } @@ -244,6 +259,7 @@ result = prime * result + alias.hashCode(); result = prime * result + (customProperties == null ? 0 : customProperties.hashCode()); result = prime * result + (snapshotId == null ? 0 : snapshotId.hashCode()); + result = prime * result + (logicalName == null ? 0 : logicalName.hashCode()); return result; } @@ -270,7 +286,8 @@ && getIsReadOnly().equals(other.getIsReadOnly()) && alias.equals(other.alias) && ObjectUtils.objectsEqual(customProperties, other.customProperties) - && ObjectUtils.objectsEqual(snapshotId, other.snapshotId)); + && ObjectUtils.objectsEqual(snapshotId, other.snapshotId) + && ObjectUtils.objectsEqual(logicalName, other.logicalName)); } @Override @@ -302,6 +319,8 @@ sb.append(getCustomProperties()); sb.append(", snapshotId="); sb.append(getSnapshotId()); + sb.append(", logicalName="); + sb.append(getLogicalName()); sb.append("}"); return sb.toString(); } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java index 1f32b8d..c60f5ba 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/utils/VmDeviceCommonUtils.java @@ -74,6 +74,7 @@ false, "", null, + null, null); } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDeviceDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDeviceDAODbFacadeImpl.java index b4c5d59..b2e2646 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDeviceDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDeviceDAODbFacadeImpl.java @@ -48,7 +48,8 @@ .addValue("alias", entity.getAlias()) .addValue("custom_properties", SerializationFactory.getSerializer().serialize(entity.getCustomProperties())) - .addValue("snapshot_id", entity.getSnapshotId()); + .addValue("snapshot_id", entity.getSnapshotId()) + .addValue("logical_name", entity.getLogicalName()); } @Override @@ -156,6 +157,7 @@ vmDevice.setCustomProperties(SerializationFactory.getDeserializer() .deserializeOrCreateNew(rs.getString("custom_properties"), LinkedHashMap.class)); vmDevice.setSnapshotId(getGuid(rs, "snapshot_id")); + vmDevice.setLogicalName(rs.getString("logical_name")); return vmDevice; } } diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDeviceDAOTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDeviceDAOTest.java index e01a8af..5825c47 100644 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDeviceDAOTest.java +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/VmDeviceDAOTest.java @@ -49,12 +49,13 @@ "type:'drive', controller:'0', bus:'0', unit:'1'", 2, new HashMap<String, Object>(), - true, false, false, "alias", customProp, null); + true, false, false, "alias", customProp, null, null); } @Override protected void updateExistingEntity() { existingEntity.setAddress("type:'drive', controller:'0', bus:'0', unit:'0'"); + existingEntity.setLogicalName("testLogicalName"); } @Override diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml b/backend/manager/modules/dal/src/test/resources/fixtures.xml index 16cf011..6820e18 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -5807,6 +5807,7 @@ <column>alias</column> <column>custom_properties</column> <column>snapshot_id</column> + <column>logical_name</column> <row> <value>1b26a52b-b60f-44cb-9f46-3ef333b04a34</value> <value>1b85420c-b84c-4f29-997e-0eb674b40b79</value> @@ -5836,6 +5837,7 @@ <value>alias</value> <value>{ "prop1" : "true", "prop2" : "123456" }</value> <null /> + <value>logicalname</value> </row> <row> @@ -5852,6 +5854,7 @@ <value>alias</value> <value>{ "prop1" : "true", "prop2" : "123456" }</value> <null /> + <null /> </row> <row> <value>e14ed6f0-3b12-11e1-b614-63d00126418d</value> @@ -5866,6 +5869,7 @@ <value>false</value> <value>alias</value> <value>{ "prop1" : "true", "prop2" : "123456" }</value> + <null /> <null /> </row> <row> @@ -5882,6 +5886,7 @@ <value>alias</value> <value>{ "prop1" : "true", "prop2" : "123456" }</value> <null /> + <null /> </row> <row> <value>52058975-3d5e-484a-80c1-01c31207f578</value> @@ -5896,6 +5901,7 @@ <value>false</value> <value>alias</value> <value>{ "prop1" : "true", "prop2" : "123456" }</value> + <null /> <null /> </row> <row> @@ -5912,6 +5918,7 @@ <value>alias</value> <value>{}</value> <null /> + <null /> </row> <row> <value>14550e82-1e1f-47b5-ae41-b009348dabfa</value> @@ -5926,6 +5933,7 @@ <value>false</value> <value>alias</value> <value>{ "prop1" : "true", "prop2" : "123456" }</value> + <null /> <null /> </row> <row> @@ -5942,6 +5950,7 @@ <value>alias</value> <value>{ "prop1" : "true" }</value> <null /> + <null /> </row> <row> <value>14550e82-1e1f-47b5-ae41-b009348dabfb</value> @@ -5955,6 +5964,7 @@ <value>false</value> <value>false</value> <value>alias</value> + <null /> <null /> <null /> </row> @@ -5972,6 +5982,7 @@ <value>alias</value> <null /> <null /> + <null /> </row> <row> <value>1b26a52b-b60f-44cb-9f46-3ef333b04a41</value> @@ -5986,6 +5997,7 @@ <value>false</value> <value>alias</value> <null /> + <null /> </row> </table> diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java index 5ea2809..5aac6f8 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsUpdateRunTimeInfo.java @@ -1330,6 +1330,7 @@ Boolean.getBoolean((String) device.get(VdsProperties.ReadOnly)), alias, null, + null, null); newVmDevices.add(newDevice); log.debugFormat("New device was marked for adding to VM {0} Devices : {1}", vmId, newDevice); diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java index c919eae..e47cc77 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java @@ -151,6 +151,7 @@ true, "", null, + null, null); struct = new HashMap<String, Object>(); addCdDetails(vmDevice, struct, vm); @@ -205,6 +206,7 @@ true, true, "", + null, null, null); Map<String, Object> struct = new HashMap<String, Object>(); @@ -554,6 +556,7 @@ true, "", null, + null, null); Map<String, Object> struct = new HashMap<String, Object>(); addFloppyDetails(vmDevice, struct); @@ -580,6 +583,7 @@ true, true, "", + null, null, null); Map<String, Object> struct = new HashMap<String, Object>(); @@ -905,6 +909,7 @@ true, "", null, + null, null); addMemBalloonDevice(vmDevice); } else { diff --git a/packaging/dbscripts/create_views.sql b/packaging/dbscripts/create_views.sql index 3717d52..9d46601 100644 --- a/packaging/dbscripts/create_views.sql +++ b/packaging/dbscripts/create_views.sql @@ -1587,7 +1587,7 @@ CREATE OR REPLACE VIEW vm_device_view AS SELECT device_id, vm_id, type, device, address, boot_order, spec_params, - is_managed, is_plugged, is_readonly, alias, custom_properties, snapshot_id + is_managed, is_plugged, is_readonly, alias, custom_properties, snapshot_id, logical_name FROM vm_device; -- Permissions on VNIC Profiles diff --git a/packaging/dbscripts/upgrade/03_06_0390_add_logical_name_to_vm_device.sql b/packaging/dbscripts/upgrade/03_06_0390_add_logical_name_to_vm_device.sql new file mode 100644 index 0000000..2531949 --- /dev/null +++ b/packaging/dbscripts/upgrade/03_06_0390_add_logical_name_to_vm_device.sql @@ -0,0 +1 @@ +select fn_db_add_column('vm_device', 'logical_name', 'VARCHAR(255)'); \ No newline at end of file diff --git a/packaging/dbscripts/vm_device_sp.sql b/packaging/dbscripts/vm_device_sp.sql index e711755..19212f9 100644 --- a/packaging/dbscripts/vm_device_sp.sql +++ b/packaging/dbscripts/vm_device_sp.sql @@ -14,7 +14,8 @@ v_is_readonly boolean, v_alias varchar(255), v_custom_properties text, - v_snapshot_id uuid) + v_snapshot_id uuid, + v_logical_name varchar(255)) RETURNS VOID AS $procedure$ BEGIN @@ -31,7 +32,8 @@ is_readonly, alias, custom_properties, - snapshot_id) + snapshot_id, + logical_name) VALUES( v_device_id , v_vm_id , @@ -45,7 +47,8 @@ v_is_readonly, v_alias, v_custom_properties, - v_snapshot_id); + v_snapshot_id, + v_logical_name); END; $procedure$ LANGUAGE plpgsql; @@ -62,7 +65,8 @@ v_is_readonly boolean, v_alias varchar(255), v_custom_properties text, - v_snapshot_id uuid) + v_snapshot_id uuid, + v_logical_name varchar(255)) RETURNS VOID AS $procedure$ BEGIN @@ -79,6 +83,7 @@ alias = v_alias, custom_properties = v_custom_properties, snapshot_id = v_snapshot_id, + logical_name = v_logical_name, _update_date = current_timestamp WHERE device_id = v_device_id and vm_id = v_vm_id; END; $procedure$ -- To view, visit http://gerrit.ovirt.org/34480 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If9b5a8e771a05c1fe44834adfe998cf921f6ae52 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Liron Aravot <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
