From 8fa14c7200f9e3cfcbb918874cb3f58754977d2e Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Fri, 30 Mar 2012 10:37:14 -0700 Subject: [PATCH] bug 14559: podId is required parameter in addCluster api status 14559: resolved fixed Conflicts: server/src/com/cloud/resource/ResourceManagerImpl.java --- .../com/cloud/api/commands/AddClusterCmd.java | 2 +- console-viewer/.project | 17 ++++++++++++++++ console/.project | 17 ++++++++++++++++ .../cloud/resource/ResourceManagerImpl.java | 20 +++++++++---------- 4 files changed, 44 insertions(+), 12 deletions(-) create mode 100644 console-viewer/.project create mode 100644 console/.project 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/console-viewer/.project b/console-viewer/.project new file mode 100644 index 00000000000..55284cd29b2 --- /dev/null +++ b/console-viewer/.project @@ -0,0 +1,17 @@ + + + console-viewer + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/console/.project b/console/.project new file mode 100644 index 00000000000..d1df45df74b --- /dev/null +++ b/console/.project @@ -0,0 +1,17 @@ + + + console + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/server/src/com/cloud/resource/ResourceManagerImpl.java b/server/src/com/cloud/resource/ResourceManagerImpl.java index 50d0c9d4857..ef1a1e441ec 100755 --- a/server/src/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/com/cloud/resource/ResourceManagerImpl.java @@ -313,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(); @@ -338,15 +338,13 @@ 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 - HostPodVO pod = _podDao.findById(podId); - if (!Long.valueOf(pod.getDataCenterId()).equals(dcId)) { - throw new InvalidParameterValueException("Pod " + podId + " doesn't belong to the zone " + dcId); - } + if (_podDao.findById(podId) == null) { + throw new InvalidParameterValueException("Can't find pod by id " + podId); + } + // check if pod belongs to the zone + HostPodVO pod = _podDao.findById(podId); + if (!Long.valueOf(pod.getDataCenterId()).equals(dcId)) { + throw new InvalidParameterValueException("Pod " + podId + " doesn't belong to the zone " + dcId); } // Verify cluster information and create a new cluster if needed