Add supported hypervisors to a list

- By doing so the check is simple and will require less effort when adding other hypervisors.

Signed-off-by: wilderrodrigues <wrodrigues@schubergphilis.com>
This commit is contained in:
wilderrodrigues 2015-06-25 09:47:40 +02:00
parent ba19d47ea0
commit b6f12984c5

View File

@ -578,6 +578,7 @@ import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.host.dao.HostDetailsDao;
import com.cloud.host.dao.HostTagsDao;
import com.cloud.hypervisor.Hypervisor;
import com.cloud.hypervisor.Hypervisor.HypervisorType;
import com.cloud.hypervisor.HypervisorCapabilities;
import com.cloud.hypervisor.HypervisorCapabilitiesVO;
@ -762,8 +763,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
private ImageStoreDao _imgStoreDao;
@Inject
private ServiceOfferingDetailsDao _serviceOfferingDetailsDao;
@Inject
private ProjectManager _projectMgr;
@Inject
@ -801,6 +800,8 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
protected List<DeploymentPlanner> _planners;
private final List<HypervisorType> supportedHypervisors = new ArrayList<Hypervisor.HypervisorType>();
public List<DeploymentPlanner> getPlanners() {
return _planners;
}
@ -879,6 +880,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
_availableIdsMap.put(id, true);
}
supportedHypervisors.add(HypervisorType.KVM);
supportedHypervisors.add(HypervisorType.XenServer);
return true;
}
@ -3778,7 +3782,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
final ClusterVO cluster = ApiDBUtils.findClusterById(command.getClusterId());
if (cluster == null || cluster.getHypervisorType() != HypervisorType.XenServer || cluster.getHypervisorType() != HypervisorType.KVM) {
if (cluster == null || !supportedHypervisors.contains(cluster.getHypervisorType())) {
throw new InvalidParameterValueException("This operation is not supported for this hypervisor type");
}
return updateHostsInCluster(command);
@ -3793,10 +3797,9 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
final HostVO host = _hostDao.findById(cmd.getHostId());
if (host.getHypervisorType() != HypervisorType.XenServer || host.getHypervisorType() != HypervisorType.KVM) {
if (!supportedHypervisors.contains(host.getHypervisorType())) {
throw new InvalidParameterValueException("This operation is not supported for this hypervisor type");
}
Transaction.execute(new TransactionCallbackNoReturn() {
@Override
public void doInTransactionWithoutResult(final TransactionStatus status) {
@ -3816,7 +3819,6 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
}
}
});
return true;
}