Eli Mesika has uploaded a new change for review. Change subject: core:PCI addresses are deleted when VM...(#873581) ......................................................................
core:PCI addresses are deleted when VM...(#873581) PCI addresses are deleted when VM Template is imported When a VM or Template is imported, we must set the VM/Template device addresses as appears in the OVF. This patch adds another signature to addManagedDevice with an additional address parameter and uses it for imported managed objects. Change-Id: I41a0826a82aaec39425261c9030d99cd3b462832 Signed-off-by: Eli Mesika <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/utils/VmDeviceUtils.java 1 file changed, 34 insertions(+), 2 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/87/9087/1 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 21def3a..956bece 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 @@ -277,6 +277,29 @@ return addManagedDevice(id, VmDeviceType.INTERFACE, VmDeviceType.BRIDGE, Collections.<String, Object> emptyMap(), plugged, false); } + /** + * @param id + * @param type + * @param device + * @param specParams + * @param is_plugged + * @param isReadOnly + * @param address + * @return New created VmDevice instance + */ + public static VmDevice addManagedDevice(VmDeviceId id, + VmDeviceType type, + VmDeviceType device, + Map<String, Object> specParams, + boolean is_plugged, + boolean isReadOnly, + String address) { + VmDevice managedDevice = addManagedDevice(id, type, device, specParams,is_plugged,isReadOnly); + if (!StringUtils.isEmpty(address)){ + managedDevice.setAddress(address); + } + return managedDevice; + } /** * adds managed device to vm_device @@ -517,7 +540,8 @@ VmDeviceType.DISK, null, true, - false); + false, + getAddress(entity, id)); updateVmDevice(entity, vmDevice, deviceId, vmDeviceToUpdate); } } @@ -562,11 +586,19 @@ VmDeviceType.BRIDGE, null, true, - false); + false, + getAddress(entity, id)); updateVmDevice(entity, vmDevice, deviceId, vmDeviceToUpdate); } } + private static <T extends VmBase> String getAddress(T entity, final Guid id) { + if (entity.getManagedVmDeviceMap().get(id) != null) + return entity.getManagedVmDeviceMap().get(id).getAddress(); + else + return StringUtils.EMPTY; + } + /** * Adds Special managed devices (monitor/CDROM ) and unmanaged devices * -- To view, visit http://gerrit.ovirt.org/9087 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I41a0826a82aaec39425261c9030d99cd3b462832 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Eli Mesika <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
