[Kimchi-devel] [PATCH V4 3/5] Storagepool SCSI/FC: Implement UI for FC scsi_host pool

Aline Manera alinefm at linux.vnet.ibm.com
Mon Feb 10 14:20:30 UTC 2014


Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>


On 02/05/2014 12:18 PM, Rodrigo Trujillo wrote:
> This patch modifies the storagepool add user interface in order to show all
> Fibre Channel scsi hosts found in the host system and let user to create a
> pool attached to this host (the LUNs will be the volumes).
> A second option to use and enable FC storages is when a LUN is assigned as
> a pool of FS type, hosting guest images. This second option will be implement
> in the future.
>
> Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
> ---
>   ui/js/src/kimchi.api.js                  | 11 ++++++++
>   ui/js/src/kimchi.storagepool_add_main.js | 46 +++++++++++++++++++++++++++++++-
>   ui/pages/i18n.html.tmpl                  |  4 +++
>   ui/pages/storagepool-add.html.tmpl       | 12 +++++++++
>   4 files changed, 72 insertions(+), 1 deletion(-)
>
> diff --git a/ui/js/src/kimchi.api.js b/ui/js/src/kimchi.api.js
> index 63ddd88..66fc41e 100644
> --- a/ui/js/src/kimchi.api.js
> +++ b/ui/js/src/kimchi.api.js
> @@ -731,5 +731,16 @@ var kimchi = {
>               success : suc,
>               error : err
>           });
> +    },
> +
> +    listFCHosts : function(suc, err) {
> +        kimchi.requestJSON({
> +            url : kimchi.url + 'host/devices?_cap=fc_host',
> +            type : 'GET',
> +            contentType : 'application/json',
> +            dataType : 'json',
> +            success : suc,
> +            error : err
> +        });
>       }
>   };
> diff --git a/ui/js/src/kimchi.storagepool_add_main.js b/ui/js/src/kimchi.storagepool_add_main.js
> index e5922b3..1f1ec41 100644
> --- a/ui/js/src/kimchi.storagepool_add_main.js
> +++ b/ui/js/src/kimchi.storagepool_add_main.js
> @@ -40,7 +40,21 @@ kimchi.initStorageAddPage = function() {
>           label : "iSCSI",
>           value : "iscsi"
>       } ];
> -    kimchi.listHostPartitions(function(data) {
> +    kimchi.listFCHosts(function(data){
> +        if (data.length > 0)  {
> +            options.push( {
> +                label : "SCSI Fibre Channel",
> +                value : "scsi"
> +            });
> +        }
> +        var scsiFCHtml = $('#scsiFCTmpl').html();
> +        var scsiFCHostListHtml = '';
> +        $.each(data, function(index, value) {
> +            scsiFCHostListHtml += kimchi.template(scsiFCHtml, value);
> +        });
> +        $('.scsifc-hosts').html(scsiFCHostListHtml);
> +
> +      kimchi.listHostPartitions(function(data) {
>           if (data.length > 0) {
>               options.push({
>                   label : "LOGICAL",
> @@ -107,21 +121,31 @@ kimchi.initStorageAddPage = function() {
>                   $('.logical-section').addClass('tmpl-html');
>                   $('.nfs-section').addClass('tmpl-html');
>                   $('.iscsi-section').addClass('tmpl-html');
> +                $('.scsifc-section').addClass('tmpl-html');
>               } else if ($(this).val() === 'netfs') {
>                   $('.path-section').addClass('tmpl-html');
>                   $('.logical-section').addClass('tmpl-html');
>                   $('.nfs-section').removeClass('tmpl-html');
>                   $('.iscsi-section').addClass('tmpl-html');
> +                $('.scsifc-section').addClass('tmpl-html');
>               } else if ($(this).val() === 'iscsi') {
>                   $('.path-section').addClass('tmpl-html');
>                   $('.logical-section').addClass('tmpl-html');
>                   $('.nfs-section').addClass('tmpl-html');
>                   $('.iscsi-section').removeClass('tmpl-html');
> +                $('.scsifc-section').addClass('tmpl-html');
> +            } else if ($(this).val() === 'scsi') {
> +                $('.path-section').addClass('tmpl-html');
> +                $('.logical-section').addClass('tmpl-html');
> +                $('.nfs-section').addClass('tmpl-html');
> +                $('.iscsi-section').addClass('tmpl-html');
> +                $('.scsifc-section').removeClass('tmpl-html');
>               } else if ($(this).val() === 'logical') {
>                   $('.path-section').addClass('tmpl-html');
>                   $('.logical-section').removeClass('tmpl-html');
>                   $('.nfs-section').addClass('tmpl-html');
>                   $('.iscsi-section').addClass('tmpl-html');
> +                $('.scsifc-section').addClass('tmpl-html');
>               }
>           });
>           $('#authId').click(function() {
> @@ -134,6 +158,10 @@ kimchi.initStorageAddPage = function() {
>           $('#iscsiportId').keyup(function(event) {
>               $(this).toggleClass("invalid-field",!/^[0-9]+$/.test($(this).val()));
>           });
> +      });
> +    }, function() {
> +        // listFCHosts error handler
> +        kimchi.message.error(i18n['msg.kimchi.list.fchosts.fail']);
>       });
>   };
>
> @@ -154,6 +182,8 @@ kimchi.validateForm = function() {
>           return kimchi.validateNfsForm();
>       } else if (poolType === "iscsi") {
>           return kimchi.validateIscsiForm();
> +    } else if (poolType === "scsi") {
> +        return kimchi.validateScsiFCForm();
>       } else if (poolType === "logical") {
>           return kimchi.validateLogicalForm();
>       } else {
> @@ -204,6 +234,15 @@ kimchi.validateIscsiForm = function() {
>       return true;
>   };
>
> +kimchi.validateScsiFCForm = function() {
> +    var fcHost = $('input:radio[name=adapter_name]:checked').val();
> +    if (fcHost === undefined) {
> +        kimchi.message.error(i18n['msg.validate.pool.edit.scsifchost']);
> +        return false;
> +    }
> +    return true;
> +};
> +
>   kimchi.validateServer = function(serverField) {
>       if ('' === serverField) {
>           kimchi.message.error(i18n['msg.pool.edit.server.blank']);
> @@ -248,6 +287,11 @@ kimchi.addPool = function(event) {
>               source.path = $('#nfspathId').val();
>               source.host = $('#nfsserverId').val();
>               formData.source = source;
> +        } else if (poolType === 'scsi'){
> +            var source = {};
> +            source.adapter_name = formData.adapter_name;
> +            delete formData.adapter_name;
> +            formData.source = source;
>           } else if (poolType === 'iscsi') {
>               var source = {};
>               source.target = $('#iscsiTargetId').val();
> diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl
> index d63d4e9..a4c3ccb 100644
> --- a/ui/pages/i18n.html.tmpl
> +++ b/ui/pages/i18n.html.tmpl
> @@ -55,6 +55,8 @@ var i18n = {
>       'msg.fail.template.no.iso': "$_("No iso found")",
>       'msg.fail.template.scan': "$_("Failed to scan")",
>       'msg.fail.template.distr': "$_("Failed to list iso distributions")",
> +    'msg.fail.template.retrieve': "$_("Failed to retrieve template")",
> +    'msg.kimchi.list.fchosts.fail': "$_("Failed to list Fibre Channel SCSI hosts")",
>       'msg.confirm.delete.title': "$_("Delete Confirmation")",
>       'msg.confirm': "$_("OK")",
>       'msg.cancel': "$_("Cancel")",
> @@ -100,9 +102,11 @@ var i18n = {
>       'msg.validate.pool.edit.path':"$_("This is not a real linux path.")",
>       'msg.validate.pool.edit.nfspath':"$_("Invalid nfs mount path.")",
>       'msg.validate.pool.edit.logical.device':"$_("No logical device selected.")",
> +    'msg.validate.pool.edit.scsifchost':"$_("A Fibre Channel SCSI host must be selected.")",
>       'msg.kimchi.storage.pool.empty':"$_("This storage pool is empty.")",
>       'msg.kimchi.list.volume.fail':"$_("Failed to list the storage pool.")",
>       'msg.kimchi.storage.pool.not.active':"$_("The storage pool is not active now.")",
> +    'msg.kimchi.retrieve.pool.fail': "$_("Failed to retrieve storage pool.")",
>       'fail.delete.template': "$_("Failed to delete template.")",
>       'Guests':"$_("Guests")",
>       'Host':"$_("Host")",
> diff --git a/ui/pages/storagepool-add.html.tmpl b/ui/pages/storagepool-add.html.tmpl
> index dac99fe..4782d15 100644
> --- a/ui/pages/storagepool-add.html.tmpl
> +++ b/ui/pages/storagepool-add.html.tmpl
> @@ -104,6 +104,12 @@
>                           <div class="host-partition"></div>
>                       </section>
>                   </div>
> +                <div class="scsifc-section tmpl-html">
> +                    <section class="form-section">
> +                        <h2>3. $_("Select SCSI Fibre Channel Host")</h2>
> +                        <div class="scsifc-hosts"></div>
> +                    </section>
> +                </div>
>                   <div class="iscsi-section tmpl-html">
>                       <section class="form-section">
>                           <h2>3. $_("iSCSI Server")</h2>
> @@ -154,5 +160,11 @@
>               <label for="{name}">{path}</label>
>           </div>
>       </script>
> +        <script id="scsiFCTmpl" type="html/text">
> +        <div class="field">
> +            <input type="radio" value="{name}" name="adapter_name" id="fc-{name}">
> +            <label for="fc-{name}">{name}</label>
> +        </div>
> +    </script>
>   </body>
>   </html>




More information about the Kimchi-devel mailing list