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 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/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_0240_add_logical_name_to_vm_device.sql M packaging/dbscripts/vm_device_sp.sql 15 files changed, 74 insertions(+), 20 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/54/31754/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 7da9c37..ef9024e 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 @@ -577,6 +577,7 @@ isReadOnly, "", customProp, + null, null); dao.save(managedDevice); // If we add Disk/Interface/CD/Floppy, we have to recalculate boot order @@ -1137,6 +1138,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 9053b8f..85b0edc 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 @@ -767,6 +767,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 f795882..3059e5f 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 @@ -143,7 +143,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/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 f0c4a82..2e228d7 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 7ceb93b..569dc84 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -5691,6 +5691,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> @@ -5703,6 +5704,7 @@ <value>false</value> <value>false</value> <value>alias</value> + <null /> <null /> <null /> </row> @@ -5720,6 +5722,7 @@ <value>alias</value> <value>{ "prop1" : "true", "prop2" : "123456" }</value> <null /> + <null /> </row> <row> @@ -5736,6 +5739,7 @@ <value>alias</value> <value>{ "prop1" : "true", "prop2" : "123456" }</value> <null /> + <null /> </row> <row> <value>e14ed6f0-3b12-11e1-b614-63d00126418d</value> @@ -5750,6 +5754,7 @@ <value>false</value> <value>alias</value> <value>{ "prop1" : "true", "prop2" : "123456" }</value> + <null /> <null /> </row> <row> @@ -5766,6 +5771,7 @@ <value>alias</value> <value>{ "prop1" : "true", "prop2" : "123456" }</value> <null /> + <null /> </row> <row> <value>52058975-3d5e-484a-80c1-01c31207f578</value> @@ -5780,6 +5786,7 @@ <value>false</value> <value>alias</value> <value>{ "prop1" : "true", "prop2" : "123456" }</value> + <null /> <null /> </row> <row> @@ -5796,6 +5803,7 @@ <value>alias</value> <value>{}</value> <null /> + <null /> </row> <row> <value>14550e82-1e1f-47b5-ae41-b009348dabfa</value> @@ -5810,6 +5818,7 @@ <value>false</value> <value>alias</value> <value>{ "prop1" : "true", "prop2" : "123456" }</value> + <null /> <null /> </row> <row> @@ -5826,6 +5835,7 @@ <value>alias</value> <value>{ "prop1" : "true" }</value> <null /> + <null /> </row> <row> <value>14550e82-1e1f-47b5-ae41-b009348dabfb</value> @@ -5839,6 +5849,7 @@ <value>false</value> <value>false</value> <value>alias</value> + <null /> <null /> <null /> </row> @@ -5856,6 +5867,7 @@ <value>alias</value> <null /> <null /> + <null /> </row> <row> <value>1b26a52b-b60f-44cb-9f46-3ef333b04a41</value> @@ -5870,6 +5882,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 da7c0df..85407b6 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 @@ -1301,6 +1301,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 6d48284..2a1e38f 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 @@ -139,6 +139,7 @@ true, "", null, + null, null); struct = new HashMap<String, Object>(); addCdDetails(vmDevice, struct, vm); @@ -157,6 +158,7 @@ true, true, "", + null, null, null); struct = new HashMap<String, Object>(); @@ -200,6 +202,7 @@ true, "", null, + null, null); Map<String, Object> struct = new HashMap<String, Object>(); addCdDetails(vmDevice, struct, vm); @@ -218,6 +221,7 @@ true, true, "", + null, null, null); Map<String, Object> struct = new HashMap<String, Object>(); @@ -497,6 +501,7 @@ true, "", null, + null, null); Map<String, Object> struct = new HashMap<String, Object>(); addFloppyDetails(vmDevice, struct); @@ -523,6 +528,7 @@ true, true, "", + null, null, null); Map<String, Object> struct = new HashMap<String, Object>(); @@ -848,6 +854,7 @@ true, "", null, + null, null); addMemBalloonDevice(vmDevice); } else { diff --git a/packaging/dbscripts/create_views.sql b/packaging/dbscripts/create_views.sql index d0bdcb3..3c34ec8 100644 --- a/packaging/dbscripts/create_views.sql +++ b/packaging/dbscripts/create_views.sql @@ -1571,7 +1571,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_0240_add_logical_name_to_vm_device.sql b/packaging/dbscripts/upgrade/03_06_0240_add_logical_name_to_vm_device.sql new file mode 100644 index 0000000..5a405f0 --- /dev/null +++ b/packaging/dbscripts/upgrade/03_06_0240_add_logical_name_to_vm_device.sql @@ -0,0 +1 @@ +select fn_db_add_column('vm_device', 'logical_name', 'VARCHAR(30) '); \ No newline at end of file diff --git a/packaging/dbscripts/vm_device_sp.sql b/packaging/dbscripts/vm_device_sp.sql index e711755..63ca74f 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(30)) 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(30)) 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/31754 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If9b5a8e771a05c1fe44834adfe998cf921f6ae52 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Liron Aravot <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
