cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sanjaytripa...@apache.org
Subject git commit: updated refs/heads/master to 2ae9da8
Date Tue, 08 Apr 2014 16:36:15 GMT
Repository: cloudstack
Updated Branches:
  refs/heads/master 09f83e48e -> 2ae9da8d4


CLOUDSTACK-6357: Not able to select GPU card in case of GPU-passthrough.


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

Branch: refs/heads/master
Commit: 2ae9da8d4762fb546d8104475bb2fb429c33994f
Parents: 09f83e4
Author: Sanjay Tripathi <sanjay.tripathi@citrix.com>
Authored: Tue Apr 8 22:03:37 2014 +0530
Committer: Sanjay Tripathi <sanjay.tripathi@citrix.com>
Committed: Tue Apr 8 22:10:09 2014 +0530

----------------------------------------------------------------------
 api/src/com/cloud/gpu/GPU.java                  |  4 ---
 .../src/com/cloud/resource/ResourceManager.java |  9 ++++--
 .../allocator/impl/FirstFitAllocator.java       | 10 +++---
 .../configuration/ConfigurationManagerImpl.java | 32 ++++++--------------
 .../deploy/DeploymentPlanningManagerImpl.java   |  8 +++--
 .../cloud/hypervisor/HypervisorGuruBase.java    |  3 +-
 .../com/cloud/resource/ResourceManagerImpl.java | 16 +++++-----
 .../cloud/resource/MockResourceManagerImpl.java |  6 ++--
 ui/scripts/configuration.js                     | 23 ++++++--------
 9 files changed, 47 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2ae9da8d/api/src/com/cloud/gpu/GPU.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/gpu/GPU.java b/api/src/com/cloud/gpu/GPU.java
index 0eb4667..0df821f 100644
--- a/api/src/com/cloud/gpu/GPU.java
+++ b/api/src/com/cloud/gpu/GPU.java
@@ -23,10 +23,6 @@ public class GPU {
         pciDevice,
         vgpuType
     }
