mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
(1) When hypervisor.type is kvm, allow option to add host in UI.
(2) When when hypervisor.type is kvm, hide cluster section in add host dialog.
This commit is contained in:
parent
7cf14dcffa
commit
66ccd6f7ad
@ -277,10 +277,10 @@
|
|||||||
<input class="text" type="password" name="host_password" id="host_password" AUTOCOMPLETE="off" />
|
<input class="text" type="password" name="host_password" id="host_password" AUTOCOMPLETE="off" />
|
||||||
<div id="host_password_errormsg" class="dialog_formcontent_errormsg" style="display:none;" ></div>
|
<div id="host_password_errormsg" class="dialog_formcontent_errormsg" style="display:none;" ></div>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li id="cluster_options_container">
|
||||||
<label> </label><span><u>Cluster Options</u></span>
|
<label> </label><span><u>Cluster Options</u></span>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li id="new_cluster_radio_container">
|
||||||
<label><input type="radio" name="cluster" value="new_cluster_radio" checked /> New cluster:</label>
|
<label><input type="radio" name="cluster" value="new_cluster_radio" checked /> New cluster:</label>
|
||||||
<input class="text" type="text" id="new_cluster_name"/>
|
<input class="text" type="text" id="new_cluster_name"/>
|
||||||
<div id="new_cluster_name_errormsg" class="dialog_formcontent_errormsg" style="display:none;" ></div>
|
<div id="new_cluster_name_errormsg" class="dialog_formcontent_errormsg" style="display:none;" ></div>
|
||||||
|
|||||||
@ -24,72 +24,75 @@ function showHostsTab() {
|
|||||||
var pIndex = 0;
|
var pIndex = 0;
|
||||||
|
|
||||||
// Dialog Setup
|
// Dialog Setup
|
||||||
if (getHypervisorType() != "kvm") { //"xenserver"
|
$("#host_action_new_routing").show();
|
||||||
$("#host_action_new_routing").show();
|
activateDialog($("#dialog_add_routing").dialog({
|
||||||
activateDialog($("#dialog_add_routing").dialog({
|
autoOpen: false,
|
||||||
autoOpen: false,
|
modal: true,
|
||||||
modal: true,
|
zIndex: 2000
|
||||||
zIndex: 2000
|
}));
|
||||||
}));
|
|
||||||
|
|
||||||
var dialogAddRouting = $("#dialog_add_routing");
|
var dialogAddRouting = $("#dialog_add_routing");
|
||||||
|
|
||||||
|
//xenserver supports cluster. kvm doesn't support cluster.
|
||||||
|
if (getHypervisorType() == "kvm")
|
||||||
|
dialogAddRouting.find("#cluster_options_container, #new_cluster_radio_container, #existing_cluster_radio_container, #no_cluster_radio_container").hide();
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
data: createURL("command=listZones&available=true&response=json"+maxPageSize),
|
||||||
|
dataType: "json",
|
||||||
|
success: function(json) {
|
||||||
|
var zones = json.listzonesresponse.zone;
|
||||||
|
var zoneSelect = dialogAddRouting.find("#host_zone").empty();
|
||||||
|
if (zones != null && zones.length > 0) {
|
||||||
|
for (var i = 0; i < zones.length; i++)
|
||||||
|
zoneSelect.append("<option value='" + zones[i].id + "'>" + sanitizeXSS(zones[i].name) + "</option>");
|
||||||
|
}
|
||||||
|
//dialogAddRouting.find("#host_zone").change();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
dialogAddRouting.find("#host_zone").bind("change", function(event) {
|
||||||
|
var zoneId = $(this).val();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
data: createURL("command=listZones&available=true&response=json"+maxPageSize),
|
data: createURL("command=listPods&zoneId="+zoneId+"&response=json"+maxPageSize),
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
|
async: false,
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
var zones = json.listzonesresponse.zone;
|
var pods = json.listpodsresponse.pod;
|
||||||
var zoneSelect = dialogAddRouting.find("#host_zone").empty();
|
var podSelect = dialogAddRouting.find("#host_pod").empty();
|
||||||
if (zones != null && zones.length > 0) {
|
if (pods != null && pods.length > 0) {
|
||||||
for (var i = 0; i < zones.length; i++)
|
for (var i = 0; i < pods.length; i++) {
|
||||||
zoneSelect.append("<option value='" + zones[i].id + "'>" + sanitizeXSS(zones[i].name) + "</option>");
|
podSelect.append("<option value='" + pods[i].id + "'>" + sanitizeXSS(pods[i].name) + "</option>");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//dialogAddRouting.find("#host_zone").change();
|
dialogAddRouting.find("#host_pod").change();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
dialogAddRouting.find("#host_zone").bind("change", function(event) {
|
dialogAddRouting.find("#host_pod").bind("change", function(event) {
|
||||||
var zoneId = $(this).val();
|
var podId = $(this).val();
|
||||||
$.ajax({
|
if(podId == null || podId.length == 0)
|
||||||
data: createURL("command=listPods&zoneId="+zoneId+"&response=json"+maxPageSize),
|
return;
|
||||||
dataType: "json",
|
var clusterSelect = dialogAddRouting.find("#cluster_select").empty();
|
||||||
async: false,
|
$.ajax({
|
||||||
success: function(json) {
|
data: createURL("command=listClusters&response=json&podid=" + podId+maxPageSize),
|
||||||
var pods = json.listpodsresponse.pod;
|
dataType: "json",
|
||||||
var podSelect = dialogAddRouting.find("#host_pod").empty();
|
success: function(json) {
|
||||||
if (pods != null && pods.length > 0) {
|
var items = json.listclustersresponse.cluster;
|
||||||
for (var i = 0; i < pods.length; i++) {
|
if(items != null && items.length > 0) {
|
||||||
podSelect.append("<option value='" + pods[i].id + "'>" + sanitizeXSS(pods[i].name) + "</option>");
|
for(var i=0; i<items.length; i++)
|
||||||
}
|
clusterSelect.append("<option value='" + items[i].id + "'>" + items[i].name + "</option>");
|
||||||
}
|
dialogAddRouting.find("input[value=existing_cluster_radio]").attr("checked", true);
|
||||||
dialogAddRouting.find("#host_pod").change();
|
}
|
||||||
}
|
else {
|
||||||
});
|
clusterSelect.append("<option value='-1'>None Available</option>");
|
||||||
});
|
dialogAddRouting.find("input[value=new_cluster_radio]").attr("checked", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
dialogAddRouting.find("#host_pod").bind("change", function(event) {
|
|
||||||
var podId = $(this).val();
|
|
||||||
if(podId == null || podId.length == 0)
|
|
||||||
return;
|
|
||||||
var clusterSelect = dialogAddRouting.find("#cluster_select").empty();
|
|
||||||
$.ajax({
|
|
||||||
data: createURL("command=listClusters&response=json&podid=" + podId+maxPageSize),
|
|
||||||
dataType: "json",
|
|
||||||
success: function(json) {
|
|
||||||
var items = json.listclustersresponse.cluster;
|
|
||||||
if(items != null && items.length > 0) {
|
|
||||||
for(var i=0; i<items.length; i++)
|
|
||||||
clusterSelect.append("<option value='" + items[i].id + "'>" + items[i].name + "</option>");
|
|
||||||
dialogAddRouting.find("input[value=existing_cluster_radio]").attr("checked", true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
clusterSelect.append("<option value='-1'>None Available</option>");
|
|
||||||
dialogAddRouting.find("input[value=new_cluster_radio]").attr("checked", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
activateDialog($("#dialog_update_os").dialog({
|
activateDialog($("#dialog_update_os").dialog({
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
modal: true,
|
modal: true,
|
||||||
@ -576,104 +579,105 @@ function showHostsTab() {
|
|||||||
var submenuContent = $("#submenu_content_routing");
|
var submenuContent = $("#submenu_content_routing");
|
||||||
|
|
||||||
// Add New Routing Host
|
// Add New Routing Host
|
||||||
if (getHypervisorType() != "kvm") {
|
$("#host_action_new_routing").bind("click", function(event) {
|
||||||
$("#host_action_new_routing").bind("click", function(event) {
|
dialogAddRouting.find("#new_cluster_name").val("");
|
||||||
dialogAddRouting.find("#new_cluster_name").val("");
|
dialogAddRouting.find("#host_zone").change(); //refresh cluster dropdown
|
||||||
dialogAddRouting.find("#host_zone").change(); //refresh cluster dropdown
|
|
||||||
|
|
||||||
dialogAddRouting
|
dialogAddRouting
|
||||||
.dialog('option', 'buttons', {
|
.dialog('option', 'buttons', {
|
||||||
"Add": function() {
|
"Add": function() {
|
||||||
var dialogBox = $(this);
|
var dialogBox = $(this);
|
||||||
var clusterRadio = dialogBox.find("input[name=cluster]:checked").val();
|
var clusterRadio = dialogBox.find("input[name=cluster]:checked").val();
|
||||||
|
|
||||||
// validate values
|
// validate values
|
||||||
var isValid = true;
|
var isValid = true;
|
||||||
isValid &= validateString("Host name", dialogBox.find("#host_hostname"), dialogBox.find("#host_hostname_errormsg"));
|
isValid &= validateString("Host name", dialogBox.find("#host_hostname"), dialogBox.find("#host_hostname_errormsg"));
|
||||||
isValid &= validateString("User name", dialogBox.find("#host_username"), dialogBox.find("#host_username_errormsg"));
|
isValid &= validateString("User name", dialogBox.find("#host_username"), dialogBox.find("#host_username_errormsg"));
|
||||||
isValid &= validateString("Password", dialogBox.find("#host_password"), dialogBox.find("#host_password_errormsg"));
|
isValid &= validateString("Password", dialogBox.find("#host_password"), dialogBox.find("#host_password_errormsg"));
|
||||||
if(clusterRadio == "new_cluster_radio")
|
if(clusterRadio == "new_cluster_radio")
|
||||||
isValid &= validateString("Cluster name", dialogBox.find("#new_cluster_name"), dialogBox.find("#new_cluster_name_errormsg"));
|
isValid &= validateString("Cluster name", dialogBox.find("#new_cluster_name"), dialogBox.find("#new_cluster_name_errormsg"));
|
||||||
if (!isValid) return;
|
if (!isValid) return;
|
||||||
|
|
||||||
var array1 = [];
|
var array1 = [];
|
||||||
|
|
||||||
var zoneId = dialogBox.find("#host_zone").val();
|
var zoneId = dialogBox.find("#host_zone").val();
|
||||||
array1.push("&zoneId="+zoneId);
|
array1.push("&zoneId="+zoneId);
|
||||||
|
|
||||||
var podId = dialogBox.find("#host_pod").val();
|
var podId = dialogBox.find("#host_pod").val();
|
||||||
array1.push("&podId="+podId);
|
array1.push("&podId="+podId);
|
||||||
|
|
||||||
var username = trim(dialogBox.find("#host_username").val());
|
var username = trim(dialogBox.find("#host_username").val());
|
||||||
array1.push("&username="+encodeURIComponent(username));
|
array1.push("&username="+encodeURIComponent(username));
|
||||||
|
|
||||||
var password = trim(dialogBox.find("#host_password").val());
|
var password = trim(dialogBox.find("#host_password").val());
|
||||||
array1.push("&password="+encodeURIComponent(password));
|
array1.push("&password="+encodeURIComponent(password));
|
||||||
|
|
||||||
if(clusterRadio == "new_cluster_radio") {
|
//xenserver supports cluster. kvm doesn't support cluster.
|
||||||
var newClusterName = trim(dialogBox.find("#new_cluster_name").val());
|
if (getHypervisorType() != "kvm") {
|
||||||
array1.push("&clustername="+encodeURIComponent(newClusterName));
|
if(clusterRadio == "new_cluster_radio") {
|
||||||
}
|
var newClusterName = trim(dialogBox.find("#new_cluster_name").val());
|
||||||
else if(clusterRadio == "existing_cluster_radio") {
|
array1.push("&clustername="+encodeURIComponent(newClusterName));
|
||||||
var clusterId = dialogBox.find("#cluster_select").val();
|
}
|
||||||
// We will default to no cluster if someone selects Join Cluster with no cluster available.
|
else if(clusterRadio == "existing_cluster_radio") {
|
||||||
if (clusterId != '-1') {
|
var clusterId = dialogBox.find("#cluster_select").val();
|
||||||
array1.push("&clusterid="+clusterId);
|
// We will default to no cluster if someone selects Join Cluster with no cluster available.
|
||||||
}
|
if (clusterId != '-1') {
|
||||||
}
|
array1.push("&clusterid="+clusterId);
|
||||||
|
}
|
||||||
var hostname = trim(dialogBox.find("#host_hostname").val());
|
}
|
||||||
var url;
|
|
||||||
if(hostname.indexOf("http://")==-1)
|
|
||||||
url = "http://" + hostname;
|
|
||||||
else
|
|
||||||
url = hostname;
|
|
||||||
array1.push("&url="+encodeURIComponent(url));
|
|
||||||
|
|
||||||
var template = $("#routing_template").clone(true);
|
|
||||||
var loadingImg = template.find(".adding_loading");
|
|
||||||
var rowContainer = template.find("#row_container");
|
|
||||||
loadingImg.find(".adding_text").text("Adding....");
|
|
||||||
loadingImg.show();
|
|
||||||
rowContainer.hide();
|
|
||||||
submenuContent.find("#grid_content").append(template.fadeIn("slow"));
|
|
||||||
|
|
||||||
dialogBox.dialog("close");
|
|
||||||
$.ajax({
|
|
||||||
data: createURL("command=addHost&response=json" + array1.join("")),
|
|
||||||
dataType: "json",
|
|
||||||
success: function(json) {
|
|
||||||
var items = json.addhostresponse.host;
|
|
||||||
routingJSONToTemplate(items[0], template);
|
|
||||||
loadingImg.hide();
|
|
||||||
rowContainer.show();
|
|
||||||
changeGridRowsTotal(submenuContent.find("#grid_rows_total"), 1);
|
|
||||||
|
|
||||||
if(items.length > 1) {
|
|
||||||
for(var i=1; i<items.length; i++) {
|
|
||||||
var anotherNewTemplate = $("#routing_template").clone(true);
|
|
||||||
routingJSONToTemplate(items[i], anotherNewTemplate);
|
|
||||||
submenuContent.find("#grid_content").append(anotherNewTemplate.fadeIn("slow"));
|
|
||||||
changeGridRowsTotal(submenuContent.find("#grid_rows_total"), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(clusterRadio == "new_cluster_radio")
|
|
||||||
dialogBox.find("#new_cluster_name").val("");
|
|
||||||
},
|
|
||||||
error: function(XMLHttpResponse) {
|
|
||||||
handleError(XMLHttpResponse);
|
|
||||||
template.slideUp("slow", function(){ $(this).remove(); } );
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
"Cancel": function() {
|
|
||||||
$(this).dialog("close");
|
|
||||||
}
|
}
|
||||||
}).dialog("open");
|
|
||||||
return false;
|
var hostname = trim(dialogBox.find("#host_hostname").val());
|
||||||
});
|
var url;
|
||||||
}
|
if(hostname.indexOf("http://")==-1)
|
||||||
|
url = "http://" + hostname;
|
||||||
|
else
|
||||||
|
url = hostname;
|
||||||
|
array1.push("&url="+encodeURIComponent(url));
|
||||||
|
|
||||||
|
var template = $("#routing_template").clone(true);
|
||||||
|
var loadingImg = template.find(".adding_loading");
|
||||||
|
var rowContainer = template.find("#row_container");
|
||||||
|
loadingImg.find(".adding_text").text("Adding....");
|
||||||
|
loadingImg.show();
|
||||||
|
rowContainer.hide();
|
||||||
|
submenuContent.find("#grid_content").append(template.fadeIn("slow"));
|
||||||
|
|
||||||
|
dialogBox.dialog("close");
|
||||||
|
$.ajax({
|
||||||
|
data: createURL("command=addHost&response=json" + array1.join("")),
|
||||||
|
dataType: "json",
|
||||||
|
success: function(json) {
|
||||||
|
var items = json.addhostresponse.host;
|
||||||
|
routingJSONToTemplate(items[0], template);
|
||||||
|
loadingImg.hide();
|
||||||
|
rowContainer.show();
|
||||||
|
changeGridRowsTotal(submenuContent.find("#grid_rows_total"), 1);
|
||||||
|
|
||||||
|
if(items.length > 1) {
|
||||||
|
for(var i=1; i<items.length; i++) {
|
||||||
|
var anotherNewTemplate = $("#routing_template").clone(true);
|
||||||
|
routingJSONToTemplate(items[i], anotherNewTemplate);
|
||||||
|
submenuContent.find("#grid_content").append(anotherNewTemplate.fadeIn("slow"));
|
||||||
|
changeGridRowsTotal(submenuContent.find("#grid_rows_total"), 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(clusterRadio == "new_cluster_radio")
|
||||||
|
dialogBox.find("#new_cluster_name").val("");
|
||||||
|
},
|
||||||
|
error: function(XMLHttpResponse) {
|
||||||
|
handleError(XMLHttpResponse);
|
||||||
|
template.slideUp("slow", function(){ $(this).remove(); } );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
"Cancel": function() {
|
||||||
|
$(this).dialog("close");
|
||||||
|
}
|
||||||
|
}).dialog("open");
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
function listHosts() {
|
function listHosts() {
|
||||||
var submenuContent = $("#submenu_content_routing");
|
var submenuContent = $("#submenu_content_routing");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user