mirror of https://github.com/apache/cloudstack.git
bug 7064: zone page - implement Add Primary Storage option from zone.
This commit is contained in:
parent
fa499dadbc
commit
b6f496561e
|
|
@ -544,6 +544,102 @@
|
|||
</div>
|
||||
<!-- Add Host Dialog in zone page (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>
|
||||
Add a primary storage for zone <b><span id="zone_name"></span></b>
|
||||
</span></b>
|
||||
</p>
|
||||
<div class="dialog_formcontent">
|
||||
<form action="#" method="post" id="form_acquire">
|
||||
<ol>
|
||||
<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 id="pool_cluster_container">
|
||||
<label for="pool_cluster">
|
||||
Cluster:</label>
|
||||
<select class="select" id="cluster_select">
|
||||
</select>
|
||||
<div id="cluster_select_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<label for="user_name">
|
||||
Name:</label>
|
||||
<input class="text" type="text" name="add_pool_name" id="add_pool_name" />
|
||||
<div id="add_pool_name_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<label for="add_pool_protocol">
|
||||
Protocol:</label>
|
||||
<select class="select" id="add_pool_protocol">
|
||||
<option value="nfs">NFS</option>
|
||||
<option value="iscsi">ISCSI</option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<label for="add_pool_nfs_server">
|
||||
Server:</label>
|
||||
<input class="text" type="text" name="add_pool_nfs_server" id="add_pool_nfs_server" />
|
||||
<div id="add_pool_nfs_server_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li id="add_pool_path_container">
|
||||
<label for="add_pool_path">
|
||||
Path:</label>
|
||||
<input class="text" type="text" name="add_pool_path" id="add_pool_path" />
|
||||
<div id="add_pool_path_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li id="add_pool_iqn_container" style="display: none">
|
||||
<label for="add_pool_iqn">
|
||||
Target IQN:</label>
|
||||
<input class="text" type="text" name="add_pool_iqn" id="add_pool_iqn" />
|
||||
<div id="add_pool_iqn_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li id="add_pool_lun_container" style="display: none">
|
||||
<label for="add_pool_lun">
|
||||
LUN #:</label>
|
||||
<input class="text" type="text" name="add_pool_lun" id="add_pool_lun" />
|
||||
<div id="add_pool_lun_errormsg" class="dialog_formcontent_errormsg" style="display: none;">
|
||||
</div>
|
||||
</li>
|
||||
<li id="add_pool_tags_container">
|
||||
<label for="add_pool_tags">
|
||||
Tags:</label>
|
||||
<input class="text" type="text" id="add_pool_tags" />
|
||||
<div id="add_pool_tags_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 Primary Storage Dialog in zone page (end) -->
|
||||
|
||||
<!-- ***** dialogs ***** (end)-->
|
||||
<!-- VLAN Template (begin) -->
|
||||
<div class="networkswitch_vlanpanel" id="vlan_template" style="display: none;">
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
});
|
||||
if(pods.length > 0) {
|
||||
initAddHostButtonOnZonePage($("#midmenu_add_host_button"), zoneId, zoneName, pods);
|
||||
//initAddPrimaryStorageButtonOnZonePage($("#midmenu_add_primarystorage_button"), zoneId, zoneName, pods);
|
||||
initAddPrimaryStorageButtonOnZonePage($("#midmenu_add_primarystorage_button"), zoneId, zoneName, pods);
|
||||
}
|
||||
|
||||
initDialog("dialog_add_pod", 320);
|
||||
|
|
@ -886,7 +886,7 @@ function initAddHostButtonOnZonePage($button, zoneId, zoneName, pods) {
|
|||
refreshClsuterFieldInAddHostDialog($dialogAddHost, podId, null);
|
||||
});
|
||||
|
||||
$dialogAddHost.find("#pod_dropdown").change();
|
||||
$podSelect.change();
|
||||
|
||||
$button.unbind("click").bind("click", function(event) {
|
||||
$dialogAddHost.find("#zone_name").text(zoneName);
|
||||
|
|
@ -998,4 +998,160 @@ function initAddHostButtonOnZonePage($button, zoneId, zoneName, pods) {
|
|||
}).dialog("open");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function initAddPrimaryStorageButtonOnZonePage($button, zoneId, zoneName, pods) {
|
||||
$button.show();
|
||||
|
||||
initDialog("dialog_add_pool_in_zone_page");
|
||||
var $dialogAddPool = $("#dialog_add_pool_in_zone_page");
|
||||
|
||||
// if hypervisor is KVM, limit the server option to NFS for now
|
||||
if (getHypervisorType() == 'kvm')
|
||||
$dialogAddPool.find("#add_pool_protocol").empty().html('<option value="nfs">NFS</option>');
|
||||
bindEventHandlerToDialogAddPool($dialogAddPool);
|
||||
|
||||
var $podSelect = $dialogAddPool.find("#pod_dropdown");
|
||||
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.bind("change", function(event) {
|
||||
var podId = $(this).val();
|
||||
if(podId == null || podId.length == 0)
|
||||
return;
|
||||
var $clusterSelect = $dialogAddPool.find("#cluster_select").empty();
|
||||
$.ajax({
|
||||
data: createURL("command=listClusters&podid=" + podId),
|
||||
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 + "'>" + fromdb(items[i].name) + "</option>");
|
||||
$dialogAddPool.find("input[value=existing_cluster_radio]").attr("checked", true);
|
||||
}
|
||||
else {
|
||||
$clusterSelect.append("<option value='-1'>None Available</option>");
|
||||
$dialogAddPool.find("input[value=new_cluster_radio]").attr("checked", true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$podSelect.change();
|
||||
|
||||
$button.unbind("click").bind("click", function(event) {
|
||||
$dialogAddPool.find("#zone_name").text(zoneName);
|
||||
$dialogAddPool.find("#zone_dropdown").change(); //refresh cluster dropdown (do it here to avoid race condition)
|
||||
$dialogAddPool.find("#info_container").hide();
|
||||
|
||||
$("#dialog_add_pool_in_zone_page")
|
||||
.dialog('option', 'buttons', {
|
||||
"Add": function() {
|
||||
var $thisDialog = $(this);
|
||||
|
||||
// validate values
|
||||
var protocol = $thisDialog.find("#add_pool_protocol").val();
|
||||
|
||||
var isValid = true;
|
||||
isValid &= validateDropDownBox("Pod", $thisDialog.find("#pod_dropdown"), $thisDialog.find("#pod_dropdown_errormsg"));
|
||||
isValid &= validateDropDownBox("Cluster", $thisDialog.find("#cluster_select"), $thisDialog.find("#cluster_select_errormsg"), false); //required, reset error text
|
||||
isValid &= validateString("Name", $thisDialog.find("#add_pool_name"), $thisDialog.find("#add_pool_name_errormsg"));
|
||||
isValid &= validateString("Server", $thisDialog.find("#add_pool_nfs_server"), $thisDialog.find("#add_pool_nfs_server_errormsg"));
|
||||
if (protocol == "nfs") {
|
||||
isValid &= validateString("Path", $thisDialog.find("#add_pool_path"), $thisDialog.find("#add_pool_path_errormsg"));
|
||||
} else {
|
||||
isValid &= validateString("Target IQN", $thisDialog.find("#add_pool_iqn"), $thisDialog.find("#add_pool_iqn_errormsg"));
|
||||
isValid &= validateString("LUN #", $thisDialog.find("#add_pool_lun"), $thisDialog.find("#add_pool_lun_errormsg"));
|
||||
}
|
||||
isValid &= validateString("Tags", $thisDialog.find("#add_pool_tags"), $thisDialog.find("#add_pool_tags_errormsg"), true); //optional
|
||||
if (!isValid)
|
||||
return;
|
||||
|
||||
$thisDialog.find("#spinning_wheel").show()
|
||||
|
||||
var array1 = [];
|
||||
|
||||
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 clusterId = $thisDialog.find("#cluster_select").val();
|
||||
array1.push("&clusterid="+clusterId);
|
||||
|
||||
var name = trim($thisDialog.find("#add_pool_name").val());
|
||||
array1.push("&name="+todb(name));
|
||||
|
||||
var server = trim($thisDialog.find("#add_pool_nfs_server").val());
|
||||
|
||||
var url = null;
|
||||
if (protocol == "nfs") {
|
||||
var path = trim($thisDialog.find("#add_pool_path").val());
|
||||
if(path.substring(0,1)!="/")
|
||||
path = "/" + path;
|
||||
url = nfsURL(server, path);
|
||||
} else {
|
||||
var iqn = trim($thisDialog.find("#add_pool_iqn").val());
|
||||
if(iqn.substring(0,1)!="/")
|
||||
iqn = "/" + iqn;
|
||||
var lun = trim($thisDialog.find("#add_pool_lun").val());
|
||||
url = iscsiURL(server, iqn, lun);
|
||||
}
|
||||
array1.push("&url="+encodeURIComponent(url));
|
||||
|
||||
var tags = trim($thisDialog.find("#add_pool_tags").val());
|
||||
if(tags != null && tags.length > 0)
|
||||
array1.push("&tags="+todb(tags));
|
||||
|
||||
$.ajax({
|
||||
data: createURL("command=createStoragePool" + array1.join("")),
|
||||
dataType: "json",
|
||||
success: function(json) {
|
||||
if(isMiddleMenuShown() == false) { //not on cluster node (still on pod node, so middle menu is hidden)
|
||||
var $clusterNode = $("#cluster_"+clusterId);
|
||||
if($clusterNode.length > 0)
|
||||
$("#cluster_"+clusterId).find("#cluster_name").click();
|
||||
else //pod node is close. Expand pod node.
|
||||
refreshClusterUnderPod($("#pod_" + podId), null, clusterId);
|
||||
}
|
||||
else {
|
||||
var $container = $("#midmenu_container").find("#midmenu_primarystorage_container");
|
||||
var $noItemsAvailable = $container.siblings("#midmenu_container_no_items_available");
|
||||
if($noItemsAvailable.length > 0) {
|
||||
$noItemsAvailable.slideUp("slow", function() {
|
||||
$(this).remove();
|
||||
});
|
||||
}
|
||||
|
||||
var $midmenuItem1 = $("#midmenu_item").clone();
|
||||
$container.append($midmenuItem1.fadeIn("slow"));
|
||||
var item = json.createstoragepoolresponse.storagepool;
|
||||
primarystorageToMidmenu(item, $midmenuItem1);
|
||||
bindClickToMidMenu($midmenuItem1, primarystorageToRightPanel, primarystorageGetMidmenuId);
|
||||
}
|
||||
|
||||
$thisDialog.find("#spinning_wheel").hide();
|
||||
$thisDialog.dialog("close");
|
||||
},
|
||||
error: function(XMLHttpResponse) {
|
||||
handleError(XMLHttpResponse, function() {
|
||||
handleErrorInDialog(XMLHttpResponse, $thisDialog);
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
"Cancel": function() {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
}).dialog("open");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
Loading…
Reference in New Issue