-    public enum Type {
-        GPU_Passthrough,
-        VGPU
-    }
 
     public enum vGPUType {
         GRID_K100("GRID K100"),

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2ae9da8d/engine/components-api/src/com/cloud/resource/ResourceManager.java
----------------------------------------------------------------------
diff --git a/engine/components-api/src/com/cloud/resource/ResourceManager.java b/engine/components-api/src/com/cloud/resource/ResourceManager.java
index 0608cb4..052c250 100755
--- a/engine/components-api/src/com/cloud/resource/ResourceManager.java
+++ b/engine/components-api/src/com/cloud/resource/ResourceManager.java
@@ -151,26 +151,29 @@ public interface ResourceManager extends ResourceService {
     /**
      * Check if host has GPU devices available
      * @param hostId the host to be checked
+     * @param groupName: gpuCard name
      * @param vgpuType the VGPU type
      * @return true when the host has the capacity with given VGPU type
      */
-    boolean isGPUDeviceAvailable(long hostId, String vgpuType);
+    boolean isGPUDeviceAvailable(long hostId, String groupName, String vgpuType);
 
     /**
      * Get available GPU device
      * @param hostId the host to be checked
+     * @param groupName: gpuCard name
      * @param vgpuType the VGPU type
      * @return GPUDeviceTO[]
      */
-    GPUDeviceTO getGPUDevice(long hostId, String vgpuType);
+    GPUDeviceTO getGPUDevice(long hostId, String groupName, String vgpuType);
 
     /**
      * Return listof available GPU devices
      * @param hostId, the host to be checked
+     * @param groupName: gpuCard name
      * @param vgpuType the VGPU type
      * @return List of HostGpuGroupsVO.
      */
-    List<HostGpuGroupsVO> listAvailableGPUDevice(long hostId, String vgpuType);
+    List<HostGpuGroupsVO> listAvailableGPUDevice(long hostId, String groupName, String
vgpuType);
 
     /**
      * Update GPU device details (post VM deployment)

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2ae9da8d/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
index a451fad..3bd5c94 100755
--- a/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
+++ b/server/src/com/cloud/agent/manager/allocator/impl/FirstFitAllocator.java
@@ -278,10 +278,12 @@ public class FirstFitAllocator extends AdapterBase implements HostAllocator
{
             }
 
             // Check if GPU device is required by offering and host has the availability
-            if ((offeringDetails   = _serviceOfferingDetailsDao.findDetail(serviceOfferingId,
GPU.Keys.vgpuType.toString())) != null
-                    && !_resourceMgr.isGPUDeviceAvailable(host.getId(), offeringDetails.getValue())){
-                s_logger.info("Host name: " + host.getName() + ", hostId: "+ host.getId()
+" does not have required GPU devices available");
-                continue;
+            if ((offeringDetails   = _serviceOfferingDetailsDao.findDetail(serviceOfferingId,
GPU.Keys.vgpuType.toString())) != null) {
+                ServiceOfferingDetailsVO groupName = _serviceOfferingDetailsDao.findDetail(serviceOfferingId,
GPU.Keys.pciDevice.toString());
+                if(!_resourceMgr.isGPUDeviceAvailable(host.getId(), groupName.getValue(),
offeringDetails.getValue())){
+                    s_logger.info("Host name: " + host.getName() + ", hostId: "+ host.getId()
+" does not have required GPU devices available");
+                    continue;
+                }
             }
 
             int cpu_requested = offering.getCpu() * offering.getSpeed();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2ae9da8d/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 75f4d8a..30afd7b 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -2084,47 +2084,33 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
         offering.setHypervisorSnapshotReserve(hypervisorSnapshotReserve);
 
         List<ServiceOfferingDetailsVO> detailsVO = null;
-            if (details != null) {
+        if (details != null) {
             // Check if the user has passed the gpu-type before passing the VGPU type
-            if (!details.containsKey(GPU.Keys.pciDevice.toString()) && details.containsKey(GPU.Keys.vgpuType.toString()))
{
-                throw new InvalidParameterValueException("Please specify the gpu type");
+            if (!details.containsKey(GPU.Keys.pciDevice.toString()) || !details.containsKey(GPU.Keys.vgpuType.toString()))
{
+                throw new InvalidParameterValueException("Please specify the pciDevice and
vgpuType correctly.");
             }
             detailsVO = new ArrayList<ServiceOfferingDetailsVO>();
-                for (Entry<String, String> detailEntry : details.entrySet()) {
+            for (Entry<String, String> detailEntry : details.entrySet()) {
                 String value = null;
                 if (detailEntry.getKey().equals(GPU.Keys.pciDevice.toString())) {
-                    for (GPU.Type type : GPU.Type.values()) {
-                        if (detailEntry.getValue().equals(type.toString())) {
-                            value = detailEntry.getValue();
-                        }
-                    }
-                    if (value == null) {
-                        throw new InvalidParameterValueException("Please specify valid gpu
type");
+                    if (detailEntry.getValue() == null) {
+                        throw new InvalidParameterValueException("Please specify a GPU Card.");
                     }
                 }
                 if (detailEntry.getKey().equals(GPU.Keys.vgpuType.toString())) {
-                    if (details.get(GPU.Keys.pciDevice.toString()).equals(GPU.Type.GPU_Passthrough.toString()))
{
-                        throw new InvalidParameterValueException("vgpuTypes are supported
only with vGPU pciDevice");
-                    }
                     if (detailEntry.getValue() == null) {
-                        throw new InvalidParameterValueException("With vGPU as pciDevice,
vGPUType value cannot be null");
+                        throw new InvalidParameterValueException("vGPUType value cannot be
null");
                     }
                     for (GPU.vGPUType entry : GPU.vGPUType.values()) {
                         if (detailEntry.getValue().equals(entry.getType())) {
                             value = entry.getType();
                         }
                     }
-                    if (value == null || detailEntry.getValue().equals(GPU.vGPUType.passthrough.getType()))
{
+                    if (value == null) {
                         throw new InvalidParameterValueException("Please specify valid vGPU
type");
                     }
                 }
-                    detailsVO.add(new ServiceOfferingDetailsVO(offering.getId(), detailEntry.getKey(),
detailEntry.getValue(), true));
-                }
-            // If pciDevice type is passed, put the default VGPU type as 'passthrough'
-            if (details.containsKey(GPU.Keys.pciDevice.toString())
-                    && !details.containsKey(GPU.Keys.vgpuType.toString())) {
-                detailsVO.add(new ServiceOfferingDetailsVO(offering.getId(),
-                        GPU.Keys.vgpuType.toString(), GPU.vGPUType.passthrough.getType(),
true));
+                detailsVO.add(new ServiceOfferingDetailsVO(offering.getId(), detailEntry.getKey(),
detailEntry.getValue(), true));
             }
         }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2ae9da8d/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
index fc7c300..fdca447 100644
--- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
+++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java
@@ -363,9 +363,11 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements
Deploy
             } else if (_capacityMgr.checkIfHostReachMaxGuestLimit(host)) {
                 s_logger.debug("The last Host, hostId: " + host.getId() +
                     " already has max Running VMs(count includes system VMs), skipping this
and trying other available hosts");
-            } else if ((offeringDetails  = _serviceOfferingDetailsDao.findDetail(offering.getId(),
GPU.Keys.vgpuType.toString())) != null
-                    && !_resourceMgr.isGPUDeviceAvailable(host.getId(), offeringDetails.getValue())){
-                s_logger.debug("The last host of this VM does not have required GPU devices
available");
+            } else if ((offeringDetails  = _serviceOfferingDetailsDao.findDetail(offering.getId(),
GPU.Keys.vgpuType.toString())) != null) {
+                ServiceOfferingDetailsVO groupName = _serviceOfferingDetailsDao.findDetail(offering.getId(),
GPU.Keys.pciDevice.toString());
+                if(!_resourceMgr.isGPUDeviceAvailable(host.getId(), groupName.getValue(),
offeringDetails.getValue())){
+                    s_logger.debug("The last host of this VM does not have required GPU devices
available");
+                }
             } else {
                 if (host.getStatus() == Status.Up && host.getResourceState() == ResourceState.Enabled)
{
                     boolean hostTagsMatch = true;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2ae9da8d/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
index b643ec4..e2520d2 100644
--- a/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
+++ b/server/src/com/cloud/hypervisor/HypervisorGuruBase.java
@@ -144,7 +144,8 @@ public abstract class HypervisorGuruBase extends AdapterBase implements
Hypervis
         // Set GPU details
         ServiceOfferingDetailsVO offeringDetail = null;
         if ((offeringDetail  = _serviceOfferingDetailsDao.findDetail(offering.getId(), GPU.Keys.vgpuType.toString()))
!= null) {
-            to.setGpuDevice(_resourceMgr.getGPUDevice(vm.getHostId(), offeringDetail.getValue()));
+            ServiceOfferingDetailsVO groupName = _serviceOfferingDetailsDao.findDetail(offering.getId(),
GPU.Keys.pciDevice.toString());
+            to.setGpuDevice(_resourceMgr.getGPUDevice(vm.getHostId(), groupName.getValue(),
offeringDetail.getValue()));
         }
 
         // Workaround to make sure the TO has the UUID we need for Niciri integration

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2ae9da8d/server/src/com/cloud/resource/ResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java
index 0fefd62..f8870db 100755
--- a/server/src/com/cloud/resource/ResourceManagerImpl.java
+++ b/server/src/com/cloud/resource/ResourceManagerImpl.java
@@ -97,7 +97,6 @@ import com.cloud.exception.DiscoveryException;
 import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.exception.PermissionDeniedException;
 import com.cloud.exception.ResourceInUseException;
-import com.cloud.gpu.GPU.vGPUType;
 import com.cloud.gpu.HostGpuGroupsVO;
 import com.cloud.gpu.VGPUTypesVO;
 import com.cloud.gpu.dao.HostGpuGroupsDao;
@@ -1349,6 +1348,7 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
 
         _gpuAvailability = _hostGpuGroupsDao.createSearchBuilder();
         _gpuAvailability.and("hostId", _gpuAvailability.entity().getHostId(), Op.EQ);
+        _gpuAvailability.and("groupName", _gpuAvailability.entity().getGroupName(), Op.EQ);
         SearchBuilder<VGPUTypesVO> join1 = _vgpuTypesDao.createSearchBuilder();
         join1.and("vgpuType", join1.entity().getVgpuType(), Op.EQ);
         join1.and("remainingCapacity", join1.entity().getRemainingCapacity(), Op.GT);
@@ -2508,21 +2508,19 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
     }
 
     @Override
-    public List<HostGpuGroupsVO> listAvailableGPUDevice(long hostId, String vgpuType)
{
-        if (vgpuType == null) {
-            vgpuType = vGPUType.passthrough.getType();
-        }
+    public List<HostGpuGroupsVO> listAvailableGPUDevice(long hostId, String groupName,
String vgpuType) {
         Filter searchFilter = new Filter(VGPUTypesVO.class, "remainingCapacity", false, null,
null);
         SearchCriteria<HostGpuGroupsVO> sc = _gpuAvailability.create();
         sc.setParameters("hostId", hostId);
+        sc.setParameters("groupName", groupName);
         sc.setJoinParameters("groupId", "vgpuType", vgpuType);
         sc.setJoinParameters("groupId", "remainingCapacity", 0);
         return _hostGpuGroupsDao.customSearch(sc, searchFilter);
     }
 
     @Override
-    public boolean isGPUDeviceAvailable(long hostId, String vgpuType) {
-        if(!listAvailableGPUDevice(hostId, vgpuType).isEmpty()) {
+    public boolean isGPUDeviceAvailable(long hostId, String groupName, String vgpuType) {
+        if(!listAvailableGPUDevice(hostId, groupName, vgpuType).isEmpty()) {
             return true;
         } else {
             if (s_logger.isDebugEnabled()) {
@@ -2533,8 +2531,8 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager,
     }
 
     @Override
-    public GPUDeviceTO getGPUDevice(long hostId, String vgpuType) {
-        HostGpuGroupsVO gpuDevice = listAvailableGPUDevice(hostId, vgpuType).get(0);
+    public GPUDeviceTO getGPUDevice(long hostId, String groupName, String vgpuType) {
+        HostGpuGroupsVO gpuDevice = listAvailableGPUDevice(hostId, groupName, vgpuType).get(0);
         return new GPUDeviceTO(gpuDevice.getGroupName(), vgpuType, null);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2ae9da8d/server/test/com/cloud/resource/MockResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/resource/MockResourceManagerImpl.java b/server/test/com/cloud/resource/MockResourceManagerImpl.java
index 8c5f5da..409e3a6 100644
--- a/server/test/com/cloud/resource/MockResourceManagerImpl.java
+++ b/server/test/com/cloud/resource/MockResourceManagerImpl.java
@@ -558,19 +558,19 @@ public class MockResourceManagerImpl extends ManagerBase implements
ResourceMana
     }
 
     @Override
-    public boolean isGPUDeviceAvailable(long hostId, String vgpuType) {
+    public boolean isGPUDeviceAvailable(long hostId, String groupName, String vgpuType) {
         // TODO Auto-generated method stub
         return false;
     }
 
     @Override
-    public GPUDeviceTO getGPUDevice(long hostId, String vgpuType) {
+    public GPUDeviceTO getGPUDevice(long hostId, String groupName, String vgpuType) {
         // TODO Auto-generated method stub
         return null;
     }
 
     @Override
-    public List<HostGpuGroupsVO> listAvailableGPUDevice(long hostId, String vgpuType)
{
+    public List<HostGpuGroupsVO> listAvailableGPUDevice(long hostId, String groupName,
String vgpuType) {
         // TODO Auto-generated method stub
         return null;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2ae9da8d/ui/scripts/configuration.js
----------------------------------------------------------------------
diff --git a/ui/scripts/configuration.js b/ui/scripts/configuration.js
index 7b2f4e9..ba6bdce 100644
--- a/ui/scripts/configuration.js
+++ b/ui/scripts/configuration.js
@@ -370,25 +370,16 @@
                                                 description: ''
                                             });
                                             items.push({
-                                                id: 'GPU_Passthrough',
-                                                description: 'GPU-Passthrough'
+                                                id: 'Group of NVIDIA Corporation GK107GL
[GRID K1] GPUs',
+                                                description: 'NVIDIA GRID K1'
                                             });
                                             items.push({
-                                                id: 'VGPU',
-                                                description: 'VGPU'
+                                                id: 'Group of NVIDIA Corporation GK104GL
[GRID K2] GPUs',
+                                                description: 'NVIDIA GRID K2'
                                             });
                                             args.response.success({
                                                 data: items
                                             });
-                                            args.$select.change(function() {
-                                                var $form = $(this).closest('form');
-                                                var $fields = $form.find('.field');
-                                                if (($(this).val() == "") || $(this).val()
== "GPU-Passthrough") {
-                                                  $form.find('[rel=vgpuType]').hide();
-                                                } else if ($(this).val() == "VGPU") {
-                                                  $form.find('[rel=vgpuType]').css('display',
'block');
-                                                }
-                                            });
                                         }
                                     },
 
@@ -401,6 +392,10 @@
                                                 description: ''
                                             });
                                             items.push({
+                                                id: 'passthrough',
+                                                description: 'passthrough'
+                                            });
+                                            items.push({
                                                 id: 'GRID K100',
                                                 description: 'GRID K100'
                                             });
@@ -499,7 +494,7 @@
                                     array1.push("&serviceofferingdetails[1].value" +
"=" + args.data.pciDevice);
                                 }
 
-                                if (args.data.pciDevice == "VGPU") {
+                                if (args.data.vgpuType != "") {
                                     array1.push("&serviceofferingdetails[2].key" + "="
+ "vgpuType");
                                     array1.push("&serviceofferingdetails[2].value" +
"=" + args.data.vgpuType);
                                 }


Mime
View raw message