Shahar Havivi has uploaded a new change for review. Change subject: RFE: sysprep file name should be according to its version ......................................................................
RFE: sysprep file name should be according to its version We are using sysprep inside a floppy by the filename: sysprep.inf, - which is what sysprep is looking for in .ini file format that was in xp and 2003. The new format is xml and the filename should be "Unattend.xml" for this versions. Change-Id: Ie1aff3a70c4d34c3e4ba74152e61551f09d33fff Bug-Url: https://bugzilla.redhat.com/1145999 Signed-off-by: Shahar Havivi <[email protected]> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java M backend/manager/modules/utils/src/main/antlr4/org/ovirt/engine/core/utils/osinfo/Osinfo.g4 M backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java M backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java M packaging/conf/osinfo-defaults.properties 6 files changed, 39 insertions(+), 12 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/22/36322/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java index 2fc9356..f1407cd 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java @@ -2,15 +2,13 @@ import java.util.ArrayList; import java.util.HashMap; -import java.util.Set; - import java.util.List; import java.util.Map; - +import java.util.Set; import org.ovirt.engine.core.common.businessentities.ArchitectureType; +import org.ovirt.engine.core.common.businessentities.DisplayType; import org.ovirt.engine.core.common.businessentities.VmWatchdogType; import org.ovirt.engine.core.common.utils.Pair; -import org.ovirt.engine.core.common.businessentities.DisplayType; import org.ovirt.engine.core.common.utils.VmDeviceType; import org.ovirt.engine.core.compat.Version; @@ -151,6 +149,15 @@ public String getSysprepPath(int osId, Version version); /** + * this is Windows OSs specific file name sysprep in the floppy, + * ie: sysprep.inf for xp and 2003 and Unattend.xml for the new sysprep xml files + * @param osId + * @param version + * @return + */ + public String getSysprepFileName(int osId, Version version); + + /** * this Windows OSs specific product key * @param osId * @param version diff --git a/backend/manager/modules/utils/src/main/antlr4/org/ovirt/engine/core/utils/osinfo/Osinfo.g4 b/backend/manager/modules/utils/src/main/antlr4/org/ovirt/engine/core/utils/osinfo/Osinfo.g4 index db474bf..2091b23 100644 --- a/backend/manager/modules/utils/src/main/antlr4/org/ovirt/engine/core/utils/osinfo/Osinfo.g4 +++ b/backend/manager/modules/utils/src/main/antlr4/org/ovirt/engine/core/utils/osinfo/Osinfo.g4 @@ -33,6 +33,7 @@ | 'cpu.unsupported' stringValue | 'bus' busValue | 'sysprepPath' stringValue + | 'sysprepFileName' stringValue | 'productKey' stringValue | 'isTimezoneTypeInteger' booleanValue | resources diff --git a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java index 27a5e47..74f7820 100644 --- a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java +++ b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java @@ -10,16 +10,15 @@ import java.util.Set; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; - +import org.ovirt.engine.core.common.businessentities.ArchitectureType; +import org.ovirt.engine.core.common.businessentities.DisplayType; import org.ovirt.engine.core.common.businessentities.VmWatchdogType; import org.ovirt.engine.core.common.config.Config; import org.ovirt.engine.core.common.config.ConfigValues; import org.ovirt.engine.core.common.osinfo.MapBackedPreferences; import org.ovirt.engine.core.common.osinfo.OsRepository; import org.ovirt.engine.core.common.utils.Pair; -import org.ovirt.engine.core.common.businessentities.DisplayType; import org.ovirt.engine.core.common.utils.VmDeviceType; -import org.ovirt.engine.core.common.businessentities.ArchitectureType; import org.ovirt.engine.core.compat.Version; import org.ovirt.engine.core.utils.log.Log; import org.ovirt.engine.core.utils.log.LogFactory; @@ -388,6 +387,11 @@ } @Override + public String getSysprepFileName(int osId, Version version) { + return getValueByVersion(idToUnameLookup.get(osId), "sysprepFileName", version); + } + + @Override public String getProductKey(int osId, Version version) { return getValueByVersion(idToUnameLookup.get(osId), "productKey", version); } diff --git a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java index b5c451d..3ca5027 100644 --- a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java +++ b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java @@ -11,9 +11,7 @@ import java.util.Set; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; - import org.junit.Assert; - import org.junit.BeforeClass; import org.junit.Test; import org.ovirt.engine.core.common.businessentities.DisplayType; @@ -26,6 +24,8 @@ private static MapBackedPreferences preferences; + public static final String SYSPREP_INF = "sysprep.inf"; + public static final String UNATTEND_XML = "unattend.xml"; public static final String NETWORK_DEVICES = "e100,pv"; public static final String DISK_HOTPLUGGABLE_INTERFACES = "VirtIO_SCSI, VirtIO"; public static final String WATCH_DOG_MODELS = "model1, model2"; @@ -62,8 +62,13 @@ preferences.node("/os/rhel8/derivedFrom").put("value", "rhel7"); preferences.node("/os/windows_8/id").put("value", "20"); preferences.node("/backwardCompatibility").put("Windows8", "20"); + preferences.node("/os/windows_7/id").put("value", "11"); + preferences.node("/os/windows_7/sysprepFileName").put("value", UNATTEND_XML); preferences.node("/os/windows_7/devices/hyperv/enabled").put("value", "true"); preferences.node("/os/windows_8/cpu/unsupported").put("value", "conroe, opteron_g1"); + preferences.node("/os/windows_8/sysprepFileName").put("value", UNATTEND_XML); + preferences.node("/os/windows_xp/id").put("value", "1"); + preferences.node("/os/windows_xp/sysprepFileName").put("value", SYSPREP_INF); OsRepositoryImpl.INSTANCE.init(preferences); } @@ -189,6 +194,13 @@ } @Test + public void testGetSysprepFileName() throws Exception { + assertTrue(OsRepositoryImpl.INSTANCE.getSysprepFileName(1, null).equals(SYSPREP_INF)); + assertTrue(OsRepositoryImpl.INSTANCE.getSysprepFileName(11, null).equals(UNATTEND_XML)); + assertTrue(OsRepositoryImpl.INSTANCE.getSysprepFileName(20, null).equals(UNATTEND_XML)); + } + + @Test public void testGetProductKey() throws Exception { assertTrue(OsRepositoryImpl.INSTANCE.getProductKey(777, null).equals(SOME_PRODUCT_KEY)); } 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 4f95485..38d0c75 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 @@ -8,7 +8,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; - import org.apache.commons.codec.CharEncoding; import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang.StringUtils; @@ -53,7 +52,6 @@ @SuppressWarnings({"rawtypes", "unchecked"}) public class VmInfoBuilder extends VmInfoBuilderBase { - private static final String SYSPREP_FILE_NAME = "sysprep.inf"; private static final String DEVICES = "devices"; private static final String USB_BUS = "usb"; private final static String FIRST_MASTER_MODEL = "ich9-ehci1"; @@ -563,7 +561,8 @@ // The sysprep file size isn't being verified for 3.0 clusters and below, so we maintain the same behavior here. VmPayload vmPayload = new VmPayload(); vmPayload.setDeviceType(VmDeviceType.FLOPPY); - vmPayload.getFiles().put(SYSPREP_FILE_NAME, new String(BASE_64.encode(sysPrepContent.getBytes()), Charset.forName(CharEncoding.UTF_8))); + vmPayload.getFiles().put(getOsRepository().getSysprepFileName(vm.getOs(), vm.getVdsGroupCompatibilityVersion()), + new String(BASE_64.encode(sysPrepContent.getBytes()), Charset.forName(CharEncoding.UTF_8))); VmDevice vmDevice = new VmDevice(new VmDeviceId(Guid.newGuid(), vm.getId()), diff --git a/packaging/conf/osinfo-defaults.properties b/packaging/conf/osinfo-defaults.properties index 97d345b..84c65fc 100644 --- a/packaging/conf/osinfo-defaults.properties +++ b/packaging/conf/osinfo-defaults.properties @@ -155,6 +155,7 @@ os.windows_xp.name.value = Windows XP os.windows_xp.derivedFrom.value = other os.windows_xp.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.xp +os.windows_xp.sysprepFileName.value = "sysprep.inf" os.windows_xp.productKey.value = os.windows_xp.isTimezoneTypeInteger.value = true os.windows_xp.devices.network.value = rtl8139_pv, rtl8139, e1000, pv @@ -184,6 +185,7 @@ os.windows_2008.id.value = 4 os.windows_2008.name.value = Windows 2008 os.windows_2008.derivedFrom.value = windows_2003 +os.windows_2008.sysprepFileName.value = "Unattend.xml" os.windows_2008.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.2k8 os.windows_2008.productKey.value = os.windows_2008.isTimezoneTypeInteger.value = false @@ -204,6 +206,7 @@ os.windows_7.name.value = Windows 7 os.windows_7.derivedFrom.value = windows_xp os.windows_7.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.w7 +os.windows_7.sysprepFileName.value = "Unattend.xml" os.windows_7.productKey.value = os.windows_7.devices.audio.value = ich6 os.windows_7.devices.diskInterfaces.value.3.3 = IDE, VirtIO_SCSI, VirtIO @@ -226,6 +229,7 @@ os.windows_2008x64.name.value = Windows 2008 x64 os.windows_2008x64.derivedFrom.value = windows_2003x64 os.windows_2008x64.sysprepPath.value = ${ENGINE_USR}/conf/sysprep/sysprep.2k8x64 +os.windows_2008x64.sysprepFileName.value = "Unattend.xml" os.windows_2008x64.productKey.value = os.windows_2008x64.devices.audio.value = ich6 os.windows_2008x64.isTimezoneTypeInteger.value = false -- To view, visit http://gerrit.ovirt.org/36322 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie1aff3a70c4d34c3e4ba74152e61551f09d33fff Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Shahar Havivi <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
