From 9ae3c0a5a9f3438e9714ddb8307a6835231bf583 Mon Sep 17 00:00:00 2001 From: SudharmaJain Date: Wed, 9 Dec 2015 11:53:51 +0530 Subject: [PATCH] CLOUDSTACK-9127 Missing PV-bootloader-args for "SUSE Linux Enterprise Server 10 SP2 and SP3" Added Unit test for the new method --- .../xenserver/resource/CitrixHelper.java | 11 ++++++ .../resource/CitrixResourceBase.java | 1 + .../xenserver/resource/CitrixHelperTest.java | 34 +++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/CitrixHelperTest.java diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixHelper.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixHelper.java index 265573d7e4a5..cf2bd76f3cc2 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixHelper.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixHelper.java @@ -236,4 +236,15 @@ public static String getProductVersion(final Host.Record record) { } return prodVersion; } + + public static String getPVbootloaderArgs(String guestOS) { + if (guestOS.startsWith("SUSE Linux Enterprise Server")) { + if (guestOS.contains("64-bit")) { + return "--kernel /boot/vmlinuz-xen --ramdisk /boot/initrd-xen"; + } else if (guestOS.contains("32-bit")) { + return "--kernel /boot/vmlinuz-xenpae --ramdisk /boot/initrd-xenpae"; + } + } + return ""; + } } diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java index e1f7d3d61e58..7c8bca7f1bdb 100644 --- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java +++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java @@ -1352,6 +1352,7 @@ public VM createVmFromTemplate(final Connection conn, final VirtualMachineTO vmS } } else if (vmSpec.getBootloader() == BootloaderType.PyGrub) { vm.setPVBootloader(conn, "pygrub"); + vm.setPVBootloaderArgs(conn,CitrixHelper.getPVbootloaderArgs(guestOsTypeName)); } else { vm.destroy(conn); throw new CloudRuntimeException("Unable to handle boot loader type: " + vmSpec.getBootloader()); diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/CitrixHelperTest.java b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/CitrixHelperTest.java new file mode 100644 index 000000000000..b656ec39c604 --- /dev/null +++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/CitrixHelperTest.java @@ -0,0 +1,34 @@ +package com.cloud.hypervisor.xenserver.resource; + +import junit.framework.Assert; +import org.junit.Test; + + +/** + * Created by ajna123 on 12/11/2015. + */ +public class CitrixHelperTest { + + @Test + public void testGetPVbootloaderArgs() throws Exception { + + String os_name_Suse10Sp2_64 = "SUSE Linux Enterprise Server 10 SP2 (64-bit)"; + String os_name_Suse10Sp2_32 = "SUSE Linux Enterprise Server 10 SP2 (32-bit)"; + String os_name_Suse11Sp3_64 = "SUSE Linux Enterprise Server 11 SP3 (64-bit)"; + String os_name_Suse11Sp3_32 = "SUSE Linux Enterprise Server 11 SP3 (32-bit)"; + + String os_name_Windows8_64 = "Windows 8 (64-bit)"; + String os_name_Windows8_32 = "Windows 8 (32-bit)"; + + String pvBootLoaderArgs_32 = "--kernel /boot/vmlinuz-xenpae --ramdisk /boot/initrd-xenpae"; + String pvBootLoaderArgs_64 = "--kernel /boot/vmlinuz-xen --ramdisk /boot/initrd-xen"; + + Assert.assertEquals(CitrixHelper.getPVbootloaderArgs(os_name_Suse10Sp2_32), pvBootLoaderArgs_32); + Assert.assertEquals(CitrixHelper.getPVbootloaderArgs(os_name_Suse10Sp2_64),pvBootLoaderArgs_64); + Assert.assertEquals(CitrixHelper.getPVbootloaderArgs(os_name_Suse11Sp3_32),pvBootLoaderArgs_32); + Assert.assertEquals(CitrixHelper.getPVbootloaderArgs(os_name_Suse11Sp3_64),pvBootLoaderArgs_64); + + Assert.assertEquals(CitrixHelper.getPVbootloaderArgs(os_name_Windows8_32),""); + Assert.assertEquals(CitrixHelper.getPVbootloaderArgs(os_name_Windows8_64),""); + } +} \ No newline at end of file