[Kimchi-devel] [PATCH V2 7/7] (WIP) Storagepool SCSI/FC: Draft UI to allow user to select a LUN to new VM

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Tue Jan 28 21:59:34 UTC 2014


On 01/25/2014 09:57 PM, Aline Manera wrote:
> 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 at 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?

 From the UI, I don't think so. But, someone consuming the API could 
pass a wrong template name.
Or the template could be removed. Just code resilience, this is not bad.

>
>> +                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
My bad! This was for testing purposes and forget to remove  (should have 
removed extra spaces too)

>> + 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.

I asked for help in the same day.  Yu Xin Huo and Hongliang Wang kindly 
answered (thanks), I am going to complete this UI in next patch  =)

>
>> +                            // 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();
>
> _______________________________________________
> Kimchi-devel mailing list
> Kimchi-devel at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/kimchi-devel
>




More information about the Kimchi-devel mailing list