Improve the user experience (to have less room for customer to make mistakes) to add host to an existing VMware cluster

This commit is contained in:
Kelven Yang 2011-06-13 11:38:55 -07:00
parent 60db03f6be
commit 04060508e8
9 changed files with 61 additions and 5 deletions

View File

@ -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<String, String> 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")) {

View File

@ -183,6 +183,7 @@ dictionary = {
<div id="host_password_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<!--
<li input_group="vmware" style="display: none;">
<label for="host_vcenter_address">
<fmt:message key="label.vcenter.host"/>:</label>
@ -211,6 +212,7 @@ dictionary = {
<div id="host_vcenter_dc_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
-->
<li input_group="vmware" style="display: none;">
<label for="host_vcenter_host">
<fmt:message key="label.esx.host"/>:</label>

View File

@ -744,6 +744,7 @@ dictionary = {
<div id="host_password_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<!--
<li input_group="vmware" style="display: none;">
<label for="host_vcenter_address">
<fmt:message key="label.vcenter.host"/>:</label>
@ -772,6 +773,7 @@ dictionary = {
<div id="host_vcenter_dc_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
-->
<li input_group="vmware" style="display: none;">
<label for="host_vcenter_host">
<fmt:message key="label.esx.host"/>:</label>

View File

@ -308,6 +308,8 @@ dictionary = {
<div id="host_password_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<!--
<li input_group="vmware" style="display: none;">
<label for="host_vcenter_address">
<fmt:message key="label.vcenter.host"/>:</label>
@ -336,6 +338,7 @@ dictionary = {
<div id="host_vcenter_dc_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
-->
<li input_group="vmware" style="display: none;">
<label for="host_vcenter_host">
<fmt:message key="label.esx.host"/>:</label>

View File

@ -909,6 +909,7 @@
<div id="host_password_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<!--
<li input_group="vmware" style="display: none;">
<label for="host_vcenter_address">
<fmt:message key="label.vcenter.host"/>:</label>
@ -937,6 +938,7 @@
<div id="host_vcenter_dc_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
-->
<li input_group="vmware" style="display: none;">
<label for="host_vcenter_host">
<fmt:message key="label.esx.host"/>:</label>

View File

@ -389,6 +389,7 @@ dictionary = {
<div id="host_password_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<!--
<li input_group="vmware" style="display: none;">
<label for="host_vcenter_address">
<fmt:message key="label.vcenter.host"/>:</label>
@ -417,6 +418,7 @@ dictionary = {
<div id="host_vcenter_dc_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
-->
<li input_group="vmware" style="display: none;">
<label for="host_vcenter_host">
<fmt:message key="label.esx.host"/>:</label>

View File

@ -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;

View File

@ -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);

View File

@ -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);