mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
vmware: Bypass empty string check for username and password (#5337)
* Bypass empty string check for username and password Co-authored-by: dahn <daan.hoogland@gmail.com>
This commit is contained in:
parent
83dd294940
commit
e1e6ec107c
@ -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;
|
||||
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user