Commit c3a72367 authored by Ahmad Siavashi's avatar Ahmad Siavashi

Add isGpuEquipped method to GpuHost

parent 4f096fa3
......@@ -72,11 +72,11 @@ public class GpuHost extends Host {
}
return smallerTime;
}
@Override
public boolean isSuitableForVm(Vm vm) {
boolean result = vmCreate(vm);
if(result) {
if (result) {
vmDestroy(vm);
}
return result;
......@@ -103,7 +103,7 @@ public class GpuHost extends Host {
* @return
*/
public boolean hasVideoCard(int videoCardId) {
if (getVideoCardAllocationPolicy() == null || getVideoCardAllocationPolicy().getVideoCards().isEmpty()) {
if (!isGpuEquipped()) {
return false;
}
for (VideoCard videoCard : getVideoCardAllocationPolicy().getVideoCards()) {
......@@ -121,7 +121,7 @@ public class GpuHost extends Host {
* @return
*/
public boolean hasPgpu(int pgpuId) {
if (getVideoCardAllocationPolicy() == null || getVideoCardAllocationPolicy().getVideoCards().isEmpty()) {
if (!isGpuEquipped()) {
return false;
}
for (VideoCard videoCard : getVideoCardAllocationPolicy().getVideoCards()) {
......@@ -134,6 +134,10 @@ public class GpuHost extends Host {
return false;
}
public boolean isGpuEquipped() {
return getVideoCardAllocationPolicy() != null && !getVideoCardAllocationPolicy().getVideoCards().isEmpty();
}
public void vgpuDestroy(Vgpu vgpu) {
if (vgpu != null) {
getVideoCardAllocationPolicy().deallocate(vgpu);
......@@ -163,9 +167,7 @@ public class GpuHost extends Host {
}
public Set<Vgpu> getVgpuSet() {
if (getVideoCardAllocationPolicy() == null) {
return null;
} else if (getVideoCardAllocationPolicy().getVideoCards().isEmpty()) {
if (!isGpuEquipped()) {
return null;
}
return getVideoCardAllocationPolicy().getVgpuVideoCardMap().keySet();
......
......@@ -149,8 +149,7 @@ public abstract class GpuVmAllocationPolicy extends VmAllocationPolicy {
protected void setGpuHostList(List<GpuHost> gpuHostList) {
this.gpuHostList = new ArrayList<GpuHost>();
for (GpuHost host : gpuHostList) {
if (host.getVideoCardAllocationPolicy() != null
&& !host.getVideoCardAllocationPolicy().getVideoCards().isEmpty()) {
if (host.isGpuEquipped()) {
getGpuHostList().add(host);
}
}
......
......@@ -43,8 +43,7 @@ public class GridGpuVmAllocationPolicyBestFit extends GpuVmAllocationPolicy {
// Create nonGpuHost list
for (Host host : list) {
GpuHost pm = (GpuHost) host;
if (pm.getVideoCardAllocationPolicy() == null
|| pm.getVideoCardAllocationPolicy().getVideoCards().isEmpty()) {
if (!pm.isGpuEquipped()) {
nonGpuHostList.add(pm);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment