On 01/23/2014 10:30 PM, Rodrigo Trujillo wrote:
This patch implements the UI functions and API calls until show to
user
the list of volumes (LUNs) of a SCSI FC storagepools. The user can then
select the LUN when creating a new VM.
This patch is a draft and gives the steps of the functionality, missing
only the final selection window and function to get the proper selected
value from it.
Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo(a)linux.vnet.ibm.com>
---
ui/js/src/kimchi.api.js | 13 +++++++++++++
ui/js/src/kimchi.guest_add_main.js | 32 ++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+)
diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
index 66fc41e..4597c5d 100644
--- a/ui/js/src/kimchi.api.js
+++ b/ui/js/src/kimchi.api.js
@@ -155,6 +155,19 @@ var kimchi = {
});
},
+ /*
+ * Retrieve the information of a storage pool by the given name.
+ */
+ retrieveStoragePool : function(storagePoolName, suc, err) {
+ kimchi.requestJSON({
+ url : kimchi.url + "storagepools/" +
+ encodeURIComponent(storagePoolName),
+ type : 'GET',
+ contentType : 'application/json',
+ dataType : 'json'
+ }).done(suc);
+ },
+
/**
* Retrieve the information of a template by the given name.
*/
diff --git a/ui/js/src/kimchi.guest_add_main.js b/ui/js/src/kimchi.guest_add_main.js
index 2085562..ab731fb 100644
--- a/ui/js/src/kimchi.guest_add_main.js
+++ b/ui/js/src/kimchi.guest_add_main.js
@@ -65,6 +65,38 @@ kimchi.guest_add_main = function() {
var addGuest = function(event) {
var formData = $('#form-vm-add').serializeObject();
+ // Checking if need to ask LUN to user
+ var templateName = formData.template.substring(11);
+ kimchi.retrieveTemplate(templateName, function(templateInfo) {
+ if (templateInfo) {
Is there a case the template info won't be available?
+ var poolName =
templateInfo.storagepool.substring(14);
+ kimchi.retrieveStoragePool(poolName, function(poolInfo){
+ if (poolInfo.type !== "scsi") {
It should be for scsi pools, right? We don't need to show anything for
other pools
+ kimchi.listStorageVolumes(poolInfo.name,
function(lunsList) {
+ if (lunsList.length == 0) {
+ kimchi.message.error('There are not volumes for this
pool');
+ return false;
+ }
+ var popUpList = '<div
class="field">';
+ // TODO
+ // Implement a better UI and retrieve
+ // the selected LUN from a popup window
+ $.each(lunsList, function(index, value) {
+ popUpList += '<div class=field> <input
type="radio" value="' + value.name + '"
name="lun">' +
+ '<label>' + value.name +
'</label></div>';
+ });
+ popUpList += '</div>';
+ myhtml = $(popUpList);
+ myhtml.dialog();
I think we need to implement the UI, right?
It will show a ugly window
Some UI export can look into it?
Rodrigo, if you want to do the UI go ahead but make it completely.
Otherwise, remove this code and ask UI guys to do it.
+ // TODO / FIXME
+ // Retrieve the LUN name from here, should come from window
+ var lunName = "selectedLun";
+ formData.volume = lunName;
+ });
+ }
+ });
+ }
+ });
kimchi.createVM(formData, function() {
kimchi.listVmsAuto();
kimchi.window.close();