diff --git a/server/src/com/cloud/agent/manager/AgentManagerImpl.java b/server/src/com/cloud/agent/manager/AgentManagerImpl.java index dc41727117c..cca82bdfdb9 100755 --- a/server/src/com/cloud/agent/manager/AgentManagerImpl.java +++ b/server/src/com/cloud/agent/manager/AgentManagerImpl.java @@ -851,9 +851,30 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS } if (clusterId != null) { - if (_clusterDao.findById(clusterId) == null) { + ClusterVO cluster = _clusterDao.findById(clusterId); + if (cluster == null) { throw new InvalidParameterValueException("Can't find cluster by id " + clusterId); } + + // VMware only allows adding host to an existing cluster, as we already have a lot of information + // in cluster object, to simplify user input, we will construct neccessary information here + Map clusterDetails = this._clusterDetailsDao.findDetails(clusterId); + username = clusterDetails.get("username"); + assert(username != null); + + password = clusterDetails.get("password"); + assert(password != null); + + try { + uri = new URI(UriUtils.encodeURIComponent(url)); + + url = clusterDetails.get("url") + "/" + uri.getHost(); + } catch (URISyntaxException e) { + throw new InvalidParameterValueException(url + " is not a valid uri"); + } + } else { + if(hypervisorType.equalsIgnoreCase(HypervisorType.VMware.toString())) + throw new InvalidParameterValueException("Expecting cluster id in parameter, VMware only allows adding host to an existing cluster"); } if (clusterName != null) { @@ -872,6 +893,7 @@ public class AgentManagerImpl implements AgentManager, HandlerFactory, ResourceS try { uri = new URI(UriUtils.encodeURIComponent(url)); + if (uri.getScheme() == null) { throw new InvalidParameterValueException("uri.scheme is null " + url + ", add nfs:// as a prefix"); } else if (uri.getScheme().equalsIgnoreCase("nfs")) { diff --git a/ui/jsp/cluster.jsp b/ui/jsp/cluster.jsp index 8649d43a172..4a3606dd9fb 100644 --- a/ui/jsp/cluster.jsp +++ b/ui/jsp/cluster.jsp @@ -183,6 +183,7 @@ dictionary = { +
  • diff --git a/ui/jsp/host.jsp b/ui/jsp/host.jsp index 0b30e568efe..d28978f43ed 100644 --- a/ui/jsp/host.jsp +++ b/ui/jsp/host.jsp @@ -744,6 +744,7 @@ dictionary = {
  • +
  • diff --git a/ui/jsp/pod.jsp b/ui/jsp/pod.jsp index 922277dd049..a2ba45448e0 100644 --- a/ui/jsp/pod.jsp +++ b/ui/jsp/pod.jsp @@ -308,6 +308,8 @@ dictionary = {
  • + +
  • diff --git a/ui/jsp/resource.jsp b/ui/jsp/resource.jsp index c1b3941720e..c4025a656fe 100644 --- a/ui/jsp/resource.jsp +++ b/ui/jsp/resource.jsp @@ -909,6 +909,7 @@
  • +
  • diff --git a/ui/jsp/zone.jsp b/ui/jsp/zone.jsp index fb8628c0b7f..5b08d9f5164 100644 --- a/ui/jsp/zone.jsp +++ b/ui/jsp/zone.jsp @@ -389,6 +389,7 @@ dictionary = {
  • +
  • diff --git a/ui/scripts/cloud.core.pod.js b/ui/scripts/cloud.core.pod.js index bb68e10c5ac..2ae5e9fcc67 100644 --- a/ui/scripts/cloud.core.pod.js +++ b/ui/scripts/cloud.core.pod.js @@ -515,10 +515,14 @@ function bindAddHostButton($leftmenuItem1) { clusterObj = clustersUnderOnePod[clusterId]; hypervisor = clusterObj.hypervisortype; if(hypervisor == "VMware") { + + // for VMware, we can only add host to existing cluster, only host address is needed as of now +/* isValid &= validateString("vCenter Address", $thisDialog.find("#host_vcenter_address"), $thisDialog.find("#host_vcenter_address_errormsg")); isValid &= validateString("vCenter User", $thisDialog.find("#host_vcenter_username"), $thisDialog.find("#host_vcenter_username_errormsg")); isValid &= validateString("vCenter Password", $thisDialog.find("#host_vcenter_password"), $thisDialog.find("#host_vcenter_password_errormsg")); isValid &= validateString("vCenter Datacenter", $thisDialog.find("#host_vcenter_dc"), $thisDialog.find("#host_vcenter_dc_errormsg")); +*/ isValid &= validateString("vCenter Host", $thisDialog.find("#host_vcenter_host"), $thisDialog.find("#host_vcenter_host_errormsg")); } else { isValid &= validateString("Host name", $thisDialog.find("#host_hostname"), $thisDialog.find("#host_hostname_errormsg")); @@ -540,6 +544,7 @@ function bindAddHostButton($leftmenuItem1) { array1.push("&clustertype=" + clustertype); if(hypervisor == "VMware") { +/* var username = trim($thisDialog.find("#host_vcenter_username").val()); array1.push("&username="+todb(username)); @@ -549,7 +554,11 @@ function bindAddHostButton($leftmenuItem1) { var hostname = trim($thisDialog.find("#host_vcenter_address").val()); hostname += "/" + todb(trim($thisDialog.find("#host_vcenter_dc").val())); hostname += "/" + todb(trim($thisDialog.find("#host_vcenter_host").val())); - +*/ + array1.push("&username="); + array1.push("&password="); + var hostname = trim($thisDialog.find("#host_vcenter_host").val()); + var url; if(hostname.indexOf("http://")==-1) url = "http://" + hostname; diff --git a/ui/scripts/cloud.core.resource.js b/ui/scripts/cloud.core.resource.js index 9d69b4151c7..7910ecbca10 100644 --- a/ui/scripts/cloud.core.resource.js +++ b/ui/scripts/cloud.core.resource.js @@ -866,10 +866,12 @@ function initAddHostShortcut() { clusterObj = clustersUnderOnePod[clusterId]; hypervisor = clusterObj.hypervisortype; if(hypervisor == "VMware") { +/* isValid &= validateString("vCenter Address", $thisDialog.find("#host_vcenter_address"), $thisDialog.find("#host_vcenter_address_errormsg")); isValid &= validateString("vCenter User", $thisDialog.find("#host_vcenter_username"), $thisDialog.find("#host_vcenter_username_errormsg")); isValid &= validateString("vCenter Password", $thisDialog.find("#host_vcenter_password"), $thisDialog.find("#host_vcenter_password_errormsg")); isValid &= validateString("vCenter Datacenter", $thisDialog.find("#host_vcenter_dc"), $thisDialog.find("#host_vcenter_dc_errormsg")); +*/ isValid &= validateString("vCenter Host", $thisDialog.find("#host_vcenter_host"), $thisDialog.find("#host_vcenter_host_errormsg")); } else { isValid &= validateString("Host name", $thisDialog.find("#host_hostname"), $thisDialog.find("#host_hostname_errormsg")); @@ -903,6 +905,7 @@ function initAddHostShortcut() { array1.push("&clustertype=" + clustertype); if(hypervisor == "VMware") { +/* var username = trim($thisDialog.find("#host_vcenter_username").val()); array1.push("&username="+todb(username)); @@ -912,7 +915,11 @@ function initAddHostShortcut() { var hostname = trim($thisDialog.find("#host_vcenter_address").val()); hostname += "/" + trim($thisDialog.find("#host_vcenter_dc").val()); hostname += "/" + trim($thisDialog.find("#host_vcenter_host").val()); - +*/ + array1.push("&username="); + array1.push("&password="); + var hostname = trim($thisDialog.find("#host_vcenter_host").val()); + var url; if(hostname.indexOf("http://")==-1) url = "http://" + todb(hostname); diff --git a/ui/scripts/cloud.core.zone.js b/ui/scripts/cloud.core.zone.js index b997e923576..12525ee6319 100644 --- a/ui/scripts/cloud.core.zone.js +++ b/ui/scripts/cloud.core.zone.js @@ -729,10 +729,12 @@ function bindAddHostButtonOnZonePage($button, zoneId, zoneName) { clusterObj = clustersUnderOnePod[clusterId]; hypervisor = clusterObj.hypervisortype; if(hypervisor == "VMware") { +/* isValid &= validateString("vCenter Address", $thisDialog.find("#host_vcenter_address"), $thisDialog.find("#host_vcenter_address_errormsg")); isValid &= validateString("vCenter User", $thisDialog.find("#host_vcenter_username"), $thisDialog.find("#host_vcenter_username_errormsg")); isValid &= validateString("vCenter Password", $thisDialog.find("#host_vcenter_password"), $thisDialog.find("#host_vcenter_password_errormsg")); isValid &= validateString("vCenter Datacenter", $thisDialog.find("#host_vcenter_dc"), $thisDialog.find("#host_vcenter_dc_errormsg")); +*/ isValid &= validateString("vCenter Host", $thisDialog.find("#host_vcenter_host"), $thisDialog.find("#host_vcenter_host_errormsg")); } else { isValid &= validateString("Host name", $thisDialog.find("#host_hostname"), $thisDialog.find("#host_hostname_errormsg")); @@ -765,7 +767,8 @@ function bindAddHostButtonOnZonePage($button, zoneId, zoneName) { array1.push("&clustertype=" + clustertype); if(hypervisor == "VMware") { - var username = trim($thisDialog.find("#host_vcenter_username").val()); +/* + var username = trim($thisDialog.find("#host_vcenter_username").val()); array1.push("&username="+todb(username)); var password = trim($thisDialog.find("#host_vcenter_password").val()); @@ -774,7 +777,11 @@ function bindAddHostButtonOnZonePage($button, zoneId, zoneName) { var hostname = trim($thisDialog.find("#host_vcenter_address").val()); hostname += "/" + trim($thisDialog.find("#host_vcenter_dc").val()); hostname += "/" + trim($thisDialog.find("#host_vcenter_host").val()); - +*/ + array1.push("&username="); + array1.push("&password="); + var hostname = trim($thisDialog.find("#host_vcenter_host").val()); + var url; if(hostname.indexOf("http://")==-1) url = "http://" + todb(hostname);