diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java index 960be8df577..b58aaf345ae 100644 --- a/api/src/main/java/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java +++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java @@ -54,7 +54,10 @@ public class AddHostCmd extends BaseCmd { @Parameter(name = ApiConstants.CLUSTER_NAME, type = CommandType.STRING, description = "the cluster name for the host") private String clusterName; - @Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, required = true, description = "the password for the host") + @Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, description = "the username for the host; required to be passed for hypervisors other than VMWare") + private String username; + + @Parameter(name = ApiConstants.PASSWORD, type = CommandType.STRING, description = "the password for the host; required to be passed for hypervisors other than VMWare") private String password; @Parameter(name = ApiConstants.POD_ID, type = CommandType.UUID, entityType = PodResponse.class, required = true, description = "the Pod ID for the host") @@ -63,9 +66,6 @@ public class AddHostCmd extends BaseCmd { @Parameter(name = ApiConstants.URL, type = CommandType.STRING, required = true, description = "the host URL") private String url; - @Parameter(name = ApiConstants.USERNAME, type = CommandType.STRING, required = true, description = "the username for the host") - private String username; - @Parameter(name = ApiConstants.ZONE_ID, type = CommandType.UUID, entityType = ZoneResponse.class, required = true, description = "the Zone ID for the host") private Long zoneId; diff --git a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java index 4731ac6d08a..89ccf17b148 100755 --- a/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java +++ b/server/src/main/java/com/cloud/resource/ResourceManagerImpl.java @@ -44,6 +44,7 @@ import com.cloud.storage.dao.DiskOfferingDao; import com.cloud.vm.UserVmManager; import com.cloud.vm.VirtualMachineProfile; import com.cloud.vm.VirtualMachineProfileImpl; +import com.google.common.base.Strings; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.command.admin.cluster.AddClusterCmd; import org.apache.cloudstack.api.command.admin.cluster.DeleteClusterCmd; @@ -688,6 +689,10 @@ public class ResourceManagerImpl extends ManagerBase implements ResourceManager, if ((clusterName != null || clusterId != null) && podId == null) { throw new InvalidParameterValueException("Can't specify cluster without specifying the pod"); } + if (!HypervisorType.VMware.toString().equalsIgnoreCase(hypervisorType) && + (Strings.isNullOrEmpty(username) || Strings.isNullOrEmpty(password))) { + throw new InvalidParameterValueException("Username and Password need to be provided."); + } if (clusterId != null) { if (_clusterDao.findById(clusterId) == null) {