1) Enable addExternalCluster API command

2) UI changes for new addExternalCluster API command (for vmware)
This commit is contained in:
Kelven Yang 2010-12-16 16:40:01 -08:00
parent 077e2f7cea
commit 4a6933fa9e
12 changed files with 383 additions and 9 deletions

View File

@ -40,6 +40,9 @@ public class ClusterResponse extends BaseResponse {
@SerializedName("zonename") @Param(description="the Zone name of the cluster")
private String zoneName;
@SerializedName("clustertype") @Param(description="the type of the cluster")
private String clusterType;
public Long getId() {
return id;
}
@ -87,4 +90,12 @@ public class ClusterResponse extends BaseResponse {
public void setZoneName(String zoneName) {
this.zoneName = zoneName;
}
public String getClusterType() {
return clusterType;
}
public void setClusterType(String clusterType) {
this.clusterType = clusterType;
}
}

View File

@ -18,6 +18,7 @@ label.add=Add
label.add.zone=Add Zone
label.adding.zone=Adding Zone
label.add.host=Add Host
label.add.cluster=Add External Cluster
label.add.primarystorage=Add Primary Storage
label.add.secondarystorage=Add Secondary Storage
label.add.pod=Add Pod

View File

@ -18,6 +18,7 @@ label.add=Add
label.add.zone=Add Zone
label.adding.zone=Adding Zone
label.add.host=Add Host
label.add.cluster=Add External Cluster
label.add.primarystorage=Add Primary Storage
label.add.secondarystorage=Add Secondary Storage
label.add.pod=Add Pod

View File

@ -166,6 +166,8 @@ listCapacity=com.cloud.api.commands.ListCapacityCmd;1
#### host commands
addHost=com.cloud.api.commands.AddHostCmd;1
addExternalCluster=com.cloud.api.commands.AddExternalClusterCmd;1
add=com.cloud.api.commands.AddHostCmd;1
reconnectHost=com.cloud.api.commands.ReconnectHostCmd;1
updateHost=com.cloud.api.commands.UpdateHostCmd;1
deleteHost=com.cloud.api.commands.DeleteHostCmd;1

View File

@ -863,6 +863,7 @@ public class ApiResponseHelper implements ResponseGenerator {
clusterResponse.setName(cluster.getName());
clusterResponse.setPodId(cluster.getPodId());
clusterResponse.setZoneId(cluster.getDataCenterId());
clusterResponse.setClusterType(cluster.getClusterType().toString());
HostPodVO pod = ApiDBUtils.findPodById(cluster.getPodId());
clusterResponse.setPodName(pod.getName());
DataCenterVO zone = ApiDBUtils.findZoneById(cluster.getDataCenterId());

View File

@ -186,7 +186,16 @@
<fmt:message key="label.add.zone"/>
</div>
</div>
</div>
</div>
<div class="actionpanel_button_wrapper" id="midmenu_add_cluster_button" style="display: none;">
<div class="actionpanel_button">
<div class="actionpanel_button_icons">
<img src="images/addvm_actionicon.png" alt="Add External Cluster" /></div>
<div class="actionpanel_button_links" id="label">
<fmt:message key="label.add.cluster"/>
</div>
</div>
</div>
<div class="actionpanel_button_wrapper" id="midmenu_add_host_button" style="display: none;">
<div class="actionpanel_button">
<div class="actionpanel_button_icons">

View File

@ -2,6 +2,8 @@
<%@ page import="com.cloud.utils.*" %>
<%@ include file="resourcedlgs.jsp" %>
<%
Locale browserLocale = request.getLocale();
CloudResourceBundle t = CloudResourceBundle.getBundle("resources/resource", browserLocale);
@ -160,6 +162,7 @@
</div>
<!-- Add Host Dialog (end) -->
<!-- Add Primary Storage Dialog (begin) -->
<div id="dialog_add_pool" title="Add Primary Storage" style="display: none">
<p>

View File

@ -305,6 +305,79 @@
</div>
<!-- Add Host Dialog (end) -->
<!-- Add Hypervisor managed cluster Dialog (begin) -->
<div id="dialog_add_external_cluster" title="Add External Cluster" style="display: none">
<p>
Add a hypervisor managed cluster for zone <b><span id="zone_name"></span></b>, pod <b><span id="pod_name">
</span></b>
</p>
<div class="dialog_formcontent">
<form action="#" method="post" id="form_acquire">
<ol>
<li>
<label for="cluster_hypervisor">Hypervisor:</label>
<select class="select" id="cluster_hypervisor">
<option value="VmWare" SELECTED>VMware</option>
</select>
</li>
<li>
<label for="cluster_hostname">
vCenter Server:</label>
<input class="text" type="text" name="cluster_hostname" id="cluster_hostname" />
<div id="cluster_hostname_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li>
<label for="cluster_username">
vCenter user:</label>
<input class="text" type="text" name="cluster_username" id="cluster_username" />
<div id="cluster_username_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li>
<label for="cluster_password">
Password:</label>
<input class="text" type="password" name="cluster_password" id="cluster_password" autocomplete="off" />
<div id="cluster_password_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li>
<label for="cluster_datacenter">
vCenter Datacenter:</label>
<input class="text" type="text" name="cluster_datacenter" id="cluster_datacenter" />
<div id="cluster_datacenter_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li>
<label for="cluster_name">
vCenter Cluster:</label>
<input class="text" type="text" name="cluster_name" id="cluster_name" />
<div id="cluster_name_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
</ol>
</form>
</div>
<!--Loading box-->
<div id="spinning_wheel" class="ui_dialog_loaderbox" style="display: none;">
<div class="ui_dialog_loader">
</div>
<p>
Adding....</p>
</div>
<!--Confirmation msg box-->
<!--Note: for error msg, just have to add error besides everything for eg. add error(class) next to ui_dialog_messagebox error, ui_dialog_msgicon error, ui_dialog_messagebox_text error. -->
<div id="info_container" class="ui_dialog_messagebox error" style="display: none;">
<div id="icon" class="ui_dialog_msgicon error">
</div>
<div id="info" class="ui_dialog_messagebox_text error">
(info)</div>
</div>
</div>
<!-- Add Hypervisor managed cluster Dialog (end) -->
<!-- Add Primary Storage Dialog (begin) -->
<div id="dialog_add_pool" title="Add Primary Storage" style="display: none">
<p>

View File

@ -569,6 +569,87 @@
</div>
<!-- Add Host Dialog in zone page (end) -->
<!-- Add Hypervisor managed cluster Dialog (begin) -->
<div id="dialog_add_external_cluster_in_zone_page" title="Add External Cluster" style="display: none">
<p>
Add a hypervisor managed cluster for zone <b><span id="zone_name"></span></b>
</p>
<div class="dialog_formcontent">
<form action="#" method="post" id="form_acquire">
<ol>
<li>
<label for="cluster_hypervisor">Hypervisor:</label>
<select class="select" id="cluster_hypervisor">
<option value="VmWare" SELECTED>VMware</option>
</select>
</li>
<li>
<label>
Pod:</label>
<select class="select" id="pod_dropdown">
</select>
<div id="pod_dropdown_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li>
<label for="cluster_hostname">
vCenter Server:</label>
<input class="text" type="text" name="cluster_hostname" id="cluster_hostname" />
<div id="cluster_hostname_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li>
<label for="cluster_username">
vCenter user:</label>
<input class="text" type="text" name="cluster_username" id="cluster_username" />
<div id="cluster_username_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li>
<label for="cluster_password">
Password:</label>
<input class="text" type="password" name="cluster_password" id="cluster_password" autocomplete="off" />
<div id="cluster_password_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li>
<label for="cluster_datacenter">
vCenter Datacenter:</label>
<input class="text" type="text" name="cluster_datacenter" id="cluster_datacenter" />
<div id="cluster_datacenter_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
<li>
<label for="cluster_name">
vCenter Cluster:</label>
<input class="text" type="text" name="cluster_name" id="cluster_name" />
<div id="cluster_name_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
</div>
</li>
</ol>
</form>
</div>
<!--Loading box-->
<div id="spinning_wheel" class="ui_dialog_loaderbox" style="display: none;">
<div class="ui_dialog_loader">
</div>
<p>
Adding....</p>
</div>
<!--Confirmation msg box-->
<!--Note: for error msg, just have to add error besides everything for eg. add error(class) next to ui_dialog_messagebox error, ui_dialog_msgicon error, ui_dialog_messagebox_text error. -->
<div id="info_container" class="ui_dialog_messagebox error" style="display: none;">
<div id="icon" class="ui_dialog_msgicon error">
</div>
<div id="info" class="ui_dialog_messagebox_text error">
(info)</div>
</div>
</div>
<!-- Add Hypervisor managed cluster Dialog (end) -->
<!-- Add Primary Storage Dialog in zone page (begin) -->
<div id="dialog_add_pool_in_zone_page" title="Add Primary Storage" style="display: none">
<p>

View File

@ -17,8 +17,12 @@
*/
function afterLoadClusterJSP($leftmenuItem1) {
clearAddButtonsOnTop();
initAddHostButton($("#midmenu_add_host_button"), "cluster_page", $leftmenuItem1);
clearAddButtonsOnTop();
var objCluster = $leftmenuItem1.data("jsonObj");
if(objCluster.clustertype == "CloudManaged")
initAddHostButton($("#midmenu_add_host_button"), "cluster_page", $leftmenuItem1);
initAddPrimaryStorageButton($("#midmenu_add_primarystorage_button"), "cluster_page", $leftmenuItem1);
initDialog("dialog_add_host");
@ -27,8 +31,8 @@ function afterLoadClusterJSP($leftmenuItem1) {
clusterJsonToRightPanel($leftmenuItem1);
var clusterId = $leftmenuItem1.data("jsonObj").id;
listMidMenuItems("hosts", ("listHosts&type=Routing&clusterid="+clusterId), hostGetSearchParams, "listhostsresponse", "host", "jsp/host.jsp", afterLoadHostJSP, hostToMidmenu, hostToRightPanel, getMidmenuId, false, ("cluster_"+clusterId));
listMidMenuItems("hosts", ("listHosts&type=Routing&clusterid="+objCluster.id), hostGetSearchParams, "listhostsresponse", "host", "jsp/host.jsp",
afterLoadHostJSP, hostToMidmenu, hostToRightPanel, getMidmenuId, false, ("cluster_"+objCluster.id));
}
function clusterJsonToRightPanel($leftmenuItem1) {

View File

@ -18,10 +18,12 @@
function afterLoadPodJSP($leftmenuItem1) {
hideMiddleMenu();
initAddClusterButton($("#midmenu_add_cluster_button"), "pod_page", $leftmenuItem1);
initAddHostButton($("#midmenu_add_host_button"), "pod_page", $leftmenuItem1);
initAddPrimaryStorageButton($("#midmenu_add_primarystorage_button"), "pod_page", $leftmenuItem1);
initDialog("dialog_add_external_cluster");
initDialog("dialog_add_host");
initDialog("dialog_add_pool");
@ -260,6 +262,90 @@ function refreshClsuterFieldInAddHostDialog(dialogAddHost, podId, clusterId) {
}
});
}
function initAddClusterButton($button, currentPageInRightPanel, $leftmenuItem1) {
$button.show();
$button.unbind("click").bind("click", function(event) {
dialogAddCluster = $("#dialog_add_external_cluster");
dialogAddCluster.find("#info_container").hide();
var zoneId, podId;
if(currentPageInRightPanel == "pod_page") {
var podObj = $leftmenuItem1.data("jsonObj");
zoneId = podObj.zoneid;
podId = podObj.id;
dialogAddCluster.find("#zone_name").text(fromdb(podObj.zonename));
dialogAddCluster.find("#pod_name").text(fromdb(podObj.name));
}
dialogAddCluster.dialog('option', 'buttons', {
"Add": function() {
var $thisDialog = $(this);
// validate values
var isValid = true;
isValid &= validateString("vCenter Server", $thisDialog.find("#cluster_hostname"), $thisDialog.find("#cluster_hostname_errormsg"));
isValid &= validateString("vCenter user", $thisDialog.find("#cluster_username"), $thisDialog.find("#cluster_username_errormsg"));
isValid &= validateString("Password", $thisDialog.find("#cluster_password"), $thisDialog.find("#cluster_password_errormsg"));
isValid &= validateString("Datacenter", $thisDialog.find("#cluster_datacenter"), $thisDialog.find("#cluster_datacenter_errormsg"));
isValid &= validateString("Cluster name", $thisDialog.find("#cluster_name"), $thisDialog.find("#cluster_name_errormsg"));
if (!isValid)
return;
$thisDialog.find("#spinning_wheel").show();
var array1 = [];
var hypervisor = $thisDialog.find("#cluster_hypervisor").val();
array1.push("&hypervisor="+hypervisor);
array1.push("&zoneId="+zoneId);
array1.push("&podId="+podId);
var username = trim($thisDialog.find("#cluster_username").val());
array1.push("&username="+todb(username));
var password = trim($thisDialog.find("#cluster_password").val());
array1.push("&password="+todb(password));
var hostname = trim($thisDialog.find("#cluster_hostname").val());
var dcName = trim($thisDialog.find("#cluster_datacenter").val());
var clusterName = trim($thisDialog.find("#cluster_name").val());
array1.push("&clustername=" + todb(hostname + "/" + dcName + "/" + clusterName));
var url;
if(hostname.indexOf("http://")==-1)
url = "http://" + todb(hostname);
else
url = hostname;
url += "/" + todb(dcName) + "/" + todb(clusterName);
array1.push("&url=" + todb(url));
$.ajax({
data: createURL("command=addExternalCluster" + array1.join("")),
dataType: "json",
success: function(json) {
$thisDialog.find("#spinning_wheel").hide();
$thisDialog.dialog("close");
showMiddleMenu();
clickClusterNodeAfterAddHost(clusterRadio, podId, clusterName, null, $thisDialog);
},
error: function(XMLHttpResponse) {
handleError(XMLHttpResponse, function() {
handleErrorInDialog(XMLHttpResponse, $thisDialog);
});
}
});
},
"Cancel": function() {
$(this).dialog("close");
}
}).dialog("open");
return false;
});
}
function initAddHostButton($button, currentPageInRightPanel, $leftmenuItem1) {
$button.show();

View File

@ -36,11 +36,13 @@
pods = json.listpodsresponse.pod;
}
});
if(pods != null && pods.length > 0) {
if(pods != null && pods.length > 0) {
initAddClusterButtonOnZonePage($("#midmenu_add_cluster_button"), zoneId, zoneName);
initAddHostButtonOnZonePage($("#midmenu_add_host_button"), zoneId, zoneName);
initAddPrimaryStorageButtonOnZonePage($("#midmenu_add_primarystorage_button"), zoneId, zoneName);
}
}
initDialog("dialog_add_external_cluster_in_zone_page");
initDialog("dialog_add_pod", 320);
initDialog("dialog_add_vlan_for_zone");
initDialog("dialog_add_secondarystorage");
@ -975,6 +977,106 @@ function doEditZone2($actionLink, $detailsTab, $leftmenuItem1, $readonlyFields,
}
}
function initAddClusterButtonOnZonePage($button, zoneId, zoneName) {
$button.show();
$button.unbind("click").bind("click", function(event) {
$dialogAddCluster = $("#dialog_add_external_cluster_in_zone_page");
$dialogAddCluster.find("#info_container").hide();
var $podSelect = $dialogAddCluster.find("#pod_dropdown");
$.ajax({
data: createURL("command=listPods&zoneid="+zoneId),
dataType: "json",
async: false,
success: function(json) {
var pods = json.listpodsresponse.pod;
$podSelect.empty();
if(pods != null && pods.length > 0) {
for(var i=0; i<pods.length; i++)
$podSelect.append("<option value='" + pods[i].id + "'>" + fromdb(pods[i].name) + "</option>");
}
$podSelect.change();
}
});
$dialogAddCluster.dialog('option', 'buttons', {
"Add": function() {
var $thisDialog = $(this);
// validate values
var isValid = true;
isValid &= validateString("vCenter Server", $thisDialog.find("#cluster_hostname"), $thisDialog.find("#cluster_hostname_errormsg"));
isValid &= validateString("vCenter user", $thisDialog.find("#cluster_username"), $thisDialog.find("#cluster_username_errormsg"));
isValid &= validateString("Password", $thisDialog.find("#cluster_password"), $thisDialog.find("#cluster_password_errormsg"));
isValid &= validateString("Datacenter", $thisDialog.find("#cluster_datacenter"), $thisDialog.find("#cluster_datacenter_errormsg"));
isValid &= validateString("Cluster name", $thisDialog.find("#cluster_name"), $thisDialog.find("#cluster_name_errormsg"));
if (!isValid)
return;
$thisDialog.find("#spinning_wheel").show();
var array1 = [];
var hypervisor = $thisDialog.find("#cluster_hypervisor").val();
array1.push("&hypervisor="+hypervisor);
array1.push("&zoneId="+zoneId);
//expand zone in left menu tree (to show pod, cluster under the zone)
var $zoneNode = $("#leftmenu_zone_tree").find("#tree_container").find("#zone_" + zoneId);
if($zoneNode.find("#zone_arrow").hasClass("expanded_close"))
$zoneNode.find("#zone_arrow").click();
var podId = $thisDialog.find("#pod_dropdown").val();
array1.push("&podId="+podId);
var username = trim($thisDialog.find("#cluster_username").val());
array1.push("&username="+todb(username));
var password = trim($thisDialog.find("#cluster_password").val());
array1.push("&password="+todb(password));
var hostname = trim($thisDialog.find("#cluster_hostname").val());
var dcName = trim($thisDialog.find("#cluster_datacenter").val());
var clusterName = trim($thisDialog.find("#cluster_name").val());
array1.push("&clustername=" + todb(hostname + "/" + dcName + "/" + clusterName));
var url;
if(hostname.indexOf("http://")==-1)
url = "http://" + todb(hostname);
else
url = hostname;
url += "/" + todb(dcName) + "/" + todb(clusterName);
array1.push("&url=" + todb(url));
$.ajax({
data: createURL("command=addExternalCluster" + array1.join("")),
dataType: "json",
success: function(json) {
$thisDialog.find("#spinning_wheel").hide();
$thisDialog.dialog("close");
showMiddleMenu();
clickClusterNodeAfterAddHost(clusterRadio, podId, clusterName, null, $thisDialog);
},
error: function(XMLHttpResponse) {
handleError(XMLHttpResponse, function() {
handleErrorInDialog(XMLHttpResponse, $thisDialog);
});
}
});
},
"Cancel": function() {
$(this).dialog("close");
}
}).dialog("open");
return false;
});
}
function initAddHostButtonOnZonePage($button, zoneId, zoneName) {
$button.show();