mirror of https://github.com/apache/cloudstack.git
Removed unnecessary code from getGuestOsType in CitrixResourceBase
This commit is contained in:
parent
94a14485f7
commit
935113fbd3
|
|
@ -44,7 +44,6 @@ import java.util.Set;
|
|||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
|
@ -164,7 +163,6 @@ import com.xensource.xenapi.XenAPIObject;
|
|||
* before you do any changes in this code here.
|
||||
*
|
||||
*/
|
||||
@Local(value = ServerResource.class)
|
||||
public abstract class CitrixResourceBase implements ServerResource, HypervisorResource, VirtualRouterDeployer {
|
||||
|
||||
public enum SRType {
|
||||
|
|
@ -1232,7 +1230,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
}
|
||||
|
||||
public VM createVmFromTemplate(final Connection conn, final VirtualMachineTO vmSpec, final Host host) throws XenAPIException, XmlRpcException {
|
||||
final String guestOsTypeName = getGuestOsType(vmSpec.getOs(), vmSpec.getPlatformEmulator(), vmSpec.getBootloader() == BootloaderType.CD);
|
||||
final String guestOsTypeName = getGuestOsType(vmSpec.getPlatformEmulator());
|
||||
final Set<VM> templates = VM.getByNameLabel(conn, guestOsTypeName);
|
||||
if (templates == null || templates.isEmpty()) {
|
||||
throw new CloudRuntimeException("Cannot find template " + guestOsTypeName + " on XenServer host");
|
||||
|
|
@ -1337,7 +1335,7 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
final TemplateObjectTO iso = (TemplateObjectTO) disk.getData();
|
||||
final String osType = iso.getGuestOsType();
|
||||
if (osType != null) {
|
||||
final String isoGuestOsName = getGuestOsType(osType, vmSpec.getPlatformEmulator(), vmSpec.getBootloader() == BootloaderType.CD);
|
||||
final String isoGuestOsName = getGuestOsType(vmSpec.getPlatformEmulator());
|
||||
if (!isoGuestOsName.equals(guestOsTypeName)) {
|
||||
vmSpec.setBootloader(BootloaderType.PyGrub);
|
||||
}
|
||||
|
|
@ -2019,8 +2017,8 @@ public abstract class CitrixResourceBase implements ServerResource, HypervisorRe
|
|||
return null;
|
||||
}
|
||||
|
||||
protected String getGuestOsType(final String stdType, String platformEmulator, final boolean bootFromCD) {
|
||||
if (platformEmulator == null) {
|
||||
protected String getGuestOsType(String platformEmulator) {
|
||||
if (org.apache.commons.lang.StringUtils.isBlank(platformEmulator)) {
|
||||
s_logger.debug("no guest OS type, start it as HVM guest");
|
||||
platformEmulator = "Other install media";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,16 +17,12 @@
|
|||
|
||||
package com.cloud.hypervisor.xenserver.resource;
|
||||
|
||||
import javax.ejb.Local;
|
||||
|
||||
import org.apache.xmlrpc.XmlRpcException;
|
||||
|
||||
import com.cloud.resource.ServerResource;
|
||||
import com.xensource.xenapi.Connection;
|
||||
import com.xensource.xenapi.Types.XenAPIException;
|
||||
import com.xensource.xenapi.VM;
|
||||
|
||||
@Local(value = ServerResource.class)
|
||||
public class XcpOssResource extends CitrixResourceBase {
|
||||
|
||||
private static final long mem_32m = 33554432L;
|
||||
|
|
@ -36,18 +32,6 @@ public class XcpOssResource extends CitrixResourceBase {
|
|||
return "scripts/vm/hypervisor/xenserver/xcposs/patch";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getGuestOsType(final String stdType,
|
||||
final String platformEmulator, final boolean bootFromCD) {
|
||||
if (stdType.equalsIgnoreCase("Debian GNU/Linux 6(64-bit)")) {
|
||||
return "Debian Squeeze 6.0 (64-bit)";
|
||||
} else if (stdType.equalsIgnoreCase("CentOS 5.6 (64-bit)")) {
|
||||
return "CentOS 5 (64-bit)";
|
||||
} else {
|
||||
return super.getGuestOsType(stdType, platformEmulator, bootFromCD);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setMemory(final Connection conn, final VM vm, long minMemsize, final long maxMemsize) throws XmlRpcException, XenAPIException {
|
||||
vm.setMemoryLimits(conn, mem_32m, maxMemsize, minMemsize, maxMemsize);
|
||||
|
|
|
|||
|
|
@ -49,4 +49,35 @@ public abstract class CitrixResourceBaseTest {
|
|||
String receivedPath = files.get(0).getAbsolutePath();
|
||||
Assert.assertEquals(receivedPath, pathExpected);
|
||||
}
|
||||
|
||||
public void testGetGuestOsTypeNull(CitrixResourceBase citrixResourceBase) {
|
||||
String platformEmulator = null;
|
||||
|
||||
String expected = "Other install media";
|
||||
String guestOsType = citrixResourceBase.getGuestOsType(platformEmulator);
|
||||
Assert.assertEquals(expected, guestOsType);
|
||||
}
|
||||
|
||||
public void testGetGuestOsTypeEmpty(CitrixResourceBase citrixResourceBase) {
|
||||
String platformEmulator = "";
|
||||
|
||||
String expected = "Other install media";
|
||||
String guestOsType = citrixResourceBase.getGuestOsType(platformEmulator);
|
||||
Assert.assertEquals(expected, guestOsType);
|
||||
}
|
||||
|
||||
public void testGetGuestOsTypeBlank(CitrixResourceBase citrixResourceBase) {
|
||||
String platformEmulator = " ";
|
||||
|
||||
String expected = "Other install media";
|
||||
String guestOsType = citrixResourceBase.getGuestOsType(platformEmulator);
|
||||
Assert.assertEquals(expected, guestOsType);
|
||||
}
|
||||
|
||||
public void testGetGuestOsTypeOther(CitrixResourceBase citrixResourceBase) {
|
||||
String platformEmulator = "My Own Linux Distribution Y.M (64-bit)";
|
||||
|
||||
String guestOsType = citrixResourceBase.getGuestOsType(platformEmulator);
|
||||
Assert.assertEquals(platformEmulator, guestOsType);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,4 +47,21 @@ public class XcpOssResourceTest extends CitrixResourceBaseTest{
|
|||
public void testGetFilesListReturned(){
|
||||
testGetPathFilesListReturned(xcpOssResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOsTypeNull() {
|
||||
testGetGuestOsTypeNull(xcpOssResource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeEmpty() {
|
||||
testGetGuestOsTypeEmpty(xcpOssResource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeBlank() {
|
||||
testGetGuestOsTypeBlank(xcpOssResource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeOther() {
|
||||
testGetGuestOsTypeOther(xcpOssResource);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,4 +48,21 @@ public class XcpServerResourceTest extends CitrixResourceBaseTest{
|
|||
public void testGetFilesListReturned(){
|
||||
testGetPathFilesListReturned(xcpServerResource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOsTypeNull() {
|
||||
testGetGuestOsTypeNull(xcpServerResource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeEmpty() {
|
||||
testGetGuestOsTypeEmpty(xcpServerResource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeBlank() {
|
||||
testGetGuestOsTypeBlank(xcpServerResource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeOther() {
|
||||
testGetGuestOsTypeOther(xcpServerResource);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,4 +45,21 @@ public class XenServer56FP1ResourceTest extends CitrixResourceBaseTest{
|
|||
public void testGetFilesListReturned(){
|
||||
testGetPathFilesListReturned(xenServer56FP1Resource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOsTypeNull() {
|
||||
testGetGuestOsTypeNull(xenServer56FP1Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeEmpty() {
|
||||
testGetGuestOsTypeEmpty(xenServer56FP1Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeBlank() {
|
||||
testGetGuestOsTypeBlank(xenServer56FP1Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeOther() {
|
||||
testGetGuestOsTypeOther(xenServer56FP1Resource);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,4 +46,21 @@ public class XenServer56ResourceTest extends CitrixResourceBaseTest {
|
|||
public void testGetFilesListReturned(){
|
||||
testGetPathFilesListReturned(xenServer56Resource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOsTypeNull() {
|
||||
testGetGuestOsTypeNull(xenServer56Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeEmpty() {
|
||||
testGetGuestOsTypeEmpty(xenServer56Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeBlank() {
|
||||
testGetGuestOsTypeBlank(xenServer56Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeOther() {
|
||||
testGetGuestOsTypeOther(xenServer56Resource);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,4 +45,21 @@ public class XenServer56SP2ResourceTest extends CitrixResourceBaseTest{
|
|||
public void testGetFilesListReturned(){
|
||||
testGetPathFilesListReturned(xenServer56SP2Resource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOsTypeNull() {
|
||||
testGetGuestOsTypeNull(xenServer56SP2Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeEmpty() {
|
||||
testGetGuestOsTypeEmpty(xenServer56SP2Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeBlank() {
|
||||
testGetGuestOsTypeBlank(xenServer56SP2Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeOther() {
|
||||
testGetGuestOsTypeOther(xenServer56SP2Resource);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,4 +45,21 @@ public class XenServer600ResourceTest extends CitrixResourceBaseTest{
|
|||
public void testGetFilesListReturned(){
|
||||
testGetPathFilesListReturned(xenServer600Resource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOsTypeNull() {
|
||||
testGetGuestOsTypeNull(xenServer600Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeEmpty() {
|
||||
testGetGuestOsTypeEmpty(xenServer600Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeBlank() {
|
||||
testGetGuestOsTypeBlank(xenServer600Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeOther() {
|
||||
testGetGuestOsTypeOther(xenServer600Resource);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,4 +45,21 @@ public class XenServer625ResourceTest extends CitrixResourceBaseTest{
|
|||
public void testGetFilesListReturned(){
|
||||
testGetPathFilesListReturned(xenServer625Resource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOsTypeNull() {
|
||||
testGetGuestOsTypeNull(xenServer625Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeEmpty() {
|
||||
testGetGuestOsTypeEmpty(xenServer625Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeBlank() {
|
||||
testGetGuestOsTypeBlank(xenServer625Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeOther() {
|
||||
testGetGuestOsTypeOther(xenServer625Resource);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,4 +46,21 @@ public class XenServer650ResourceTest extends CitrixResourceBaseTest{
|
|||
public void testGetFilesListReturned(){
|
||||
testGetPathFilesListReturned(xenServer650Resource);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOsTypeNull() {
|
||||
testGetGuestOsTypeNull(xenServer650Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeEmpty() {
|
||||
testGetGuestOsTypeEmpty(xenServer650Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeBlank() {
|
||||
testGetGuestOsTypeBlank(xenServer650Resource);
|
||||
}
|
||||
@Test
|
||||
public void testGetOsTypeOther() {
|
||||
testGetGuestOsTypeOther(xenServer650Resource);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue