diff --git a/api/src/com/cloud/api/commands/AddClusterCmd.java b/api/src/com/cloud/api/commands/AddClusterCmd.java index 2b1daadc786..caa9e89e8de 100755 --- a/api/src/com/cloud/api/commands/AddClusterCmd.java +++ b/api/src/com/cloud/api/commands/AddClusterCmd.java @@ -48,7 +48,7 @@ public class AddClusterCmd extends BaseCmd { private String password; @IdentityMapper(entityTableName="host_pod_ref") - @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, description="the Pod ID for the host") + @Parameter(name=ApiConstants.POD_ID, type=CommandType.LONG, required=true, description="the Pod ID for the host") private Long podId; @Parameter(name=ApiConstants.URL, type=CommandType.STRING, required=false, description="the URL") diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index 04423e88a48..e026cf3106e 100755 --- a/server/src/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -140,7 +140,6 @@ import com.cloud.utils.net.Ip; import com.cloud.utils.net.NetUtils; import com.cloud.utils.ssh.SSHCmdHelper; import com.cloud.utils.ssh.sshException; -import com.cloud.utils.AnnotationHelper; import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine.State; import com.cloud.vm.VirtualMachineManager; @@ -314,8 +313,8 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma @Override public List discoverCluster(AddClusterCmd cmd) throws IllegalArgumentException, DiscoveryException { - Long dcId = cmd.getZoneId(); - Long podId = cmd.getPodId(); + long dcId = cmd.getZoneId(); + long podId = cmd.getPodId(); String clusterName = cmd.getClusterName(); String url = cmd.getUrl(); String username = cmd.getUsername(); @@ -348,18 +347,17 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma } // Check if the pod exists in the system - if (podId != null) { - if (_podDao.findById(podId) == null) { - throw new InvalidParameterValueException("Can't find pod by id " + podId); - } - // check if pod belongs to the zone - if (!Long.valueOf(pod.getDataCenterId()).equals(dcId)) { - InvalidParameterValueException ex = new InvalidParameterValueException("Pod with specified id doesn't belong to the zone " + dcId); - ex.addProxyObject(pod, podId, "podId"); - ex.addProxyObject(zone, dcId, "dcId"); - throw ex; - } + if (_podDao.findById(podId) == null) { + throw new InvalidParameterValueException("Can't find pod by id " + podId); } + // check if pod belongs to the zone + if (!Long.valueOf(pod.getDataCenterId()).equals(dcId)) { + InvalidParameterValueException ex = new InvalidParameterValueException("Pod with specified id doesn't belong to the zone " + dcId); + ex.addProxyObject(pod, podId, "podId"); + ex.addProxyObject(zone, dcId, "dcId"); + throw ex; + } + // Verify cluster information and create a new cluster if needed if (clusterName == null || clusterName.isEmpty()) {