cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sw...@apache.org
Subject [1/3] git commit: updated refs/heads/master to a3371d2
Date Mon, 18 Apr 2016 18:42:36 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master a95782107 -> a3371d282


Removed unnecessary code from getGuestOsType in CitrixResourceBase

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/935113fb
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/935113fb
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/935113fb

Branch: refs/heads/master
Commit: 935113fbd3f1f370604a652b5d19d69e5fe56b9b
Parents: 94a1448
Author: cirstofolini <lucascristofolini@gmail.com>
Authored: Sat Dec 19 16:42:52 2015 -0200
Committer: cirstofolini <lucascristofolini@gmail.com>
Committed: Sun Dec 20 15:08:44 2015 -0200

----------------------------------------------------------------------
 .../xenserver/resource/CitrixResourceBase.java  | 10 +++----
 .../xenserver/resource/XcpOssResource.java      | 16 ----------
 .../resource/CitrixResourceBaseTest.java        | 31 ++++++++++++++++++++
 .../xenserver/resource/XcpOssResourceTest.java  | 17 +++++++++++
 .../resource/XcpServerResourceTest.java         | 17 +++++++++++
 .../resource/XenServer56FP1ResourceTest.java    | 17 +++++++++++
 .../resource/XenServer56ResourceTest.java       | 17 +++++++++++
 .../resource/XenServer56SP2ResourceTest.java    | 17 +++++++++++
 .../resource/XenServer600ResourceTest.java      | 17 +++++++++++
 .../resource/XenServer625ResourceTest.java      | 17 +++++++++++
 .../resource/XenServer650ResourceTest.java      | 17 +++++++++++
 11 files changed, 171 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/935113fb/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
----------------------------------------------------------------------
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 7c8bca7..155c84b 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
@@ -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";
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/935113fb/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XcpOssResource.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XcpOssResource.java
b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XcpOssResource.java
index 44fad93..ea7fe6f 100644
--- a/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XcpOssResource.java
+++ b/plugins/hypervisors/xenserver/src/com/cloud/hypervisor/xenserver/resource/XcpOssResource.java
@@ -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;
@@ -37,18 +33,6 @@ public class XcpOssResource extends CitrixResourceBase {
     }
 
     @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);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/935113fb/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/CitrixResourceBaseTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/CitrixResourceBaseTest.java
b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/CitrixResourceBaseTest.java
index 353b106..81853d4 100644
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/CitrixResourceBaseTest.java
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/CitrixResourceBaseTest.java
@@ -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);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/935113fb/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpOssResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpOssResourceTest.java
b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpOssResourceTest.java
index b0c900c..cd4db0f 100644
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpOssResourceTest.java
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpOssResourceTest.java
@@ -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);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/935113fb/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpServerResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpServerResourceTest.java
b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpServerResourceTest.java
index ba3d91d..95ba8f6 100644
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpServerResourceTest.java
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XcpServerResourceTest.java
@@ -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);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/935113fb/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56FP1ResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56FP1ResourceTest.java
b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56FP1ResourceTest.java
index def51cf..bba3b6a 100644
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56FP1ResourceTest.java
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56FP1ResourceTest.java
@@ -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);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/935113fb/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56ResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56ResourceTest.java
b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56ResourceTest.java
index 960dd7f..4a6ff0b 100644
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56ResourceTest.java
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56ResourceTest.java
@@ -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);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/935113fb/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56SP2ResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56SP2ResourceTest.java
b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56SP2ResourceTest.java
index 300f95d..defbe9b 100644
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56SP2ResourceTest.java
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer56SP2ResourceTest.java
@@ -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);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/935113fb/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer600ResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer600ResourceTest.java
b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer600ResourceTest.java
index 34deeb8..899f0a7 100644
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer600ResourceTest.java
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer600ResourceTest.java
@@ -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);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/935113fb/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer625ResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer625ResourceTest.java
b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer625ResourceTest.java
index 640ca06..4c6a6ec 100644
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer625ResourceTest.java
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer625ResourceTest.java
@@ -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);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/935113fb/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer650ResourceTest.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer650ResourceTest.java
b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer650ResourceTest.java
index 148b22d..a062c0c 100644
--- a/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer650ResourceTest.java
+++ b/plugins/hypervisors/xenserver/test/com/cloud/hypervisor/xenserver/resource/XenServer650ResourceTest.java
@@ -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);
+    }
 }


Mime
View raw message