From 951d86f41fa47b7e50e28e028ad1b9fa454cd1c6 Mon Sep 17 00:00:00 2001 From: anthony Date: Thu, 30 Dec 2010 15:44:13 -0800 Subject: [PATCH] bug 7782: check if hypervisor type is specified before creating cluster status 7782: resolved fixed --- .../com/cloud/agent/manager/AgentManagerImpl.java | 12 +++++++----- .../secondary/SecondaryStorageDiscoverer.java | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index 87b95e1b6dc..70b8564cf27 100755 --- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -684,7 +684,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS public List discoverHosts(AddSecondaryStorageCmd cmd) throws IllegalArgumentException, DiscoveryException, InvalidParameterValueException { Long dcId = cmd.getZoneId(); String url = cmd.getUrl(); - return discoverHosts(dcId, null, null, null, url, null, null, ""); + return discoverHosts(dcId, null, null, null, url, null, null, "SecondaryStorage"); } @Override @@ -719,6 +719,10 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS throw new InvalidParameterValueException("Can't specify cluster by both id and name"); } + if (hypervisorType == null || hypervisorType.isEmpty() ) { + throw new InvalidParameterValueException("Need to specify Hypervisor Type"); + } + if ((clusterName != null || clusterId != null) && podId == null) { throw new InvalidParameterValueException("Can't specify cluster without specifying the pod"); } @@ -762,10 +766,8 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS boolean isHypervisorTypeSupported = false; while (en.hasMoreElements()) { Discoverer discoverer = en.nextElement(); - if(hypervisorType != null) { - if(!discoverer.matchHypervisor(hypervisorType)) { - continue; - } + if(!discoverer.matchHypervisor(hypervisorType)) { + continue; } isHypervisorTypeSupported = true; Map> resources = null; diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageDiscoverer.java b/server/src/com/cloud/storage/secondary/SecondaryStorageDiscoverer.java index 6a1434b6e72..30b0555c28c 100644 --- a/server/src/com/cloud/storage/secondary/SecondaryStorageDiscoverer.java +++ b/server/src/com/cloud/storage/secondary/SecondaryStorageDiscoverer.java @@ -241,7 +241,7 @@ public class SecondaryStorageDiscoverer extends DiscovererBase implements Discov @Override public boolean matchHypervisor(String hypervisor) { - if( hypervisor == null || hypervisor.isEmpty()) { + if( hypervisor.equals("SecondaryStorage")) { return true; } else { return false;